This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] libstdc++/21238
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 29 Apr 2005 20:52:31 +0200
- Subject: [v3] libstdc++/21238
Hi,
tested x86/x86_64-linux, committed.
Paolo.
////////////////
2005-04-29 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/21238
* include/bits/locale_facets.tcc (num_get::_M_extract_float,
num_get::_M_extract_int, num_get::do_get(bool&),
num_put::_M_insert_int, num_put::_M_insert_float,
num_put::do_put(bool), money_get::_M_extract,
money_put::_M_insert): Adjust the __cache_type typedef not to
forward to a numpunct/moneypunct typedef.
* testsuite/testsuite_character.h: Add pod_uint and its numpunct
and moneypunct specializations.
* testsuite/testsuite_character.cc: Add numpunct<pod_uint>::id
and moneypunct<pod_uint>::id.
* testsuite/22_locale/num_get/3.cc: New.
* testsuite/22_locale/num_put/3.cc: Likewise.
* testsuite/22_locale/money_get/3.cc: Likewise.
* testsuite/22_locale/money_put/3.cc: Likewise.
* include/bits/locale_facets.tcc (money_put::_M_insert,
time_get::_M_extract_name): Prefer operator== to operator!=
on char_types.
diff -urN libstdc++-v3-orig/include/bits/locale_facets.tcc libstdc++-v3/include/bits/locale_facets.tcc
--- libstdc++-v3-orig/include/bits/locale_facets.tcc 2005-04-26 11:31:02.000000000 +0200
+++ libstdc++-v3/include/bits/locale_facets.tcc 2005-04-29 13:35:46.000000000 +0200
@@ -277,7 +277,7 @@
ios_base::iostate& __err, string& __xtrc) const
{
typedef char_traits<_CharT> __traits_type;
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@@ -462,8 +462,8 @@
ios_base::iostate& __err, _ValueT& __v) const
{
typedef char_traits<_CharT> __traits_type;
- typedef typename __to_unsigned_type<_ValueT>::__type __unsigned_type;
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef typename __to_unsigned_type<_ValueT>::__type __unsigned_type;
+ typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@@ -650,7 +650,7 @@
else
{
// Parse bool values as alphanumeric.
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@@ -915,7 +915,7 @@
_M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@@ -1038,7 +1038,7 @@
_M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@@ -1165,7 +1165,7 @@
}
else
{
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ typedef __numpunct_cache<_CharT> __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
@@ -1259,8 +1259,7 @@
typedef char_traits<_CharT> __traits_type;
typedef typename string_type::size_type size_type;
typedef money_base::part part;
- typedef moneypunct<_CharT, _Intl> __moneypunct_type;
- typedef typename __moneypunct_type::__cache_type __cache_type;
+ typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
@@ -1518,8 +1517,7 @@
{
typedef typename string_type::size_type size_type;
typedef money_base::part part;
- typedef moneypunct<_CharT, _Intl> __moneypunct_type;
- typedef typename __moneypunct_type::__cache_type __cache_type;
+ typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
@@ -1535,7 +1533,7 @@
money_base::pattern __p;
const char_type* __sign;
size_type __sign_size;
- if (*__beg != __lit[money_base::_S_minus])
+ if (!(*__beg == __lit[money_base::_S_minus]))
{
__p = __lc->_M_pos_format;
__sign = __lc->_M_positive_sign;
@@ -2020,7 +2018,7 @@
for (size_t __i3 = 0; __i3 < __nmatches;)
{
__name = __names[__matches[__i3]];
- if (__name[__pos] != *__beg)
+ if (!(__name[__pos] == *__beg))
__matches[__i3] = __matches[--__nmatches];
else
++__i3;
diff -urN libstdc++-v3-orig/testsuite/22_locale/money_get/3.cc libstdc++-v3/testsuite/22_locale/money_get/3.cc
--- libstdc++-v3-orig/testsuite/22_locale/money_get/3.cc 1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/22_locale/money_get/3.cc 2005-04-29 18:04:31.000000000 +0200
@@ -0,0 +1,41 @@
+// 2005-04-29 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 Template class money_get
+
+// { dg-do compile }
+
+#include <locale>
+#include <testsuite_character.h>
+
+class gnu_money_get: public std::money_get<__gnu_test::pod_uint>
+{ };
+
+// libstdc++/21238
+void test01()
+{
+ gnu_money_get facet01;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff -urN libstdc++-v3-orig/testsuite/22_locale/money_put/3.cc libstdc++-v3/testsuite/22_locale/money_put/3.cc
--- libstdc++-v3-orig/testsuite/22_locale/money_put/3.cc 1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/22_locale/money_put/3.cc 2005-04-29 18:04:42.000000000 +0200
@@ -0,0 +1,41 @@
+// 2005-04-29 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.2 Template class money_put
+
+// { dg-do compile }
+
+#include <locale>
+#include <testsuite_character.h>
+
+class gnu_money_put: public std::money_put<__gnu_test::pod_uint>
+{ };
+
+// libstdc++/21238
+void test01()
+{
+ gnu_money_put facet01;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff -urN libstdc++-v3-orig/testsuite/22_locale/num_get/3.cc libstdc++-v3/testsuite/22_locale/num_get/3.cc
--- libstdc++-v3-orig/testsuite/22_locale/num_get/3.cc 1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/22_locale/num_get/3.cc 2005-04-29 18:04:02.000000000 +0200
@@ -0,0 +1,41 @@
+// 2005-04-29 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 Template class num_get
+
+// { dg-do compile }
+
+#include <locale>
+#include <testsuite_character.h>
+
+class gnu_num_get: public std::num_get<__gnu_test::pod_uint>
+{ };
+
+// libstdc++/21238
+void test01()
+{
+ gnu_num_get facet01;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff -urN libstdc++-v3-orig/testsuite/22_locale/num_put/3.cc libstdc++-v3/testsuite/22_locale/num_put/3.cc
--- libstdc++-v3-orig/testsuite/22_locale/num_put/3.cc 1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/22_locale/num_put/3.cc 2005-04-29 18:04:17.000000000 +0200
@@ -0,0 +1,41 @@
+// 2005-04-29 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.2 Template class num_put
+
+// { dg-do compile }
+
+#include <locale>
+#include <testsuite_character.h>
+
+class gnu_num_put: public std::num_put<__gnu_test::pod_uint>
+{ };
+
+// libstdc++/21238
+void test01()
+{
+ gnu_num_put facet01;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff -urN libstdc++-v3-orig/testsuite/testsuite_character.cc libstdc++-v3/testsuite/testsuite_character.cc
--- libstdc++-v3-orig/testsuite/testsuite_character.cc 2005-04-15 04:06:22.000000000 +0200
+++ libstdc++-v3/testsuite/testsuite_character.cc 2005-04-29 18:17:06.000000000 +0200
@@ -39,6 +39,12 @@
locale::id
ctype<__gnu_test::pod_uchar>::id;
+ locale::id
+ numpunct<__gnu_test::pod_uint>::id;
+
+ locale::id
+ moneypunct<__gnu_test::pod_uint>::id;
+
// Member specializations for the existing facet classes.
// NB: This isn't especially portable. Perhaps a better way would be
// to just specialize all of numpunct and ctype.
diff -urN libstdc++-v3-orig/testsuite/testsuite_character.h libstdc++-v3/testsuite/testsuite_character.h
--- libstdc++-v3-orig/testsuite/testsuite_character.h 2005-04-15 04:06:22.000000000 +0200
+++ libstdc++-v3/testsuite/testsuite_character.h 2005-04-29 18:17:12.000000000 +0200
@@ -71,6 +71,7 @@
typedef character<unsigned char, pod_int, pod_state> pod_char;
typedef character<unsigned char, unsigned int, pod_state> pod_uchar;
typedef character<unsigned short, unsigned int> pod_ushort;
+ typedef character<unsigned int, unsigned long> pod_uint;
// Specializations.
// pod_char
@@ -377,6 +378,160 @@
return high;
}
};
+
+ // numpunct specializations
+ template<>
+ class numpunct<__gnu_test::pod_uint>
+ : public locale::facet
+ {
+ public:
+ typedef __gnu_test::pod_uint char_type;
+ typedef basic_string<char_type> string_type;
+
+ static locale::id id;
+
+ explicit
+ numpunct(size_t refs = 0)
+ : locale::facet(refs)
+ { }
+
+ char_type
+ decimal_point() const
+ { return this->do_decimal_point(); }
+
+ char_type
+ thousands_sep() const
+ { return this->do_thousands_sep(); }
+
+ string
+ grouping() const
+ { return this->do_grouping(); }
+
+ string_type
+ truename() const
+ { return this->do_truename(); }
+
+ string_type
+ falsename() const
+ { return this->do_falsename(); }
+
+ protected:
+ ~numpunct()
+ { }
+
+ virtual char_type
+ do_decimal_point() const
+ { return char_type(); }
+
+ virtual char_type
+ do_thousands_sep() const
+ { return char_type(); }
+
+ virtual string
+ do_grouping() const
+ { return string(); }
+
+ virtual string_type
+ do_truename() const
+ { return string_type(); }
+
+ virtual string_type
+ do_falsename() const
+ { return string_type(); }
+ };
+
+ template<>
+ class moneypunct<__gnu_test::pod_uint>
+ : public locale::facet, public money_base
+ {
+ public:
+ typedef __gnu_test::pod_uint char_type;
+ typedef basic_string<char_type> string_type;
+
+ static locale::id id;
+ static const bool intl = false;
+
+ explicit
+ moneypunct(size_t refs = 0)
+ : locale::facet(refs)
+ { }
+
+ char_type
+ decimal_point() const
+ { return this->do_decimal_point(); }
+
+ char_type
+ thousands_sep() const
+ { return this->do_thousands_sep(); }
+
+ string
+ grouping() const
+ { return this->do_grouping(); }
+
+ string_type
+ curr_symbol() const
+ { return this->do_curr_symbol(); }
+
+ string_type
+ positive_sign() const
+ { return this->do_positive_sign(); }
+
+ string_type
+ negative_sign() const
+ { return this->do_negative_sign(); }
+
+ int
+ frac_digits() const
+ { return this->do_frac_digits(); }
+
+ pattern
+ pos_format() const
+ { return this->do_pos_format(); }
+
+ pattern
+ neg_format() const
+ { return this->do_neg_format(); }
+
+ protected:
+ ~moneypunct()
+ { }
+
+ virtual char_type
+ do_decimal_point() const
+ { return char_type(); }
+
+ virtual char_type
+ do_thousands_sep() const
+ { return char_type(); }
+
+ virtual string
+ do_grouping() const
+ { return string(); }
+
+ virtual string_type
+ do_curr_symbol() const
+ { return string_type(); }
+
+ string_type
+ do_positive_sign() const
+ { return string_type(); }
+
+ string_type
+ do_negative_sign() const
+ { return string_type(); }
+
+ int
+ do_frac_digits() const
+ { return 0; }
+
+ pattern
+ do_pos_format() const
+ { return pattern(); }
+
+ pattern
+ do_neg_format() const
+ { return pattern(); }
+ };
} // namespace std
#endif // _GLIBCXX_TESTSUITE_CHARACTER_H