diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-02-21 09:26:35 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-02-21 09:26:35 +0000 |
commit | fe932e504bb0efaaa874d1caffdc25e4d34c5484 (patch) | |
tree | 658b1a60aa9e4e6e7272da508ab2dff3e4f6d74b | |
parent | 8bb418a3d5c47572c382c7b8f195526247c02a1f (diff) | |
download | gcc-fe932e504bb0efaaa874d1caffdc25e4d34c5484.zip gcc-fe932e504bb0efaaa874d1caffdc25e4d34c5484.tar.gz gcc-fe932e504bb0efaaa874d1caffdc25e4d34c5484.tar.bz2 |
locale_facets.h (class money_base): Add { _S_minus, _S_zero, _S_end } enum, _S_atoms.
2004-02-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.h (class money_base): Add { _S_minus,
_S_zero, _S_end } enum, _S_atoms.
(struct __moneypunct_cache<>): Parameterize on _Intl too; add
_M_grouping_size, _M_curr_symbol_size, _M_positive_sign_size,
_M_negative_sign_size, _M_atoms; tweak constructor consistently.
(__moneypunct_cache<>::~__moneypunct_cache): Update.
(__moneypunct_cache<>::_M_cache): Fill the cache.
(class moneypunct): Tweak __cache_type typedef.
(class money_put): Inherit from money_base too; tweak declaration
of _M_insert, now parameterized on _Intl.
* include/bits/locale_facets.tcc
(struct __use_cache<__moneypunct_cache<_CharT, _Intl> >): New.
(money_put<>::_M_insert): Update definition to use the cache;
call reserve on __res to avoid multiple reallocations.
(money_put<>::do_put(long double),
money_put<>::do_put(const string_type&): Update calls of _M_insert.
* config/locale/generic/monetary_members.cc
(moneypunct<char, true>::_M_initialize_moneypunct,
moneypunct<char, false>::_M_initialize_moneypunct,
moneypunct<wchar_t, true>::_M_initialize_moneypunct,
moneypunct<wchar_t, false>::_M_initialize_moneypunct): Update.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/monetary_members.cc
(moneypunct<wchar_t, true>::~moneypunct(),
moneypunct<wchar_t, false>::~moneypunct()): Likewise.
* src/globals_locale.cc: Tweak fake_money_cache_c.
* src/locale-inst.cc: Add instantiations for
money_put::_M_insert<false> and money_put::_M_insert<true> and
__moneypunct_cache<C, false>, __moneypunct_cache<C, true>.
* src/locale_facets.cc: Define money_base::_S_atoms.
* src/locale_init.cc: Update placement new of
__moneypunct_cache<char, false>, __moneypunct_cache<char, true>,
__moneypunct_cache<wchar_t, false>, __moneypunct_cache<wchar_T, true>.
* config/locale/generic/numeric_members.cc: Clean up.
* config/locale/gnu/numeric_members.cc: Likewise.
* testsuite/22_locale/money_put/put/char/1.cc: Likewise.
* testsuite/22_locale/money_put/put/char/2.cc: Likewise.
* testsuite/22_locale/money_put/put/char/3.cc: Likewise.
* testsuite/22_locale/money_put/put/wchar_t/1.cc: Likewise.
* testsuite/22_locale/money_put/put/wchar_t/2.cc: Likewise.
* testsuite/22_locale/money_put/put/wchar_t/3.cc: Likewise.
From-SVN: r78216
17 files changed, 505 insertions, 310 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c842d82..fbbf8f5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,48 @@ +2004-02-21 Paolo Carlini <pcarlini@suse.de> + + * include/bits/locale_facets.h (class money_base): Add { _S_minus, + _S_zero, _S_end } enum, _S_atoms. + (struct __moneypunct_cache<>): Parameterize on _Intl too; add + _M_grouping_size, _M_curr_symbol_size, _M_positive_sign_size, + _M_negative_sign_size, _M_atoms; tweak constructor consistently. + (__moneypunct_cache<>::~__moneypunct_cache): Update. + (__moneypunct_cache<>::_M_cache): Fill the cache. + (class moneypunct): Tweak __cache_type typedef. + (class money_put): Inherit from money_base too; tweak declaration + of _M_insert, now parameterized on _Intl. + * include/bits/locale_facets.tcc + (struct __use_cache<__moneypunct_cache<_CharT, _Intl> >): New. + (money_put<>::_M_insert): Update definition to use the cache; + call reserve on __res to avoid multiple reallocations. + (money_put<>::do_put(long double), + money_put<>::do_put(const string_type&): Update calls of _M_insert. + * config/locale/generic/monetary_members.cc + (moneypunct<char, true>::_M_initialize_moneypunct, + moneypunct<char, false>::_M_initialize_moneypunct, + moneypunct<wchar_t, true>::_M_initialize_moneypunct, + moneypunct<wchar_t, false>::_M_initialize_moneypunct): Update. + * config/locale/gnu/monetary_members.cc: Likewise. + * config/locale/gnu/monetary_members.cc + (moneypunct<wchar_t, true>::~moneypunct(), + moneypunct<wchar_t, false>::~moneypunct()): Likewise. + * src/globals_locale.cc: Tweak fake_money_cache_c. + * src/locale-inst.cc: Add instantiations for + money_put::_M_insert<false> and money_put::_M_insert<true> and + __moneypunct_cache<C, false>, __moneypunct_cache<C, true>. + * src/locale_facets.cc: Define money_base::_S_atoms. + * src/locale_init.cc: Update placement new of + __moneypunct_cache<char, false>, __moneypunct_cache<char, true>, + __moneypunct_cache<wchar_t, false>, __moneypunct_cache<wchar_T, true>. + + * config/locale/generic/numeric_members.cc: Clean up. + * config/locale/gnu/numeric_members.cc: Likewise. + * testsuite/22_locale/money_put/put/char/1.cc: Likewise. + * testsuite/22_locale/money_put/put/char/2.cc: Likewise. + * testsuite/22_locale/money_put/put/char/3.cc: Likewise. + * testsuite/22_locale/money_put/put/wchar_t/1.cc: Likewise. + * testsuite/22_locale/money_put/put/wchar_t/2.cc: Likewise. + * testsuite/22_locale/money_put/put/wchar_t/3.cc: Likewise. + 2004-02-20 Mark Mitchell <mark@codesourcery.com> * testsuite/27_io/basic_filebuf/showmanyc/char/9533-1.cc: Open diff --git a/libstdc++-v3/config/locale/generic/monetary_members.cc b/libstdc++-v3/config/locale/generic/monetary_members.cc index 51bbe0b..957a326 100644 --- a/libstdc++-v3/config/locale/generic/monetary_members.cc +++ b/libstdc++-v3/config/locale/generic/monetary_members.cc @@ -1,6 +1,6 @@ // std::moneypunct implementation details, generic version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -49,17 +49,24 @@ namespace std { // "C" locale. if (!_M_data) - _M_data = new __moneypunct_cache<char>; + _M_data = new __moneypunct_cache<char, true>; _M_data->_M_decimal_point = '.'; _M_data->_M_thousands_sep = ','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } template<> @@ -68,17 +75,24 @@ namespace std { // "C" locale. if (!_M_data) - _M_data = new __moneypunct_cache<char>; + _M_data = new __moneypunct_cache<char, false>; _M_data->_M_decimal_point = '.'; _M_data->_M_thousands_sep = ','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } template<> @@ -97,17 +111,28 @@ namespace std { // "C" locale if (!_M_data) - _M_data = new __moneypunct_cache<wchar_t>; + _M_data = new __moneypunct_cache<wchar_t, true>; _M_data->_M_decimal_point = L'.'; _M_data->_M_thousands_sep = L','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } template<> @@ -117,17 +142,28 @@ namespace std { // "C" locale if (!_M_data) - _M_data = new __moneypunct_cache<wchar_t>; + _M_data = new __moneypunct_cache<wchar_t, false>; _M_data->_M_decimal_point = L'.'; _M_data->_M_thousands_sep = L','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } template<> diff --git a/libstdc++-v3/config/locale/generic/numeric_members.cc b/libstdc++-v3/config/locale/generic/numeric_members.cc index 0645865..e2afed9 100644 --- a/libstdc++-v3/config/locale/generic/numeric_members.cc +++ b/libstdc++-v3/config/locale/generic/numeric_members.cc @@ -46,6 +46,7 @@ namespace std _M_data = new __numpunct_cache<char>; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_use_grouping = false; _M_data->_M_decimal_point = '.'; @@ -57,8 +58,6 @@ namespace std for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) _M_data->_M_atoms_in[__i] = __num_base::_S_atoms_in[__i]; - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); - _M_data->_M_truename = "true"; _M_data->_M_truename_size = strlen(_M_data->_M_truename); _M_data->_M_falsename = "false"; @@ -79,6 +78,7 @@ namespace std _M_data = new __numpunct_cache<wchar_t>; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_use_grouping = false; _M_data->_M_decimal_point = L'.'; @@ -98,8 +98,6 @@ namespace std _M_data->_M_atoms_in[__i] = btowc(uc); } - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); - _M_data->_M_truename = L"true"; _M_data->_M_truename_size = wcslen(_M_data->_M_truename); _M_data->_M_falsename = L"false"; diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc b/libstdc++-v3/config/locale/gnu/monetary_members.cc index a2aa0c5..63bcdd8 100644 --- a/libstdc++-v3/config/locale/gnu/monetary_members.cc +++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc @@ -210,7 +210,7 @@ namespace std const char*) { if (!_M_data) - _M_data = new __moneypunct_cache<char>; + _M_data = new __moneypunct_cache<char, true>; if (!__cloc) { @@ -218,12 +218,19 @@ namespace std _M_data->_M_decimal_point = '.'; _M_data->_M_thousands_sep = ','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } else { @@ -233,7 +240,9 @@ namespace std _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign); char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); if (!__nposn) @@ -241,9 +250,11 @@ namespace std else _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); + _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign); // _Intl == true _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); + _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol); _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); @@ -264,7 +275,7 @@ namespace std const char*) { if (!_M_data) - _M_data = new __moneypunct_cache<char>; + _M_data = new __moneypunct_cache<char, false>; if (!__cloc) { @@ -272,12 +283,19 @@ namespace std _M_data->_M_decimal_point = '.'; _M_data->_M_thousands_sep = ','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } else { @@ -287,17 +305,21 @@ namespace std _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign); char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); if (!__nposn) _M_data->_M_negative_sign = "()"; else - _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); + _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign); // _Intl == false _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); + _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol); _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); @@ -330,7 +352,7 @@ namespace std #endif { if (!_M_data) - _M_data = new __moneypunct_cache<wchar_t>; + _M_data = new __moneypunct_cache<wchar_t, true>; if (!__cloc) { @@ -338,12 +360,24 @@ namespace std _M_data->_M_decimal_point = L'.'; _M_data->_M_thousands_sep = L','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + // Use ctype::widen code without the facet... + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } else { @@ -363,6 +397,7 @@ namespace std __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); @@ -385,6 +420,7 @@ namespace std } else _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign); __len = strlen(__cnegsign); if (!__nposn) @@ -399,6 +435,7 @@ namespace std } else _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign); // _Intl == true. __len = strlen(__ccurr); @@ -412,6 +449,7 @@ namespace std } else _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); } catch (...) { @@ -459,7 +497,7 @@ namespace std #endif { if (!_M_data) - _M_data = new __moneypunct_cache<wchar_t>; + _M_data = new __moneypunct_cache<wchar_t, false>; if (!__cloc) { @@ -467,12 +505,24 @@ namespace std _M_data->_M_decimal_point = L'.'; _M_data->_M_thousands_sep = L','; _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; _M_data->_M_frac_digits = 0; _M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_neg_format = money_base::_S_default_pattern; + + // Use ctype::widen code without the facet... + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } else { @@ -492,6 +542,7 @@ namespace std __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); @@ -515,6 +566,7 @@ namespace std } else _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign); __len = strlen(__cnegsign); if (!__nposn) @@ -529,7 +581,8 @@ namespace std } else _M_data->_M_negative_sign = L""; - + _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign); + // _Intl == true. __len = strlen(__ccurr); if (__len) @@ -542,6 +595,7 @@ namespace std } else _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); } catch (...) { @@ -581,12 +635,12 @@ namespace std template<> moneypunct<wchar_t, true>::~moneypunct() { - if (wcslen(_M_data->_M_positive_sign)) + if (_M_data->_M_positive_sign_size) delete [] _M_data->_M_positive_sign; - if (wcslen(_M_data->_M_negative_sign) - && (wcscmp(_M_data->_M_negative_sign, L"()") != 0)) + if (_M_data->_M_negative_sign_size + && wcscmp(_M_data->_M_negative_sign, L"()") != 0) delete [] _M_data->_M_negative_sign; - if (wcslen(_M_data->_M_curr_symbol)) + if (_M_data->_M_curr_symbol_size) delete [] _M_data->_M_curr_symbol; delete _M_data; } @@ -594,12 +648,12 @@ namespace std template<> moneypunct<wchar_t, false>::~moneypunct() { - if (wcslen(_M_data->_M_positive_sign)) + if (_M_data->_M_positive_sign_size) delete [] _M_data->_M_positive_sign; - if (wcslen(_M_data->_M_negative_sign) - && (wcscmp(_M_data->_M_negative_sign, L"()") != 0)) + if (_M_data->_M_negative_sign_size + && wcscmp(_M_data->_M_negative_sign, L"()") != 0) delete [] _M_data->_M_negative_sign; - if (wcslen(_M_data->_M_curr_symbol)) + if (_M_data->_M_curr_symbol_size) delete [] _M_data->_M_curr_symbol; delete _M_data; } diff --git a/libstdc++-v3/config/locale/gnu/numeric_members.cc b/libstdc++-v3/config/locale/gnu/numeric_members.cc index debee10..e2bb089 100644 --- a/libstdc++-v3/config/locale/gnu/numeric_members.cc +++ b/libstdc++-v3/config/locale/gnu/numeric_members.cc @@ -49,6 +49,7 @@ namespace std { // "C" locale _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_use_grouping = false; _M_data->_M_decimal_point = '.'; @@ -71,8 +72,8 @@ namespace std _M_data->_M_grouping = ""; else _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); } - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); // NB: There is no way to extact this info from posix locales. // _M_truename = __nl_langinfo_l(YESSTR, __cloc); @@ -99,6 +100,7 @@ namespace std { // "C" locale _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; _M_data->_M_use_grouping = false; _M_data->_M_decimal_point = L'.'; @@ -138,8 +140,8 @@ namespace std _M_data->_M_grouping = ""; else _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); } - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); // NB: There is no way to extact this info from posix locales. // _M_truename = __nl_langinfo_l(YESSTR, __cloc); diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 889c778..9f24cde 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -3464,32 +3464,55 @@ namespace std static const pattern _S_default_pattern; + enum + { + _S_minus, + _S_zero, + _S_end = 11 + }; + + // String literal of acceptable (narrow) input/output, for + // money_get/money_put. "-0123456789" + static const char* _S_atoms; + // Construct and return valid pattern consisting of some combination of: // space none symbol sign value static pattern _S_construct_pattern(char __precedes, char __space, char __posn); }; - template<typename _CharT> + template<typename _CharT, bool _Intl> struct __moneypunct_cache : public locale::facet { const char* _M_grouping; + size_t _M_grouping_size; bool _M_use_grouping; _CharT _M_decimal_point; _CharT _M_thousands_sep; const _CharT* _M_curr_symbol; + size_t _M_curr_symbol_size; const _CharT* _M_positive_sign; + size_t _M_positive_sign_size; const _CharT* _M_negative_sign; + size_t _M_negative_sign_size; int _M_frac_digits; money_base::pattern _M_pos_format; money_base::pattern _M_neg_format; + // A list of valid numeric literals for input and output: in the standard + // "C" locale, this is "-0123456789". This array contains the chars after + // having been passed through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms[money_base::_S_end]; + bool _M_allocated; __moneypunct_cache(size_t __refs = 0) : facet(__refs), - _M_grouping(NULL), _M_use_grouping(false), _M_decimal_point(_CharT()), - _M_thousands_sep(_CharT()), _M_curr_symbol(NULL), _M_positive_sign(NULL), - _M_negative_sign(NULL), _M_frac_digits(0), + _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false), + _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()), + _M_curr_symbol(NULL), _M_curr_symbol_size(0), + _M_positive_sign(NULL), _M_positive_sign_size(0), + _M_negative_sign(NULL), _M_negative_sign_size(0), + _M_frac_digits(0), _M_pos_format(money_base::pattern()), _M_neg_format(money_base::pattern()), _M_allocated(false) { } @@ -3500,15 +3523,60 @@ namespace std _M_cache(const locale& __loc); }; - template<typename _CharT> - __moneypunct_cache<_CharT>::~__moneypunct_cache() + template<typename _CharT, bool _Intl> + __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache() { if (_M_allocated) { - // XXX. + delete [] _M_grouping; + delete [] _M_curr_symbol; + delete [] _M_positive_sign; + delete [] _M_negative_sign; } } + template<typename _CharT, bool _Intl> + void + __moneypunct_cache<_CharT, _Intl>::_M_cache(const locale& __loc) + { + _M_allocated = true; + + const moneypunct<_CharT, _Intl>& __mp = + use_facet<moneypunct<_CharT, _Intl> >(__loc); + + _M_grouping_size = __mp.grouping().size(); + char* __grouping = new char[_M_grouping_size]; + __mp.grouping().copy(__grouping, _M_grouping_size); + _M_grouping = __grouping; + _M_use_grouping = _M_grouping_size && __mp.grouping()[0] != 0; + + _M_decimal_point = __mp.decimal_point(); + _M_thousands_sep = __mp.thousands_sep(); + _M_frac_digits = __mp.frac_digits(); + + _M_curr_symbol_size = __mp.curr_symbol().size(); + _CharT* __curr_symbol = new _CharT[_M_curr_symbol_size]; + __mp.curr_symbol().copy(__curr_symbol, _M_curr_symbol_size); + _M_curr_symbol = __curr_symbol; + + _M_positive_sign_size = __mp.positive_sign().size(); + _CharT* __positive_sign = new _CharT[_M_positive_sign_size]; + __mp.positive_sign().copy(__positive_sign, _M_positive_sign_size); + _M_positive_sign = __positive_sign; + + _M_negative_sign_size = __mp.negative_sign().size(); + _CharT* __negative_sign = new _CharT[_M_negative_sign_size]; + __mp.negative_sign().copy(__negative_sign, _M_negative_sign_size); + _M_negative_sign = __negative_sign; + + _M_pos_format = __mp.pos_format(); + _M_neg_format = __mp.neg_format(); + + const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc); + __ct.widen(money_base::_S_atoms, + money_base::_S_atoms + money_base::_S_end, _M_atoms); + } + /** * @brief Facet for formatting data for money amounts. * @@ -3525,7 +3593,7 @@ namespace std typedef _CharT char_type; typedef basic_string<_CharT> string_type; //@} - typedef __moneypunct_cache<_CharT> __cache_type; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; private: __cache_type* _M_data; @@ -4078,7 +4146,7 @@ namespace std * the money_put facet. */ template<typename _CharT, typename _OutIter> - class money_put : public locale::facet + class money_put : public locale::facet, public money_base { public: //@{ @@ -4194,9 +4262,10 @@ namespace std do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, const string_type& __digits) const; - iter_type - _M_insert(iter_type __s, bool __intl, ios_base& __io, char_type __fill, - const string_type& __digits) const; + template<bool _Intl> + iter_type + _M_insert(iter_type __s, ios_base& __io, char_type __fill, + const string_type& __digits) const; }; template<typename _CharT, typename _OutIter> diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 7ccb946..0b56c5f 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -1130,6 +1130,34 @@ namespace std return __s; } + template<typename _CharT, bool _Intl> + struct __use_cache<__moneypunct_cache<_CharT, _Intl> > + { + const __moneypunct_cache<_CharT, _Intl>* + operator() (const locale& __loc) const + { + const size_t __i = moneypunct<_CharT, _Intl>::id._M_id(); + const locale::facet** __caches = __loc._M_impl->_M_caches; + if (!__caches[__i]) + { + __moneypunct_cache<_CharT, _Intl>* __tmp = NULL; + try + { + __tmp = new __moneypunct_cache<_CharT, _Intl>; + __tmp->_M_cache(__loc); + } + catch(...) + { + delete __tmp; + __throw_exception_again; + } + __loc._M_impl->_M_install_cache(__tmp, __i); + } + return static_cast< + const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]); + } + }; + template<typename _CharT, typename _InIter> _InIter money_get<_CharT, _InIter>:: @@ -1365,168 +1393,168 @@ namespace std { return _M_extract(__beg, __end, __intl, __io, __err, __units); } template<typename _CharT, typename _OutIter> - _OutIter - money_put<_CharT, _OutIter>:: - _M_insert(iter_type __s, bool __intl, ios_base& __io, char_type __fill, - const string_type& __digits) const - { - typedef typename string_type::size_type size_type; - typedef money_base::part part; + template<bool _Intl> + _OutIter + money_put<_CharT, _OutIter>:: + _M_insert(iter_type __s, ios_base& __io, char_type __fill, + const string_type& __digits) const + { + typedef typename string_type::size_type size_type; + typedef money_base::part part; + typedef moneypunct<_CharT, _Intl> __moneypunct_type; + typedef typename __moneypunct_type::__cache_type __cache_type; - const locale __loc = __io.getloc(); - const size_type __width = static_cast<size_type>(__io.width()); - - // These contortions are quite unfortunate. - typedef moneypunct<_CharT, true> __money_true; - typedef moneypunct<_CharT, false> __money_false; - const __money_true& __mpt = use_facet<__money_true>(__loc); - const __money_false& __mpf = use_facet<__money_false>(__loc); - const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); - - // Determine if negative or positive formats are to be used, and - // discard leading negative_sign if it is present. - const char_type* __beg = __digits.data(); - const char_type* __end = __beg + __digits.size(); - money_base::pattern __p; - string_type __sign; - if (*__beg != __ctype.widen('-')) - { - __p = __intl ? __mpt.pos_format() : __mpf.pos_format(); - __sign = __intl ? __mpt.positive_sign() : __mpf.positive_sign(); - } - else - { - __p = __intl ? __mpt.neg_format() : __mpf.neg_format(); - __sign = __intl ? __mpt.negative_sign() : __mpf.negative_sign(); - ++__beg; - } - - // Look for valid numbers in the current ctype facet within input digits. - __end = __ctype.scan_not(ctype_base::digit, __beg, __end); - if (__beg != __end) - { - // Assume valid input, and attempt to format. - // Break down input numbers into base components, as follows: - // final_value = grouped units + (decimal point) + (digits) - string_type __res; - string_type __value; - const string_type __symbol = __intl ? __mpt.curr_symbol() - : __mpf.curr_symbol(); - - // Deal with decimal point, decimal digits. - const int __frac = __intl ? __mpt.frac_digits() - : __mpf.frac_digits(); - if (__frac > 0) - { - const char_type __d = __intl ? __mpt.decimal_point() - : __mpf.decimal_point(); - if (__end - __beg >= __frac) - { - __value = string_type(__end - __frac, __end); - __value.insert(__value.begin(), __d); - __end -= __frac; - } - else - { - // Have to pad zeros in the decimal position. - __value = string_type(__beg, __end); - const int __paddec = __frac - (__end - __beg); - const char_type __zero = __ctype.widen('0'); - __value.insert(__value.begin(), __paddec, __zero); - __value.insert(__value.begin(), __d); - __beg = __end; - } - } - - // Add thousands separators to non-decimal digits, per - // grouping rules. - if (__beg != __end) - { - const string __grouping = __intl ? __mpt.grouping() - : __mpf.grouping(); - if (__grouping.size()) - { - const char_type __sep = __intl ? __mpt.thousands_sep() - : __mpf.thousands_sep(); - const char* __gbeg = __grouping.data(); - const size_t __glen = __grouping.size(); - const int __n = (__end - __beg) * 2; - _CharT* __ws2 = - static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n)); - _CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg, - __glen, __beg, __end); - __value.insert(0, __ws2, __ws_end - __ws2); - } - else - __value.insert(0, string_type(__beg, __end)); - } - - // Calculate length of resulting string. - const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield; - size_type __len = __value.size() + __sign.size(); - __len += (__io.flags() & ios_base::showbase) ? __symbol.size() : 0; - const bool __testipad = __f == ios_base::internal && __len < __width; - - // Fit formatted digits into the required pattern. - for (int __i = 0; __i < 4; ++__i) - { - const part __which = static_cast<part>(__p.field[__i]); - switch (__which) - { - case money_base::symbol: - if (__io.flags() & ios_base::showbase) - __res += __symbol; - break; - case money_base::sign: - // Sign might not exist, or be more than one - // charater long. In that case, add in the rest - // below. - if (__sign.size()) - __res += __sign[0]; - break; - case money_base::value: - __res += __value; - break; - case money_base::space: - // At least one space is required, but if internal - // formatting is required, an arbitrary number of - // fill spaces will be necessary. - if (__testipad) - __res += string_type(__width - __len, __fill); - else - __res += __ctype.widen(__fill); - break; - case money_base::none: - if (__testipad) - __res += string_type(__width - __len, __fill); - break; - } - } + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); - // Special case of multi-part sign parts. - if (__sign.size() > 1) - __res += string_type(__sign.begin() + 1, __sign.end()); + __use_cache<__cache_type> __uc; + const __cache_type* __lc = __uc(__loc); + const char_type* __lit = __lc->_M_atoms; - // Pad, if still necessary. - __len = __res.size(); - if (__width > __len) - { - if (__f == ios_base::left) - // After. - __res.append(__width - __len, __fill); - else - // Before. - __res.insert(0, string_type(__width - __len, __fill)); - __len = __width; - } - - // Write resulting, fully-formatted string to output iterator. - __s = std::__write(__s, __res.data(), __len); - } - __io.width(0); - return __s; - } + // Determine if negative or positive formats are to be used, and + // discard leading negative_sign if it is present. + const char_type* __beg = __digits.data(); + const char_type* __end = __beg + __digits.size(); + money_base::pattern __p; + const char_type* __sign; + size_type __sign_size; + if (*__beg != __lit[_S_minus]) + { + __p = __lc->_M_pos_format; + __sign = __lc->_M_positive_sign; + __sign_size = __lc->_M_positive_sign_size; + } + else + { + __p = __lc->_M_neg_format; + __sign = __lc->_M_negative_sign; + __sign_size = __lc->_M_negative_sign_size; + ++__beg; + } + + // Look for valid numbers in the ctype facet within input digits. + __end = __ctype.scan_not(ctype_base::digit, __beg, __end); + if (__beg != __end) + { + // Assume valid input, and attempt to format. + // Break down input numbers into base components, as follows: + // final_value = grouped units + (decimal point) + (digits) + string_type __res; + string_type __value; + + // Deal with decimal point, decimal digits. + if (__lc->_M_frac_digits > 0) + { + if (__end - __beg >= __lc->_M_frac_digits) + { + __value = string_type(__end - __lc->_M_frac_digits, __end); + __value.insert(__value.begin(), __lc->_M_decimal_point); + __end -= __lc->_M_frac_digits; + } + else + { + // Have to pad zeros in the decimal position. + __value = string_type(__beg, __end); + const int __paddec = __lc->_M_frac_digits - (__end - __beg); + __value.insert(__value.begin(), __paddec, __lit[_S_zero]); + __value.insert(__value.begin(), __lc->_M_decimal_point); + __beg = __end; + } + } + + // Add thousands separators to non-decimal digits, per + // grouping rules. + if (__beg != __end) + { + if (__lc->_M_grouping_size) + { + const int __n = (__end - __beg) * 2; + _CharT* __ws2 = + static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __n)); + _CharT* __ws_end = + std::__add_grouping(__ws2, __lc->_M_thousands_sep, + __lc->_M_grouping, + __lc->_M_grouping_size, + __beg, __end); + __value.insert(0, __ws2, __ws_end - __ws2); + } + else + __value.insert(0, string_type(__beg, __end)); + } + + // Calculate length of resulting string. + const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield; + size_type __len = __value.size() + __sign_size; + __len += ((__io.flags() & ios_base::showbase) + ? __lc->_M_curr_symbol_size : 0); + __res.reserve(__len); + + const size_type __width = static_cast<size_type>(__io.width()); + const bool __testipad = (__f == ios_base::internal + && __len < __width); + // Fit formatted digits into the required pattern. + for (int __i = 0; __i < 4; ++__i) + { + const part __which = static_cast<part>(__p.field[__i]); + switch (__which) + { + case money_base::symbol: + if (__io.flags() & ios_base::showbase) + __res.append(__lc->_M_curr_symbol, + __lc->_M_curr_symbol_size); + break; + case money_base::sign: + // Sign might not exist, or be more than one + // charater long. In that case, add in the rest + // below. + if (__sign_size) + __res += __sign[0]; + break; + case money_base::value: + __res += __value; + break; + case money_base::space: + // At least one space is required, but if internal + // formatting is required, an arbitrary number of + // fill spaces will be necessary. + if (__testipad) + __res += string_type(__width - __len, __fill); + else + __res += __fill; + break; + case money_base::none: + if (__testipad) + __res += string_type(__width - __len, __fill); + break; + } + } + + // Special case of multi-part sign parts. + if (__sign_size > 1) + __res.append(__sign + 1, __sign_size - 1); + + // Pad, if still necessary. + __len = __res.size(); + if (__width > __len) + { + if (__f == ios_base::left) + // After. + __res.append(__width - __len, __fill); + else + // Before. + __res.insert(0, string_type(__width - __len, __fill)); + __len = __width; + } + + // Write resulting, fully-formatted string to output iterator. + __s = std::__write(__s, __res.data(), __len); + } + __io.width(0); + return __s; + } + template<typename _CharT, typename _OutIter> _OutIter money_put<_CharT, _OutIter>:: @@ -1562,7 +1590,8 @@ namespace std * __cs_size)); __ctype.widen(__cs, __cs + __len, __ws); const string_type __digits(__ws, __len); - return _M_insert(__s, __intl, __io, __fill, __digits); + return __intl ? _M_insert<true>(__s, __io, __fill, __digits) + : _M_insert<false>(__s, __io, __fill, __digits); } template<typename _CharT, typename _OutIter> @@ -1570,7 +1599,8 @@ namespace std money_put<_CharT, _OutIter>:: do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, const string_type& __digits) const - { return _M_insert(__s, __intl, __io, __fill, __digits); } + { return __intl ? _M_insert<true>(__s, __io, __fill, __digits) + : _M_insert<false>(__s, __io, __fill, __digits); } // NB: Not especially useful. Without an ios_base object or some // kind of locale reference, we are left clawing at the air where diff --git a/libstdc++-v3/src/globals_locale.cc b/libstdc++-v3/src/globals_locale.cc index 7e37028..67192c4 100644 --- a/libstdc++-v3/src/globals_locale.cc +++ b/libstdc++-v3/src/globals_locale.cc @@ -184,8 +184,8 @@ namespace __gnu_internal __attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>)))); fake_num_cache_c numpunct_cache_c; - typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char>)] - __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char>)))); + typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char, true>)] + __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char, true>)))); fake_money_cache_c moneypunct_cache_ct; fake_money_cache_c moneypunct_cache_cf; @@ -198,8 +198,8 @@ namespace __gnu_internal __attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>)))); fake_num_cache_w numpunct_cache_w; - typedef char fake_money_cache_w[sizeof(std::__moneypunct_cache<wchar_t>)] - __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<wchar_t>)))); + typedef char fake_money_cache_w[sizeof(std::__moneypunct_cache<wchar_t,true>)] + __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<wchar_t,true>)))); fake_money_cache_w moneypunct_cache_wt; fake_money_cache_w moneypunct_cache_wf; diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc index 25c3018..737716c 100644 --- a/libstdc++-v3/src/locale-inst.cc +++ b/libstdc++-v3/src/locale-inst.cc @@ -1,6 +1,7 @@ // Locale support -*- C++ -*- -// Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 +// 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 @@ -43,11 +44,23 @@ namespace std // moneypunct, money_get, and money_put template class moneypunct<C, false>; template class moneypunct<C, true>; - template struct __moneypunct_cache<C>; + template struct __moneypunct_cache<C, false>; + template struct __moneypunct_cache<C, true>; template class moneypunct_byname<C, false>; template class moneypunct_byname<C, true>; template class money_get<C, istreambuf_iterator<C> >; template class money_put<C, ostreambuf_iterator<C> >; + template + ostreambuf_iterator<C> + money_put<C, ostreambuf_iterator<C> >:: + _M_insert<true>(ostreambuf_iterator<C>, ios_base&, C, + const string_type&) const; + + template + ostreambuf_iterator<C> + money_put<C, ostreambuf_iterator<C> >:: + _M_insert<false>(ostreambuf_iterator<C>, ios_base&, C, + const string_type&) const; // numpunct, numpunct_byname, num_get, and num_put template class numpunct<C>; diff --git a/libstdc++-v3/src/locale_facets.cc b/libstdc++-v3/src/locale_facets.cc index da975f0..db8c9e0 100644 --- a/libstdc++-v3/src/locale_facets.cc +++ b/libstdc++-v3/src/locale_facets.cc @@ -1,4 +1,4 @@ -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -53,6 +53,8 @@ namespace std const money_base::pattern money_base::_S_default_pattern = { {symbol, sign, none, value} }; + const char* money_base::_S_atoms = "-0123456789"; + const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF"; const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF"; diff --git a/libstdc++-v3/src/locale_init.cc b/libstdc++-v3/src/locale_init.cc index 276d686..78f91d2 100644 --- a/libstdc++-v3/src/locale_init.cc +++ b/libstdc++-v3/src/locale_init.cc @@ -45,48 +45,48 @@ namespace __gnu_internal extern char* name_vec[6 + _GLIBCXX_NUM_CATEGORIES]; extern char name_c[6 + _GLIBCXX_NUM_CATEGORIES][2]; - extern std::ctype<char> ctype_c; - extern std::collate<char> collate_c; - extern std::numpunct<char> numpunct_c; - extern std::num_get<char> num_get_c; - extern std::num_put<char> num_put_c; - extern std::codecvt<char, char, mbstate_t> codecvt_c; - extern std::moneypunct<char, false> moneypunct_cf; - extern std::moneypunct<char, true> moneypunct_ct; - extern std::money_get<char> money_get_c; - extern std::money_put<char> money_put_c; - extern std::__timepunct<char> timepunct_c; - extern std::time_get<char> time_get_c; - extern std::time_put<char> time_put_c; - extern std::messages<char> messages_c; + extern std::ctype<char> ctype_c; + extern std::collate<char> collate_c; + extern std::numpunct<char> numpunct_c; + extern std::num_get<char> num_get_c; + extern std::num_put<char> num_put_c; + extern std::codecvt<char, char, mbstate_t> codecvt_c; + extern std::moneypunct<char, false> moneypunct_cf; + extern std::moneypunct<char, true> moneypunct_ct; + extern std::money_get<char> money_get_c; + extern std::money_put<char> money_put_c; + extern std::__timepunct<char> timepunct_c; + extern std::time_get<char> time_get_c; + extern std::time_put<char> time_put_c; + extern std::messages<char> messages_c; #ifdef _GLIBCXX_USE_WCHAR_T - extern std::ctype<wchar_t> ctype_w; - extern std::collate<wchar_t> collate_w; - extern std::numpunct<wchar_t> numpunct_w; - extern std::num_get<wchar_t> num_get_w; - extern std::num_put<wchar_t> num_put_w; - extern std::codecvt<wchar_t, char, mbstate_t> codecvt_w; - extern std::moneypunct<wchar_t, false> moneypunct_wf; - extern std::moneypunct<wchar_t, true> moneypunct_wt; - extern std::money_get<wchar_t> money_get_w; - extern std::money_put<wchar_t> money_put_w; - extern std::__timepunct<wchar_t> timepunct_w; - extern std::time_get<wchar_t> time_get_w; - extern std::time_put<wchar_t> time_put_w; - extern std::messages<wchar_t> messages_w; + extern std::ctype<wchar_t> ctype_w; + extern std::collate<wchar_t> collate_w; + extern std::numpunct<wchar_t> numpunct_w; + extern std::num_get<wchar_t> num_get_w; + extern std::num_put<wchar_t> num_put_w; + extern std::codecvt<wchar_t, char, mbstate_t> codecvt_w; + extern std::moneypunct<wchar_t, false> moneypunct_wf; + extern std::moneypunct<wchar_t, true> moneypunct_wt; + extern std::money_get<wchar_t> money_get_w; + extern std::money_put<wchar_t> money_put_w; + extern std::__timepunct<wchar_t> timepunct_w; + extern std::time_get<wchar_t> time_get_w; + extern std::time_put<wchar_t> time_put_w; + extern std::messages<wchar_t> messages_w; #endif // And the caches.... extern std::locale::facet* cache_vec[_GLIBCXX_NUM_FACETS]; - extern std::__numpunct_cache<char> numpunct_cache_c; - extern std::__moneypunct_cache<char> moneypunct_cache_cf; - extern std::__moneypunct_cache<char> moneypunct_cache_ct; - extern std::__timepunct_cache<char> timepunct_cache_c; + extern std::__numpunct_cache<char> numpunct_cache_c; + extern std::__moneypunct_cache<char, false> moneypunct_cache_cf; + extern std::__moneypunct_cache<char, true> moneypunct_cache_ct; + extern std::__timepunct_cache<char> timepunct_cache_c; #ifdef _GLIBCXX_USE_WCHAR_T - extern std::__numpunct_cache<wchar_t> numpunct_cache_w; - extern std::__moneypunct_cache<wchar_t> moneypunct_cache_wf; - extern std::__moneypunct_cache<wchar_t> moneypunct_cache_wt; - extern std::__timepunct_cache<wchar_t> timepunct_cache_w; + extern std::__numpunct_cache<wchar_t> numpunct_cache_w; + extern std::__moneypunct_cache<wchar_t, false> moneypunct_cache_wf; + extern std::__moneypunct_cache<wchar_t, true> moneypunct_cache_wt; + extern std::__timepunct_cache<wchar_t> timepunct_cache_w; #endif } // namespace __gnu_internal @@ -273,10 +273,11 @@ namespace std _M_init_facet(new (&num_put_c) num_put<char>(1)); _M_init_facet(new (&collate_c) std::collate<char>(1)); - typedef __moneypunct_cache<char> money_cache_c; - money_cache_c* __mpcf = new (&moneypunct_cache_cf) money_cache_c(2); + typedef __moneypunct_cache<char, false> money_cache_cf; + typedef __moneypunct_cache<char, true> money_cache_ct; + money_cache_cf* __mpcf = new (&moneypunct_cache_cf) money_cache_cf(2); _M_init_facet(new (&moneypunct_cf) moneypunct<char, false>(__mpcf, 1)); - money_cache_c* __mpct = new (&moneypunct_cache_ct) money_cache_c(2); + money_cache_ct* __mpct = new (&moneypunct_cache_ct) money_cache_ct(2); _M_init_facet(new (&moneypunct_ct) moneypunct<char, true>(__mpct, 1)); _M_init_facet(new (&money_get_c) money_get<char>(1)); @@ -302,10 +303,11 @@ namespace std _M_init_facet(new (&num_put_w) num_put<wchar_t>(1)); _M_init_facet(new (&collate_w) std::collate<wchar_t>(1)); - typedef __moneypunct_cache<wchar_t> money_cache_w; - money_cache_w* __mpwf = new (&moneypunct_cache_wf) money_cache_w(2); + typedef __moneypunct_cache<wchar_t, false> money_cache_wf; + typedef __moneypunct_cache<wchar_t, true> money_cache_wt; + money_cache_wf* __mpwf = new (&moneypunct_cache_wf) money_cache_wf(2); _M_init_facet(new (&moneypunct_wf) moneypunct<wchar_t, false>(__mpwf, 1)); - money_cache_w* __mpwt = new (&moneypunct_cache_wt) money_cache_w(2); + money_cache_wt* __mpwt = new (&moneypunct_cache_wt) money_cache_wt(2); _M_init_facet(new (&moneypunct_wt) moneypunct<wchar_t, true>(__mpwt, 1)); _M_init_facet(new (&money_get_w) money_get<wchar_t>(1)); diff --git a/libstdc++-v3/testsuite/22_locale/money_put/put/char/1.cc b/libstdc++-v3/testsuite/22_locale/money_put/put/char/1.cc index bba6145..8599885 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put/put/char/1.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put/put/char/1.cc @@ -1,6 +1,6 @@ // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> -// Copyright (C) 2001, 2002, 2003 Free Software Foundation +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation // // 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 @@ -28,8 +28,6 @@ void test01() { using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; typedef ostreambuf_iterator<char> iterator_type; bool test __attribute__((unused)) = true; @@ -39,10 +37,6 @@ void test01() locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); VERIFY( loc_c != loc_de ); - // cache the moneypunct facets - typedef moneypunct<char, true> __money_true; - typedef moneypunct<char, false> __money_false; - // sanity check the data is correct. const string empty; diff --git a/libstdc++-v3/testsuite/22_locale/money_put/put/char/2.cc b/libstdc++-v3/testsuite/22_locale/money_put/put/char/2.cc index 35882b6..2833afb 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put/put/char/2.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put/put/char/2.cc @@ -1,6 +1,6 @@ // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> -// Copyright (C) 2001, 2002, 2003 Free Software Foundation +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation // // 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 @@ -28,8 +28,6 @@ void test02() { using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; typedef ostreambuf_iterator<char> iterator_type; bool test __attribute__((unused)) = true; @@ -37,16 +35,7 @@ void test02() // basic construction locale loc_c = locale::classic(); locale loc_hk = __gnu_test::try_named_locale("en_HK"); - locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro"); - locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); - VERIFY( loc_c != loc_de ); - VERIFY( loc_hk != loc_fr ); - VERIFY( loc_hk != loc_de ); - VERIFY( loc_de != loc_fr ); - - // cache the moneypunct facets - typedef moneypunct<char, true> __money_true; - typedef moneypunct<char, false> __money_false; + VERIFY( loc_c != loc_hk ); // sanity check the data is correct. const string empty; diff --git a/libstdc++-v3/testsuite/22_locale/money_put/put/char/3.cc b/libstdc++-v3/testsuite/22_locale/money_put/put/char/3.cc index 1a1ca33..f4e70ec 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put/put/char/3.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put/put/char/3.cc @@ -1,6 +1,6 @@ // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> -// Copyright (C) 2001, 2002, 2003 Free Software Foundation +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation // // 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 @@ -28,25 +28,14 @@ void test03() { using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; typedef ostreambuf_iterator<char> iterator_type; bool test __attribute__((unused)) = true; // basic construction locale loc_c = locale::classic(); - locale loc_hk = __gnu_test::try_named_locale("en_HK"); - locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro"); locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); VERIFY( loc_c != loc_de ); - VERIFY( loc_hk != loc_fr ); - VERIFY( loc_hk != loc_de ); - VERIFY( loc_de != loc_fr ); - - // cache the moneypunct facets - typedef moneypunct<char, true> __money_true; - typedef moneypunct<char, false> __money_false; // sanity check the data is correct. const string empty; diff --git a/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/1.cc index a025d37..9518d16f 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/1.cc @@ -1,6 +1,6 @@ // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> -// Copyright (C) 2001, 2002, 2003 Free Software Foundation +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation // // 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 @@ -28,8 +28,6 @@ void test01() { using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; typedef ostreambuf_iterator<wchar_t> iterator_type; bool test __attribute__((unused)) = true; @@ -39,10 +37,6 @@ void test01() locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); VERIFY( loc_c != loc_de ); - // cache the moneypunct facets - typedef moneypunct<wchar_t, true> __money_true; - typedef moneypunct<wchar_t, false> __money_false; - // sanity check the data is correct. const wstring empty; diff --git a/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/2.cc index f0e7ea1..312a505 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/2.cc @@ -1,6 +1,6 @@ // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> -// Copyright (C) 2001, 2002, 2003 Free Software Foundation +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation // // 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 @@ -28,8 +28,6 @@ void test02() { using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; typedef ostreambuf_iterator<wchar_t> iterator_type; bool test __attribute__((unused)) = true; @@ -37,16 +35,7 @@ void test02() // basic construction locale loc_c = locale::classic(); locale loc_hk = __gnu_test::try_named_locale("en_HK"); - locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro"); - locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); - VERIFY( loc_c != loc_de ); - VERIFY( loc_hk != loc_fr ); - VERIFY( loc_hk != loc_de ); - VERIFY( loc_de != loc_fr ); - - // cache the moneypunct facets - typedef moneypunct<wchar_t, true> __money_true; - typedef moneypunct<wchar_t, false> __money_false; + VERIFY( loc_c != loc_hk ); // sanity check the data is correct. const wstring empty; diff --git a/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/3.cc index cd79e54..7e381d9 100644 --- a/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/3.cc +++ b/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/3.cc @@ -1,6 +1,6 @@ // 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> -// Copyright (C) 2001, 2002, 2003 Free Software Foundation +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation // // 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 @@ -28,25 +28,14 @@ void test03() { using namespace std; - typedef money_base::part part; - typedef money_base::pattern pattern; typedef ostreambuf_iterator<wchar_t> iterator_type; bool test __attribute__((unused)) = true; // basic construction locale loc_c = locale::classic(); - locale loc_hk = __gnu_test::try_named_locale("en_HK"); - locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro"); locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); VERIFY( loc_c != loc_de ); - VERIFY( loc_hk != loc_fr ); - VERIFY( loc_hk != loc_de ); - VERIFY( loc_de != loc_fr ); - - // cache the moneypunct facets - typedef moneypunct<wchar_t, true> __money_true; - typedef moneypunct<wchar_t, false> __money_false; // sanity check the data is correct. const wstring empty; |