// 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
// if (__precedes) symbol -> value
// else value -> symbol
-
+
// if (__space) space
// else none
if (__precedes)
{
__ret.field[0] = sign;
- __ret.field[1] = symbol;
+ __ret.field[1] = symbol;
if (__space)
{
__ret.field[2] = space;
}
else
{
- __ret.field[2] = value;
+ __ret.field[2] = value;
__ret.field[3] = none;
}
}
}
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)
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')
_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);
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')
{
delete [] __group;
delete [] __ps;
delete [] __ns;
+ __throw_exception_again;
}
char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
}
}
- 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)
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.
delete [] __group;
delete [] __ps;
delete [] __ns;
+ __throw_exception_again;
}
char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
}
}
- template<>
+ template<>
moneypunct<char, true>::~moneypunct()
{
if (_M_data->_M_grouping_size)
delete _M_data;
}
- template<>
+ template<>
moneypunct<char, false>::~moneypunct()
{
if (_M_data->_M_grouping_size)
}
#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
__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);
_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);
}
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"()";
}
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)
_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
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));
}
}
- template<>
+ template<>
void
moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__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);
}
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);
}
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.
_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
}
}
- template<>
+ template<>
moneypunct<wchar_t, true>::~moneypunct()
{
if (_M_data->_M_grouping_size)
delete _M_data;
}
- template<>
+ template<>
moneypunct<wchar_t, false>::~moneypunct()
{
if (_M_data->_M_grouping_size)
}
#endif
-_GLIBCXX_END_NAMESPACE
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace