locale_facets.tcc (money_get::do_get(string)): Check for zero-length negative sign before adding it to output string.
2002-01-11 Benjamin Kosnik <bkoz@redhat.com> * include/bits/locale_facets.tcc (money_get::do_get(string)): Check for zero-length negative sign before adding it to output string. (money_get::do_get(long double)): Return beg. * testsuite/22_locale/money_get_members_char.cc (test02): Add iterator checks. * testsuite/22_locale/money_get_members_wchar_t.cc: Same. From-SVN: r48777
This commit is contained in:
parent
96ae8197d2
commit
87a9c33cb1
@ -1,3 +1,13 @@
|
||||
2002-01-11 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* include/bits/locale_facets.tcc (money_get::do_get(string)):
|
||||
Check for zero-length negative sign before adding it to output
|
||||
string.
|
||||
(money_get::do_get(long double)): Return beg.
|
||||
* testsuite/22_locale/money_get_members_char.cc (test02): Add
|
||||
iterator checks.
|
||||
* testsuite/22_locale/money_get_members_wchar_t.cc: Same.
|
||||
|
||||
2002-01-10 David Seymour <seymour_dj@yahoo.com>
|
||||
|
||||
libstdc++/5331
|
||||
|
@ -1035,7 +1035,7 @@ namespace std
|
||||
ios_base::iostate& __err, long double& __units) const
|
||||
{
|
||||
string_type __str;
|
||||
this->do_get(__beg, __end, __intl, __io, __err, __str);
|
||||
__beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
|
||||
|
||||
const int __n = numeric_limits<long double>::digits10;
|
||||
char* __cs = static_cast<char*>(__builtin_alloca(sizeof(char) * __n));
|
||||
@ -1222,7 +1222,7 @@ namespace std
|
||||
while (__units[0] == __ctype.widen('0'))
|
||||
__units.erase(__units.begin());
|
||||
|
||||
if (__sign == __neg_sign)
|
||||
if (__sign.size() && __sign == __neg_sign)
|
||||
__units.insert(__units.begin(), __ctype.widen('-'));
|
||||
|
||||
// Test for grouping fidelity.
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 2001-09-12 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation
|
||||
// Copyright (C) 2001-2002 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
|
||||
@ -172,7 +172,7 @@ void test01()
|
||||
VERIFY( err11 == ios_base::goodbit );
|
||||
}
|
||||
|
||||
// test double/string versions
|
||||
// test double version
|
||||
void test02()
|
||||
{
|
||||
using namespace std;
|
||||
@ -249,9 +249,50 @@ void test02()
|
||||
VERIFY( err03 == ios_base::goodbit );
|
||||
}
|
||||
|
||||
void test03()
|
||||
{
|
||||
using namespace std;
|
||||
bool test = true;
|
||||
|
||||
// Check money_get works with other iterators besides streambuf
|
||||
// output iterators.
|
||||
typedef string::const_iterator iter_type;
|
||||
typedef money_get<char, iter_type> mon_get_type;
|
||||
const ios_base::iostate goodbit = ios_base::goodbit;
|
||||
const ios_base::iostate eofbit = ios_base::eofbit;
|
||||
ios_base::iostate err = goodbit;
|
||||
const locale loc_c = locale::classic();
|
||||
const string str = "0.01Eleanor Roosevelt";
|
||||
|
||||
istringstream iss;
|
||||
iss.imbue(locale(loc_c, new mon_get_type));
|
||||
|
||||
// Iterator advanced, state, output.
|
||||
const mon_get_type& mg = use_facet<mon_get_type>(iss.getloc());
|
||||
|
||||
// 01 string
|
||||
string res1;
|
||||
iter_type end1 = mg.get(str.begin(), str.end(), false, iss, err, res1);
|
||||
string rem1(end1, str.end());
|
||||
VERIFY( err == goodbit );
|
||||
VERIFY( res1 == "1" );
|
||||
VERIFY( rem1 == "Eleanor Roosevelt" );
|
||||
|
||||
// 02 long double
|
||||
iss.clear();
|
||||
err = goodbit;
|
||||
long double res2;
|
||||
iter_type end2 = mg.get(str.begin(), str.end(), false, iss, err, res2);
|
||||
string rem2(end2, str.end());
|
||||
VERIFY( err == goodbit );
|
||||
VERIFY( res2 == 1 );
|
||||
VERIFY( rem2 == "Eleanor Roosevelt" );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 2001-09-14 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation
|
||||
// Copyright (C) 2001-2002 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
|
||||
@ -250,13 +250,55 @@ void test02()
|
||||
VERIFY( result3 == digits4 );
|
||||
VERIFY( err03 == ios_base::goodbit );
|
||||
}
|
||||
|
||||
void test03()
|
||||
{
|
||||
using namespace std;
|
||||
bool test = true;
|
||||
|
||||
// Check money_get works with other iterators besides streambuf
|
||||
// output iterators.
|
||||
typedef wstring::const_iterator iter_type;
|
||||
typedef money_get<wchar_t, iter_type> mon_get_type;
|
||||
const ios_base::iostate goodbit = ios_base::goodbit;
|
||||
const ios_base::iostate eofbit = ios_base::eofbit;
|
||||
ios_base::iostate err = goodbit;
|
||||
const locale loc_c = locale::classic();
|
||||
const wstring str = L"0.01Eleanor Roosevelt";
|
||||
|
||||
wistringstream iss;
|
||||
iss.imbue(locale(loc_c, new mon_get_type));
|
||||
|
||||
// Iterator advanced, state, output.
|
||||
const mon_get_type& mg = use_facet<mon_get_type>(iss.getloc());
|
||||
|
||||
// 01 string
|
||||
wstring res1;
|
||||
iter_type end1 = mg.get(str.begin(), str.end(), false, iss, err, res1);
|
||||
wstring rem1(end1, str.end());
|
||||
VERIFY( err == goodbit );
|
||||
VERIFY( res1 == L"1" );
|
||||
VERIFY( rem1 == L"Eleanor Roosevelt" );
|
||||
|
||||
// 02 long double
|
||||
iss.clear();
|
||||
err = goodbit;
|
||||
long double res2;
|
||||
iter_type end2 = mg.get(str.begin(), str.end(), false, iss, err, res2);
|
||||
wstring rem2(end2, str.end());
|
||||
VERIFY( err == goodbit );
|
||||
VERIFY( res2 == 1 );
|
||||
VERIFY( rem2 == L"Eleanor Roosevelt" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user