diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-18 02:27:16 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-18 02:27:16 +0000 |
commit | 90467111ded1be244f34ede52173ab20c42d59a8 (patch) | |
tree | c629218ba92ff6f90589c473437fd02fda11bfb3 /libstdc++-v3 | |
parent | 1d0406e567e83323a64504ffeec9aaeb0ffc94b7 (diff) | |
download | gcc-90467111ded1be244f34ede52173ab20c42d59a8.tar.gz |
2003-07-17 Benjamin Kosnik <bkoz@redhat.com>
* config/linker-map.gnu: Add __moneypunct_cache, __timepunct_cache.
* config/locale/generic/messages_members.h: Tweaks.
* config/locale/generic/monetary_members.cc
(moneypunct::_M_initialize_moneypunct): Use cache.
(moneypunct::~moneypunct): Delete cache.
* config/locale/generic/time_members.cc:
(__timepunct::_M_initialize_timepunct): Use cache.
* config/locale/generic/time_members.h:
(__timepunct::~__timepunct): Delete cache.
(__timepunct::__timepunct): Set cache.
* config/locale/gnu/messages_members.h: Tweaks.
* config/locale/gnu/monetary_members.cc:
(moneypunct::_M_initialize_moneypunct): Use cache.
(moneypunct::~moneypunct): Delete cache.
* config/locale/gnu/time_members.cc:
(__timepunct::_M_initialize_timepunct): Use cache.
* config/locale/gnu/time_members.h:
(__timepunct::~__timepunct): Delete cache.
(__timepunct::__timepunct): Set cache.
* include/bits/locale_facets.h (__timepunct_cache): New.
(__moneypunct_cache): New.
* include/bits/locale_facets.tcc: Tweak.
* src/locale.cc (__timepunct::_S_timezones): Adjust for cache.
* src/locale-inst.cc: Instantiate caches.
* src/globals.cc: Add "C" caches.
* src/localename.cc: Use external "C" caches.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69535 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 29 | ||||
-rw-r--r-- | libstdc++-v3/config/linker-map.gnu | 4 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/generic/messages_members.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/generic/monetary_members.cc | 98 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/generic/time_members.cc | 200 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/generic/time_members.h | 13 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/gnu/messages_members.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/gnu/monetary_members.cc | 226 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/gnu/time_members.cc | 384 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/gnu/time_members.h | 15 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/locale_facets.h | 327 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/locale_facets.tcc | 2 | ||||
-rw-r--r-- | libstdc++-v3/src/globals.cc | 36 | ||||
-rw-r--r-- | libstdc++-v3/src/locale-inst.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/src/locale.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/src/localename.cc | 62 |
16 files changed, 827 insertions, 585 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 59b3eacddbc..692e8d62f1f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,32 @@ +2003-07-17 Benjamin Kosnik <bkoz@redhat.com> + + * config/linker-map.gnu: Add __moneypunct_cache, __timepunct_cache. + * config/locale/generic/messages_members.h: Tweaks. + * config/locale/generic/monetary_members.cc + (moneypunct::_M_initialize_moneypunct): Use cache. + (moneypunct::~moneypunct): Delete cache. + * config/locale/generic/time_members.cc: + (__timepunct::_M_initialize_timepunct): Use cache. + * config/locale/generic/time_members.h: + (__timepunct::~__timepunct): Delete cache. + (__timepunct::__timepunct): Set cache. + * config/locale/gnu/messages_members.h: Tweaks. + * config/locale/gnu/monetary_members.cc: + (moneypunct::_M_initialize_moneypunct): Use cache. + (moneypunct::~moneypunct): Delete cache. + * config/locale/gnu/time_members.cc: + (__timepunct::_M_initialize_timepunct): Use cache. + * config/locale/gnu/time_members.h: + (__timepunct::~__timepunct): Delete cache. + (__timepunct::__timepunct): Set cache. + * include/bits/locale_facets.h (__timepunct_cache): New. + (__moneypunct_cache): New. + * include/bits/locale_facets.tcc: Tweak. + * src/locale.cc (__timepunct::_S_timezones): Adjust for cache. + * src/locale-inst.cc: Instantiate caches. + * src/globals.cc: Add "C" caches. + * src/localename.cc: Use external "C" caches. + 2003-07-17 Phil Edwards <pme@gcc.gnu.org> * docs/doxygen/guide.html: Fix typo. diff --git a/libstdc++-v3/config/linker-map.gnu b/libstdc++-v3/config/linker-map.gnu index 3e6b5a3040d..4f0db8d79d1 100644 --- a/libstdc++-v3/config/linker-map.gnu +++ b/libstdc++-v3/config/linker-map.gnu @@ -55,7 +55,9 @@ GLIBCXX_3.4 { std::__num_base::_S_format_int*; std::__num_base::_S_atoms_in; std::__num_base::_S_atoms_out; - std::__numpunct_cache* + std::__moneypunct_cache*; + std::__numpunct_cache*; + std::__timepunct_cache* }; # Names not in an 'extern' block are mangled names. diff --git a/libstdc++-v3/config/locale/generic/messages_members.h b/libstdc++-v3/config/locale/generic/messages_members.h index 9d48759353f..2d588049c4f 100644 --- a/libstdc++-v3/config/locale/generic/messages_members.h +++ b/libstdc++-v3/config/locale/generic/messages_members.h @@ -36,12 +36,12 @@ // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) - : locale::facet(__refs) + : facet(__refs) { _M_c_locale_messages = _S_c_locale; } template<typename _CharT> messages<_CharT>::messages(__c_locale, const char*, size_t __refs) - : locale::facet(__refs) + : facet(__refs) { _M_c_locale_messages = _S_c_locale; } template<typename _CharT> diff --git a/libstdc++-v3/config/locale/generic/monetary_members.cc b/libstdc++-v3/config/locale/generic/monetary_members.cc index 1ee08444f5a..51bbe0b0c01 100644 --- a/libstdc++-v3/config/locale/generic/monetary_members.cc +++ b/libstdc++-v3/config/locale/generic/monetary_members.cc @@ -1,6 +1,6 @@ // std::moneypunct implementation details, generic version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -47,41 +47,47 @@ namespace std void moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*) { - // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + // "C" locale. + if (!_M_data) + _M_data = new __moneypunct_cache<char>; + + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = ""; + _M_data->_M_positive_sign = ""; + _M_data->_M_negative_sign = ""; + _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; } template<> void moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*) { - // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + // "C" locale. + if (!_M_data) + _M_data = new __moneypunct_cache<char>; + + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = ""; + _M_data->_M_positive_sign = ""; + _M_data->_M_negative_sign = ""; + _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; } template<> moneypunct<char, true>::~moneypunct() - { } + { delete _M_data; } template<> moneypunct<char, false>::~moneypunct() - { } + { delete _M_data; } #ifdef _GLIBCXX_USE_WCHAR_T template<> @@ -90,15 +96,18 @@ namespace std const char*) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t>; + + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = L""; + _M_data->_M_positive_sign = L""; + _M_data->_M_negative_sign = L""; + _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; } template<> @@ -107,23 +116,26 @@ namespace std const char*) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t>; + + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = L""; + _M_data->_M_positive_sign = L""; + _M_data->_M_negative_sign = L""; + _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; } template<> moneypunct<wchar_t, true>::~moneypunct() - { } + { delete _M_data; } template<> moneypunct<wchar_t, false>::~moneypunct() - { } + { delete _M_data; } #endif } diff --git a/libstdc++-v3/config/locale/generic/time_members.cc b/libstdc++-v3/config/locale/generic/time_members.cc index f6913fe3294..3574a844b5a 100644 --- a/libstdc++-v3/config/locale/generic/time_members.cc +++ b/libstdc++-v3/config/locale/generic/time_members.cc @@ -1,6 +1,6 @@ // std::time_get, std::time_put implementation, generic version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -55,62 +55,65 @@ namespace std void __timepunct<char>::_M_initialize_timepunct(__c_locale) { - // "C" locale - _M_date_format = "%m/%d/%y"; - _M_date_era_format = "%m/%d/%y"; - _M_time_format = "%H:%M:%S"; - _M_time_era_format = "%H:%M:%S"; - _M_date_time_format = ""; - _M_date_time_era_format = ""; - _M_am = "AM"; - _M_pm = "PM"; - _M_am_pm_format = ""; + // "C" locale. + if (!_M_data) + _M_data = new __timepunct_cache<char>; + + _M_data->_M_date_format = "%m/%d/%y"; + _M_data->_M_date_era_format = "%m/%d/%y"; + _M_data->_M_time_format = "%H:%M:%S"; + _M_data->_M_time_era_format = "%H:%M:%S"; + _M_data->_M_date_time_format = ""; + _M_data->_M_date_time_era_format = ""; + _M_data->_M_am = "AM"; + _M_data->_M_pm = "PM"; + _M_data->_M_am_pm_format = ""; // Day names, starting with "C"'s Sunday. - _M_day1 = "Sunday"; - _M_day2 = "Monday"; - _M_day3 = "Tuesday"; - _M_day4 = "Wednesday"; - _M_day5 = "Thursday"; - _M_day6 = "Friday"; - _M_day7 = "Saturday"; + _M_data->_M_day1 = "Sunday"; + _M_data->_M_day2 = "Monday"; + _M_data->_M_day3 = "Tuesday"; + _M_data->_M_day4 = "Wednesday"; + _M_data->_M_day5 = "Thursday"; + _M_data->_M_day6 = "Friday"; + _M_data->_M_day7 = "Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = "Sun"; - _M_day_a2 = "Mon"; - _M_day_a3 = "Tue"; - _M_day_a4 = "Wed"; - _M_day_a5 = "Thu"; - _M_day_a6 = "Fri"; - _M_day_a7 = "Sat"; + _M_data->_M_aday1 = "Sun"; + _M_data->_M_aday2 = "Mon"; + _M_data->_M_aday3 = "Tue"; + _M_data->_M_aday4 = "Wed"; + _M_data->_M_aday5 = "Thu"; + _M_data->_M_aday6 = "Fri"; + _M_data->_M_aday7 = "Sat"; // Month names, starting with "C"'s January. - _M_month01 = "January"; - _M_month02 = "February"; - _M_month03 = "March"; - _M_month04 = "April"; - _M_month05 = "May"; - _M_month06 = "June"; - _M_month07 = "July"; - _M_month08 = "August"; - _M_month09 = "September"; - _M_month10 = "October"; - _M_month11 = "November"; - _M_month12 = "December"; + _M_data->_M_month01 = "January"; + _M_data->_M_month02 = "February"; + _M_data->_M_month03 = "March"; + _M_data->_M_month04 = "April"; + _M_data->_M_month05 = "May"; + _M_data->_M_month06 = "June"; + _M_data->_M_month07 = "July"; + _M_data->_M_month08 = "August"; + _M_data->_M_month09 = "September"; + _M_data->_M_month10 = "October"; + _M_data->_M_month11 = "November"; + _M_data->_M_month12 = "December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = "Jan"; - _M_month_a02 = "Feb"; - _M_month_a03 = "Mar"; - _M_month_a04 = "Apr"; - _M_month_a05 = "May"; - _M_month_a06 = "Jun"; - _M_month_a07 = "July"; - _M_month_a08 = "Aug"; - _M_month_a09 = "Sep"; - _M_month_a10 = "Oct"; - _M_month_a11 = "Nov"; - _M_month_a12 = "Dec"; + _M_data->_M_amonth01 = "Jan"; + _M_data->_M_amonth02 = "Feb"; + _M_data->_M_amonth03 = "Mar"; + _M_data->_M_amonth04 = "Apr"; + _M_data->_M_amonth05 = "May"; + _M_data->_M_amonth06 = "Jun"; + _M_data->_M_amonth07 = "July"; + _M_data->_M_amonth08 = "Aug"; + _M_data->_M_amonth09 = "Sep"; + _M_data->_M_amonth10 = "Oct"; + _M_data->_M_amonth11 = "Nov"; + _M_data->_M_amonth12 = "Dec"; } #ifdef _GLIBCXX_USE_WCHAR_T @@ -131,62 +134,65 @@ namespace std void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale) { - // "C" locale - _M_date_format = L"%m/%d/%y"; - _M_date_era_format = L"%m/%d/%y"; - _M_time_format = L"%H:%M:%S"; - _M_time_era_format = L"%H:%M:%S"; - _M_date_time_format = L""; - _M_date_time_era_format = L""; - _M_am = L"AM"; - _M_pm = L"PM"; - _M_am_pm_format = L""; + // "C" locale. + if (!_M_data) + _M_data = new __timepunct_cache<wchar_t>; + + _M_data->_M_date_format = L"%m/%d/%y"; + _M_data->_M_date_era_format = L"%m/%d/%y"; + _M_data->_M_time_format = L"%H:%M:%S"; + _M_data->_M_time_era_format = L"%H:%M:%S"; + _M_data->_M_date_time_format = L""; + _M_data->_M_date_time_era_format = L""; + _M_data->_M_am = L"AM"; + _M_data->_M_pm = L"PM"; + _M_data->_M_am_pm_format = L""; // Day names, starting with "C"'s Sunday. - _M_day1 = L"Sunday"; - _M_day2 = L"Monday"; - _M_day3 = L"Tuesday"; - _M_day4 = L"Wednesday"; - _M_day5 = L"Thursday"; - _M_day6 = L"Friday"; - _M_day7 = L"Saturday"; + _M_data->_M_day1 = L"Sunday"; + _M_data->_M_day2 = L"Monday"; + _M_data->_M_day3 = L"Tuesday"; + _M_data->_M_day4 = L"Wednesday"; + _M_data->_M_day5 = L"Thursday"; + _M_data->_M_day6 = L"Friday"; + _M_data->_M_day7 = L"Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = L"Sun"; - _M_day_a2 = L"Mon"; - _M_day_a3 = L"Tue"; - _M_day_a4 = L"Wed"; - _M_day_a5 = L"Thu"; - _M_day_a6 = L"Fri"; - _M_day_a7 = L"Sat"; + _M_data->_M_aday1 = L"Sun"; + _M_data->_M_aday2 = L"Mon"; + _M_data->_M_aday3 = L"Tue"; + _M_data->_M_aday4 = L"Wed"; + _M_data->_M_aday5 = L"Thu"; + _M_data->_M_aday6 = L"Fri"; + _M_data->_M_aday7 = L"Sat"; // Month names, starting with "C"'s January. - _M_month01 = L"January"; - _M_month02 = L"February"; - _M_month03 = L"March"; - _M_month04 = L"April"; - _M_month05 = L"May"; - _M_month06 = L"June"; - _M_month07 = L"July"; - _M_month08 = L"August"; - _M_month09 = L"September"; - _M_month10 = L"October"; - _M_month11 = L"November"; - _M_month12 = L"December"; + _M_data->_M_month01 = L"January"; + _M_data->_M_month02 = L"February"; + _M_data->_M_month03 = L"March"; + _M_data->_M_month04 = L"April"; + _M_data->_M_month05 = L"May"; + _M_data->_M_month06 = L"June"; + _M_data->_M_month07 = L"July"; + _M_data->_M_month08 = L"August"; + _M_data->_M_month09 = L"September"; + _M_data->_M_month10 = L"October"; + _M_data->_M_month11 = L"November"; + _M_data->_M_month12 = L"December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = L"Jan"; - _M_month_a02 = L"Feb"; - _M_month_a03 = L"Mar"; - _M_month_a04 = L"Apr"; - _M_month_a05 = L"May"; - _M_month_a06 = L"Jun"; - _M_month_a07 = L"July"; - _M_month_a08 = L"Aug"; - _M_month_a09 = L"Sep"; - _M_month_a10 = L"Oct"; - _M_month_a11 = L"Nov"; - _M_month_a12 = L"Dec"; + _M_data->_M_amonth01 = L"Jan"; + _M_data->_M_amonth02 = L"Feb"; + _M_data->_M_amonth03 = L"Mar"; + _M_data->_M_amonth04 = L"Apr"; + _M_data->_M_amonth05 = L"May"; + _M_data->_M_amonth06 = L"Jun"; + _M_data->_M_amonth07 = L"July"; + _M_data->_M_amonth08 = L"Aug"; + _M_data->_M_amonth09 = L"Sep"; + _M_data->_M_amonth10 = L"Oct"; + _M_data->_M_amonth11 = L"Nov"; + _M_data->_M_amonth12 = L"Dec"; } #endif } diff --git a/libstdc++-v3/config/locale/generic/time_members.h b/libstdc++-v3/config/locale/generic/time_members.h index 03c31d1797e..8db2cb53ed8 100644 --- a/libstdc++-v3/config/locale/generic/time_members.h +++ b/libstdc++-v3/config/locale/generic/time_members.h @@ -36,7 +36,15 @@ template<typename _CharT> __timepunct<_CharT>::__timepunct(size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) + { + _M_name_timepunct = _S_c_name; + _M_initialize_timepunct(); + } + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache) { _M_name_timepunct = _S_c_name; _M_initialize_timepunct(); @@ -45,7 +53,7 @@ template<typename _CharT> __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) { _M_name_timepunct = new char[strlen(__s) + 1]; strcpy(_M_name_timepunct, __s); @@ -57,5 +65,6 @@ { if (_S_c_name != _M_name_timepunct) delete [] _M_name_timepunct; + delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } diff --git a/libstdc++-v3/config/locale/gnu/messages_members.h b/libstdc++-v3/config/locale/gnu/messages_members.h index 8cab730acfa..48dcf32dd2e 100644 --- a/libstdc++-v3/config/locale/gnu/messages_members.h +++ b/libstdc++-v3/config/locale/gnu/messages_members.h @@ -36,7 +36,7 @@ // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) - : locale::facet(__refs) + : facet(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) _M_name_messages = _S_c_name; @@ -48,7 +48,7 @@ messages<_CharT>::messages(__c_locale __cloc, const char* __s __attribute__ ((__unused__)), size_t __refs) - : locale::facet(__refs) + : facet(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) _M_name_messages = new char[strlen(__s) + 1]; diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc b/libstdc++-v3/config/locale/gnu/monetary_members.cc index 3ad7d34c17c..a22bdfe6f24 100644 --- a/libstdc++-v3/config/locale/gnu/monetary_members.cc +++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc @@ -1,6 +1,6 @@ // std::moneypunct implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -220,43 +220,52 @@ namespace std moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, const char*) { + if (!_M_data) + _M_data = new __moneypunct_cache<char>; + if (!__cloc) { // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = ""; + _M_data->_M_positive_sign = ""; + _M_data->_M_negative_sign = ""; + _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; } else { // Named locale. - _M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, __cloc)); - _M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); - _M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, + __cloc)); + _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_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); if (!__nposn) - _M_negative_sign = "()"; + _M_data->_M_negative_sign = "()"; else - _M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, + __cloc); // _Intl == true - _M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); - _M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); + _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); + _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, + __cloc)); char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); } } @@ -265,53 +274,61 @@ namespace std moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, const char*) { + if (!_M_data) + _M_data = new __moneypunct_cache<char>; + if (!__cloc) { // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = ""; + _M_data->_M_positive_sign = ""; + _M_data->_M_negative_sign = ""; + _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; } else { // Named locale. - _M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, __cloc)); - _M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); - _M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, + __cloc)); + _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_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); if (!__nposn) - _M_negative_sign = "()"; + _M_data->_M_negative_sign = "()"; else - _M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, + __cloc); // _Intl == false - _M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); - _M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); + _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); + _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)); char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); } } template<> moneypunct<char, true>::~moneypunct() - { } + { delete _M_data; } template<> moneypunct<char, false>::~moneypunct() - { } + { delete _M_data; } #ifdef _GLIBCXX_USE_WCHAR_T template<> @@ -323,18 +340,21 @@ namespace std const char* __name) #endif { + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t>; + if (!__cloc) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = L""; + _M_data->_M_positive_sign = L""; + _M_data->_M_negative_sign = L""; + _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; } else { @@ -349,11 +369,11 @@ namespace std union __s_and_w { const char *__s; unsigned int __w; } __u; __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc); - _M_decimal_point = static_cast<wchar_t>(__u.__w); + _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w); __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); - _M_thousands_sep = static_cast<wchar_t>(__u.__w); - _M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); + _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); @@ -367,25 +387,25 @@ namespace std memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len]; mbsrtowcs(__wcs, &__cpossign, __len, &__state); - _M_positive_sign = __wcs; + _M_data->_M_positive_sign = __wcs; } else - _M_positive_sign = L""; + _M_data->_M_positive_sign = L""; char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); __len = strlen(__cnegsign); if (!__nposn) - _M_negative_sign = L"()"; + _M_data->_M_negative_sign = L"()"; else if (__len) { ++__len; memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len]; mbsrtowcs(__wcs, &__cnegsign, __len, &__state); - _M_negative_sign = __wcs; + _M_data->_M_negative_sign = __wcs; } else - _M_negative_sign = L""; + _M_data->_M_negative_sign = L""; // _Intl == true. __len = strlen(__ccurr); @@ -395,19 +415,22 @@ namespace std memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len]; mbsrtowcs(__wcs, &__ccurr, __len, &__state); - _M_curr_symbol = __wcs; + _M_data->_M_curr_symbol = __wcs; } else - _M_curr_symbol = L""; + _M_data->_M_curr_symbol = L""; - _M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); + _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, + __cloc)); char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); @@ -427,18 +450,21 @@ namespace std const char* __name) #endif { + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t>; + if (!__cloc) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_curr_symbol = L""; + _M_data->_M_positive_sign = L""; + _M_data->_M_negative_sign = L""; + _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; } else { @@ -453,11 +479,11 @@ namespace std union __s_and_w { const char *__s; unsigned int __w; } __u; __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc); - _M_decimal_point = static_cast<wchar_t>(__u.__w); + _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w); __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); - _M_thousands_sep = static_cast<wchar_t>(__u.__w); - _M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); + _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); @@ -472,25 +498,25 @@ namespace std memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len]; mbsrtowcs(__wcs, &__cpossign, __len, &__state); - _M_positive_sign = __wcs; + _M_data->_M_positive_sign = __wcs; } else - _M_positive_sign = L""; + _M_data->_M_positive_sign = L""; char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); __len = strlen(__cnegsign); if (!__nposn) - _M_negative_sign = L"()"; + _M_data->_M_negative_sign = L"()"; else if (__len) { ++__len; memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len]; mbsrtowcs(__wcs, &__cnegsign, __len, &__state); - _M_negative_sign = __wcs; + _M_data->_M_negative_sign = __wcs; } else - _M_negative_sign = L""; + _M_data->_M_negative_sign = L""; // _Intl == true. __len = strlen(__ccurr); @@ -500,19 +526,21 @@ namespace std memset(&__state, 0, sizeof(mbstate_t)); wchar_t* __wcs = new wchar_t[__len]; mbsrtowcs(__wcs, &__ccurr, __len, &__state); - _M_curr_symbol = __wcs; + _M_data->_M_curr_symbol = __wcs; } else - _M_curr_symbol = L""; + _M_data->_M_curr_symbol = L""; - _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 __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); @@ -526,23 +554,27 @@ namespace std template<> moneypunct<wchar_t, true>::~moneypunct() { - if (wcslen(_M_positive_sign)) - delete [] _M_positive_sign; - if (wcslen(_M_negative_sign) && (wcscmp(_M_negative_sign, L"()") != 0)) - delete [] _M_negative_sign; - if (wcslen(_M_curr_symbol)) - delete [] _M_curr_symbol; + if (wcslen(_M_data->_M_positive_sign)) + delete [] _M_data->_M_positive_sign; + if (wcslen(_M_data->_M_negative_sign) + && (wcscmp(_M_data->_M_negative_sign, L"()") != 0)) + delete [] _M_data->_M_negative_sign; + if (wcslen(_M_data->_M_curr_symbol)) + delete [] _M_data->_M_curr_symbol; + delete _M_data; } template<> moneypunct<wchar_t, false>::~moneypunct() { - if (wcslen(_M_positive_sign)) - delete [] _M_positive_sign; - if (wcslen(_M_negative_sign) && (wcscmp(_M_negative_sign, L"()") != 0)) - delete [] _M_negative_sign; - if (wcslen(_M_curr_symbol)) - delete [] _M_curr_symbol; + if (wcslen(_M_data->_M_positive_sign)) + delete [] _M_data->_M_positive_sign; + if (wcslen(_M_data->_M_negative_sign) + && (wcscmp(_M_data->_M_negative_sign, L"()") != 0)) + delete [] _M_data->_M_negative_sign; + if (wcslen(_M_data->_M_curr_symbol)) + delete [] _M_data->_M_curr_symbol; + delete _M_data; } #endif } diff --git a/libstdc++-v3/config/locale/gnu/time_members.cc b/libstdc++-v3/config/locale/gnu/time_members.cc index 1dcdfd5c43e..e49b66b256f 100644 --- a/libstdc++-v3/config/locale/gnu/time_members.cc +++ b/libstdc++-v3/config/locale/gnu/time_members.cc @@ -1,6 +1,6 @@ // std::time_get, std::time_put implementation, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -60,126 +60,129 @@ namespace std void __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc) { + if (!_M_data) + _M_data = new __timepunct_cache<char>; + if (!__cloc) { // "C" locale _M_c_locale_timepunct = _S_c_locale; - _M_date_format = "%m/%d/%y"; - _M_date_era_format = "%m/%d/%y"; - _M_time_format = "%H:%M:%S"; - _M_time_era_format = "%H:%M:%S"; - _M_date_time_format = ""; - _M_date_time_era_format = ""; - _M_am = "AM"; - _M_pm = "PM"; - _M_am_pm_format = ""; + _M_data->_M_date_format = "%m/%d/%y"; + _M_data->_M_date_era_format = "%m/%d/%y"; + _M_data->_M_time_format = "%H:%M:%S"; + _M_data->_M_time_era_format = "%H:%M:%S"; + _M_data->_M_date_time_format = ""; + _M_data->_M_date_time_era_format = ""; + _M_data->_M_am = "AM"; + _M_data->_M_pm = "PM"; + _M_data->_M_am_pm_format = ""; // Day names, starting with "C"'s Sunday. - _M_day1 = "Sunday"; - _M_day2 = "Monday"; - _M_day3 = "Tuesday"; - _M_day4 = "Wednesday"; - _M_day5 = "Thursday"; - _M_day6 = "Friday"; - _M_day7 = "Saturday"; + _M_data->_M_day1 = "Sunday"; + _M_data->_M_day2 = "Monday"; + _M_data->_M_day3 = "Tuesday"; + _M_data->_M_day4 = "Wednesday"; + _M_data->_M_day5 = "Thursday"; + _M_data->_M_day6 = "Friday"; + _M_data->_M_day7 = "Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = "Sun"; - _M_day_a2 = "Mon"; - _M_day_a3 = "Tue"; - _M_day_a4 = "Wed"; - _M_day_a5 = "Thu"; - _M_day_a6 = "Fri"; - _M_day_a7 = "Sat"; + _M_data->_M_aday1 = "Sun"; + _M_data->_M_aday2 = "Mon"; + _M_data->_M_aday3 = "Tue"; + _M_data->_M_aday4 = "Wed"; + _M_data->_M_aday5 = "Thu"; + _M_data->_M_aday6 = "Fri"; + _M_data->_M_aday7 = "Sat"; // Month names, starting with "C"'s January. - _M_month01 = "January"; - _M_month02 = "February"; - _M_month03 = "March"; - _M_month04 = "April"; - _M_month05 = "May"; - _M_month06 = "June"; - _M_month07 = "July"; - _M_month08 = "August"; - _M_month09 = "September"; - _M_month10 = "October"; - _M_month11 = "November"; - _M_month12 = "December"; + _M_data->_M_month01 = "January"; + _M_data->_M_month02 = "February"; + _M_data->_M_month03 = "March"; + _M_data->_M_month04 = "April"; + _M_data->_M_month05 = "May"; + _M_data->_M_month06 = "June"; + _M_data->_M_month07 = "July"; + _M_data->_M_month08 = "August"; + _M_data->_M_month09 = "September"; + _M_data->_M_month10 = "October"; + _M_data->_M_month11 = "November"; + _M_data->_M_month12 = "December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = "Jan"; - _M_month_a02 = "Feb"; - _M_month_a03 = "Mar"; - _M_month_a04 = "Apr"; - _M_month_a05 = "May"; - _M_month_a06 = "Jun"; - _M_month_a07 = "July"; - _M_month_a08 = "Aug"; - _M_month_a09 = "Sep"; - _M_month_a10 = "Oct"; - _M_month_a11 = "Nov"; - _M_month_a12 = "Dec"; + _M_data->_M_amonth01 = "Jan"; + _M_data->_M_amonth02 = "Feb"; + _M_data->_M_amonth03 = "Mar"; + _M_data->_M_amonth04 = "Apr"; + _M_data->_M_amonth05 = "May"; + _M_data->_M_amonth06 = "Jun"; + _M_data->_M_amonth07 = "July"; + _M_data->_M_amonth08 = "Aug"; + _M_data->_M_amonth09 = "Sep"; + _M_data->_M_amonth10 = "Oct"; + _M_data->_M_amonth11 = "Nov"; + _M_data->_M_amonth12 = "Dec"; } else { _M_c_locale_timepunct = _S_clone_c_locale(__cloc); - _M_date_format = __nl_langinfo_l(D_FMT, __cloc); - _M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc); - _M_time_format = __nl_langinfo_l(T_FMT, __cloc); - _M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc); - _M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc); - _M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT, __cloc); - _M_am = __nl_langinfo_l(AM_STR, __cloc); - _M_pm = __nl_langinfo_l(PM_STR, __cloc); - _M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc); + _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc); + _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc); + _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc); + _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc); + _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc); + _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT, __cloc); + _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc); + _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc); + _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc); // Day names, starting with "C"'s Sunday. - _M_day1 = __nl_langinfo_l(DAY_1, __cloc); - _M_day2 = __nl_langinfo_l(DAY_2, __cloc); - _M_day3 = __nl_langinfo_l(DAY_3, __cloc); - _M_day4 = __nl_langinfo_l(DAY_4, __cloc); - _M_day5 = __nl_langinfo_l(DAY_5, __cloc); - _M_day6 = __nl_langinfo_l(DAY_6, __cloc); - _M_day7 = __nl_langinfo_l(DAY_7, __cloc); + _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc); + _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc); + _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc); + _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc); + _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc); + _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc); + _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc); // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = __nl_langinfo_l(ABDAY_1, __cloc); - _M_day_a2 = __nl_langinfo_l(ABDAY_2, __cloc); - _M_day_a3 = __nl_langinfo_l(ABDAY_3, __cloc); - _M_day_a4 = __nl_langinfo_l(ABDAY_4, __cloc); - _M_day_a5 = __nl_langinfo_l(ABDAY_5, __cloc); - _M_day_a6 = __nl_langinfo_l(ABDAY_6, __cloc); - _M_day_a7 = __nl_langinfo_l(ABDAY_7, __cloc); + _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc); + _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc); + _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc); + _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc); + _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc); + _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc); + _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc); // Month names, starting with "C"'s January. - _M_month01 = __nl_langinfo_l(MON_1, __cloc); - _M_month02 = __nl_langinfo_l(MON_2, __cloc); - _M_month03 = __nl_langinfo_l(MON_3, __cloc); - _M_month04 = __nl_langinfo_l(MON_4, __cloc); - _M_month05 = __nl_langinfo_l(MON_5, __cloc); - _M_month06 = __nl_langinfo_l(MON_6, __cloc); - _M_month07 = __nl_langinfo_l(MON_7, __cloc); - _M_month08 = __nl_langinfo_l(MON_8, __cloc); - _M_month09 = __nl_langinfo_l(MON_9, __cloc); - _M_month10 = __nl_langinfo_l(MON_10, __cloc); - _M_month11 = __nl_langinfo_l(MON_11, __cloc); - _M_month12 = __nl_langinfo_l(MON_12, __cloc); + _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc); + _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc); + _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc); + _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc); + _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc); + _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc); + _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc); + _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc); + _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc); + _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc); + _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc); + _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc); // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = __nl_langinfo_l(ABMON_1, __cloc); - _M_month_a02 = __nl_langinfo_l(ABMON_2, __cloc); - _M_month_a03 = __nl_langinfo_l(ABMON_3, __cloc); - _M_month_a04 = __nl_langinfo_l(ABMON_4, __cloc); - _M_month_a05 = __nl_langinfo_l(ABMON_5, __cloc); - _M_month_a06 = __nl_langinfo_l(ABMON_6, __cloc); - _M_month_a07 = __nl_langinfo_l(ABMON_7, __cloc); - _M_month_a08 = __nl_langinfo_l(ABMON_8, __cloc); - _M_month_a09 = __nl_langinfo_l(ABMON_9, __cloc); - _M_month_a10 = __nl_langinfo_l(ABMON_10, __cloc); - _M_month_a11 = __nl_langinfo_l(ABMON_11, __cloc); - _M_month_a12 = __nl_langinfo_l(ABMON_12, __cloc); + _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc); + _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc); + _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc); + _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc); + _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc); + _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc); + _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc); + _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc); + _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc); + _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc); + _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc); + _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc); } } @@ -205,126 +208,129 @@ namespace std void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc) { + if (!_M_data) + _M_data = new __timepunct_cache<wchar_t>; + if (!__cloc) { // "C" locale _M_c_locale_timepunct = _S_c_locale; - _M_date_format = L"%m/%d/%y"; - _M_date_era_format = L"%m/%d/%y"; - _M_time_format = L"%H:%M:%S"; - _M_time_era_format = L"%H:%M:%S"; - _M_date_time_format = L""; - _M_date_time_era_format = L""; - _M_am = L"AM"; - _M_pm = L"PM"; - _M_am_pm_format = L""; + _M_data->_M_date_format = L"%m/%d/%y"; + _M_data->_M_date_era_format = L"%m/%d/%y"; + _M_data->_M_time_format = L"%H:%M:%S"; + _M_data->_M_time_era_format = L"%H:%M:%S"; + _M_data->_M_date_time_format = L""; + _M_data->_M_date_time_era_format = L""; + _M_data->_M_am = L"AM"; + _M_data->_M_pm = L"PM"; + _M_data->_M_am_pm_format = L""; // Day names, starting with "C"'s Sunday. - _M_day1 = L"Sunday"; - _M_day2 = L"Monday"; - _M_day3 = L"Tuesday"; - _M_day4 = L"Wednesday"; - _M_day5 = L"Thursday"; - _M_day6 = L"Friday"; - _M_day7 = L"Saturday"; + _M_data->_M_day1 = L"Sunday"; + _M_data->_M_day2 = L"Monday"; + _M_data->_M_day3 = L"Tuesday"; + _M_data->_M_day4 = L"Wednesday"; + _M_data->_M_day5 = L"Thursday"; + _M_data->_M_day6 = L"Friday"; + _M_data->_M_day7 = L"Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = L"Sun"; - _M_day_a2 = L"Mon"; - _M_day_a3 = L"Tue"; - _M_day_a4 = L"Wed"; - _M_day_a5 = L"Thu"; - _M_day_a6 = L"Fri"; - _M_day_a7 = L"Sat"; + _M_data->_M_aday1 = L"Sun"; + _M_data->_M_aday2 = L"Mon"; + _M_data->_M_aday3 = L"Tue"; + _M_data->_M_aday4 = L"Wed"; + _M_data->_M_aday5 = L"Thu"; + _M_data->_M_aday6 = L"Fri"; + _M_data->_M_aday7 = L"Sat"; // Month names, starting with "C"'s January. - _M_month01 = L"January"; - _M_month02 = L"February"; - _M_month03 = L"March"; - _M_month04 = L"April"; - _M_month05 = L"May"; - _M_month06 = L"June"; - _M_month07 = L"July"; - _M_month08 = L"August"; - _M_month09 = L"September"; - _M_month10 = L"October"; - _M_month11 = L"November"; - _M_month12 = L"December"; + _M_data->_M_month01 = L"January"; + _M_data->_M_month02 = L"February"; + _M_data->_M_month03 = L"March"; + _M_data->_M_month04 = L"April"; + _M_data->_M_month05 = L"May"; + _M_data->_M_month06 = L"June"; + _M_data->_M_month07 = L"July"; + _M_data->_M_month08 = L"August"; + _M_data->_M_month09 = L"September"; + _M_data->_M_month10 = L"October"; + _M_data->_M_month11 = L"November"; + _M_data->_M_month12 = L"December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = L"Jan"; - _M_month_a02 = L"Feb"; - _M_month_a03 = L"Mar"; - _M_month_a04 = L"Apr"; - _M_month_a05 = L"May"; - _M_month_a06 = L"Jun"; - _M_month_a07 = L"July"; - _M_month_a08 = L"Aug"; - _M_month_a09 = L"Sep"; - _M_month_a10 = L"Oct"; - _M_month_a11 = L"Nov"; - _M_month_a12 = L"Dec"; + _M_data->_M_amonth01 = L"Jan"; + _M_data->_M_amonth02 = L"Feb"; + _M_data->_M_amonth03 = L"Mar"; + _M_data->_M_amonth04 = L"Apr"; + _M_data->_M_amonth05 = L"May"; + _M_data->_M_amonth06 = L"Jun"; + _M_data->_M_amonth07 = L"July"; + _M_data->_M_amonth08 = L"Aug"; + _M_data->_M_amonth09 = L"Sep"; + _M_data->_M_amonth10 = L"Oct"; + _M_data->_M_amonth11 = L"Nov"; + _M_data->_M_amonth12 = L"Dec"; } else { _M_c_locale_timepunct = _S_clone_c_locale(__cloc); - _M_date_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_FMT, __cloc)); - _M_date_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_FMT, __cloc)); - _M_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT, __cloc)); - _M_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_T_FMT, __cloc)); - _M_date_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_T_FMT, __cloc)); - _M_date_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc)); - _M_am = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WAM_STR, __cloc)); - _M_pm = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WPM_STR, __cloc)); - _M_am_pm_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc)); + _M_data->_M_date_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_FMT, __cloc)); + _M_data->_M_date_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_FMT, __cloc)); + _M_data->_M_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT, __cloc)); + _M_data->_M_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_T_FMT, __cloc)); + _M_data->_M_date_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_T_FMT, __cloc)); + _M_data->_M_date_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc)); + _M_data->_M_am = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WAM_STR, __cloc)); + _M_data->_M_pm = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WPM_STR, __cloc)); + _M_data->_M_am_pm_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc)); // Day names, starting with "C"'s Sunday. - _M_day1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_1, __cloc)); - _M_day2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_2, __cloc)); - _M_day3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_3, __cloc)); - _M_day4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_4, __cloc)); - _M_day5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_5, __cloc)); - _M_day6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_6, __cloc)); - _M_day7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_7, __cloc)); + _M_data->_M_day1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_1, __cloc)); + _M_data->_M_day2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_2, __cloc)); + _M_data->_M_day3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_3, __cloc)); + _M_data->_M_day4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_4, __cloc)); + _M_data->_M_day5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_5, __cloc)); + _M_data->_M_day6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_6, __cloc)); + _M_data->_M_day7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_7, __cloc)); // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_1, __cloc)); - _M_day_a2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_2, __cloc)); - _M_day_a3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_3, __cloc)); - _M_day_a4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_4, __cloc)); - _M_day_a5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_5, __cloc)); - _M_day_a6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_6, __cloc)); - _M_day_a7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_7, __cloc)); + _M_data->_M_aday1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_1, __cloc)); + _M_data->_M_aday2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_2, __cloc)); + _M_data->_M_aday3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_3, __cloc)); + _M_data->_M_aday4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_4, __cloc)); + _M_data->_M_aday5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_5, __cloc)); + _M_data->_M_aday6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_6, __cloc)); + _M_data->_M_aday7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_7, __cloc)); // Month names, starting with "C"'s January. - _M_month01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_1, __cloc)); - _M_month02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_2, __cloc)); - _M_month03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_3, __cloc)); - _M_month04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_4, __cloc)); - _M_month05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_5, __cloc)); - _M_month06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_6, __cloc)); - _M_month07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_7, __cloc)); - _M_month08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_8, __cloc)); - _M_month09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_9, __cloc)); - _M_month10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_10, __cloc)); - _M_month11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_11, __cloc)); - _M_month12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_12, __cloc)); + _M_data->_M_month01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_1, __cloc)); + _M_data->_M_month02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_2, __cloc)); + _M_data->_M_month03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_3, __cloc)); + _M_data->_M_month04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_4, __cloc)); + _M_data->_M_month05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_5, __cloc)); + _M_data->_M_month06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_6, __cloc)); + _M_data->_M_month07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_7, __cloc)); + _M_data->_M_month08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_8, __cloc)); + _M_data->_M_month09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_9, __cloc)); + _M_data->_M_month10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_10, __cloc)); + _M_data->_M_month11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_11, __cloc)); + _M_data->_M_month12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_12, __cloc)); // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_1, __cloc)); - _M_month_a02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_2, __cloc)); - _M_month_a03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_3, __cloc)); - _M_month_a04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_4, __cloc)); - _M_month_a05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_5, __cloc)); - _M_month_a06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_6, __cloc)); - _M_month_a07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_7, __cloc)); - _M_month_a08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_8, __cloc)); - _M_month_a09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_9, __cloc)); - _M_month_a10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_10, __cloc)); - _M_month_a11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_11, __cloc)); - _M_month_a12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_12, __cloc)); + _M_data->_M_amonth01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_1, __cloc)); + _M_data->_M_amonth02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_2, __cloc)); + _M_data->_M_amonth03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_3, __cloc)); + _M_data->_M_amonth04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_4, __cloc)); + _M_data->_M_amonth05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_5, __cloc)); + _M_data->_M_amonth06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_6, __cloc)); + _M_data->_M_amonth07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_7, __cloc)); + _M_data->_M_amonth08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_8, __cloc)); + _M_data->_M_amonth09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_9, __cloc)); + _M_data->_M_amonth10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_10, __cloc)); + _M_data->_M_amonth11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_11, __cloc)); + _M_data->_M_amonth12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_12, __cloc)); } } #endif diff --git a/libstdc++-v3/config/locale/gnu/time_members.h b/libstdc++-v3/config/locale/gnu/time_members.h index 8ef7a07107c..6badaacbfa0 100644 --- a/libstdc++-v3/config/locale/gnu/time_members.h +++ b/libstdc++-v3/config/locale/gnu/time_members.h @@ -36,7 +36,17 @@ template<typename _CharT> __timepunct<_CharT>::__timepunct(size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) + { +#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) + _M_name_timepunct = _S_c_name; +#endif + _M_initialize_timepunct(); + } + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) _M_name_timepunct = _S_c_name; @@ -48,7 +58,7 @@ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s __attribute__ ((__unused__)), size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) _M_name_timepunct = new char[strlen(__s) + 1]; @@ -64,5 +74,6 @@ if (_S_c_name != _M_name_timepunct) delete [] _M_name_timepunct; #endif + delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 7bea5eac509..39a6a246356 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -225,7 +225,7 @@ namespace std protected: explicit - __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { } + __ctype_abstract_base(size_t __refs = 0): facet(__refs) { } virtual ~__ctype_abstract_base() { } @@ -602,7 +602,7 @@ namespace std bool _M_allocated; - __numpunct_cache(size_t __refs = 0) : locale::facet(__refs), + __numpunct_cache(size_t __refs = 0) : facet(__refs), _M_grouping(NULL), _M_use_grouping(false), _M_truename(NULL), _M_falsename(NULL), _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()), _M_allocated(false) @@ -692,7 +692,7 @@ namespace std explicit numpunct(__c_locale __cloc, size_t __refs = 0) - : locale::facet(__refs), _M_data(NULL) + : facet(__refs), _M_data(NULL) { _M_initialize_numpunct(__cloc); } char_type @@ -798,7 +798,7 @@ namespace std static locale::id id; explicit - num_get(size_t __refs = 0) : locale::facet(__refs) { } + num_get(size_t __refs = 0) : facet(__refs) { } iter_type get(iter_type __in, iter_type __end, ios_base& __io, @@ -944,7 +944,7 @@ namespace std static locale::id id; explicit - num_put(size_t __refs = 0) : locale::facet(__refs) { } + num_put(size_t __refs = 0) : facet(__refs) { } iter_type put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const @@ -1061,12 +1061,12 @@ namespace std explicit collate(size_t __refs = 0) - : locale::facet(__refs) + : facet(__refs) { _M_c_locale_collate = _S_c_locale; } explicit collate(__c_locale __cloc, size_t __refs = 0) - : locale::facet(__refs) + : facet(__refs) { _M_c_locale_collate = _S_clone_c_locale(__cloc); } int @@ -1155,21 +1155,11 @@ namespace std }; template<typename _CharT> - class __timepunct : public locale::facet + struct __timepunct_cache : public locale::facet { - public: - // Types: - typedef _CharT __char_type; - typedef basic_string<_CharT> __string_type; - - static locale::id id; - // List of all known timezones, with GMT first. static const _CharT* _S_timezones[14]; - protected: - __c_locale _M_c_locale_timepunct; - char* _M_name_timepunct; const _CharT* _M_date_format; const _CharT* _M_date_era_format; const _CharT* _M_time_format; @@ -1190,13 +1180,13 @@ namespace std const _CharT* _M_day7; // Abbreviated day names, starting with "C"'s Sun. - const _CharT* _M_day_a1; - const _CharT* _M_day_a2; - const _CharT* _M_day_a3; - const _CharT* _M_day_a4; - const _CharT* _M_day_a5; - const _CharT* _M_day_a6; - const _CharT* _M_day_a7; + const _CharT* _M_aday1; + const _CharT* _M_aday2; + const _CharT* _M_aday3; + const _CharT* _M_aday4; + const _CharT* _M_aday5; + const _CharT* _M_aday6; + const _CharT* _M_aday7; // Month names, starting with "C"'s January. const _CharT* _M_month01; @@ -1213,24 +1203,92 @@ namespace std const _CharT* _M_month12; // Abbreviated month names, starting with "C"'s Jan. - const _CharT* _M_month_a01; - const _CharT* _M_month_a02; - const _CharT* _M_month_a03; - const _CharT* _M_month_a04; - const _CharT* _M_month_a05; - const _CharT* _M_month_a06; - const _CharT* _M_month_a07; - const _CharT* _M_month_a08; - const _CharT* _M_month_a09; - const _CharT* _M_month_a10; - const _CharT* _M_month_a11; - const _CharT* _M_month_a12; + const _CharT* _M_amonth01; + const _CharT* _M_amonth02; + const _CharT* _M_amonth03; + const _CharT* _M_amonth04; + const _CharT* _M_amonth05; + const _CharT* _M_amonth06; + const _CharT* _M_amonth07; + const _CharT* _M_amonth08; + const _CharT* _M_amonth09; + const _CharT* _M_amonth10; + const _CharT* _M_amonth11; + const _CharT* _M_amonth12; + + bool _M_allocated; + + __timepunct_cache(size_t __refs = 0) : facet(__refs), + _M_date_format(NULL), _M_date_era_format(NULL), _M_time_format(NULL), + _M_time_era_format(NULL), _M_date_time_format(NULL), + _M_date_time_era_format(NULL), _M_am(NULL), _M_pm(NULL), + _M_am_pm_format(NULL), _M_day1(NULL), _M_day2(NULL), _M_day3(NULL), + _M_day4(NULL), _M_day5(NULL), _M_day6(NULL), _M_day7(NULL), + _M_aday1(NULL), _M_aday2(NULL), _M_aday3(NULL), _M_aday4(NULL), + _M_aday5(NULL), _M_aday6(NULL), _M_aday7(NULL), _M_month01(NULL), + _M_month02(NULL), _M_month03(NULL), _M_month04(NULL), _M_month05(NULL), + _M_month06(NULL), _M_month07(NULL), _M_month08(NULL), _M_month09(NULL), + _M_month10(NULL), _M_month11(NULL), _M_month12(NULL), _M_amonth01(NULL), + _M_amonth02(NULL), _M_amonth03(NULL), _M_amonth04(NULL), + _M_amonth05(NULL), _M_amonth06(NULL), _M_amonth07(NULL), + _M_amonth08(NULL), _M_amonth09(NULL), _M_amonth10(NULL), + _M_amonth11(NULL), _M_amonth12(NULL), _M_allocated(false) + { } + + ~__timepunct_cache(); + + void + _M_cache(const locale& __loc); + }; + + template<typename _CharT> + __timepunct_cache<_CharT>::~__timepunct_cache() + { + if (_M_allocated) + { + // XXX. + } + } + + // Specializations. + template<> + const char* + __timepunct_cache<char>::_S_timezones[14]; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + const wchar_t* + __timepunct_cache<wchar_t>::_S_timezones[14]; +#endif + + // Generic. + template<typename _CharT> + const _CharT* __timepunct_cache<_CharT>::_S_timezones[14]; + + template<typename _CharT> + class __timepunct : public locale::facet + { + public: + // Types: + typedef _CharT __char_type; + typedef basic_string<_CharT> __string_type; + typedef __timepunct_cache<_CharT> __cache_type; + + protected: + __cache_type* _M_data; + __c_locale _M_c_locale_timepunct; + char* _M_name_timepunct; public: + static locale::id id; + explicit __timepunct(size_t __refs = 0); explicit + __timepunct(__cache_type* __cache, size_t __refs = 0); + + explicit __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0); void @@ -1241,89 +1299,89 @@ namespace std _M_date_formats(const _CharT** __date) const { // Always have default first. - __date[0] = _M_date_format; - __date[1] = _M_date_era_format; + __date[0] = _M_data->_M_date_format; + __date[1] = _M_data->_M_date_era_format; } void _M_time_formats(const _CharT** __time) const { // Always have default first. - __time[0] = _M_time_format; - __time[1] = _M_time_era_format; + __time[0] = _M_data->_M_time_format; + __time[1] = _M_data->_M_time_era_format; } void _M_ampm(const _CharT** __ampm) const { - __ampm[0] = _M_am; - __ampm[1] = _M_pm; + __ampm[0] = _M_data->_M_am; + __ampm[1] = _M_data->_M_pm; } void _M_date_time_formats(const _CharT** __dt) const { // Always have default first. - __dt[0] = _M_date_time_format; - __dt[1] = _M_date_time_era_format; + __dt[0] = _M_data->_M_date_time_format; + __dt[1] = _M_data->_M_date_time_era_format; } void _M_days(const _CharT** __days) const { - __days[0] = _M_day1; - __days[1] = _M_day2; - __days[2] = _M_day3; - __days[3] = _M_day4; - __days[4] = _M_day5; - __days[5] = _M_day6; - __days[6] = _M_day7; + __days[0] = _M_data->_M_day1; + __days[1] = _M_data->_M_day2; + __days[2] = _M_data->_M_day3; + __days[3] = _M_data->_M_day4; + __days[4] = _M_data->_M_day5; + __days[5] = _M_data->_M_day6; + __days[6] = _M_data->_M_day7; } void _M_days_abbreviated(const _CharT** __days) const { - __days[0] = _M_day_a1; - __days[1] = _M_day_a2; - __days[2] = _M_day_a3; - __days[3] = _M_day_a4; - __days[4] = _M_day_a5; - __days[5] = _M_day_a6; - __days[6] = _M_day_a7; + __days[0] = _M_data->_M_aday1; + __days[1] = _M_data->_M_aday2; + __days[2] = _M_data->_M_aday3; + __days[3] = _M_data->_M_aday4; + __days[4] = _M_data->_M_aday5; + __days[5] = _M_data->_M_aday6; + __days[6] = _M_data->_M_aday7; } void _M_months(const _CharT** __months) const { - __months[0] = _M_month01; - __months[1] = _M_month02; - __months[2] = _M_month03; - __months[3] = _M_month04; - __months[4] = _M_month05; - __months[5] = _M_month06; - __months[6] = _M_month07; - __months[7] = _M_month08; - __months[8] = _M_month09; - __months[9] = _M_month10; - __months[10] = _M_month11; - __months[11] = _M_month12; + __months[0] = _M_data->_M_month01; + __months[1] = _M_data->_M_month02; + __months[2] = _M_data->_M_month03; + __months[3] = _M_data->_M_month04; + __months[4] = _M_data->_M_month05; + __months[5] = _M_data->_M_month06; + __months[6] = _M_data->_M_month07; + __months[7] = _M_data->_M_month08; + __months[8] = _M_data->_M_month09; + __months[9] = _M_data->_M_month10; + __months[10] = _M_data->_M_month11; + __months[11] = _M_data->_M_month12; } void _M_months_abbreviated(const _CharT** __months) const { - __months[0] = _M_month_a01; - __months[1] = _M_month_a02; - __months[2] = _M_month_a03; - __months[3] = _M_month_a04; - __months[4] = _M_month_a05; - __months[5] = _M_month_a06; - __months[6] = _M_month_a07; - __months[7] = _M_month_a08; - __months[8] = _M_month_a09; - __months[9] = _M_month_a10; - __months[10] = _M_month_a11; - __months[11] = _M_month_a12; + __months[0] = _M_data->_M_amonth01; + __months[1] = _M_data->_M_amonth02; + __months[2] = _M_data->_M_amonth03; + __months[3] = _M_data->_M_amonth04; + __months[4] = _M_data->_M_amonth05; + __months[5] = _M_data->_M_amonth06; + __months[6] = _M_data->_M_amonth07; + __months[7] = _M_data->_M_amonth08; + __months[8] = _M_data->_M_amonth09; + __months[9] = _M_data->_M_amonth10; + __months[10] = _M_data->_M_amonth11; + __months[11] = _M_data->_M_amonth12; } protected: @@ -1340,10 +1398,6 @@ namespace std // Specializations. template<> - const char* - __timepunct<char>::_S_timezones[14]; - - template<> void __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc); @@ -1353,10 +1407,6 @@ namespace std #ifdef _GLIBCXX_USE_WCHAR_T template<> - const wchar_t* - __timepunct<wchar_t>::_S_timezones[14]; - - template<> void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc); @@ -1366,10 +1416,6 @@ namespace std const tm*) const; #endif - // Generic. - template<typename _CharT> - const _CharT* __timepunct<_CharT>::_S_timezones[14]; - // Include host and configuration specific timepunct functions. #include <bits/time_members.h> @@ -1386,7 +1432,7 @@ namespace std explicit time_get(size_t __refs = 0) - : locale::facet (__refs) { } + : facet (__refs) { } dateorder date_order() const @@ -1497,7 +1543,7 @@ namespace std explicit time_put(size_t __refs = 0) - : locale::facet(__refs) { } + : facet(__refs) { } iter_type put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, @@ -1554,36 +1600,73 @@ namespace std _S_construct_pattern(char __precedes, char __space, char __posn); }; + template<typename _CharT> + struct __moneypunct_cache : public locale::facet + { + const char* _M_grouping; + bool _M_use_grouping; + _CharT _M_decimal_point; + _CharT _M_thousands_sep; + const _CharT* _M_curr_symbol; + const _CharT* _M_positive_sign; + const _CharT* _M_negative_sign; + int _M_frac_digits; + money_base::pattern _M_pos_format; + money_base::pattern _M_neg_format; + + 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_pos_format(money_base::pattern()), + _M_neg_format(money_base::pattern()), _M_allocated(false) + { } + + ~__moneypunct_cache(); + + void + _M_cache(const locale& __loc); + }; + + template<typename _CharT> + __moneypunct_cache<_CharT>::~__moneypunct_cache() + { + if (_M_allocated) + { + // XXX. + } + } + template<typename _CharT, bool _Intl> class moneypunct : public locale::facet, public money_base { public: // Types: - typedef _CharT char_type; + typedef _CharT char_type; typedef basic_string<_CharT> string_type; + typedef __moneypunct_cache<_CharT> __cache_type; + + private: + __cache_type* _M_data; + public: static const bool intl = _Intl; static locale::id id; - private: - const char* _M_grouping; - char_type _M_decimal_point; - char_type _M_thousands_sep; - const char_type* _M_curr_symbol; - const char_type* _M_positive_sign; - const char_type* _M_negative_sign; - int _M_frac_digits; - pattern _M_pos_format; - pattern _M_neg_format; + explicit + moneypunct(size_t __refs = 0) : facet(__refs), _M_data(NULL) + { _M_initialize_moneypunct(); } - public: explicit - moneypunct(size_t __refs = 0) : locale::facet(__refs) + moneypunct(__cache_type* __cache, size_t __refs = 0) + : facet(__refs), _M_data(__cache) { _M_initialize_moneypunct(); } explicit moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) { _M_initialize_moneypunct(__cloc, __s); } char_type @@ -1628,39 +1711,39 @@ namespace std virtual char_type do_decimal_point() const - { return _M_decimal_point; } + { return _M_data->_M_decimal_point; } virtual char_type do_thousands_sep() const - { return _M_thousands_sep; } + { return _M_data->_M_thousands_sep; } virtual string do_grouping() const - { return _M_grouping; } + { return _M_data->_M_grouping; } virtual string_type do_curr_symbol() const - { return _M_curr_symbol; } + { return _M_data->_M_curr_symbol; } virtual string_type do_positive_sign() const - { return _M_positive_sign; } + { return _M_data->_M_positive_sign; } virtual string_type do_negative_sign() const - { return _M_negative_sign; } + { return _M_data->_M_negative_sign; } virtual int do_frac_digits() const - { return _M_frac_digits; } + { return _M_data->_M_frac_digits; } virtual pattern do_pos_format() const - { return _M_pos_format; } + { return _M_data->_M_pos_format; } virtual pattern do_neg_format() const - { return _M_neg_format; } + { return _M_data->_M_neg_format; } // For use at construction time only. void @@ -1746,7 +1829,7 @@ namespace std static locale::id id; explicit - money_get(size_t __refs = 0) : locale::facet(__refs) { } + money_get(size_t __refs = 0) : facet(__refs) { } iter_type get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, @@ -1785,7 +1868,7 @@ namespace std static locale::id id; explicit - money_put(size_t __refs = 0) : locale::facet(__refs) { } + money_put(size_t __refs = 0) : facet(__refs) { } iter_type put(iter_type __s, bool __intl, ios_base& __io, diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index f724ea27eac..46ee3a425ea 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -1701,7 +1701,7 @@ namespace std { int __tmp; _M_extract_name(__beg, __end, __tmp, - __timepunct<_CharT>::_S_timezones, + __timepunct_cache<_CharT>::_S_timezones, 14, __err); // GMT requires special effort. diff --git a/libstdc++-v3/src/globals.cc b/libstdc++-v3/src/globals.cc index 5cfa621086e..e9e5814f6b5 100644 --- a/libstdc++-v3/src/globals.cc +++ b/libstdc++-v3/src/globals.cc @@ -157,8 +157,8 @@ namespace __gnu_cxx typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)] __attribute__ ((aligned(__alignof__(moneypunct<char, true>)))); - fake_moneypunct_c moneypunct_tc; - fake_moneypunct_c moneypunct_fc; + fake_moneypunct_c moneypunct_ct; + fake_moneypunct_c moneypunct_cf; typedef char fake_money_get_c[sizeof(money_get<char>)] __attribute__ ((aligned(__alignof__(money_get<char>)))); @@ -211,8 +211,8 @@ namespace __gnu_cxx typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)] __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>)))); - fake_moneypunct_w moneypunct_tw; - fake_moneypunct_w moneypunct_fw; + fake_moneypunct_w moneypunct_wt; + fake_moneypunct_w moneypunct_wf; typedef char fake_money_get_w[sizeof(money_get<wchar_t>)] __attribute__ ((aligned(__alignof__(money_get<wchar_t>)))); @@ -239,15 +239,33 @@ namespace __gnu_cxx fake_messages_w messages_w; #endif - // Storage for C locale caches - typedef char fake_locale_cache_c[sizeof(std::__numpunct_cache<char>)] + // Storage for "C" locale caches. + typedef char fake_num_cache_c[sizeof(std::__numpunct_cache<char>)] __attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>)))); - fake_locale_cache_c numpunct_cache_c; + 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>)))); + fake_money_cache_c moneypunct_cache_ct; + fake_money_cache_c moneypunct_cache_cf; + + typedef char fake_time_cache_c[sizeof(std::__timepunct_cache<char>)] + __attribute__ ((aligned(__alignof__(std::__timepunct_cache<char>)))); + fake_time_cache_c timepunct_cache_c; #ifdef _GLIBCXX_USE_WCHAR_T - typedef char fake_locale_cache_w[sizeof(std::__numpunct_cache<wchar_t>)] + typedef char fake_num_cache_w[sizeof(std::__numpunct_cache<wchar_t>)] __attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>)))); - fake_locale_cache_w numpunct_cache_w; + 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>)))); + fake_money_cache_w moneypunct_cache_wt; + fake_money_cache_w moneypunct_cache_wf; + + typedef char fake_time_cache_w[sizeof(std::__timepunct_cache<wchar_t>)] + __attribute__ ((aligned(__alignof__(std::__timepunct_cache<wchar_t>)))); + fake_time_cache_w timepunct_cache_w; #endif // Globals for once-only runtime initialization of mutex objects. This diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc index b7c4694796e..2a12a932206 100644 --- a/libstdc++-v3/src/locale-inst.cc +++ b/libstdc++-v3/src/locale-inst.cc @@ -41,6 +41,7 @@ namespace std // moneypunct, money_get, and money_put template class moneypunct<char, false>; template class moneypunct<char, true>; + template struct __moneypunct_cache<char>; template class moneypunct_byname<char, false>; template class moneypunct_byname<char, true>; template class money_get<char, istreambuf_iterator<char> >; @@ -49,6 +50,7 @@ namespace std #ifdef _GLIBCXX_USE_WCHAR_T template class moneypunct<wchar_t, false>; template class moneypunct<wchar_t, true>; + template struct __moneypunct_cache<wchar_t>; template class moneypunct_byname<wchar_t, false>; template class moneypunct_byname<wchar_t, true>; template class money_get<wchar_t, istreambuf_iterator<wchar_t> >; @@ -147,6 +149,7 @@ namespace std // time_get and time_put template class __timepunct<char>; + template struct __timepunct_cache<char>; template class time_put<char, ostreambuf_iterator<char> >; template class time_put_byname<char, ostreambuf_iterator<char> >; template class time_get<char, istreambuf_iterator<char> >; @@ -154,6 +157,7 @@ namespace std #ifdef _GLIBCXX_USE_WCHAR_T template class __timepunct<wchar_t>; + template struct __timepunct_cache<wchar_t>; template class time_put<wchar_t, ostreambuf_iterator<wchar_t> >; template class time_put_byname<wchar_t, ostreambuf_iterator<wchar_t> >; template class time_get<wchar_t, istreambuf_iterator<wchar_t> >; diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index f9244bd9333..d1de4db6c1a 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -455,7 +455,7 @@ namespace std // Definitions for static const data members of time_base. template<> const char* - __timepunct<char>::_S_timezones[14] = + __timepunct_cache<char>::_S_timezones[14] = { "GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET", "IST", "EET", "CST", "JST" @@ -464,7 +464,7 @@ namespace std #ifdef _GLIBCXX_USE_WCHAR_T template<> const wchar_t* - __timepunct<wchar_t>::_S_timezones[14] = + __timepunct_cache<wchar_t>::_S_timezones[14] = { L"GMT", L"HST", L"AKST", L"PST", L"MST", L"CST", L"EST", L"AST", L"NST", L"CET", L"IST", L"EET", L"CST", L"JST" diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index 0a2ef129f4e..d428290b438 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -43,10 +43,10 @@ namespace __gnu_cxx extern std::collate<char> collate_c; extern numpunct<char> numpunct_c; extern num_get<char> num_get_c; - extern num_put<char> num_put_c; - extern codecvt<char, char, mbstate_t> codecvt_c; - extern moneypunct<char, false> moneypunct_fc; - extern moneypunct<char, true> moneypunct_tc; + extern num_put<char> num_put_c; +extern codecvt<char, char, mbstate_t> codecvt_c; + extern moneypunct<char, false> moneypunct_cf; + extern moneypunct<char, true> moneypunct_ct; extern money_get<char> money_get_c; extern money_put<char> money_put_c; extern __timepunct<char> timepunct_c; @@ -60,8 +60,8 @@ namespace __gnu_cxx extern num_get<wchar_t> num_get_w; extern num_put<wchar_t> num_put_w; extern codecvt<wchar_t, char, mbstate_t> codecvt_w; - extern moneypunct<wchar_t, false> moneypunct_fw; - extern moneypunct<wchar_t, true> moneypunct_tw; + extern moneypunct<wchar_t, false> moneypunct_wf; + extern moneypunct<wchar_t, true> moneypunct_wt; extern money_get<wchar_t> money_get_w; extern money_put<wchar_t> money_put_w; extern __timepunct<wchar_t> timepunct_w; @@ -70,10 +70,17 @@ namespace __gnu_cxx extern std::messages<wchar_t> messages_w; #endif + // And the caches.... extern locale::facet* cache_vec[_GLIBCXX_NUM_FACETS]; - extern std::__numpunct_cache<char> numpunct_cache_c; + extern __numpunct_cache<char> numpunct_cache_c; + extern __moneypunct_cache<char> moneypunct_cache_cf; + extern __moneypunct_cache<char> moneypunct_cache_ct; + extern __timepunct_cache<char> timepunct_cache_c; #ifdef _GLIBCXX_USE_WCHAR_T - extern std::__numpunct_cache<wchar_t> numpunct_cache_w; + extern __numpunct_cache<wchar_t> numpunct_cache_w; + extern __moneypunct_cache<wchar_t> moneypunct_cache_wf; + extern __moneypunct_cache<wchar_t> moneypunct_cache_wt; + extern __timepunct_cache<wchar_t> timepunct_cache_w; #endif } // namespace __gnu_cxx @@ -296,7 +303,6 @@ namespace std _M_init_facet(new (&ctype_c) std::ctype<char>(0, false, 1)); _M_init_facet(new (&codecvt_c) codecvt<char, char, mbstate_t>(1)); - // Safe to cache this. typedef __numpunct_cache<char> num_cache_c; num_cache_c* __npc = new (&numpunct_cache_c) num_cache_c(2); _M_init_facet(new (&numpunct_c) numpunct<char>(__npc, 1)); @@ -304,11 +310,20 @@ namespace std _M_init_facet(new (&num_get_c) num_get<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 (&moneypunct_fc) moneypunct<char, false>(1)); - _M_init_facet(new (&moneypunct_tc) moneypunct<char, true>(1)); + + typedef __moneypunct_cache<char> money_cache_c; + money_cache_c* __mpcf = new (&moneypunct_cache_cf) money_cache_c(2); + _M_init_facet(new (&moneypunct_cf) moneypunct<char, false>(__mpcf, 1)); + money_cache_c* __mpct = new (&moneypunct_cache_ct) money_cache_c(2); + _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_put_c) money_put<char>(1)); - _M_init_facet(new (&timepunct_c) __timepunct<char>(1)); + + typedef __timepunct_cache<char> time_cache_c; + time_cache_c* __tpc = new (&timepunct_cache_c) time_cache_c(2); + _M_init_facet(new (&timepunct_c) __timepunct<char>(__tpc, 1)); + _M_init_facet(new (&time_get_c) time_get<char>(1)); _M_init_facet(new (&time_put_c) time_put<char>(1)); _M_init_facet(new (&messages_c) std::messages<char>(1)); @@ -324,21 +339,36 @@ namespace std _M_init_facet(new (&num_get_w) num_get<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 (&moneypunct_fw) moneypunct<wchar_t, false>(1)); - _M_init_facet(new (&moneypunct_tw) moneypunct<wchar_t, true>(1)); + + typedef __moneypunct_cache<wchar_t> money_cache_w; + money_cache_w* __mpwf = new (&moneypunct_cache_wf) money_cache_w(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); + _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_put_w) money_put<wchar_t>(1)); - _M_init_facet(new (&timepunct_w) __timepunct<wchar_t>(1)); + + typedef __timepunct_cache<wchar_t> time_cache_w; + time_cache_w* __tpw = new (&timepunct_cache_w) time_cache_w(2); + _M_init_facet(new (&timepunct_w) __timepunct<wchar_t>(__tpw, 1)); + _M_init_facet(new (&time_get_w) time_get<wchar_t>(1)); _M_init_facet(new (&time_put_w) time_put<wchar_t>(1)); _M_init_facet(new (&messages_w) std::messages<wchar_t>(1)); #endif // This locale is safe to pre-cache, after all the facets have - // been installed. + // been created and installed. _M_caches[numpunct<char>::id._M_id()] = __npc; + _M_caches[moneypunct<char, false>::id._M_id()] = __mpcf; + _M_caches[moneypunct<char, true>::id._M_id()] = __mpct; + _M_caches[__timepunct<char>::id._M_id()] = __tpc; #ifdef _GLIBCXX_USE_WCHAR_T _M_caches[numpunct<wchar_t>::id._M_id()] = __npw; + _M_caches[moneypunct<wchar_t, false>::id._M_id()] = __mpwf; + _M_caches[moneypunct<wchar_t, true>::id._M_id()] = __mpwt; + _M_caches[__timepunct<wchar_t>::id._M_id()] = __tpw; #endif } |