locale_facets.tcc (money_get::do_get(string_type&)): Thousands-sep are always optional...

2004-02-05  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/locale_facets.tcc (money_get::do_get(string_type&)):
	Thousands-sep are always optional; thousands-sep are not allowed
	after the decimal_point.
	* testsuite/22_locale/money_get/get/char/12.cc: New.
	* testsuite/22_locale/money_get/get/char/13.cc: New.
	* testsuite/22_locale/money_get/get/wchar_t/12.cc: New.
	* testsuite/22_locale/money_get/get/wchar_t/13.cc: New.

	* testsuite/22_locale/money_get/get/char/1.cc: Clean-up.
	* testsuite/22_locale/money_get/get/char/2.cc: Likewise.
	* testsuite/22_locale/money_get/get/char/3.cc: Likewise.
	* testsuite/22_locale/money_get/get/char/4.cc: Likewise.
	* testsuite/22_locale/money_get/get/wchar_t/1.cc: Likewise.
	* testsuite/22_locale/money_get/get/wchar_t/2.cc: Likewise.
	* testsuite/22_locale/money_get/get/wchar_t/3.cc: Likewise.
	* testsuite/22_locale/money_get/get/wchar_t/4.cc: Likewise.

	* testsuite/22_locale/money_get/get/char/9.cc: Fix citation from
	the standard.
	* testsuite/22_locale/money_get/get/wchar_t/9.cc: Likewise.

From-SVN: r77339
This commit is contained in:
Paolo Carlini 2004-02-05 20:13:37 +00:00 committed by Paolo Carlini
parent 6327d36ac6
commit d9010fcacc
16 changed files with 323 additions and 58 deletions

View File

@ -1,3 +1,26 @@
2004-02-05 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (money_get::do_get(string_type&)):
Thousands-sep are always optional; thousands-sep are not allowed
after the decimal_point.
* testsuite/22_locale/money_get/get/char/12.cc: New.
* testsuite/22_locale/money_get/get/char/13.cc: New.
* testsuite/22_locale/money_get/get/wchar_t/12.cc: New.
* testsuite/22_locale/money_get/get/wchar_t/13.cc: New.
* testsuite/22_locale/money_get/get/char/1.cc: Clean-up.
* testsuite/22_locale/money_get/get/char/2.cc: Likewise.
* testsuite/22_locale/money_get/get/char/3.cc: Likewise.
* testsuite/22_locale/money_get/get/char/4.cc: Likewise.
* testsuite/22_locale/money_get/get/wchar_t/1.cc: Likewise.
* testsuite/22_locale/money_get/get/wchar_t/2.cc: Likewise.
* testsuite/22_locale/money_get/get/wchar_t/3.cc: Likewise.
* testsuite/22_locale/money_get/get/wchar_t/4.cc: Likewise.
* testsuite/22_locale/money_get/get/char/9.cc: Fix citation from
the standard.
* testsuite/22_locale/money_get/get/wchar_t/9.cc: Likewise.
2004-02-05 Richard Sandiford <rsandifo@redhat.com>
* config/os/irix/irix6.5/os_defines.h (_GLIBCXX_FIONREAD_TAKES_OFF_T):

View File

@ -1253,11 +1253,15 @@ namespace std
}
else if (__c == __d && !__testdecfound)
{
__grouping_tmp += static_cast<char>(__sep_pos);
// If no grouping chars are seen, no grouping check
// is applied. Therefore __grouping_tmp is adjusted
// only if decimal_point comes after some thousands_sep.
if (__grouping_tmp.size())
__grouping_tmp += static_cast<char>(__sep_pos);
__sep_pos = 0;
__testdecfound = true;
}
else if (__c == __sep)
else if (__c == __sep && !__testdecfound)
{
if (__grouping.size())
{
@ -1319,6 +1323,10 @@ namespace std
// Test for grouping fidelity.
if (__grouping.size() && __grouping_tmp.size())
{
// Add the ending grouping if a decimal wasn't found.
if (!__testdecfound)
__grouping_tmp += static_cast<char>(__sep_pos);
if (!std::__verify_grouping(__grouping.data(),
__grouping.size(),
__grouping_tmp))

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -36,13 +36,8 @@ void test01()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the moneypunct facets
typedef moneypunct<char, true> __money_true;

View File

@ -0,0 +1,70 @@
// 2004-02-05 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.6.1.1 money_get members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// Same as 3.cc but no thousands-sep in input: they are always optional.
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef istreambuf_iterator<char> iterator_type;
// basic construction
locale loc_c = locale::classic();
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
// total EPA budget FY 2002
const long double digits1 = 720000000000.0;
iterator_type end;
istringstream iss;
iss.imbue(loc_de);
// cache the money_get facet
const money_get<char>& mon_get = use_facet<money_get<char> >(iss.getloc());
iss.str("7200000000,00 ");
iterator_type is_it01(iss);
long double result1;
ios_base::iostate err01 = ios_base::goodbit;
mon_get.get(is_it01, end, true, iss, err01, result1);
VERIFY( result1 == digits1 );
VERIFY( err01 == ios_base::eofbit );
iss.str("7200000000,00 ");
iterator_type is_it02(iss);
long double result2;
ios_base::iostate err02 = ios_base::goodbit;
mon_get.get(is_it02, end, false, iss, err02, result2);
VERIFY( result2 == digits1 );
VERIFY( err02 == ios_base::eofbit );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,67 @@
// 2004-02-05 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.6.1.1 money_get members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// No thousands-sep allowed after the decimal-point.
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef istreambuf_iterator<char> iterator_type;
// basic construction
locale loc_c = locale::classic();
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
iterator_type end01, end02;
istringstream iss;
iss.imbue(loc_de);
// cache the money_get facet
const money_get<char>& mon_get = use_facet<money_get<char> >(iss.getloc());
iss.str("500,1.0 ");
iterator_type is_it01(iss);
long double result1;
ios_base::iostate err01 = ios_base::goodbit;
end01 = mon_get.get(is_it01, end01, true, iss, err01, result1);
VERIFY( err01 == ios_base::failbit );
VERIFY( *end01 == '.' );
iss.str("500,1.0 ");
iterator_type is_it02(iss);
long double result2;
ios_base::iostate err02 = ios_base::goodbit;
end02 = mon_get.get(is_it02, end02, false, iss, err02, result2);
VERIFY( err02 == ios_base::failbit );
VERIFY( *end02 == '.' );
}
int main()
{
test01();
return 0;
}

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -37,12 +37,7 @@ void test02()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
VERIFY( loc_c != loc_hk );
// cache the moneypunct facets
typedef moneypunct<char, true> __money_true;

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -36,13 +36,8 @@ void test03()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the moneypunct facets
typedef moneypunct<char, true> __money_true;

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -37,12 +37,7 @@ void test04()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
VERIFY( loc_c != loc_hk );
// cache the moneypunct facets
typedef moneypunct<char, true> __money_true;

View File

@ -1,6 +1,6 @@
// 2003-05-27 Brendan Kehoe <brendan@zen.org>
// Copyright (C) 2003 Free Software Foundation
// Copyright (C) 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -18,7 +18,7 @@
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// $22.2.6.3.3/8
// $22.2.6.3/3
// The number of digits required after the decimal point (if any) is exactly
// the value returned by frac_digits().

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -36,13 +36,8 @@ void test01()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the moneypunct facets
typedef moneypunct<wchar_t, true> __money_true;

View File

@ -0,0 +1,70 @@
// 2004-02-05 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.6.1.1 money_get members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// Same as 3.cc but no thousands-sep in input: they are always optional.
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef istreambuf_iterator<wchar_t> iterator_type;
// basic construction
locale loc_c = locale::classic();
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
// total EPA budget FY 2002
const long double digits1 = 720000000000.0;
iterator_type end;
wistringstream iss;
iss.imbue(loc_de);
// cache the money_get facet
const money_get<wchar_t>& mon_get = use_facet<money_get<wchar_t> >(iss.getloc());
iss.str(L"7200000000,00 ");
iterator_type is_it01(iss);
long double result1;
ios_base::iostate err01 = ios_base::goodbit;
mon_get.get(is_it01, end, true, iss, err01, result1);
VERIFY( result1 == digits1 );
VERIFY( err01 == ios_base::eofbit );
iss.str(L"7200000000,00 ");
iterator_type is_it02(iss);
long double result2;
ios_base::iostate err02 = ios_base::goodbit;
mon_get.get(is_it02, end, false, iss, err02, result2);
VERIFY( result2 == digits1 );
VERIFY( err02 == ios_base::eofbit );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,67 @@
// 2004-02-05 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.2.6.1.1 money_get members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// No thousands-sep allowed after the decimal-point.
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef istreambuf_iterator<wchar_t> iterator_type;
// basic construction
locale loc_c = locale::classic();
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
iterator_type end01, end02;
wistringstream iss;
iss.imbue(loc_de);
// cache the money_get facet
const money_get<wchar_t>& mon_get = use_facet<money_get<wchar_t> >(iss.getloc());
iss.str(L"500,1.0 ");
iterator_type is_it01(iss);
long double result1;
ios_base::iostate err01 = ios_base::goodbit;
end01 = mon_get.get(is_it01, end01, true, iss, err01, result1);
VERIFY( err01 == ios_base::failbit );
VERIFY( *end01 == '.' );
iss.str(L"500,1.0 ");
iterator_type is_it02(iss);
long double result2;
ios_base::iostate err02 = ios_base::goodbit;
end02 = mon_get.get(is_it02, end02, false, iss, err02, result2);
VERIFY( err02 == ios_base::failbit );
VERIFY( *end02 == '.' );
}
int main()
{
test01();
return 0;
}

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -37,12 +37,7 @@ void test02()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
VERIFY( loc_c != loc_hk );
// cache the moneypunct facets
typedef moneypunct<wchar_t, true> __money_true;

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -36,13 +36,8 @@ void test03()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the moneypunct facets
typedef moneypunct<wchar_t, true> __money_true;

View File

@ -1,6 +1,6 @@
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 Free Software Foundation
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -37,12 +37,7 @@ void test04()
// basic construction
locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro");
locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
VERIFY( loc_c != loc_hk );
// cache the moneypunct facets
typedef moneypunct<wchar_t, true> __money_true;

View File

@ -1,6 +1,6 @@
// 2003-05-27 Brendan Kehoe <brendan@zen.org>
// Copyright (C) 2003 Free Software Foundation
// Copyright (C) 2003, 2004 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -18,7 +18,7 @@
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// $22.2.6.3.3/8
// $22.2.6.3/3
// The number of digits required after the decimal point (if any) is exactly
// the value returned by frac_digits().