This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] libstdc++/22131
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 28 Jun 2005 16:16:28 +0200
- Subject: [Patch] libstdc++/22131
Hi,
the below fixes this PR submitted by Martin. The issue in itself is
rather straightforward but adjusting consistently the library required a
few changes, because we were actively implementing something different
from the standard. A few observations:
1- As a consistency problem in the standard, the actual wording for
money_get is not as clear as that for num_get. I'm implementing a
consistent behavior but maybe a DR should be prepared.
2- In the same spirit, I'm punting on the well known consistency issue
wrt assigning vs "OR-ing" failbit at the end of the parsing in the
various facets, already discussed a bit with Martin and Nathan.
3- Also, I'm not trying to deal one-shot with DR 23 too, which finally
is making progress. I'd rather prefer waiting 'til the next meeting and
Plauger wording.
Testing x86-linux, will wait a while in case of comments. Will go in
mainline only.
Paolo.
////////////////
2005-06-28 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/22131
* include/bits/locale_facets.tcc (num_get<>::_M_extract_int,
num_get<>::_M_extract_float, money_get<>::_M_extract):
Adjust to assign the result also when digit grouping is
wrong (but the grammar is correct), as per 22.2.2.1.2, p11-12
(NB: consistently for money_get too).
* config/locale/generic/c_locale.cc (__convert_from_v): Do
not check ios_base::failbit at the outset.
* config/locale/gnu/c_locale.cc: Likewise.
* testsuite/22_locale/money_get/get/char/22131.cc: New.
* testsuite/22_locale/money_get/get/wchar_t/22131.cc: Likewise.
* testsuite/22_locale/num_get/get/char/22131.cc: Likewise.
* testsuite/22_locale/num_get/get/wchar_t/22131.cc: Likewise.
* testsuite/22_locale/num_get/get/char/12.cc: Adjust.
* testsuite/22_locale/num_get/get/wchar_t/12.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc:
Likewise.
diff -prN libstdc++-v3-orig/config/locale/generic/c_locale.cc libstdc++-v3/config/locale/generic/c_locale.cc
*** libstdc++-v3-orig/config/locale/generic/c_locale.cc Mon Oct 4 02:19:57 2004
--- libstdc++-v3/config/locale/generic/c_locale.cc Mon Jun 27 20:28:14 2005
***************
*** 1,6 ****
// Wrapper for underlying C-language localization -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// 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
--- 1,6 ----
// Wrapper for underlying C-language localization -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
//
// 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
*************** namespace std
*** 50,88 ****
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale&)
{
! if (!(__err & ios_base::failbit))
! {
! // Assumes __s formatted for "C" locale.
! char* __old = strdup(setlocale(LC_ALL, NULL));
! setlocale(LC_ALL, "C");
! char* __sanity;
! errno = 0;
#if defined(_GLIBCXX_HAVE_STRTOF)
! float __f = strtof(__s, &__sanity);
#else
! double __d = strtod(__s, &__sanity);
! float __f = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
! if (!finitef (__f))
! errno = ERANGE;
#elif defined (_GLIBCXX_HAVE_FINITE)
! if (!finite (static_cast<double> (__f)))
! errno = ERANGE;
#elif defined (_GLIBCXX_HAVE_ISINF)
! if (isinf (static_cast<double> (__f)))
! errno = ERANGE;
#else
! if (fabs(__d) > numeric_limits<float>::max())
! errno = ERANGE;
#endif
#endif
! if (__sanity != __s && errno != ERANGE)
! __v = __f;
! else
! __err |= ios_base::failbit;
! setlocale(LC_ALL, __old);
! free(__old);
! }
}
template<>
--- 50,85 ----
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale&)
{
! // Assumes __s formatted for "C" locale.
! char* __old = strdup(setlocale(LC_ALL, NULL));
! setlocale(LC_ALL, "C");
! char* __sanity;
! errno = 0;
#if defined(_GLIBCXX_HAVE_STRTOF)
! float __f = strtof(__s, &__sanity);
#else
! double __d = strtod(__s, &__sanity);
! float __f = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
! if (!finitef (__f))
! errno = ERANGE;
#elif defined (_GLIBCXX_HAVE_FINITE)
! if (!finite (static_cast<double> (__f)))
! errno = ERANGE;
#elif defined (_GLIBCXX_HAVE_ISINF)
! if (isinf (static_cast<double> (__f)))
! errno = ERANGE;
#else
! if (fabs(__d) > numeric_limits<float>::max())
! errno = ERANGE;
#endif
#endif
! if (__sanity != __s && errno != ERANGE)
! __v = __f;
! else
! __err |= ios_base::failbit;
! setlocale(LC_ALL, __old);
! free(__old);
}
template<>
*************** namespace std
*** 90,110 ****
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale&)
{
! if (!(__err & ios_base::failbit))
! {
! // Assumes __s formatted for "C" locale.
! char* __old = strdup(setlocale(LC_ALL, NULL));
! setlocale(LC_ALL, "C");
! char* __sanity;
! errno = 0;
! double __d = strtod(__s, &__sanity);
! if (__sanity != __s && errno != ERANGE)
! __v = __d;
! else
! __err |= ios_base::failbit;
! setlocale(LC_ALL, __old);
! free(__old);
! }
}
template<>
--- 87,104 ----
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale&)
{
! // Assumes __s formatted for "C" locale.
! char* __old = strdup(setlocale(LC_ALL, NULL));
! setlocale(LC_ALL, "C");
! char* __sanity;
! errno = 0;
! double __d = strtod(__s, &__sanity);
! if (__sanity != __s && errno != ERANGE)
! __v = __d;
! else
! __err |= ios_base::failbit;
! setlocale(LC_ALL, __old);
! free(__old);
}
template<>
*************** namespace std
*** 112,142 ****
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&)
{
! if (!(__err & ios_base::failbit))
! {
! // Assumes __s formatted for "C" locale.
! char* __old = strdup(setlocale(LC_ALL, NULL));
! setlocale(LC_ALL, "C");
#if defined(_GLIBCXX_HAVE_STRTOLD)
! char* __sanity;
! errno = 0;
! long double __ld = strtold(__s, &__sanity);
! if (__sanity != __s && errno != ERANGE)
! __v = __ld;
#else
! typedef char_traits<char>::int_type int_type;
! long double __ld;
! errno = 0;
! int __p = sscanf(__s, "%Lf", &__ld);
! if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
! && errno != ERANGE)
! __v = __ld;
#endif
! else
! __err |= ios_base::failbit;
! setlocale(LC_ALL, __old);
! free(__old);
! }
}
void
--- 106,133 ----
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&)
{
! // Assumes __s formatted for "C" locale.
! char* __old = strdup(setlocale(LC_ALL, NULL));
! setlocale(LC_ALL, "C");
#if defined(_GLIBCXX_HAVE_STRTOLD)
! char* __sanity;
! errno = 0;
! long double __ld = strtold(__s, &__sanity);
! if (__sanity != __s && errno != ERANGE)
! __v = __ld;
#else
! typedef char_traits<char>::int_type int_type;
! long double __ld;
! errno = 0;
! int __p = sscanf(__s, "%Lf", &__ld);
! if (__p && static_cast<int_type>(__p) != char_traits<char>::eof()
! && errno != ERANGE)
! __v = __ld;
#endif
! else
! __err |= ios_base::failbit;
! setlocale(LC_ALL, __old);
! free(__old);
}
void
diff -prN libstdc++-v3-orig/config/locale/gnu/c_locale.cc libstdc++-v3/config/locale/gnu/c_locale.cc
*** libstdc++-v3-orig/config/locale/gnu/c_locale.cc Tue Jan 27 01:49:01 2004
--- libstdc++-v3/config/locale/gnu/c_locale.cc Mon Jun 27 20:28:27 2005
***************
*** 1,6 ****
// Wrapper for underlying C-language localization -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// 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
--- 1,6 ----
// Wrapper for underlying C-language localization -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
//
// 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
*************** namespace std
*** 46,61 ****
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
! if (!(__err & ios_base::failbit))
! {
! char* __sanity;
! errno = 0;
! float __f = __strtof_l(__s, &__sanity, __cloc);
! if (__sanity != __s && errno != ERANGE)
! __v = __f;
! else
! __err |= ios_base::failbit;
! }
}
template<>
--- 46,58 ----
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
! char* __sanity;
! errno = 0;
! float __f = __strtof_l(__s, &__sanity, __cloc);
! if (__sanity != __s && errno != ERANGE)
! __v = __f;
! else
! __err |= ios_base::failbit;
}
template<>
*************** namespace std
*** 63,78 ****
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
! if (!(__err & ios_base::failbit))
! {
! char* __sanity;
! errno = 0;
! double __d = __strtod_l(__s, &__sanity, __cloc);
! if (__sanity != __s && errno != ERANGE)
! __v = __d;
! else
! __err |= ios_base::failbit;
! }
}
template<>
--- 60,72 ----
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
! char* __sanity;
! errno = 0;
! double __d = __strtod_l(__s, &__sanity, __cloc);
! if (__sanity != __s && errno != ERANGE)
! __v = __d;
! else
! __err |= ios_base::failbit;
}
template<>
*************** namespace std
*** 80,95 ****
__convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
! if (!(__err & ios_base::failbit))
! {
! char* __sanity;
! errno = 0;
! long double __ld = __strtold_l(__s, &__sanity, __cloc);
! if (__sanity != __s && errno != ERANGE)
! __v = __ld;
! else
! __err |= ios_base::failbit;
! }
}
void
--- 74,86 ----
__convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
const __c_locale& __cloc)
{
! char* __sanity;
! errno = 0;
! long double __ld = __strtold_l(__s, &__sanity, __cloc);
! if (__sanity != __s && errno != ERANGE)
! __v = __ld;
! else
! __err |= ios_base::failbit;
}
void
diff -prN libstdc++-v3-orig/include/bits/locale_facets.tcc libstdc++-v3/include/bits/locale_facets.tcc
*** libstdc++-v3-orig/include/bits/locale_facets.tcc Fri Apr 29 20:49:53 2005
--- libstdc++-v3/include/bits/locale_facets.tcc Tue Jun 28 14:53:12 2005
*************** namespace std
*** 306,311 ****
--- 306,312 ----
// Next, look for leading zeros.
bool __found_mantissa = false;
+ int __sep_pos = 0;
while (!__testeof)
{
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep
*************** namespace std
*** 318,323 ****
--- 319,326 ----
__xtrc += '0';
__found_mantissa = true;
}
+ ++__sep_pos;
+
if (++__beg != __end)
__c = *__beg;
else
*************** namespace std
*** 333,339 ****
string __found_grouping;
if (__lc->_M_use_grouping)
__found_grouping.reserve(32);
- int __sep_pos = 0;
const char_type* __q;
const char_type* __lit_zero = __lit + __num_base::_S_izero;
while (!__testeof)
--- 336,341 ----
*************** namespace std
*** 353,359 ****
}
else
{
! __err |= ios_base::failbit;
break;
}
}
--- 355,363 ----
}
else
{
! // NB: __convert_to_v will not assign __v and will
! // set the failbit.
! __xtrc.clear();
break;
}
}
*************** namespace std
*** 383,389 ****
}
else if ((__c == __lit[__num_base::_S_ie]
|| __c == __lit[__num_base::_S_iE])
! && __found_mantissa && !__found_sci)
{
// Scientific notation.
if (__found_grouping.size() && !__found_dec)
--- 387,393 ----
}
else if ((__c == __lit[__num_base::_S_ie]
|| __c == __lit[__num_base::_S_iE])
! && !__found_sci && __found_mantissa)
{
// Scientific notation.
if (__found_grouping.size() && !__found_dec)
*************** namespace std
*** 500,505 ****
--- 504,510 ----
// Next, look for leading zeros and check required digits
// for base formats.
bool __found_zero = false;
+ int __sep_pos = 0;
while (!__testeof)
{
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep
*************** namespace std
*** 507,531 ****
break;
else if (__c == __lit[__num_base::_S_izero]
&& (!__found_zero || __base == 10))
- __found_zero = true;
- else if (__found_zero)
{
! if (__c == __lit[__num_base::_S_ix]
! || __c == __lit[__num_base::_S_iX])
{
! if (__basefield == 0)
! __base = 16;
! if (__base == 16)
! __found_zero = false;
! else
! break;
}
else
! {
! if (__basefield == 0)
! __base = 8;
! break;
! }
}
else
break;
--- 512,538 ----
break;
else if (__c == __lit[__num_base::_S_izero]
&& (!__found_zero || __base == 10))
{
! __found_zero = true;
! ++__sep_pos;
! if (__basefield == 0)
! __base = 8;
! if (__base == 8)
! __sep_pos = 0;
! }
! else if ((__c == __lit[__num_base::_S_ix]
! || __c == __lit[__num_base::_S_iX])
! && __found_zero)
! {
! if (__basefield == 0)
! __base = 16;
! if (__base == 16)
{
! __found_zero = false;
! __sep_pos = 0;
}
else
! break;
}
else
break;
*************** namespace std
*** 549,556 ****
string __found_grouping;
if (__lc->_M_use_grouping)
__found_grouping.reserve(32);
! int __sep_pos = 0;
! bool __overflow = false;
const __unsigned_type __max = __negative ?
-numeric_limits<_ValueT>::min() : numeric_limits<_ValueT>::max();
const __unsigned_type __smax = __max / __base;
--- 556,562 ----
string __found_grouping;
if (__lc->_M_use_grouping)
__found_grouping.reserve(32);
! bool __testfail = false;
const __unsigned_type __max = __negative ?
-numeric_limits<_ValueT>::min() : numeric_limits<_ValueT>::max();
const __unsigned_type __smax = __max / __base;
*************** namespace std
*** 572,578 ****
}
else
{
! __err |= ios_base::failbit;
break;
}
}
--- 578,584 ----
}
else
{
! __testfail = true;
break;
}
}
*************** namespace std
*** 584,594 ****
if (__digit > 15)
__digit -= 6;
if (__result > __smax)
! __overflow = true;
else
{
__result *= __base;
! __overflow |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
--- 590,600 ----
if (__digit > 15)
__digit -= 6;
if (__result > __smax)
! __testfail = true;
else
{
__result *= __base;
! __testfail |= __result > __max - __digit;
__result += __digit;
++__sep_pos;
}
*************** namespace std
*** 616,623 ****
__err |= ios_base::failbit;
}
! if (!(__err & ios_base::failbit) && !__overflow
! && (__sep_pos || __found_zero || __found_grouping.size()))
__v = __negative ? -__result : __result;
else
__err |= ios_base::failbit;
--- 622,629 ----
__err |= ios_base::failbit;
}
! if (!__testfail && (__sep_pos || __found_zero
! || __found_grouping.size()))
__v = __negative ? -__result : __result;
else
__err |= ios_base::failbit;
*************** namespace std
*** 1444,1450 ****
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__grouping_tmp))
! __testvalid = false;
}
// Iff not enough digits were supplied after the decimal-point.
--- 1450,1456 ----
if (!std::__verify_grouping(__lc->_M_grouping,
__lc->_M_grouping_size,
__grouping_tmp))
! __err |= ios_base::failbit;
}
// Iff not enough digits were supplied after the decimal-point.
diff -prN libstdc++-v3-orig/testsuite/22_locale/money_get/get/char/22131.cc libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc
*** libstdc++-v3-orig/testsuite/22_locale/money_get/get/char/22131.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc Tue Jun 28 13:09:29 2005
***************
*** 0 ****
--- 1,83 ----
+ // 2005-06-28 Paolo Carlini <pcarlini@suse.de>
+
+ // Copyright (C) 2005 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>
+
+ struct My_money_io : public std::moneypunct<char, false>
+ {
+ std::string do_grouping() const { return "\1"; }
+ char_type do_thousands_sep() const { return '#'; }
+
+ pattern do_neg_format() const
+ {
+ pattern pat = { { symbol, none, sign, value } };
+ return pat;
+ }
+ };
+
+ // libstdc++/22131
+ void test01()
+ {
+ using namespace std;
+ typedef istreambuf_iterator<char> InIt;
+
+ bool test __attribute__((unused)) = true;
+
+ locale loc(locale::classic(), new My_money_io);
+
+ string buffer1("00#0#1");
+ string buffer2("000##1");
+
+ bool intl = false;
+
+ InIt iend1, iend2;
+ ios_base::iostate err1, err2;
+ string val1, val2;
+
+ const money_get<char,InIt>& mg =
+ use_facet<money_get<char, InIt> >(loc);
+
+ istringstream fmt1(buffer1);
+ fmt1.imbue(loc);
+ InIt ibeg1(fmt1);
+ err1 = ios_base::goodbit;
+ mg.get(ibeg1, iend1, intl, fmt1, err1, val1);
+ VERIFY( err1 == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( val1 == "1" );
+
+ istringstream fmt2(buffer2);
+ fmt2.imbue(loc);
+ InIt ibeg2(fmt2);
+ err2 = ios_base::goodbit;
+ mg.get(ibeg2, iend2, intl, fmt2, err2, val2);
+ VERIFY( err2 == ios_base::failbit );
+ VERIFY( *ibeg2 == '#' );
+ VERIFY( val2 == "" );
+ }
+
+ int main()
+ {
+ test01();
+ return 0;
+ }
diff -prN libstdc++-v3-orig/testsuite/22_locale/money_get/get/wchar_t/22131.cc libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/22131.cc
*** libstdc++-v3-orig/testsuite/22_locale/money_get/get/wchar_t/22131.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/22131.cc Tue Jun 28 13:09:41 2005
***************
*** 0 ****
--- 1,83 ----
+ // 2005-06-28 Paolo Carlini <pcarlini@suse.de>
+
+ // Copyright (C) 2005 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>
+
+ struct My_money_io : public std::moneypunct<wchar_t, false>
+ {
+ std::string do_grouping() const { return "\1"; }
+ char_type do_thousands_sep() const { return L'#'; }
+
+ pattern do_neg_format() const
+ {
+ pattern pat = { { symbol, none, sign, value } };
+ return pat;
+ }
+ };
+
+ // libstdc++/22131
+ void test01()
+ {
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> InIt;
+
+ bool test __attribute__((unused)) = true;
+
+ locale loc(locale::classic(), new My_money_io);
+
+ wstring buffer1(L"00#0#1");
+ wstring buffer2(L"000##1");
+
+ bool intl = false;
+
+ InIt iend1, iend2;
+ ios_base::iostate err1, err2;
+ wstring val1, val2;
+
+ const money_get<wchar_t,InIt>& mg =
+ use_facet<money_get<wchar_t, InIt> >(loc);
+
+ wistringstream fmt1(buffer1);
+ fmt1.imbue(loc);
+ InIt ibeg1(fmt1);
+ err1 = ios_base::goodbit;
+ mg.get(ibeg1, iend1, intl, fmt1, err1, val1);
+ VERIFY( err1 == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( val1 == L"1" );
+
+ wistringstream fmt2(buffer2);
+ fmt2.imbue(loc);
+ InIt ibeg2(fmt2);
+ err2 = ios_base::goodbit;
+ mg.get(ibeg2, iend2, intl, fmt2, err2, val2);
+ VERIFY( err2 == ios_base::failbit );
+ VERIFY( *ibeg2 == L'#' );
+ VERIFY( val2 == L"" );
+ }
+
+ int main()
+ {
+ test01();
+ return 0;
+ }
diff -prN libstdc++-v3-orig/testsuite/22_locale/num_get/get/char/12.cc libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc
*** libstdc++-v3-orig/testsuite/22_locale/num_get/get/char/12.cc Fri Mar 19 21:07:54 2004
--- libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc Mon Jun 27 20:21:27 2005
***************
*** 1,6 ****
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003 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
--- 1,6 ----
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2005 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
*************** void test01()
*** 60,67 ****
long l3 = 1l;
long l4 = 63l;
double d = 0.0;
! double d1 = .4;
! double d2 = .1;
iss1.str("+3");
err = ios_base::goodbit;
--- 60,68 ----
long l3 = 1l;
long l4 = 63l;
double d = 0.0;
! double d1 = .4;
! double d2 = 0.0;
! double d3 = .1;
iss1.str("+3");
err = ios_base::goodbit;
*************** void test01()
*** 128,133 ****
--- 129,135 ----
end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == 'X' );
+ VERIFY( l == l3 );
iss2.str("000778");
iss2.clear();
*************** void test01()
*** 141,155 ****
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == ios_base::failbit );
! VERIFY( *end == 'X' );
iss2.str("-1");
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
VERIFY( err == ios_base::eofbit );
! VERIFY( d == d2 );
}
--- 143,157 ----
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
! VERIFY( d == d2 );
iss2.str("-1");
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
VERIFY( err == ios_base::eofbit );
! VERIFY( d == d3 );
}
diff -prN libstdc++-v3-orig/testsuite/22_locale/num_get/get/char/22131.cc libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc
*** libstdc++-v3-orig/testsuite/22_locale/num_get/get/char/22131.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc Tue Jun 28 14:13:31 2005
***************
*** 0 ****
--- 1,126 ----
+ // 2005-06-28 Paolo Carlini <pcarlini@suse.de>
+
+ // Copyright (C) 2005 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.1.1 num_get members
+
+ #include <locale>
+ #include <sstream>
+ #include <testsuite_hooks.h>
+
+ struct Punct: std::numpunct<char>
+ {
+ std::string do_grouping() const { return "\1"; }
+ char do_thousands_sep() const { return '#'; }
+ };
+
+ // libstdc++/22131
+ void test01()
+ {
+ using namespace std;
+ typedef istreambuf_iterator<char> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ istringstream iss1, iss2;
+ iss1.imbue(locale(iss1.getloc(), new Punct));
+ const num_get<char>& ng1 = use_facet<num_get<char> >(iss1.getloc());
+
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ long l = 0l;
+ long l1 = 1l;
+ long l2 = 2l;
+ long l3 = 3l;
+ double d = 0.0;
+ double d1 = 1.0;
+ double d2 = 2.0;
+
+ iss1.str("00#0#1");
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( l == l1 );
+
+ iss1.str("000##2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::failbit );
+ VERIFY( *end == '#' );
+ VERIFY( l == l1 );
+
+ iss1.str("0#0#0#2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( l == l2 );
+
+ iss1.str("00#0#1");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
+ VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( d == d1 );
+
+ iss1.str("000##2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
+ VERIFY( err == ios_base::failbit );
+ VERIFY( *end == '#' );
+ VERIFY( d == d1 );
+
+ iss1.str("0#0#0#2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( d == d2 );
+
+ iss1.str("0#0");
+ iss1.clear();
+ iss1.unsetf(ios::basefield);
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::failbit );
+ VERIFY( *end == '#' );
+ VERIFY( l == l2 );
+
+ iss1.str("00#0#3");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( l == l3 );
+
+ iss1.str("00#02");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( l == l2 );
+ }
+
+ int main()
+ {
+ test01();
+ return 0;
+ }
diff -prN libstdc++-v3-orig/testsuite/22_locale/num_get/get/wchar_t/12.cc libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc
*** libstdc++-v3-orig/testsuite/22_locale/num_get/get/wchar_t/12.cc Fri Mar 19 21:07:55 2004
--- libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc Mon Jun 27 20:21:27 2005
***************
*** 1,6 ****
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003 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
--- 1,6 ----
// 2003-12-22 Paolo Carlini <pcarlini@suse.de>
! // Copyright (C) 2003, 2005 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
*************** void test01()
*** 60,67 ****
long l3 = 1l;
long l4 = 63l;
double d = 0.0;
! double d1 = .4;
! double d2 = .1;
iss1.str(L"+3");
err = ios_base::goodbit;
--- 60,68 ----
long l3 = 1l;
long l4 = 63l;
double d = 0.0;
! double d1 = .4;
! double d2 = 0.0;
! double d3 = .1;
iss1.str(L"+3");
err = ios_base::goodbit;
*************** void test01()
*** 128,133 ****
--- 129,135 ----
end = ng2.get(iss2.rdbuf(), 0, iss2, err, l);
VERIFY( err == ios_base::failbit );
VERIFY( *end == L'X' );
+ VERIFY( l == l3 );
iss2.str(L"000778");
iss2.clear();
*************** void test01()
*** 141,158 ****
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == ios_base::failbit );
! VERIFY( *end == L'X' );
iss2.str(L"-1");
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
VERIFY( err == ios_base::eofbit );
! VERIFY( d == d2 );
}
-
int main()
{
test01();
--- 143,159 ----
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
! VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
! VERIFY( d == d2 );
iss2.str(L"-1");
iss2.clear();
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, d);
VERIFY( err == ios_base::eofbit );
! VERIFY( d == d3 );
}
int main()
{
test01();
diff -prN libstdc++-v3-orig/testsuite/22_locale/num_get/get/wchar_t/22131.cc libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc
*** libstdc++-v3-orig/testsuite/22_locale/num_get/get/wchar_t/22131.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc Tue Jun 28 14:14:08 2005
***************
*** 0 ****
--- 1,126 ----
+ // 2005-06-28 Paolo Carlini <pcarlini@suse.de>
+
+ // Copyright (C) 2005 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.1.1 num_get members
+
+ #include <locale>
+ #include <sstream>
+ #include <testsuite_hooks.h>
+
+ struct Punct: std::numpunct<wchar_t>
+ {
+ std::string do_grouping() const { return "\1"; }
+ wchar_t do_thousands_sep() const { return L'#'; }
+ };
+
+ // libstdc++/22131
+ void test01()
+ {
+ using namespace std;
+ typedef istreambuf_iterator<wchar_t> iterator_type;
+
+ bool test __attribute__((unused)) = true;
+
+ wistringstream iss1, iss2;
+ iss1.imbue(locale(iss1.getloc(), new Punct));
+ const num_get<wchar_t>& ng1 = use_facet<num_get<wchar_t> >(iss1.getloc());
+
+ ios_base::iostate err = ios_base::goodbit;
+ iterator_type end;
+ long l = 0l;
+ long l1 = 1l;
+ long l2 = 2l;
+ long l3 = 3l;
+ double d = 0.0;
+ double d1 = 1.0;
+ double d2 = 2.0;
+
+ iss1.str(L"00#0#1");
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( l == l1 );
+
+ iss1.str(L"000##2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::failbit );
+ VERIFY( *end == L'#' );
+ VERIFY( l == l1 );
+
+ iss1.str(L"0#0#0#2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( l == l2 );
+
+ iss1.str(L"00#0#1");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
+ VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( d == d1 );
+
+ iss1.str(L"000##2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
+ VERIFY( err == ios_base::failbit );
+ VERIFY( *end == L'#' );
+ VERIFY( d == d1 );
+
+ iss1.str(L"0#0#0#2");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, d);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( d == d2 );
+
+ iss1.str(L"0#0");
+ iss1.clear();
+ iss1.unsetf(ios::basefield);
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::failbit );
+ VERIFY( *end == L'#' );
+ VERIFY( l == l2 );
+
+ iss1.str(L"00#0#3");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == ios_base::eofbit );
+ VERIFY( l == l3 );
+
+ iss1.str(L"00#02");
+ iss1.clear();
+ err = ios_base::goodbit;
+ end = ng1.get(iss1.rdbuf(), 0, iss1, err, l);
+ VERIFY( err == (ios_base::eofbit | ios_base::failbit) );
+ VERIFY( l == l2 );
+ }
+
+ int main()
+ {
+ test01();
+ return 0;
+ }
diff -prN libstdc++-v3-orig/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc Sat Mar 20 13:54:35 2004
--- libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc Mon Jun 27 20:21:27 2005
***************
*** 1,6 ****
// 1999-04-12 bkoz
! // Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
//
// 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
--- 1,7 ----
// 1999-04-12 bkoz
! // Copyright (C) 1999, 2000, 2002, 2003, 2005
! // Free Software Foundation, Inc.
//
// 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
*************** void test07()
*** 62,68 ****
is.clear();
is >> h2;
! VERIFY( h2 == 0 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
--- 63,69 ----
is.clear();
is >> h2;
! VERIFY( h2 == 1232224 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
*************** void test07()
*** 124,131 ****
VERIFY( is.good() );
is >> h2;
! VERIFY( h2 == 0 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
is.clear();
is >> h2;
--- 125,133 ----
VERIFY( is.good() );
is >> h2;
! VERIFY( h2 == 1000000 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ h2 = 0;
is.clear();
is >> h2;
*************** void test07()
*** 134,140 ****
h2 = 0;
is >> h2;
! VERIFY( h2 == 0 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
is.clear();
--- 136,142 ----
h2 = 0;
is >> h2;
! VERIFY( h2 == 1234567 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
is.clear();
diff -prN libstdc++-v3-orig/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc Sun Dec 19 22:57:27 2004
--- libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc Mon Jun 27 20:21:27 2005
***************
*** 1,4 ****
! // Copyright (C) 2004 Free Software Foundation, Inc.
//
// 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
--- 1,4 ----
! // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// 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
*************** void test07()
*** 59,66 ****
VERIFY( is.good() );
is.clear();
! is >> h2;
! VERIFY( h2 == 0 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
--- 59,66 ----
VERIFY( is.good() );
is.clear();
! is >> h2;
! VERIFY( h2 == 1232224 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
*************** void test07()
*** 122,129 ****
VERIFY( is.good() );
is >> h2;
! VERIFY( h2 == 0 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
is.clear();
is >> h2;
--- 122,130 ----
VERIFY( is.good() );
is >> h2;
! VERIFY( h2 == 1000000 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
+ h2 = 0;
is.clear();
is >> h2;
*************** void test07()
*** 132,138 ****
h2 = 0;
is >> h2;
! VERIFY( h2 == 0 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
is.clear();
--- 133,139 ----
h2 = 0;
is >> h2;
! VERIFY( h2 == 1234567 );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::failbit) );
VERIFY( static_cast<bool>(is.rdstate() & std::ios_base::eofbit) );
is.clear();