]> 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 b3e7645385ad0e3736af8bcf42de330482d32929..75af8e3ce42f917d592916fec1067a66725e61e7 100644 (file)
@@ -1,6 +1,6 @@
 // std::moneypunct implementation details, GNU version -*- C++ -*-
 
-// Copyright (C) 2001-2018 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
@@ -207,6 +207,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
+  extern char __narrow_multibyte_chars(const char* s, __locale_t cloc);
+
   template<>
     void
     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
@@ -241,8 +243,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          // 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,
-                                                       __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')