mirror of git://gcc.gnu.org/git/gcc.git
locale_facets.tcc (money_get::do_get(string)): First construct a tentative returned string...
2002-02-05 Paolo Carlini <pcarlini@unitus.it> * include/bits/locale_facets.tcc (money_get::do_get(string)): First construct a tentative returned string, then, only if the parsing succeeds, copy it into the string passed by reference. * testsuite/22_locale/money_get_members_char.cc: Add test06. * testsuite/22_locale/money_get_members_wchar_t.cc: Add test06. From-SVN: r49523
This commit is contained in:
parent
4505024e9e
commit
e07554eb17
|
|
@ -1,3 +1,11 @@
|
||||||
|
2002-02-05 Paolo Carlini <pcarlini@unitus.it>
|
||||||
|
|
||||||
|
* include/bits/locale_facets.tcc (money_get::do_get(string)):
|
||||||
|
First construct a tentative returned string, then, only if the
|
||||||
|
parsing succeeds, copy it into the string passed by reference.
|
||||||
|
* testsuite/22_locale/money_get_members_char.cc: Add test06.
|
||||||
|
* testsuite/22_locale/money_get_members_wchar_t.cc: Add test06.
|
||||||
|
|
||||||
2002-02-04 Phil Edwards <pme@gcc.gnu.org>
|
2002-02-04 Phil Edwards <pme@gcc.gnu.org>
|
||||||
|
|
||||||
* docs/doxygen/TODO: Impl-defined behavior now documented...
|
* docs/doxygen/TODO: Impl-defined behavior now documented...
|
||||||
|
|
|
||||||
|
|
@ -930,6 +930,9 @@ namespace std
|
||||||
// Flag marking when a decimal point is found.
|
// Flag marking when a decimal point is found.
|
||||||
bool __testdecfound = false;
|
bool __testdecfound = false;
|
||||||
|
|
||||||
|
// The tentative returned string is stored here.
|
||||||
|
string_type __temp_units;
|
||||||
|
|
||||||
char_type __c = *__beg;
|
char_type __c = *__beg;
|
||||||
char_type __eof = static_cast<char_type>(char_traits<char_type>::eof());
|
char_type __eof = static_cast<char_type>(char_traits<char_type>::eof());
|
||||||
for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
|
for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
|
||||||
|
|
@ -1019,7 +1022,7 @@ namespace std
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__units += __c;
|
__temp_units += __c;
|
||||||
++__sep_pos;
|
++__sep_pos;
|
||||||
}
|
}
|
||||||
__c = *(++__beg);
|
__c = *(++__beg);
|
||||||
|
|
@ -1050,11 +1053,11 @@ namespace std
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip leading zeros.
|
// Strip leading zeros.
|
||||||
while (__units[0] == __ctype.widen('0'))
|
while (__temp_units[0] == __ctype.widen('0'))
|
||||||
__units.erase(__units.begin());
|
__temp_units.erase(__temp_units.begin());
|
||||||
|
|
||||||
if (__sign.size() && __sign == __neg_sign)
|
if (__sign.size() && __sign == __neg_sign)
|
||||||
__units.insert(__units.begin(), __ctype.widen('-'));
|
__temp_units.insert(__temp_units.begin(), __ctype.widen('-'));
|
||||||
|
|
||||||
// Test for grouping fidelity.
|
// Test for grouping fidelity.
|
||||||
if (__grouping.size() && __grouping_tmp.size())
|
if (__grouping.size() && __grouping_tmp.size())
|
||||||
|
|
@ -1068,8 +1071,12 @@ namespace std
|
||||||
__err |= ios_base::eofbit;
|
__err |= ios_base::eofbit;
|
||||||
|
|
||||||
// Iff valid sequence is not recognized.
|
// Iff valid sequence is not recognized.
|
||||||
if (!__testvalid || !__units.size())
|
if (!__testvalid || !__temp_units.size())
|
||||||
__err |= ios_base::failbit;
|
__err |= ios_base::failbit;
|
||||||
|
else
|
||||||
|
// Use the "swap trick" to copy __temp_units into __units.
|
||||||
|
__temp_units.swap(__units);
|
||||||
|
|
||||||
return __beg;
|
return __beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -383,6 +383,42 @@ void test05()
|
||||||
VERIFY( valn_ns == "-123456" );
|
VERIFY( valn_ns == "-123456" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test06()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
typedef istreambuf_iterator<char> InIt;
|
||||||
|
InIt iend1, iend2, iend3;
|
||||||
|
|
||||||
|
locale loc;
|
||||||
|
string buffer1("123");
|
||||||
|
string buffer2("456");
|
||||||
|
string buffer3("Golgafrincham"); // From Nathan's original idea.
|
||||||
|
|
||||||
|
string val;
|
||||||
|
|
||||||
|
ios_base::iostate err;
|
||||||
|
|
||||||
|
const money_get<char,InIt>& mg =
|
||||||
|
use_facet<money_get<char, InIt> >(loc);
|
||||||
|
|
||||||
|
istringstream fmt1(buffer1);
|
||||||
|
InIt ibeg1(fmt1);
|
||||||
|
mg.get(ibeg1,iend1,false,fmt1,err,val);
|
||||||
|
VERIFY( val == buffer1 );
|
||||||
|
|
||||||
|
istringstream fmt2(buffer2);
|
||||||
|
InIt ibeg2(fmt2);
|
||||||
|
mg.get(ibeg2,iend2,false,fmt2,err,val);
|
||||||
|
VERIFY( val == buffer2 );
|
||||||
|
|
||||||
|
val = buffer3;
|
||||||
|
istringstream fmt3(buffer3);
|
||||||
|
InIt ibeg3(fmt3);
|
||||||
|
mg.get(ibeg3,iend3,false,fmt3,err,val);
|
||||||
|
VERIFY( val == buffer3 );
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
|
|
@ -390,5 +426,6 @@ int main()
|
||||||
test03();
|
test03();
|
||||||
test04();
|
test04();
|
||||||
test05();
|
test05();
|
||||||
|
test06();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,42 @@ void test05()
|
||||||
mg.get(ibegn_ns,iendn_ns,intl,fmtn_ns,err,valn_ns);
|
mg.get(ibegn_ns,iendn_ns,intl,fmtn_ns,err,valn_ns);
|
||||||
VERIFY( valn_ns == L"-123456" );
|
VERIFY( valn_ns == L"-123456" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test06()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
typedef istreambuf_iterator<wchar_t> InIt;
|
||||||
|
InIt iend1, iend2, iend3;
|
||||||
|
|
||||||
|
locale loc;
|
||||||
|
wstring buffer1(L"123");
|
||||||
|
wstring buffer2(L"456");
|
||||||
|
wstring buffer3(L"Golgafrincham");
|
||||||
|
|
||||||
|
wstring val;
|
||||||
|
|
||||||
|
ios_base::iostate err;
|
||||||
|
|
||||||
|
const money_get<wchar_t,InIt>& mg =
|
||||||
|
use_facet<money_get<wchar_t, InIt> >(loc);
|
||||||
|
|
||||||
|
wistringstream fmt1(buffer1);
|
||||||
|
InIt ibeg1(fmt1);
|
||||||
|
mg.get(ibeg1,iend1,false,fmt1,err,val);
|
||||||
|
VERIFY( val == buffer1 );
|
||||||
|
|
||||||
|
wistringstream fmt2(buffer2);
|
||||||
|
InIt ibeg2(fmt2);
|
||||||
|
mg.get(ibeg2,iend2,false,fmt2,err,val);
|
||||||
|
VERIFY( val == buffer2 );
|
||||||
|
|
||||||
|
val = buffer3;
|
||||||
|
wistringstream fmt3(buffer3);
|
||||||
|
InIt ibeg3(fmt3);
|
||||||
|
mg.get(ibeg3,iend3,false,fmt3,err,val);
|
||||||
|
VERIFY( val == buffer3 );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
@ -394,6 +430,7 @@ int main()
|
||||||
test03();
|
test03();
|
||||||
test04();
|
test04();
|
||||||
test05();
|
test05();
|
||||||
|
test06();
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue