re PR libstdc++/6410 (Trouble with non-Ascii monetary symbols and wchar_t)
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 3 Jul 2002 06:29:26 +0000 (06:29 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 3 Jul 2002 06:29:26 +0000 (06:29 +0000)
2002-07-02  Benjamin Kosnik  <bkoz@redhat.com>

PR libstdc++/6410
* include/bits/locale_facets.h (moneypunct::moneypunct): Add const
char* name parameter.
* config/locale/gnu/monetary_members.cc: Use it.
* config/locale/generic/monetary_members.cc: Same.
* src/localename.cc (_Impl::_Impl(const char*, size_t)): Use it.

* include/backward/strstream.h: Update date.

From-SVN: r55203

libstdc++-v3/ChangeLog
libstdc++-v3/config/locale/generic/monetary_members.cc
libstdc++-v3/config/locale/gnu/monetary_members.cc
libstdc++-v3/include/backward/strstream.h
libstdc++-v3/include/bits/locale_facets.h
libstdc++-v3/src/localename.cc

index 873c59b30a66b6d7ac698ddee64f8994e5e8c72b..4bfd86ae2779079ac0acfdacd6fc0a856b5c3baf 100644 (file)
@@ -1,3 +1,14 @@
+2002-07-02  Benjamin Kosnik  <bkoz@redhat.com>
+
+       PR libstdc++/6410
+       * include/bits/locale_facets.h (moneypunct::moneypunct): Add const
+       char* name parameter.
+       * config/locale/gnu/monetary_members.cc: Use it.
+       * config/locale/generic/monetary_members.cc: Same.
+       * src/localename.cc (_Impl::_Impl(const char*, size_t)): Use it.
+
+       * include/backward/strstream.h: Update date.
+
 2002-07-02  Paolo Carlini  <pcarlini@unitus.it>
 
        PR libstdc++/6642
index 7c2e13b62df939d2bba3664d74d92169f635212e..1921f46e98cfd09cf4fd4e644710ef51573a0c9c 100644 (file)
@@ -45,7 +45,7 @@ namespace std
 
   template<> 
     void
-    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale)
+    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*)
     {
       // "C" locale
       _M_decimal_point = '.';
@@ -61,7 +61,7 @@ namespace std
 
   template<> 
     void
-    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale)
+    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*)
     {
       // "C" locale
       _M_decimal_point = '.';
@@ -86,7 +86,8 @@ namespace std
 #ifdef _GLIBCPP_USE_WCHAR_T
   template<> 
     void
-    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale)
+    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 
+                                                       const char*)
     {
       // "C" locale
       _M_decimal_point = L'.';
@@ -102,7 +103,8 @@ namespace std
 
   template<> 
     void
-    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale)
+    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 
+                                                        const char*)
     {
       // "C" locale
       _M_decimal_point = L'.';
index bf9b50cbb951e8021edbb0b05bbd8a460a56da06..6a797ffbc25fa82ba7e0abb7c8c5ac5beac3ee9e 100644 (file)
@@ -216,7 +216,8 @@ namespace std
 
   template<> 
     void
-    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc)
+    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, 
+                                                    const char*)
     {
       if (__cloc == _S_c_locale)
        {
@@ -260,7 +261,8 @@ namespace std
 
   template<> 
     void
-    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc)
+    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, 
+                                                     const char*)
     {
       if (__cloc == _S_c_locale)
        {
@@ -313,7 +315,8 @@ namespace std
 #ifdef _GLIBCPP_USE_WCHAR_T
   template<> 
     void
-    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc)
+    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc, 
+                                                       const char* __name)
     {
       if (__cloc == _S_c_locale)
        {
@@ -331,6 +334,10 @@ namespace std
       else
        {
          // Named locale.
+         // XXX Fix me. Switch to named locale so that mbsrtowcs will work.
+         char* __old = strdup(setlocale(LC_ALL, NULL));
+         setlocale(LC_ALL, __name);
+
          _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w);
 
          _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w);
@@ -391,12 +398,17 @@ namespace std
          char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
          char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
          _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn);
