Commit fea6ecb7 by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/15565 ([3.4 only] SLES9: leading + sign for unsigned int with showpos)

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

	PR libstdc++/15565
	* include/bits/locale_facets.tcc (__int_to_char(unsigned long),
	__int_to_char(unsigned long long)): Showpos is not relevant
	for unsigned types.
	* testsuite/22_locale/num_put/put/char/15565.cc: New.
	* testsuite/22_locale/num_put/put/wchar_t/15565.cc: New.

	* testsuite/22_locale/num_put/put/wchar_t/1.cc: Use L for the fill
	char.
	* testsuite/22_locale/num_put/put/wchar_t/2.cc: Likewise.
	* testsuite/22_locale/num_put/put/wchar_t/3.cc: Likewise.
	* testsuite/22_locale/num_put/put/wchar_t/4.cc: Likewise.
	* testsuite/22_locale/num_put/put/wchar_t/5.cc: Likewise.
	* testsuite/22_locale/num_put/put/wchar_t/6.cc: Likewise.
	* testsuite/22_locale/num_put/put/wchar_t/8.cc: Likewise.

From-SVN: r82128
parent 0bc0f41d
2004-05-22 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/15565
* include/bits/locale_facets.tcc (__int_to_char(unsigned long),
__int_to_char(unsigned long long)): Showpos is not relevant
for unsigned types.
* testsuite/22_locale/num_put/put/char/15565.cc: New.
* testsuite/22_locale/num_put/put/wchar_t/15565.cc: New.
* testsuite/22_locale/num_put/put/wchar_t/1.cc: Use L for the fill
char.
* testsuite/22_locale/num_put/put/wchar_t/2.cc: Likewise.
* testsuite/22_locale/num_put/put/wchar_t/3.cc: Likewise.
* testsuite/22_locale/num_put/put/wchar_t/4.cc: Likewise.
* testsuite/22_locale/num_put/put/wchar_t/5.cc: Likewise.
* testsuite/22_locale/num_put/put/wchar_t/6.cc: Likewise.
* testsuite/22_locale/num_put/put/wchar_t/8.cc: Likewise.
2004-05-21 Matthias Klose <doko@debian.org> 2004-05-21 Matthias Klose <doko@debian.org>
* docs/doxygen/run_doxygen: Bump required version. * docs/doxygen/run_doxygen: Bump required version.
......
...@@ -497,7 +497,8 @@ namespace std ...@@ -497,7 +497,8 @@ namespace std
// At this point, base is determined. If not hex, only allow // At this point, base is determined. If not hex, only allow
// base digits as valid input. // base digits as valid input.
const size_t __len = __base == 16 ? __num_base::_S_iend - __num_base::_S_izero : __base; const size_t __len = (__base == 16 ? __num_base::_S_iend
- __num_base::_S_izero : __base);
// Extract. // Extract.
string __found_grouping; string __found_grouping;
...@@ -826,7 +827,11 @@ namespace std ...@@ -826,7 +827,11 @@ namespace std
inline int inline int
__int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit, __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
ios_base::fmtflags __flags) ios_base::fmtflags __flags)
{ return __int_to_char(__bufend, __v, __lit, __flags, false); } {
// About showpos, see Table 60 and C99 7.19.6.1, p6 (+).
return __int_to_char(__bufend, __v, __lit,
__flags & ~ios_base::showpos, false);
}
#ifdef _GLIBCXX_USE_LONG_LONG #ifdef _GLIBCXX_USE_LONG_LONG
template<typename _CharT> template<typename _CharT>
...@@ -848,7 +853,8 @@ namespace std ...@@ -848,7 +853,8 @@ namespace std
inline int inline int
__int_to_char(_CharT* __bufend, unsigned long long __v, __int_to_char(_CharT* __bufend, unsigned long long __v,
const _CharT* __lit, ios_base::fmtflags __flags) const _CharT* __lit, ios_base::fmtflags __flags)
{ return __int_to_char(__bufend, __v, __lit, __flags, false); } { return __int_to_char(__bufend, __v, __lit,
__flags & ~ios_base::showpos, false); }
#endif #endif
template<typename _CharT, typename _ValueT> template<typename _CharT, typename _ValueT>
......
// 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.2.2.1 num_put members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// libstdc++/15565
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
// basic construction
locale loc_c = locale::classic();
// sanity check the data is correct.
const string empty;
// cache the num_put facet
ostringstream oss;
oss.imbue(loc_c);
const num_put<char>& np = use_facet<num_put<char> >(oss.getloc());
unsigned long ul1 = 42UL;
oss.str(empty);
oss.clear();
oss.setf(ios_base::showpos);
np.put(oss.rdbuf(), oss, ' ', ul1);
VERIFY( oss.str() == "42" );
#ifdef _GLIBCXX_USE_LONG_LONG
unsigned long long ull1 = 31ULL;
oss.str(empty);
oss.clear();
oss.setf(ios_base::showpos);
np.put(oss.rdbuf(), oss, ' ', ull1);
VERIFY( oss.str() == "31" );
#endif
}
int main()
{
test01();
return 0;
}
...@@ -60,13 +60,13 @@ void test01() ...@@ -60,13 +60,13 @@ void test01()
// bool, simple // bool, simple
iterator_type os_it00 = oss.rdbuf(); iterator_type os_it00 = oss.rdbuf();
iterator_type os_it01 = np.put(os_it00, oss, '+', b1); iterator_type os_it01 = np.put(os_it00, oss, L'+', b1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"1" ); VERIFY( result1 == L"1" );
// VERIFY( os_it00 != os_it01 ); // VERIFY( os_it00 != os_it01 );
oss.str(empty); oss.str(empty);
np.put(oss.rdbuf(), oss, '+', b0); np.put(oss.rdbuf(), oss, L'+', b0);
result2 = oss.str(); result2 = oss.str();
VERIFY( result2 == L"0" ); VERIFY( result2 == L"0" );
...@@ -76,7 +76,7 @@ void test01() ...@@ -76,7 +76,7 @@ void test01()
oss.clear(); oss.clear();
oss.width(20); oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield); oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', ul1); np.put(oss.rdbuf(), oss, L'+', ul1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"1.294.967.294+++++++" ); VERIFY( result1 == L"1.294.967.294+++++++" );
...@@ -85,7 +85,7 @@ void test01() ...@@ -85,7 +85,7 @@ void test01()
oss.clear(); oss.clear();
oss.width(20); oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield); oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', d1); np.put(oss.rdbuf(), oss, L'+', d1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"1,79769e+308++++++++" ); VERIFY( result1 == L"1,79769e+308++++++++" );
...@@ -93,7 +93,7 @@ void test01() ...@@ -93,7 +93,7 @@ void test01()
oss.clear(); oss.clear();
oss.width(20); oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield); oss.setf(ios_base::right, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', d2); np.put(oss.rdbuf(), oss, L'+', d2);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"++++++++2,22507e-308" ); VERIFY( result1 == L"++++++++2,22507e-308" );
...@@ -102,7 +102,7 @@ void test01() ...@@ -102,7 +102,7 @@ void test01()
oss.width(20); oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield); oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield); oss.setf(ios_base::scientific, ios_base::floatfield);
np.put(oss.rdbuf(), oss, '+', d2); np.put(oss.rdbuf(), oss, L'+', d2);
result2 = oss.str(); result2 = oss.str();
VERIFY( result2 == L"+++++++2,225074e-308" ); VERIFY( result2 == L"+++++++2,225074e-308" );
...@@ -113,14 +113,14 @@ void test01() ...@@ -113,14 +113,14 @@ void test01()
oss.setf(ios_base::right, ios_base::adjustfield); oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield); oss.setf(ios_base::scientific, ios_base::floatfield);
oss.setf(ios_base::uppercase); oss.setf(ios_base::uppercase);
np.put(oss.rdbuf(), oss, '+', d2); np.put(oss.rdbuf(), oss, L'+', d2);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"+++2,2250738585E-308" ); VERIFY( result1 == L"+++2,2250738585E-308" );
// long double // long double
oss.str(empty); oss.str(empty);
oss.clear(); oss.clear();
np.put(oss.rdbuf(), oss, '+', ld1); np.put(oss.rdbuf(), oss, L'+', ld1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"1,7976931349E+308" ); VERIFY( result1 == L"1,7976931349E+308" );
...@@ -128,14 +128,14 @@ void test01() ...@@ -128,14 +128,14 @@ void test01()
oss.clear(); oss.clear();
oss.precision(0); oss.precision(0);
oss.setf(ios_base::fixed, ios_base::floatfield); oss.setf(ios_base::fixed, ios_base::floatfield);
np.put(oss.rdbuf(), oss, '+', ld2); np.put(oss.rdbuf(), oss, L'+', ld2);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"0" ); VERIFY( result1 == L"0" );
// const void // const void
oss.str(empty); oss.str(empty);
oss.clear(); oss.clear();
np.put(oss.rdbuf(), oss, '+', cv); np.put(oss.rdbuf(), oss, L'+', cv);
result1 = oss.str(); result1 = oss.str();
// No grouping characters. // No grouping characters.
VERIFY( !char_traits<wchar_t>::find(result1.c_str(), VERIFY( !char_traits<wchar_t>::find(result1.c_str(),
...@@ -149,7 +149,7 @@ void test01() ...@@ -149,7 +149,7 @@ void test01()
oss.str(empty); oss.str(empty);
oss.clear(); oss.clear();
np.put(oss.rdbuf(), oss, '+', ll1); np.put(oss.rdbuf(), oss, L'+', ll1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"9.223.372.036.854.775.807" ); VERIFY( result1 == L"9.223.372.036.854.775.807" );
#endif #endif
...@@ -160,5 +160,3 @@ int main() ...@@ -160,5 +160,3 @@ int main()
test01(); test01();
return 0; return 0;
} }
// 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.2.2.1 num_put members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// libstdc++/15565
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
// basic construction
locale loc_c = locale::classic();
// sanity check the data is correct.
const wstring empty;
// cache the num_put facet
wostringstream oss;
oss.imbue(loc_c);
const num_put<wchar_t>& np = use_facet<num_put<wchar_t> >(oss.getloc());
unsigned long ul1 = 42UL;
oss.str(empty);
oss.clear();
oss.setf(ios_base::showpos);
np.put(oss.rdbuf(), oss, L' ', ul1);
VERIFY( oss.str() == L"42" );
#ifdef _GLIBCXX_USE_LONG_LONG
unsigned long long ull1 = 31ULL;
oss.str(empty);
oss.clear();
oss.setf(ios_base::showpos);
np.put(oss.rdbuf(), oss, L' ', ull1);
VERIFY( oss.str() == L"31" );
#endif
}
int main()
{
test01();
return 0;
}
...@@ -54,7 +54,7 @@ void test02() ...@@ -54,7 +54,7 @@ void test02()
oss.str(empty); oss.str(empty);
oss.width(20); oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield); oss.setf(ios_base::right, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', b0); np.put(oss.rdbuf(), oss, L'+', b0);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"+++++++++++++++++++0" ); VERIFY( result1 == L"+++++++++++++++++++0" );
...@@ -62,7 +62,7 @@ void test02() ...@@ -62,7 +62,7 @@ void test02()
oss.width(20); oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield); oss.setf(ios_base::left, ios_base::adjustfield);
oss.setf(ios_base::boolalpha); oss.setf(ios_base::boolalpha);
np.put(oss.rdbuf(), oss, '+', b1); np.put(oss.rdbuf(), oss, L'+', b1);
result2 = oss.str(); result2 = oss.str();
VERIFY( result2 == L"true++++++++++++++++" ); VERIFY( result2 == L"true++++++++++++++++" );
...@@ -70,7 +70,7 @@ void test02() ...@@ -70,7 +70,7 @@ void test02()
oss.imbue(loc_c); oss.imbue(loc_c);
oss.str(empty); oss.str(empty);
oss.clear(); oss.clear();
np.put(oss.rdbuf(), oss, '+', ul1); np.put(oss.rdbuf(), oss, L'+', ul1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"1294967294" ); VERIFY( result1 == L"1294967294" );
...@@ -78,7 +78,7 @@ void test02() ...@@ -78,7 +78,7 @@ void test02()
oss.clear(); oss.clear();
oss.width(20); oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield); oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', ul2); np.put(oss.rdbuf(), oss, L'+', ul2);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"0+++++++++++++++++++" ); VERIFY( result1 == L"0+++++++++++++++++++" );
} }
...@@ -88,5 +88,3 @@ int main() ...@@ -88,5 +88,3 @@ int main()
test02(); test02();
return 0; return 0;
} }
...@@ -53,7 +53,7 @@ void test03() ...@@ -53,7 +53,7 @@ void test03()
// long, in a locale that expects grouping // long, in a locale that expects grouping
oss.str(empty); oss.str(empty);
oss.clear(); oss.clear();
np.put(oss.rdbuf(), oss, '+', l1); np.put(oss.rdbuf(), oss, L'+', l1);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"2,147,483,647" ); VERIFY( result1 == L"2,147,483,647" );
...@@ -61,7 +61,7 @@ void test03() ...@@ -61,7 +61,7 @@ void test03()
oss.clear(); oss.clear();
oss.width(20); oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield); oss.setf(ios_base::left, ios_base::adjustfield);
np.put(oss.rdbuf(), oss, '+', l2); np.put(oss.rdbuf(), oss, L'+', l2);
result1 = oss.str(); result1 = oss.str();
VERIFY( result1 == L"-2,147,483,647++++++" ); VERIFY( result1 == L"-2,147,483,647++++++" );
} }
...@@ -71,5 +71,3 @@ int main() ...@@ -71,5 +71,3 @@ int main()
test03(); test03();
return 0; return 0;
} }
...@@ -53,7 +53,7 @@ void test04() ...@@ -53,7 +53,7 @@ void test04()
// 01 put(long) // 01 put(long)
const long l = 1798; const long l = 1798;
res = x; res = x;
iter_type ret1 = tp.put(res.begin(), oss, ' ', l); iter_type ret1 = tp.put(res.begin(), oss, L' ', l);
wstring sanity1(res.begin(), ret1); wstring sanity1(res.begin(), ret1);
VERIFY( res == L"1798xxxxxxxxxxxxxx" ); VERIFY( res == L"1798xxxxxxxxxxxxxx" );
VERIFY( sanity1 == L"1798" ); VERIFY( sanity1 == L"1798" );
...@@ -61,7 +61,7 @@ void test04() ...@@ -61,7 +61,7 @@ void test04()
// 02 put(long double) // 02 put(long double)
const long double ld = 1798.0; const long double ld = 1798.0;
res = x; res = x;
iter_type ret2 = tp.put(res.begin(), oss, ' ', ld); iter_type ret2 = tp.put(res.begin(), oss, L' ', ld);
wstring sanity2(res.begin(), ret2); wstring sanity2(res.begin(), ret2);
VERIFY( res == L"1798xxxxxxxxxxxxxx" ); VERIFY( res == L"1798xxxxxxxxxxxxxx" );
VERIFY( sanity2 == L"1798" ); VERIFY( sanity2 == L"1798" );
...@@ -69,7 +69,7 @@ void test04() ...@@ -69,7 +69,7 @@ void test04()
// 03 put(bool) // 03 put(bool)
bool b = 1; bool b = 1;
res = x; res = x;
iter_type ret3 = tp.put(res.begin(), oss, ' ', b); iter_type ret3 = tp.put(res.begin(), oss, L' ', b);
wstring sanity3(res.begin(), ret3); wstring sanity3(res.begin(), ret3);
VERIFY( res == L"1xxxxxxxxxxxxxxxxx" ); VERIFY( res == L"1xxxxxxxxxxxxxxxxx" );
VERIFY( sanity3 == L"1" ); VERIFY( sanity3 == L"1" );
...@@ -77,7 +77,7 @@ void test04() ...@@ -77,7 +77,7 @@ void test04()
b = 0; b = 0;
res = x; res = x;
oss.setf(ios_base::boolalpha); oss.setf(ios_base::boolalpha);
iter_type ret4 = tp.put(res.begin(), oss, ' ', b); iter_type ret4 = tp.put(res.begin(), oss, L' ', b);
wstring sanity4(res.begin(), ret4); wstring sanity4(res.begin(), ret4);
VERIFY( res == L"falsexxxxxxxxxxxxx" ); VERIFY( res == L"falsexxxxxxxxxxxxx" );
VERIFY( sanity4 == L"false" ); VERIFY( sanity4 == L"false" );
...@@ -87,7 +87,7 @@ void test04() ...@@ -87,7 +87,7 @@ void test04()
const void* cv = &ld; const void* cv = &ld;
res = x; res = x;
oss.setf(ios_base::fixed, ios_base::floatfield); oss.setf(ios_base::fixed, ios_base::floatfield);
iter_type ret5 = tp.put(res.begin(), oss, ' ', cv); iter_type ret5 = tp.put(res.begin(), oss, L' ', cv);
wstring sanity5(res.begin(), ret5); wstring sanity5(res.begin(), ret5);
VERIFY( sanity5.size() ); VERIFY( sanity5.size() );
VERIFY( sanity5[1] == L'x' ); VERIFY( sanity5[1] == L'x' );
...@@ -98,5 +98,3 @@ int main() ...@@ -98,5 +98,3 @@ int main()
test04(); test04();
return 0; return 0;
} }
...@@ -48,7 +48,7 @@ void test05() ...@@ -48,7 +48,7 @@ void test05()
oss.clear(); oss.clear();
oss.setf(ios::showbase); oss.setf(ios::showbase);
oss.setf(ios::hex, ios::basefield); oss.setf(ios::hex, ios::basefield);
np.put(oss.rdbuf(), oss, '+', l); np.put(oss.rdbuf(), oss, L'+', l);
result = oss.str(); result = oss.str();
VERIFY( result == L"0" ); VERIFY( result == L"0" );
...@@ -56,7 +56,7 @@ void test05() ...@@ -56,7 +56,7 @@ void test05()
oss.clear(); oss.clear();
oss.setf(ios::showbase); oss.setf(ios::showbase);
oss.setf(ios::oct, ios::basefield); oss.setf(ios::oct, ios::basefield);
np.put(oss.rdbuf(), oss, '+', l); np.put(oss.rdbuf(), oss, L'+', l);
result = oss.str(); result = oss.str();
VERIFY( result == L"0" ); VERIFY( result == L"0" );
} }
...@@ -66,5 +66,3 @@ int main() ...@@ -66,5 +66,3 @@ int main()
test05(); test05();
return 0; return 0;
} }
...@@ -38,13 +38,13 @@ void test01() ...@@ -38,13 +38,13 @@ void test01()
woss1.precision(-1); woss1.precision(-1);
woss1.setf(ios_base::fixed, ios_base::floatfield); woss1.setf(ios_base::fixed, ios_base::floatfield);
np1.put(woss1.rdbuf(), woss1, '+', 30.5); np1.put(woss1.rdbuf(), woss1, L'+', 30.5);
result1 = woss1.str(); result1 = woss1.str();
VERIFY( result1 == L"30.500000" ); VERIFY( result1 == L"30.500000" );
woss2.precision(0); woss2.precision(0);
woss2.setf(ios_base::scientific, ios_base::floatfield); woss2.setf(ios_base::scientific, ios_base::floatfield);
np2.put(woss2.rdbuf(), woss2, '+', 1.0); np2.put(woss2.rdbuf(), woss2, L'+', 1.0);
result2 = woss2.str(); result2 = woss2.str();
VERIFY( result2 == L"1e+00" ); VERIFY( result2 == L"1e+00" );
} }
......
...@@ -51,13 +51,13 @@ void test01() ...@@ -51,13 +51,13 @@ void test01()
long inum = 123; long inum = 123;
double fnum = 123.456; double fnum = 123.456;
np.put(oss.rdbuf(), oss, '+', inum); np.put(oss.rdbuf(), oss, L'+', inum);
result = oss.str(); result = oss.str();
VERIFY( result == L"XYZ" ); VERIFY( result == L"XYZ" );
oss.clear(); oss.clear();
oss.str(empty); oss.str(empty);
np.put(oss.rdbuf(), oss, '+', fnum); np.put(oss.rdbuf(), oss, L'+', fnum);
result = oss.str(); result = oss.str();
VERIFY( result == L"XYZ.ABC" ); VERIFY( result == L"XYZ.ABC" );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment