]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/config/locale/gnu/monetary_members.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / config / locale / gnu / monetary_members.cc
index 02e48240ba9e6090700192aa661429ead47966a1..75af8e3ce42f917d592916fec1067a66725e61e7 100644 (file)
@@ -1,7 +1,6 @@
 // std::moneypunct implementation details, GNU version -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-// Free Software Foundation, Inc.
+// Copyright (C) 2001-2024 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
 #include <locale>
 #include <bits/c++locale_internal.h>
 
-_GLIBCXX_BEGIN_NAMESPACE(std)
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+// This file might be compiled twice, but we only want to define the members
+// of money_base once.
+#if ! _GLIBCXX_USE_CXX11_ABI
 
   // Construct and return valid pattern consisting of some combination of:
   // space none symbol sign value
   money_base::pattern
-  money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
-  { 
+  money_base::_S_construct_pattern(char __precedes, char __space,
+                                  char __posn) throw()
+  {
     pattern __ret;
 
     // This insanely complicated routine attempts to construct a valid
@@ -46,7 +52,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
     // if (__precedes) symbol -> value
     // else value -> symbol
-    
+
     // if (__space) space
     // else none
 
@@ -131,7 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        if (__precedes)
          {
            __ret.field[0] = sign;
-           __ret.field[1] = symbol;        
+           __ret.field[1] = symbol;
            if (__space)
              {
                __ret.field[2] = space;
@@ -139,7 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              }
            else
              {
-               __ret.field[2] = value;         
+               __ret.field[2] = value;
                __ret.field[3] = none;
              }
          }
@@ -199,10 +205,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       }
     return __ret;
   }
+#endif
+
+  extern char __narrow_multibyte_chars(const char* s, __locale_t cloc);
 
-  template<> 
+  template<>
     void
-    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, 
+    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
                                                     const char*)
     {
       if (!_M_data)
@@ -232,10 +241,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       else
        {
          // Named locale.
-         _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, 
-                                                       __cloc));
-         _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, 
+         _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
                                                        __cloc));
+         const char* thousands_sep = __nl_langinfo_l(__MON_THOUSANDS_SEP,
+                                                     __cloc);
+         if (thousands_sep[0] != '\0' && thousands_sep[1] != '\0')
+           _M_data->_M_thousands_sep = __narrow_multibyte_chars(thousands_sep,
+                                                                __cloc);
+         else
+           _M_data->_M_thousands_sep = *thousands_sep;
 
          // Check for NULL, which implies no fractional digits.
          if (_M_data->_M_decimal_point == '\0')
@@ -245,7 +259,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              _M_data->_M_decimal_point = '.';
            }
          else
-           _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, 
+           _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
                                                        __cloc));
 
          const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
@@ -257,11 +271,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          char* __group = 0;
          char* __ps = 0;
          char* __ns = 0;
-         const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));     
+         const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
          __try
            {
              size_t __len;
-             
+
              // Check for NULL, which implies no grouping.
              if (_M_data->_M_thousands_sep == '\0')
                {
@@ -336,6 +350,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              delete [] __group;
              delete [] __ps;
              delete [] __ns;
+             __throw_exception_again;
            }
 
          char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
@@ -350,9 +365,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        }
     }
 
-  template<> 
+  template<>
     void
-    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, 
+    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
                                                      const char*)
     {
       if (!_M_data)
@@ -382,9 +397,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       else
        {
          // Named locale.
-         _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, 
+         _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
                                                        __cloc));
-         _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, 
+         _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
                                                        __cloc));
 
          // Check for NULL, which implies no fractional digits.
@@ -486,6 +501,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              delete [] __group;
              delete [] __ps;
              delete [] __ns;
+             __throw_exception_again;
            }
 
          char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
@@ -500,7 +516,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        }
     }
 
-  template<> 
+  template<>
     moneypunct<char, true>::~moneypunct()
     {
       if (_M_data->_M_grouping_size)
@@ -515,7 +531,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       delete _M_data;
     }
 
-  template<> 
+  template<>
     moneypunct<char, false>::~moneypunct()
     {
       if (_M_data->_M_grouping_size)
@@ -531,9 +547,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     }
 
 #ifdef _GLIBCXX_USE_WCHAR_T
-  template<> 
+  template<>
     void
-    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc, 
+    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
                                                        const char*)
 #else
@@ -573,7 +589,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          __c_locale __old = __uselocale(__cloc);
 #else
          // Switch to named locale so that mbsrtowcs will work.
-         char* __old = setlocale(LC_ALL, NULL);
+         char* __old = setlocale(LC_ALL, 0);
           const size_t __llen = strlen(__old) + 1;
           char* __sav = new char[__llen];
           memcpy(__sav, __old, __llen);
@@ -595,7 +611,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              _M_data->_M_decimal_point = L'.';
            }
          else
-           _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, 
+           _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
                                                        __cloc));
 
          const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
@@ -648,9 +664,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
                }
              else
                _M_data->_M_positive_sign = L"";
-             _M_data->_M_positive_sign_size = 
+             _M_data->_M_positive_sign_size =
                wcslen(_M_data->_M_positive_sign);
-             
+
              __len = strlen(__cnegsign);
              if (!__nposn)
                _M_data->_M_negative_sign = L"()";
@@ -663,9 +679,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
                }
              else
                _M_data->_M_negative_sign = L"";
-             _M_data->_M_negative_sign_size = 
+             _M_data->_M_negative_sign_size =
                wcslen(_M_data->_M_negative_sign);
-             
+
              // _Intl == true.
              __len = strlen(__ccurr);
              if (__len)
@@ -685,7 +701,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              _M_data = 0;
              delete [] __group;
              delete [] __wcs_ps;
-             delete [] __wcs_ns;             
+             delete [] __wcs_ns;
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
              __uselocale(__old);
 #else
@@ -693,8 +709,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
              delete [] __sav;
 #endif
              __throw_exception_again;
-           } 
-         
+           }
+
          char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
          char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
          char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
@@ -714,7 +730,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        }
     }
 
-  template<> 
+  template<>
   void
   moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
@@ -756,7 +772,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
          __c_locale __old = __uselocale(__cloc);
 #else
          // Switch to named locale so that mbsrtowcs will work.
-         char* __old = setlocale(LC_ALL, NULL);
+         char* __old = setlocale(LC_ALL, 0);
           const size_t __llen = strlen(__old) + 1;
           char* __sav = new char[__llen];
           memcpy(__sav, __old, __llen);
@@ -831,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
                }
              else
                _M_data->_M_positive_sign = L"";
-              _M_data->_M_positive_sign_size = 
+              _M_data->_M_positive_sign_size =
                wcslen(_M_data->_M_positive_sign);
 
              __len = strlen(__cnegsign);
@@ -846,7 +862,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
                }
              else
                _M_data->_M_negative_sign = L"";
-              _M_data->_M_negative_sign_size = 
+              _M_data->_M_negative_sign_size =
                wcslen(_M_data->_M_negative_sign);
 
              // _Intl == true.
@@ -868,7 +884,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
               _M_data = 0;
              delete [] __group;
              delete [] __wcs_ps;
-             delete [] __wcs_ns;             
+             delete [] __wcs_ns;
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
              __uselocale(__old);
 #else
@@ -897,7 +913,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        }
     }
 
-  template<> 
+  template<>
     moneypunct<wchar_t, true>::~moneypunct()
     {
       if (_M_data->_M_grouping_size)
@@ -912,7 +928,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       delete _M_data;
     }
 
-  template<> 
+  template<>
     moneypunct<wchar_t, false>::~moneypunct()
     {
       if (_M_data->_M_grouping_size)
@@ -928,4 +944,5 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     }
 #endif
 
-_GLIBCXX_END_NAMESPACE
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace