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>
* testsuite/27_io/basic_filebuf/showmanyc/char/9533-1.cc: Open
......
// 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<>
......
......@@ -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";
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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>
......
......@@ -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;
......
// 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>;
......
// 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";
......
......@@ -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));
......
// 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;
......
// 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;
......
// 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;
......
// 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;
......
// 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;
......
// 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;
......
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