This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] libstdc++/6410


This adds the libstdc++ ABI breaking changes so that the wide money_*
functions and tests work with the gnu locale model. At some point,
this same functionality will be available in a non-ABI breaking
way. Till then, this. (See the GNATS report for more info)

tested x86/linux
tested x86/linux --enable-clocale=generic

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.

Index: config/locale/generic/monetary_members.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/generic/monetary_members.cc,v
retrieving revision 1.2
diff -c -p -r1.2 monetary_members.cc
*** config/locale/generic/monetary_members.cc	16 Apr 2002 00:45:17 -0000	1.2
--- config/locale/generic/monetary_members.cc	3 Jul 2002 06:25:59 -0000
*************** namespace std
*** 45,51 ****
  
    template<> 
      void
!     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale)
      {
        // "C" locale
        _M_decimal_point = '.';
--- 45,51 ----
  
    template<> 
      void
!     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*)
      {
        // "C" locale
        _M_decimal_point = '.';
*************** namespace std
*** 61,67 ****
  
    template<> 
      void
!     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale)
      {
        // "C" locale
        _M_decimal_point = '.';
--- 61,67 ----
  
    template<> 
      void
!     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*)
      {
        // "C" locale
        _M_decimal_point = '.';
*************** namespace std
*** 86,92 ****
  #ifdef _GLIBCPP_USE_WCHAR_T
    template<> 
      void
!     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale)
      {
        // "C" locale
        _M_decimal_point = L'.';
--- 86,93 ----
  #ifdef _GLIBCPP_USE_WCHAR_T
    template<> 
      void
!     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 
! 							const char*)
      {
        // "C" locale
        _M_decimal_point = L'.';
*************** namespace std
*** 102,108 ****
  
    template<> 
      void
!     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale)
      {
        // "C" locale
        _M_decimal_point = L'.';
--- 103,110 ----
  
    template<> 
      void
!     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 
! 							 const char*)
      {
        // "C" locale
        _M_decimal_point = L'.';
Index: config/locale/gnu/monetary_members.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/gnu/monetary_members.cc,v
retrieving revision 1.2
diff -c -p -r1.2 monetary_members.cc
*** config/locale/gnu/monetary_members.cc	16 Apr 2002 00:45:18 -0000	1.2
--- config/locale/gnu/monetary_members.cc	3 Jul 2002 06:26:01 -0000
*************** namespace std
*** 216,222 ****
  
    template<> 
      void
!     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc)
      {
        if (__cloc == _S_c_locale)
  	{
--- 216,223 ----
  
    template<> 
      void
!     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, 
! 						     const char*)
      {
        if (__cloc == _S_c_locale)
  	{
*************** namespace std
*** 260,266 ****
  
    template<> 
      void
!     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc)
      {
        if (__cloc == _S_c_locale)
  	{
--- 261,268 ----
  
    template<> 
      void
!     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, 
! 						      const char*)
      {
        if (__cloc == _S_c_locale)
  	{
*************** namespace std
*** 313,319 ****
  #ifdef _GLIBCPP_USE_WCHAR_T
    template<> 
      void
!     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc)
      {
        if (__cloc == _S_c_locale)
  	{
--- 315,322 ----
  #ifdef _GLIBCPP_USE_WCHAR_T
    template<> 
      void
!     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc, 
! 							const char* __name)
      {
        if (__cloc == _S_c_locale)
  	{
*************** namespace std
*** 331,336 ****
--- 334,343 ----
        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);
*************** namespace std
*** 391,402 ****
  	  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);
  	}
      }
  
    template<> 
      void
!     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc)
      {
        if (__cloc == _S_c_locale)
  	{
--- 398,414 ----
  	  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, 
! 							 const char* __name)
      {
        if (__cloc == _S_c_locale)
  	{
*************** namespace std
*** 414,419 ****
--- 426,435 ----
        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);
*************** namespace std
*** 473,478 ****
--- 489,498 ----
  	  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: include/backward/strstream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/backward/strstream.h,v
retrieving revision 1.7
diff -c -p -r1.7 strstream.h
*** include/backward/strstream.h	1 Jul 2002 19:58:42 -0000	1.7
--- include/backward/strstream.h	3 Jul 2002 06:26:03 -0000
***************
*** 1,6 ****
  // Backward-compat support -*- C++ -*-
  
! // Copyright (C) 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
--- 1,6 ----
  // Backward-compat support -*- C++ -*-
  
! // 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: include/bits/locale_facets.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.h,v
retrieving revision 1.43
diff -c -p -r1.43 locale_facets.h
*** include/bits/locale_facets.h	16 Apr 2002 00:45:25 -0000	1.43
--- include/bits/locale_facets.h	3 Jul 2002 06:26:06 -0000
*************** namespace std
*** 1357,1364 ****
        { _M_initialize_moneypunct(); }
  
        explicit 
!       moneypunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs)
!       { _M_initialize_moneypunct(__cloc); }
  
        char_type
        decimal_point() const
--- 1357,1365 ----
        { _M_initialize_moneypunct(); }
  
        explicit 
!       moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) 
!       : locale::facet(__refs)
!       { _M_initialize_moneypunct(__cloc, __s); }
  
        char_type
        decimal_point() const
*************** namespace std
*** 1438,1444 ****
  
        // For use at construction time only.
         void 
!        _M_initialize_moneypunct(__c_locale __cloc = _S_c_locale);
      };
  
    template<typename _CharT, bool _Intl>
--- 1439,1446 ----
  
        // For use at construction time only.
         void 
!        _M_initialize_moneypunct(__c_locale __cloc = _S_c_locale, 
! 				const char* __name = NULL);
      };
  
    template<typename _CharT, bool _Intl>
*************** namespace std
*** 1455,1465 ****
  
    template<> 
      void
!     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc);
  
    template<> 
      void
!     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc);
  
  #ifdef _GLIBCPP_USE_WCHAR_T
    template<>
--- 1457,1467 ----
  
    template<> 
      void
!     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
  
    template<> 
      void
!     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
  
  #ifdef _GLIBCPP_USE_WCHAR_T
    template<>
*************** namespace std
*** 1470,1480 ****
  
    template<> 
      void
!     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc);
  
    template<> 
      void
!     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc);
  #endif
  
    template<typename _CharT, bool _Intl>
--- 1472,1484 ----
  
    template<> 
      void
!     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 
! 							const char*);
  
    template<> 
      void
!     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 
! 							 const char*);
  #endif
  
    template<typename _CharT, bool _Intl>
Index: src/localename.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/localename.cc,v
retrieving revision 1.27
diff -c -p -r1.27 localename.cc
*** src/localename.cc	13 May 2002 13:57:57 -0000	1.27
--- src/localename.cc	3 Jul 2002 06:26:08 -0000
*************** namespace std
*** 132,139 ****
      _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 money_get<char>);
      _M_init_facet(new money_put<char>);
      _M_init_facet(new __timepunct<char>(__cloc, __s));
--- 132,139 ----
      _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, __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));
*************** namespace std
*** 148,155 ****
      _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 money_get<wchar_t>);
      _M_init_facet(new money_put<wchar_t>);
      _M_init_facet(new __timepunct<wchar_t>(__cloc, __s));
--- 148,155 ----
      _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, __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));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]