locale_facets.tcc (money_get<>::_M_extract): The value _space_ indicates that at least one space is required at that position.

2004-03-08  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/locale_facets.tcc (money_get<>::_M_extract):
	The value _space_ indicates that at least one space is required
	at that position.
	* testsuite/22_locale/money_get/get/char/17.cc: New.
	* testsuite/22_locale/money_get/get/wchar_t/17.cc: New.

	* testsuite/22_locale/money_get/get/char/7.cc: Minor tweaks.
	* testsuite/22_locale/money_get/get/wchar_t/7.cc: Likewise.

	* include/bits/locale_facets.tcc (money_get<>::do_get(long_double&)):
	Remove redundant conditional on __str.size().

From-SVN: r79111
This commit is contained in:
Paolo Carlini 2004-03-08 10:51:30 +00:00 committed by Paolo Carlini
parent d50a16c433
commit f1c89270e5
6 changed files with 178 additions and 14 deletions

View File

@ -1,3 +1,17 @@
2004-03-08 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (money_get<>::_M_extract):
The value _space_ indicates that at least one space is required
at that position.
* testsuite/22_locale/money_get/get/char/17.cc: New.
* testsuite/22_locale/money_get/get/wchar_t/17.cc: New.
* testsuite/22_locale/money_get/get/char/7.cc: Minor tweaks.
* testsuite/22_locale/money_get/get/wchar_t/7.cc: Likewise.
* include/bits/locale_facets.tcc (money_get<>::do_get(long_double&)):
Remove redundant conditional on __str.size().
2004-03-08 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/allocator.h: Switch defaults to mt_alloc.

View File

@ -1293,6 +1293,11 @@ namespace std
__testvalid = false;
break;
case money_base::space:
// At least one space is required.
if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
++__beg;
else
__testvalid = false;
case money_base::none:
// Only if not at the end of the pattern.
if (__i != 3)
@ -1372,10 +1377,7 @@ namespace std
__beg = _M_extract<true>(__beg, __end, __io, __err, __str);
else
__beg = _M_extract<false>(__beg, __end, __io, __err, __str);
if (__str.size())
std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
return __beg;
}

View File

@ -0,0 +1,71 @@
// 2004-03-08 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>
// 22.2.6.3, p2: "The value _space_ indicates that at least one space
// is required at that position."
void test01()
{
using namespace std;
typedef istreambuf_iterator<char> iterator_type;
bool test __attribute__((unused)) = true;
// 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 end, 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("7.200.000.000,00");
iterator_type is_it01(iss);
string result1;
ios_base::iostate err01 = ios_base::goodbit;
mon_get.get(is_it01, end, true, iss, err01, result1);
VERIFY( err01 == (ios_base::failbit | ios_base::eofbit) );
// now try with showbase, to get currency symbol in format
iss.setf(ios_base::showbase);
iss.str("7.200.000.000,00EUR ");
iterator_type is_it02(iss);
string result2;
ios_base::iostate err02 = ios_base::goodbit;
end02 = mon_get.get(is_it02, end, true, iss, err02, result2);
VERIFY( err02 == ios_base::failbit );
VERIFY( *end02 == 'E' );
}
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
@ -44,22 +44,25 @@ void test07()
ios_base::iostate err;
const money_get<char,InIt>& mg = use_facet<money_get<char, InIt> >(loc_c);
const money_get<char, InIt>& mg = use_facet<money_get<char, InIt> >(loc_c);
istringstream fmt1(buffer1);
fmt1.imbue(loc_c);
InIt ibeg1(fmt1);
mg.get(ibeg1,iend1,false,fmt1,err,val);
mg.get(ibeg1, iend1, false, fmt1, err, val);
VERIFY( val == buffer1 );
istringstream fmt2(buffer2);
fmt2.imbue(loc_c);
InIt ibeg2(fmt2);
mg.get(ibeg2,iend2,false,fmt2,err,val);
mg.get(ibeg2, iend2, false, fmt2, err, val);
VERIFY( val == buffer2 );
val = buffer3;
istringstream fmt3(buffer3);
fmt3.imbue(loc_c);
InIt ibeg3(fmt3);
mg.get(ibeg3,iend3,false,fmt3,err,val);
mg.get(ibeg3, iend3, false, fmt3, err, val);
VERIFY( val == buffer3 );
}

View File

@ -0,0 +1,71 @@
// 2004-03-08 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>
// 22.2.6.3, p2: "The value _space_ indicates that at least one space
// is required at that position."
void test01()
{
using namespace std;
typedef istreambuf_iterator<wchar_t> iterator_type;
bool test __attribute__((unused)) = true;
// 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 end, 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"7.200.000.000,00");
iterator_type is_it01(iss);
wstring result1;
ios_base::iostate err01 = ios_base::goodbit;
mon_get.get(is_it01, end, true, iss, err01, result1);
VERIFY( err01 == (ios_base::failbit | ios_base::eofbit) );
// now try with showbase, to get currency symbol in format
iss.setf(ios_base::showbase);
iss.str(L"7.200.000.000,00EUR ");
iterator_type is_it02(iss);
wstring result2;
ios_base::iostate err02 = ios_base::goodbit;
end02 = mon_get.get(is_it02, end, true, iss, err02, result2);
VERIFY( err02 == ios_base::failbit );
VERIFY( *end02 == L'E' );
}
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
@ -44,22 +44,25 @@ void test07()
ios_base::iostate err;
const money_get<wchar_t,InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc_c);
const money_get<wchar_t, InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc_c);
wistringstream fmt1(buffer1);
fmt1.imbue(loc_c);
InIt ibeg1(fmt1);
mg.get(ibeg1,iend1,false,fmt1,err,val);
mg.get(ibeg1, iend1, false, fmt1, err, val);
VERIFY( val == buffer1 );
wistringstream fmt2(buffer2);
fmt2.imbue(loc_c);
InIt ibeg2(fmt2);
mg.get(ibeg2,iend2,false,fmt2,err,val);
mg.get(ibeg2, iend2, false, fmt2, err, val);
VERIFY( val == buffer2 );
val = buffer3;
wistringstream fmt3(buffer3);
fmt3.imbue(loc_c);
InIt ibeg3(fmt3);
mg.get(ibeg3,iend3,false,fmt3,err,val);
mg.get(ibeg3, iend3, false, fmt3, err, val);
VERIFY( val == buffer3 );
}