Commit fe932e50 by Paolo Carlini Committed by Paolo Carlini

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
parent 8bb418a3
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> 2004-02-20 Mark Mitchell <mark@codesourcery.com>
* testsuite/27_io/basic_filebuf/showmanyc/char/9533-1.cc: Open * testsuite/27_io/basic_filebuf/showmanyc/char/9533-1.cc: Open
......
// std::moneypunct implementation details, generic version -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -49,17 +49,24 @@ namespace std ...@@ -49,17 +49,24 @@ namespace std
{ {
// "C" locale. // "C" locale.
if (!_M_data) if (!_M_data)
_M_data = new __moneypunct_cache<char>; _M_data = new __moneypunct_cache<char, true>;
_M_data->_M_decimal_point = '.'; _M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ','; _M_data->_M_thousands_sep = ',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = ""; _M_data->_M_curr_symbol = "";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = ""; _M_data->_M_positive_sign = "";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = ""; _M_data->_M_negative_sign = "";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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<> template<>
...@@ -68,17 +75,24 @@ namespace std ...@@ -68,17 +75,24 @@ namespace std
{ {
// "C" locale. // "C" locale.
if (!_M_data) if (!_M_data)
_M_data = new __moneypunct_cache<char>; _M_data = new __moneypunct_cache<char, false>;
_M_data->_M_decimal_point = '.'; _M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ','; _M_data->_M_thousands_sep = ',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = ""; _M_data->_M_curr_symbol = "";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = ""; _M_data->_M_positive_sign = "";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = ""; _M_data->_M_negative_sign = "";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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<> template<>
...@@ -97,17 +111,28 @@ namespace std ...@@ -97,17 +111,28 @@ namespace std
{ {
// "C" locale // "C" locale
if (!_M_data) 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_decimal_point = L'.';
_M_data->_M_thousands_sep = L','; _M_data->_M_thousands_sep = L',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = L""; _M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = L""; _M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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<> template<>
...@@ -117,17 +142,28 @@ namespace std ...@@ -117,17 +142,28 @@ namespace std
{ {
// "C" locale // "C" locale
if (!_M_data) 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_decimal_point = L'.';
_M_data->_M_thousands_sep = L','; _M_data->_M_thousands_sep = L',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = L""; _M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = L""; _M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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<> template<>
......
...@@ -46,6 +46,7 @@ namespace std ...@@ -46,6 +46,7 @@ namespace std
_M_data = new __numpunct_cache<char>; _M_data = new __numpunct_cache<char>;
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_use_grouping = false; _M_data->_M_use_grouping = false;
_M_data->_M_decimal_point = '.'; _M_data->_M_decimal_point = '.';
...@@ -57,8 +58,6 @@ namespace std ...@@ -57,8 +58,6 @@ namespace std
for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) 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_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 = "true";
_M_data->_M_truename_size = strlen(_M_data->_M_truename); _M_data->_M_truename_size = strlen(_M_data->_M_truename);
_M_data->_M_falsename = "false"; _M_data->_M_falsename = "false";
...@@ -79,6 +78,7 @@ namespace std ...@@ -79,6 +78,7 @@ namespace std
_M_data = new __numpunct_cache<wchar_t>; _M_data = new __numpunct_cache<wchar_t>;
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_use_grouping = false; _M_data->_M_use_grouping = false;
_M_data->_M_decimal_point = L'.'; _M_data->_M_decimal_point = L'.';
...@@ -98,8 +98,6 @@ namespace std ...@@ -98,8 +98,6 @@ namespace std
_M_data->_M_atoms_in[__i] = btowc(uc); _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 = L"true";
_M_data->_M_truename_size = wcslen(_M_data->_M_truename); _M_data->_M_truename_size = wcslen(_M_data->_M_truename);
_M_data->_M_falsename = L"false"; _M_data->_M_falsename = L"false";
......
...@@ -210,7 +210,7 @@ namespace std ...@@ -210,7 +210,7 @@ namespace std
const char*) const char*)
{ {
if (!_M_data) if (!_M_data)
_M_data = new __moneypunct_cache<char>; _M_data = new __moneypunct_cache<char, true>;
if (!__cloc) if (!__cloc)
{ {
...@@ -218,12 +218,19 @@ namespace std ...@@ -218,12 +218,19 @@ namespace std
_M_data->_M_decimal_point = '.'; _M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ','; _M_data->_M_thousands_sep = ',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = ""; _M_data->_M_curr_symbol = "";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = ""; _M_data->_M_positive_sign = "";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = ""; _M_data->_M_negative_sign = "";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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 else
{ {
...@@ -233,7 +240,9 @@ namespace std ...@@ -233,7 +240,9 @@ namespace std
_M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
__cloc)); __cloc));
_M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __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 = __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)); char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
if (!__nposn) if (!__nposn)
...@@ -241,9 +250,11 @@ namespace std ...@@ -241,9 +250,11 @@ namespace std
else else
_M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
__cloc); __cloc);
_M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
// _Intl == true // _Intl == true
_M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); _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, _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
__cloc)); __cloc));
char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
...@@ -264,7 +275,7 @@ namespace std ...@@ -264,7 +275,7 @@ namespace std
const char*) const char*)
{ {
if (!_M_data) if (!_M_data)
_M_data = new __moneypunct_cache<char>; _M_data = new __moneypunct_cache<char, false>;
if (!__cloc) if (!__cloc)
{ {
...@@ -272,12 +283,19 @@ namespace std ...@@ -272,12 +283,19 @@ namespace std
_M_data->_M_decimal_point = '.'; _M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ','; _M_data->_M_thousands_sep = ',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = ""; _M_data->_M_curr_symbol = "";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = ""; _M_data->_M_positive_sign = "";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = ""; _M_data->_M_negative_sign = "";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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 else
{ {
...@@ -287,7 +305,9 @@ namespace std ...@@ -287,7 +305,9 @@ namespace std
_M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
__cloc)); __cloc));
_M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __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 = __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)); char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
if (!__nposn) if (!__nposn)
...@@ -295,9 +315,11 @@ namespace std ...@@ -295,9 +315,11 @@ namespace std
else else
_M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
__cloc); __cloc);
_M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
// _Intl == false // _Intl == false
_M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); _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)); _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc)); char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
...@@ -330,7 +352,7 @@ namespace std ...@@ -330,7 +352,7 @@ namespace std
#endif #endif
{ {
if (!_M_data) if (!_M_data)
_M_data = new __moneypunct_cache<wchar_t>; _M_data = new __moneypunct_cache<wchar_t, true>;
if (!__cloc) if (!__cloc)
{ {
...@@ -338,12 +360,24 @@ namespace std ...@@ -338,12 +360,24 @@ namespace std
_M_data->_M_decimal_point = L'.'; _M_data->_M_decimal_point = L'.';
_M_data->_M_thousands_sep = L','; _M_data->_M_thousands_sep = L',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = L""; _M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = L""; _M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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 else
{ {
...@@ -363,6 +397,7 @@ namespace std ...@@ -363,6 +397,7 @@ namespace std
__u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); __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_thousands_sep = static_cast<wchar_t>(__u.__w);
_M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); _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* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
...@@ -385,6 +420,7 @@ namespace std ...@@ -385,6 +420,7 @@ namespace std
} }
else else
_M_data->_M_positive_sign = L""; _M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
__len = strlen(__cnegsign); __len = strlen(__cnegsign);
if (!__nposn) if (!__nposn)
...@@ -399,6 +435,7 @@ namespace std ...@@ -399,6 +435,7 @@ namespace std
} }
else else
_M_data->_M_negative_sign = L""; _M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
// _Intl == true. // _Intl == true.
__len = strlen(__ccurr); __len = strlen(__ccurr);
...@@ -412,6 +449,7 @@ namespace std ...@@ -412,6 +449,7 @@ namespace std
} }
else else
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
} }
catch (...) catch (...)
{ {
...@@ -459,7 +497,7 @@ namespace std ...@@ -459,7 +497,7 @@ namespace std
#endif #endif
{ {
if (!_M_data) if (!_M_data)
_M_data = new __moneypunct_cache<wchar_t>; _M_data = new __moneypunct_cache<wchar_t, false>;
if (!__cloc) if (!__cloc)
{ {
...@@ -467,12 +505,24 @@ namespace std ...@@ -467,12 +505,24 @@ namespace std
_M_data->_M_decimal_point = L'.'; _M_data->_M_decimal_point = L'.';
_M_data->_M_thousands_sep = L','; _M_data->_M_thousands_sep = L',';
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = L""; _M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = L""; _M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0; _M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern; _M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_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 else
{ {
...@@ -492,6 +542,7 @@ namespace std ...@@ -492,6 +542,7 @@ namespace std
__u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); __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_thousands_sep = static_cast<wchar_t>(__u.__w);
_M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); _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* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
...@@ -515,6 +566,7 @@ namespace std ...@@ -515,6 +566,7 @@ namespace std
} }
else else
_M_data->_M_positive_sign = L""; _M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
__len = strlen(__cnegsign); __len = strlen(__cnegsign);
if (!__nposn) if (!__nposn)
...@@ -529,6 +581,7 @@ namespace std ...@@ -529,6 +581,7 @@ namespace std
} }
else else
_M_data->_M_negative_sign = L""; _M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
// _Intl == true. // _Intl == true.
__len = strlen(__ccurr); __len = strlen(__ccurr);
...@@ -542,6 +595,7 @@ namespace std ...@@ -542,6 +595,7 @@ namespace std
} }
else else
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
} }
catch (...) catch (...)
{ {
...@@ -581,12 +635,12 @@ namespace std ...@@ -581,12 +635,12 @@ namespace std
template<> template<>
moneypunct<wchar_t, true>::~moneypunct() 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; delete [] _M_data->_M_positive_sign;
if (wcslen(_M_data->_M_negative_sign) if (_M_data->_M_negative_sign_size
&& (wcscmp(_M_data->_M_negative_sign, L"()") != 0)) && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
delete [] _M_data->_M_negative_sign; 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->_M_curr_symbol;
delete _M_data; delete _M_data;
} }
...@@ -594,12 +648,12 @@ namespace std ...@@ -594,12 +648,12 @@ namespace std
template<> template<>
moneypunct<wchar_t, false>::~moneypunct() 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; delete [] _M_data->_M_positive_sign;
if (wcslen(_M_data->_M_negative_sign) if (_M_data->_M_negative_sign_size
&& (wcscmp(_M_data->_M_negative_sign, L"()") != 0)) && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
delete [] _M_data->_M_negative_sign; 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->_M_curr_symbol;
delete _M_data; delete _M_data;
} }
......
...@@ -49,6 +49,7 @@ namespace std ...@@ -49,6 +49,7 @@ namespace std
{ {
// "C" locale // "C" locale
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_use_grouping = false; _M_data->_M_use_grouping = false;
_M_data->_M_decimal_point = '.'; _M_data->_M_decimal_point = '.';
...@@ -71,8 +72,8 @@ namespace std ...@@ -71,8 +72,8 @@ namespace std
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
else else
_M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); _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. // NB: There is no way to extact this info from posix locales.
// _M_truename = __nl_langinfo_l(YESSTR, __cloc); // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
...@@ -99,6 +100,7 @@ namespace std ...@@ -99,6 +100,7 @@ namespace std
{ {
// "C" locale // "C" locale
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_use_grouping = false; _M_data->_M_use_grouping = false;
_M_data->_M_decimal_point = L'.'; _M_data->_M_decimal_point = L'.';
...@@ -138,8 +140,8 @@ namespace std ...@@ -138,8 +140,8 @@ namespace std
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
else else
_M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); _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. // NB: There is no way to extact this info from posix locales.
// _M_truename = __nl_langinfo_l(YESSTR, __cloc); // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
......
...@@ -3464,32 +3464,55 @@ namespace std ...@@ -3464,32 +3464,55 @@ namespace std
static const pattern _S_default_pattern; 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: // Construct and return valid pattern consisting of some combination of:
// space none symbol sign value // space none symbol sign value
static pattern static pattern
_S_construct_pattern(char __precedes, char __space, char __posn); _S_construct_pattern(char __precedes, char __space, char __posn);
}; };
template<typename _CharT> template<typename _CharT, bool _Intl>
struct __moneypunct_cache : public locale::facet struct __moneypunct_cache : public locale::facet
{ {
const char* _M_grouping; const char* _M_grouping;
size_t _M_grouping_size;
bool _M_use_grouping; bool _M_use_grouping;
_CharT _M_decimal_point; _CharT _M_decimal_point;
_CharT _M_thousands_sep; _CharT _M_thousands_sep;
const _CharT* _M_curr_symbol; const _CharT* _M_curr_symbol;
size_t _M_curr_symbol_size;
const _CharT* _M_positive_sign; const _CharT* _M_positive_sign;
size_t _M_positive_sign_size;
const _CharT* _M_negative_sign; const _CharT* _M_negative_sign;
size_t _M_negative_sign_size;
int _M_frac_digits; int _M_frac_digits;
money_base::pattern _M_pos_format; money_base::pattern _M_pos_format;
money_base::pattern _M_neg_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; bool _M_allocated;
__moneypunct_cache(size_t __refs = 0) : facet(__refs), __moneypunct_cache(size_t __refs = 0) : facet(__refs),
_M_grouping(NULL), _M_use_grouping(false), _M_decimal_point(_CharT()), _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
_M_thousands_sep(_CharT()), _M_curr_symbol(NULL), _M_positive_sign(NULL), _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
_M_negative_sign(NULL), _M_frac_digits(0), _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_pos_format(money_base::pattern()),
_M_neg_format(money_base::pattern()), _M_allocated(false) _M_neg_format(money_base::pattern()), _M_allocated(false)
{ } { }
...@@ -3500,15 +3523,60 @@ namespace std ...@@ -3500,15 +3523,60 @@ namespace std
_M_cache(const locale& __loc); _M_cache(const locale& __loc);
}; };
template<typename _CharT> template<typename _CharT, bool _Intl>
__moneypunct_cache<_CharT>::~__moneypunct_cache() __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
{ {
if (_M_allocated) 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. * @brief Facet for formatting data for money amounts.
* *
...@@ -3525,7 +3593,7 @@ namespace std ...@@ -3525,7 +3593,7 @@ namespace std
typedef _CharT char_type; typedef _CharT char_type;
typedef basic_string<_CharT> string_type; typedef basic_string<_CharT> string_type;
//@} //@}
typedef __moneypunct_cache<_CharT> __cache_type; typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
private: private:
__cache_type* _M_data; __cache_type* _M_data;
...@@ -4078,7 +4146,7 @@ namespace std ...@@ -4078,7 +4146,7 @@ namespace std
* the money_put facet. * the money_put facet.
*/ */
template<typename _CharT, typename _OutIter> template<typename _CharT, typename _OutIter>
class money_put : public locale::facet class money_put : public locale::facet, public money_base
{ {
public: public:
//@{ //@{
...@@ -4194,8 +4262,9 @@ namespace std ...@@ -4194,8 +4262,9 @@ namespace std
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
const string_type& __digits) const; const string_type& __digits) const;
template<bool _Intl>
iter_type iter_type
_M_insert(iter_type __s, bool __intl, ios_base& __io, char_type __fill, _M_insert(iter_type __s, ios_base& __io, char_type __fill,
const string_type& __digits) const; const string_type& __digits) const;
}; };
......
...@@ -1130,6 +1130,34 @@ namespace std ...@@ -1130,6 +1130,34 @@ namespace std
return __s; 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> template<typename _CharT, typename _InIter>
_InIter _InIter
money_get<_CharT, _InIter>:: money_get<_CharT, _InIter>::
...@@ -1365,43 +1393,47 @@ namespace std ...@@ -1365,43 +1393,47 @@ namespace std
{ return _M_extract(__beg, __end, __intl, __io, __err, __units); } { return _M_extract(__beg, __end, __intl, __io, __err, __units); }
template<typename _CharT, typename _OutIter> template<typename _CharT, typename _OutIter>
template<bool _Intl>
_OutIter _OutIter
money_put<_CharT, _OutIter>:: money_put<_CharT, _OutIter>::
_M_insert(iter_type __s, bool __intl, ios_base& __io, char_type __fill, _M_insert(iter_type __s, ios_base& __io, char_type __fill,
const string_type& __digits) const const string_type& __digits) const
{ {
typedef typename string_type::size_type size_type; typedef typename string_type::size_type size_type;
typedef money_base::part part; 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 locale& __loc = __io._M_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); const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
__use_cache<__cache_type> __uc;
const __cache_type* __lc = __uc(__loc);
const char_type* __lit = __lc->_M_atoms;
// Determine if negative or positive formats are to be used, and // Determine if negative or positive formats are to be used, and
// discard leading negative_sign if it is present. // discard leading negative_sign if it is present.
const char_type* __beg = __digits.data(); const char_type* __beg = __digits.data();
const char_type* __end = __beg + __digits.size(); const char_type* __end = __beg + __digits.size();
money_base::pattern __p; money_base::pattern __p;
string_type __sign; const char_type* __sign;
if (*__beg != __ctype.widen('-')) size_type __sign_size;
if (*__beg != __lit[_S_minus])
{ {
__p = __intl ? __mpt.pos_format() : __mpf.pos_format(); __p = __lc->_M_pos_format;
__sign = __intl ? __mpt.positive_sign() : __mpf.positive_sign(); __sign = __lc->_M_positive_sign;
__sign_size = __lc->_M_positive_sign_size;
} }
else else
{ {
__p = __intl ? __mpt.neg_format() : __mpf.neg_format(); __p = __lc->_M_neg_format;
__sign = __intl ? __mpt.negative_sign() : __mpf.negative_sign(); __sign = __lc->_M_negative_sign;
__sign_size = __lc->_M_negative_sign_size;
++__beg; ++__beg;
} }
// Look for valid numbers in the current ctype facet within input digits. // Look for valid numbers in the ctype facet within input digits.
__end = __ctype.scan_not(ctype_base::digit, __beg, __end); __end = __ctype.scan_not(ctype_base::digit, __beg, __end);
if (__beg != __end) if (__beg != __end)
{ {
...@@ -1410,30 +1442,23 @@ namespace std ...@@ -1410,30 +1442,23 @@ namespace std
// final_value = grouped units + (decimal point) + (digits) // final_value = grouped units + (decimal point) + (digits)
string_type __res; string_type __res;
string_type __value; string_type __value;
const string_type __symbol = __intl ? __mpt.curr_symbol()
: __mpf.curr_symbol();
// Deal with decimal point, decimal digits. // Deal with decimal point, decimal digits.
const int __frac = __intl ? __mpt.frac_digits() if (__lc->_M_frac_digits > 0)
: __mpf.frac_digits();
if (__frac > 0)
{ {
const char_type __d = __intl ? __mpt.decimal_point() if (__end - __beg >= __lc->_M_frac_digits)
: __mpf.decimal_point();
if (__end - __beg >= __frac)
{ {
__value = string_type(__end - __frac, __end); __value = string_type(__end - __lc->_M_frac_digits, __end);
__value.insert(__value.begin(), __d); __value.insert(__value.begin(), __lc->_M_decimal_point);
__end -= __frac; __end -= __lc->_M_frac_digits;
} }
else else
{ {
// Have to pad zeros in the decimal position. // Have to pad zeros in the decimal position.
__value = string_type(__beg, __end); __value = string_type(__beg, __end);
const int __paddec = __frac - (__end - __beg); const int __paddec = __lc->_M_frac_digits - (__end - __beg);
const char_type __zero = __ctype.widen('0'); __value.insert(__value.begin(), __paddec, __lit[_S_zero]);
__value.insert(__value.begin(), __paddec, __zero); __value.insert(__value.begin(), __lc->_M_decimal_point);
__value.insert(__value.begin(), __d);
__beg = __end; __beg = __end;
} }
} }
...@@ -1442,19 +1467,17 @@ namespace std ...@@ -1442,19 +1467,17 @@ namespace std
// grouping rules. // grouping rules.
if (__beg != __end) if (__beg != __end)
{ {
const string __grouping = __intl ? __mpt.grouping() if (__lc->_M_grouping_size)
: __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; const int __n = (__end - __beg) * 2;
_CharT* __ws2 = _CharT* __ws2 =
static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n)); static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
_CharT* __ws_end = std::__add_grouping(__ws2, __sep, __gbeg, * __n));
__glen, __beg, __end); _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); __value.insert(0, __ws2, __ws_end - __ws2);
} }
else else
...@@ -1463,10 +1486,14 @@ namespace std ...@@ -1463,10 +1486,14 @@ namespace std
// Calculate length of resulting string. // Calculate length of resulting string.
const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield; const ios_base::fmtflags __f = __io.flags() & ios_base::adjustfield;
size_type __len = __value.size() + __sign.size(); size_type __len = __value.size() + __sign_size;
__len += (__io.flags() & ios_base::showbase) ? __symbol.size() : 0; __len += ((__io.flags() & ios_base::showbase)
const bool __testipad = __f == ios_base::internal && __len < __width; ? __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. // Fit formatted digits into the required pattern.
for (int __i = 0; __i < 4; ++__i) for (int __i = 0; __i < 4; ++__i)
{ {
...@@ -1475,13 +1502,14 @@ namespace std ...@@ -1475,13 +1502,14 @@ namespace std
{ {
case money_base::symbol: case money_base::symbol:
if (__io.flags() & ios_base::showbase) if (__io.flags() & ios_base::showbase)
__res += __symbol; __res.append(__lc->_M_curr_symbol,
__lc->_M_curr_symbol_size);
break; break;
case money_base::sign: case money_base::sign:
// Sign might not exist, or be more than one // Sign might not exist, or be more than one
// charater long. In that case, add in the rest // charater long. In that case, add in the rest
// below. // below.
if (__sign.size()) if (__sign_size)
__res += __sign[0]; __res += __sign[0];
break; break;
case money_base::value: case money_base::value:
...@@ -1494,7 +1522,7 @@ namespace std ...@@ -1494,7 +1522,7 @@ namespace std
if (__testipad) if (__testipad)
__res += string_type(__width - __len, __fill); __res += string_type(__width - __len, __fill);
else else
__res += __ctype.widen(__fill); __res += __fill;
break; break;
case money_base::none: case money_base::none:
if (__testipad) if (__testipad)
...@@ -1504,8 +1532,8 @@ namespace std ...@@ -1504,8 +1532,8 @@ namespace std
} }
// Special case of multi-part sign parts. // Special case of multi-part sign parts.
if (__sign.size() > 1) if (__sign_size > 1)
__res += string_type(__sign.begin() + 1, __sign.end()); __res.append(__sign + 1, __sign_size - 1);
// Pad, if still necessary. // Pad, if still necessary.
__len = __res.size(); __len = __res.size();
...@@ -1562,7 +1590,8 @@ namespace std ...@@ -1562,7 +1590,8 @@ namespace std
* __cs_size)); * __cs_size));
__ctype.widen(__cs, __cs + __len, __ws); __ctype.widen(__cs, __cs + __len, __ws);
const string_type __digits(__ws, __len); 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> template<typename _CharT, typename _OutIter>
...@@ -1570,7 +1599,8 @@ namespace std ...@@ -1570,7 +1599,8 @@ namespace std
money_put<_CharT, _OutIter>:: money_put<_CharT, _OutIter>::
do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
const string_type& __digits) const 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 // NB: Not especially useful. Without an ios_base object or some
// kind of locale reference, we are left clawing at the air where // kind of locale reference, we are left clawing at the air where
......
...@@ -184,8 +184,8 @@ namespace __gnu_internal ...@@ -184,8 +184,8 @@ namespace __gnu_internal
__attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>)))); __attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>))));
fake_num_cache_c numpunct_cache_c; fake_num_cache_c numpunct_cache_c;
typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char>)] typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char, true>)]
__attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char>)))); __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char, true>))));
fake_money_cache_c moneypunct_cache_ct; fake_money_cache_c moneypunct_cache_ct;
fake_money_cache_c moneypunct_cache_cf; fake_money_cache_c moneypunct_cache_cf;
...@@ -198,8 +198,8 @@ namespace __gnu_internal ...@@ -198,8 +198,8 @@ namespace __gnu_internal
__attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>)))); __attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>))));
fake_num_cache_w numpunct_cache_w; fake_num_cache_w numpunct_cache_w;
typedef char fake_money_cache_w[sizeof(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>)))); __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<wchar_t,true>))));
fake_money_cache_w moneypunct_cache_wt; fake_money_cache_w moneypunct_cache_wt;
fake_money_cache_w moneypunct_cache_wf; fake_money_cache_w moneypunct_cache_wf;
......
// Locale support -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -43,11 +44,23 @@ namespace std ...@@ -43,11 +44,23 @@ namespace std
// moneypunct, money_get, and money_put // moneypunct, money_get, and money_put
template class moneypunct<C, false>; template class moneypunct<C, false>;
template class moneypunct<C, true>; 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, false>;
template class moneypunct_byname<C, true>; template class moneypunct_byname<C, true>;
template class money_get<C, istreambuf_iterator<C> >; template class money_get<C, istreambuf_iterator<C> >;
template class money_put<C, ostreambuf_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 // numpunct, numpunct_byname, num_get, and num_put
template class numpunct<C>; template class numpunct<C>;
......
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -53,6 +53,8 @@ namespace std ...@@ -53,6 +53,8 @@ namespace std
const money_base::pattern const money_base::pattern
money_base::_S_default_pattern = { {symbol, sign, none, value} }; 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_in = "-+xX0123456789abcdefABCDEF";
const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF"; const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
......
...@@ -79,13 +79,13 @@ namespace __gnu_internal ...@@ -79,13 +79,13 @@ namespace __gnu_internal
// And the caches.... // And the caches....
extern std::locale::facet* cache_vec[_GLIBCXX_NUM_FACETS]; extern std::locale::facet* cache_vec[_GLIBCXX_NUM_FACETS];
extern std::__numpunct_cache<char> numpunct_cache_c; extern std::__numpunct_cache<char> numpunct_cache_c;
extern std::__moneypunct_cache<char> moneypunct_cache_cf; extern std::__moneypunct_cache<char, false> moneypunct_cache_cf;
extern std::__moneypunct_cache<char> moneypunct_cache_ct; extern std::__moneypunct_cache<char, true> moneypunct_cache_ct;
extern std::__timepunct_cache<char> timepunct_cache_c; extern std::__timepunct_cache<char> timepunct_cache_c;
#ifdef _GLIBCXX_USE_WCHAR_T #ifdef _GLIBCXX_USE_WCHAR_T
extern std::__numpunct_cache<wchar_t> numpunct_cache_w; extern std::__numpunct_cache<wchar_t> numpunct_cache_w;
extern std::__moneypunct_cache<wchar_t> moneypunct_cache_wf; extern std::__moneypunct_cache<wchar_t, false> moneypunct_cache_wf;
extern std::__moneypunct_cache<wchar_t> moneypunct_cache_wt; extern std::__moneypunct_cache<wchar_t, true> moneypunct_cache_wt;
extern std::__timepunct_cache<wchar_t> timepunct_cache_w; extern std::__timepunct_cache<wchar_t> timepunct_cache_w;
#endif #endif
} // namespace __gnu_internal } // namespace __gnu_internal
...@@ -273,10 +273,11 @@ namespace std ...@@ -273,10 +273,11 @@ namespace std
_M_init_facet(new (&num_put_c) num_put<char>(1)); _M_init_facet(new (&num_put_c) num_put<char>(1));
_M_init_facet(new (&collate_c) std::collate<char>(1)); _M_init_facet(new (&collate_c) std::collate<char>(1));
typedef __moneypunct_cache<char> money_cache_c; typedef __moneypunct_cache<char, false> money_cache_cf;
money_cache_c* __mpcf = new (&moneypunct_cache_cf) money_cache_c(2); 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)); _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 (&moneypunct_ct) moneypunct<char, true>(__mpct, 1));
_M_init_facet(new (&money_get_c) money_get<char>(1)); _M_init_facet(new (&money_get_c) money_get<char>(1));
...@@ -302,10 +303,11 @@ namespace std ...@@ -302,10 +303,11 @@ namespace std
_M_init_facet(new (&num_put_w) num_put<wchar_t>(1)); _M_init_facet(new (&num_put_w) num_put<wchar_t>(1));
_M_init_facet(new (&collate_w) std::collate<wchar_t>(1)); _M_init_facet(new (&collate_w) std::collate<wchar_t>(1));
typedef __moneypunct_cache<wchar_t> money_cache_w; typedef __moneypunct_cache<wchar_t, false> money_cache_wf;
money_cache_w* __mpwf = new (&moneypunct_cache_wf) money_cache_w(2); 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)); _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 (&moneypunct_wt) moneypunct<wchar_t, true>(__mpwt, 1));
_M_init_facet(new (&money_get_w) money_get<wchar_t>(1)); _M_init_facet(new (&money_get_w) money_get<wchar_t>(1));
......
// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
typedef money_base::part part;
typedef money_base::pattern pattern;
typedef ostreambuf_iterator<char> iterator_type; typedef ostreambuf_iterator<char> iterator_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -39,10 +37,6 @@ void test01() ...@@ -39,10 +37,6 @@ void test01()
locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de ); 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. // sanity check the data is correct.
const string empty; const string empty;
......
// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
void test02() void test02()
{ {
using namespace std; using namespace std;
typedef money_base::part part;
typedef money_base::pattern pattern;
typedef ostreambuf_iterator<char> iterator_type; typedef ostreambuf_iterator<char> iterator_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -37,16 +35,7 @@ void test02() ...@@ -37,16 +35,7 @@ void test02()
// basic construction // basic construction
locale loc_c = locale::classic(); locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK"); locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro"); VERIFY( loc_c != loc_hk );
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. // sanity check the data is correct.
const string empty; const string empty;
......
// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,25 +28,14 @@ ...@@ -28,25 +28,14 @@
void test03() void test03()
{ {
using namespace std; using namespace std;
typedef money_base::part part;
typedef money_base::pattern pattern;
typedef ostreambuf_iterator<char> iterator_type; typedef ostreambuf_iterator<char> iterator_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// basic construction // basic construction
locale loc_c = locale::classic(); 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"); locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de ); 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. // sanity check the data is correct.
const string empty; const string empty;
......
// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
typedef money_base::part part;
typedef money_base::pattern pattern;
typedef ostreambuf_iterator<wchar_t> iterator_type; typedef ostreambuf_iterator<wchar_t> iterator_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -39,10 +37,6 @@ void test01() ...@@ -39,10 +37,6 @@ void test01()
locale loc_de = __gnu_test::try_named_locale("de_DE@euro"); locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de ); 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. // sanity check the data is correct.
const wstring empty; const wstring empty;
......
// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
void test02() void test02()
{ {
using namespace std; using namespace std;
typedef money_base::part part;
typedef money_base::pattern pattern;
typedef ostreambuf_iterator<wchar_t> iterator_type; typedef ostreambuf_iterator<wchar_t> iterator_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -37,16 +35,7 @@ void test02() ...@@ -37,16 +35,7 @@ void test02()
// basic construction // basic construction
locale loc_c = locale::classic(); locale loc_c = locale::classic();
locale loc_hk = __gnu_test::try_named_locale("en_HK"); locale loc_hk = __gnu_test::try_named_locale("en_HK");
locale loc_fr = __gnu_test::try_named_locale("fr_FR@euro"); VERIFY( loc_c != loc_hk );
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. // sanity check the data is correct.
const wstring empty; const wstring empty;
......
// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,25 +28,14 @@ ...@@ -28,25 +28,14 @@
void test03() void test03()
{ {
using namespace std; using namespace std;
typedef money_base::part part;
typedef money_base::pattern pattern;
typedef ostreambuf_iterator<wchar_t> iterator_type; typedef ostreambuf_iterator<wchar_t> iterator_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// basic construction // basic construction
locale loc_c = locale::classic(); 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"); locale loc_de = __gnu_test::try_named_locale("de_DE@euro");
VERIFY( loc_c != loc_de ); 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. // sanity check the data is correct.
const wstring empty; const wstring empty;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment