+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>
* docs/doxygen/run_doxygen: Bump required version.
// At this point, base is determined. If not hex, only allow
// 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.
string __found_grouping;
inline int
__int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit,
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
template<typename _CharT>
inline int
__int_to_char(_CharT* __bufend, unsigned long long __v,
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
template<typename _CharT, typename _ValueT>
--- /dev/null
+// 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;
+}
// bool, simple
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();
VERIFY( result1 == L"1" );
// VERIFY( os_it00 != os_it01 );
oss.str(empty);
- np.put(oss.rdbuf(), oss, '+', b0);
+ np.put(oss.rdbuf(), oss, L'+', b0);
result2 = oss.str();
VERIFY( result2 == L"0" );
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
- np.put(oss.rdbuf(), oss, '+', ul1);
+ np.put(oss.rdbuf(), oss, L'+', ul1);
result1 = oss.str();
VERIFY( result1 == L"1.294.967.294+++++++" );
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
- np.put(oss.rdbuf(), oss, '+', d1);
+ np.put(oss.rdbuf(), oss, L'+', d1);
result1 = oss.str();
VERIFY( result1 == L"1,79769e+308++++++++" );
oss.clear();
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
- np.put(oss.rdbuf(), oss, '+', d2);
+ np.put(oss.rdbuf(), oss, L'+', d2);
result1 = oss.str();
VERIFY( result1 == L"++++++++2,22507e-308" );
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield);
- np.put(oss.rdbuf(), oss, '+', d2);
+ np.put(oss.rdbuf(), oss, L'+', d2);
result2 = oss.str();
VERIFY( result2 == L"+++++++2,225074e-308" );
oss.setf(ios_base::right, ios_base::adjustfield);
oss.setf(ios_base::scientific, ios_base::floatfield);
oss.setf(ios_base::uppercase);
- np.put(oss.rdbuf(), oss, '+', d2);
+ np.put(oss.rdbuf(), oss, L'+', d2);
result1 = oss.str();
VERIFY( result1 == L"+++2,2250738585E-308" );
// long double
oss.str(empty);
oss.clear();
- np.put(oss.rdbuf(), oss, '+', ld1);
+ np.put(oss.rdbuf(), oss, L'+', ld1);
result1 = oss.str();
VERIFY( result1 == L"1,7976931349E+308" );
oss.clear();
oss.precision(0);
oss.setf(ios_base::fixed, ios_base::floatfield);
- np.put(oss.rdbuf(), oss, '+', ld2);
+ np.put(oss.rdbuf(), oss, L'+', ld2);
result1 = oss.str();
VERIFY( result1 == L"0" );
// const void
oss.str(empty);
oss.clear();
- np.put(oss.rdbuf(), oss, '+', cv);
+ np.put(oss.rdbuf(), oss, L'+', cv);
result1 = oss.str();
// No grouping characters.
VERIFY( !char_traits<wchar_t>::find(result1.c_str(),
oss.str(empty);
oss.clear();
- np.put(oss.rdbuf(), oss, '+', ll1);
+ np.put(oss.rdbuf(), oss, L'+', ll1);
result1 = oss.str();
VERIFY( result1 == L"9.223.372.036.854.775.807" );
#endif
test01();
return 0;
}
-
-
--- /dev/null
+// 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;
+}
oss.str(empty);
oss.width(20);
oss.setf(ios_base::right, ios_base::adjustfield);
- np.put(oss.rdbuf(), oss, '+', b0);
+ np.put(oss.rdbuf(), oss, L'+', b0);
result1 = oss.str();
VERIFY( result1 == L"+++++++++++++++++++0" );
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
oss.setf(ios_base::boolalpha);
- np.put(oss.rdbuf(), oss, '+', b1);
+ np.put(oss.rdbuf(), oss, L'+', b1);
result2 = oss.str();
VERIFY( result2 == L"true++++++++++++++++" );
oss.imbue(loc_c);
oss.str(empty);
oss.clear();
- np.put(oss.rdbuf(), oss, '+', ul1);
+ np.put(oss.rdbuf(), oss, L'+', ul1);
result1 = oss.str();
VERIFY( result1 == L"1294967294" );
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
- np.put(oss.rdbuf(), oss, '+', ul2);
+ np.put(oss.rdbuf(), oss, L'+', ul2);
result1 = oss.str();
VERIFY( result1 == L"0+++++++++++++++++++" );
}
test02();
return 0;
}
-
-
// long, in a locale that expects grouping
oss.str(empty);
oss.clear();
- np.put(oss.rdbuf(), oss, '+', l1);
+ np.put(oss.rdbuf(), oss, L'+', l1);
result1 = oss.str();
VERIFY( result1 == L"2,147,483,647" );
oss.clear();
oss.width(20);
oss.setf(ios_base::left, ios_base::adjustfield);
- np.put(oss.rdbuf(), oss, '+', l2);
+ np.put(oss.rdbuf(), oss, L'+', l2);
result1 = oss.str();
VERIFY( result1 == L"-2,147,483,647++++++" );
}
test03();
return 0;
}
-
-
// 01 put(long)
const long l = 1798;
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);
VERIFY( res == L"1798xxxxxxxxxxxxxx" );
VERIFY( sanity1 == L"1798" );
// 02 put(long double)
const long double ld = 1798.0;
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);
VERIFY( res == L"1798xxxxxxxxxxxxxx" );
VERIFY( sanity2 == L"1798" );
// 03 put(bool)
bool b = 1;
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);
VERIFY( res == L"1xxxxxxxxxxxxxxxxx" );
VERIFY( sanity3 == L"1" );
b = 0;
res = x;
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);
VERIFY( res == L"falsexxxxxxxxxxxxx" );
VERIFY( sanity4 == L"false" );
const void* cv = &ld;
res = x;
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);
VERIFY( sanity5.size() );
VERIFY( sanity5[1] == L'x' );
test04();
return 0;
}
-
-
oss.clear();
oss.setf(ios::showbase);
oss.setf(ios::hex, ios::basefield);
- np.put(oss.rdbuf(), oss, '+', l);
+ np.put(oss.rdbuf(), oss, L'+', l);
result = oss.str();
VERIFY( result == L"0" );
oss.clear();
oss.setf(ios::showbase);
oss.setf(ios::oct, ios::basefield);
- np.put(oss.rdbuf(), oss, '+', l);
+ np.put(oss.rdbuf(), oss, L'+', l);
result = oss.str();
VERIFY( result == L"0" );
}
test05();
return 0;
}
-
-
woss1.precision(-1);
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();
VERIFY( result1 == L"30.500000" );
woss2.precision(0);
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();
VERIFY( result2 == L"1e+00" );
}
long inum = 123;
double fnum = 123.456;
- np.put(oss.rdbuf(), oss, '+', inum);
+ np.put(oss.rdbuf(), oss, L'+', inum);
result = oss.str();
VERIFY( result == L"XYZ" );
oss.clear();
oss.str(empty);
- np.put(oss.rdbuf(), oss, '+', fnum);
+ np.put(oss.rdbuf(), oss, L'+', fnum);
result = oss.str();
VERIFY( result == L"XYZ.ABC" );
}