+
+         // XXX
+         setlocale(LC_ALL, __old);
+         free(__old);
        }
     }
 
   template<> 
     void
-    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc)
+    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc, 
+                                                        const char* __name)
     {
       if (__cloc == _S_c_locale)
        {
@@ -414,6 +426,10 @@ namespace std
       else
        {
          // Named locale.
+         // XXX Fix me. Switch to named locale so that mbsrtowcs will work.
+         char* __old = strdup(setlocale(LC_ALL, NULL));
+         setlocale(LC_ALL, __name);
+
          _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w);
          _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w);
          _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
@@ -473,6 +489,10 @@ namespace std
          char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
          char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
          _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn);
+
+         // XXX
+         setlocale(LC_ALL, __old);
+         free(__old);
        }
     }
 
index c96ca768ab00277dc3cea1eaccc7154daf0db69a..c20812e3d5410e221e103f0c00294a7319832917 100644 (file)
@@ -1,6 +1,6 @@
 // Backward-compat support -*- C++ -*-
 
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002 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
index d63eb5dd2d5f8d1f5d310b51f7b79704b3ce6caa..241c4655dc2856af73a44e1a5c614e3606eb90f0 100644 (file)
@@ -1357,8 +1357,9 @@ namespace std
       { _M_initialize_moneypunct(); }
 
       explicit 
-      moneypunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs)
-      { _M_initialize_moneypunct(__cloc); }
+      moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) 
+      : locale::facet(__refs)
+      { _M_initialize_moneypunct(__cloc, __s); }
 
       char_type
       decimal_point() const
@@ -1438,7 +1439,8 @@ namespace std
 
       // For use at construction time only.
        void 
-       _M_initialize_moneypunct(__c_locale __cloc = _S_c_locale);
+       _M_initialize_moneypunct(__c_locale __cloc = _S_c_locale, 
+                               const char* __name = NULL);
     };
 
   template<typename _CharT, bool _Intl>
@@ -1455,11 +1457,11 @@ namespace std
 
   template<> 
     void
-    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc);
+    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
 
   template<> 
     void
-    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc);
+    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
 
 #ifdef _GLIBCPP_USE_WCHAR_T
   template<>
@@ -1470,11 +1472,13 @@ namespace std
 
   template<> 
     void
-    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc);
+    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 
+                                                       const char*);
 
   template<> 
     void
-    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc);
+    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 
+                                                        const char*);
 #endif
 
   template<typename _CharT, bool _Intl>
index 824d9790cef9f5e8b81248a626e2de96e6854a53..8fa911891705aad7dfab3ff7627c02f5731def3c 100644 (file)
@@ -132,8 +132,8 @@ namespace std
     _M_init_facet(new num_get<char>);
     _M_init_facet(new num_put<char>);
     _M_init_facet(new std::collate<char>(__cloc));
-    _M_init_facet(new moneypunct<char, false>(__cloc));
-    _M_init_facet(new moneypunct<char, true>(__cloc));
+    _M_init_facet(new moneypunct<char, false>(__cloc, __s));
+    _M_init_facet(new moneypunct<char, true>(__cloc, __s));
     _M_init_facet(new money_get<char>);
     _M_init_facet(new money_put<char>);
     _M_init_facet(new __timepunct<char>(__cloc, __s));
@@ -148,8 +148,8 @@ namespace std
     _M_init_facet(new num_get<wchar_t>);
     _M_init_facet(new num_put<wchar_t>);
     _M_init_facet(new std::collate<wchar_t>(__cloc));
-    _M_init_facet(new moneypunct<wchar_t, false>(__cloc));
-    _M_init_facet(new moneypunct<wchar_t, true>(__cloc));
+    _M_init_facet(new moneypunct<wchar_t, false>(__cloc, __s));
+    _M_init_facet(new moneypunct<wchar_t, true>(__cloc, __s));
     _M_init_facet(new money_get<wchar_t>);
     _M_init_facet(new money_put<wchar_t>);
     _M_init_facet(new __timepunct<wchar_t>(__cloc, __s));