diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-02 18:44:50 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-02 18:44:50 +0000 |
commit | 3bd33b8a3d165f63491c54155c89425202fb8703 (patch) | |
tree | 25ea33498c6963bfed74e7c354dd1d81f141af42 /libstdc++-v3/config | |
parent | 7417ed8d4ef89ab7b9c8ac9f014bf27783690140 (diff) |
2001-10-02 Benjamin Kosnik <bkoz@redhat.com>
* config/locale/time_members_gnu.h: Remove.
* config/locale/time_members_generic.h: Remove.
* config/locale/time_members_gnu.cc (__timepunct::_M_put_helper): Add.
* config/locale/time_members_generic.cc: Same.
* include/bits/locale_facets.h: Add data members.
(__timepunct::_M_put_helper): Change signature.
(__timepunct::_M_date_formats): Same.
(__timepunct::_M_time_formats): Same.
(__timepunct::_M_ampm): Add.
(__timepunct::_M_date_time_formats): Add.
(time_get::_M_extract_via_format): Add.
(time_get::_M_extract_time): Change to...
(time_get::_M_extract_num): ... this, modify signature.
* include/bits/locale_facets.tcc (time_get::do_get_year): Fix.
(time_get::do_get_time): Fix.
(time_get::do_get_date): Fix.
* acinclude.m4: Remove CTIME_H.
* aclocal.m4: Regenerate.
* include/Makefile.am: Same.
* include/Makefile.in: Regenerate.
* configure: Regenerate.
* testsuite/22_locale/time_get_members_char.cc: Fix.
* testsuite/22_locale/time_get_members_wchar_t.cc: Add.
* testsuite/22_locale/time_put_members_wchar_t.cc: Add.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45966 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/config')
-rw-r--r-- | libstdc++-v3/config/locale/time_members_generic.cc | 82 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/time_members_generic.h | 54 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/time_members_gnu.cc | 160 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/time_members_gnu.h | 70 |
4 files changed, 237 insertions, 129 deletions
diff --git a/libstdc++-v3/config/locale/time_members_generic.cc b/libstdc++-v3/config/locale/time_members_generic.cc index d1c10511ce5..16788d40f3d 100644 --- a/libstdc++-v3/config/locale/time_members_generic.cc +++ b/libstdc++-v3/config/locale/time_members_generic.cc @@ -38,6 +38,16 @@ namespace std { + template<> + void + __timepunct<char>:: + _M_put_helper(char* __s, size_t __maxlen, const char* __format, + const tm* __tm) const + { + setlocale(LC_ALL, _M_name_timepunct); + strftime(__s, __maxlen, __format, __tm); + } + template<> void __timepunct<char>::_M_initialize_timepunct(__c_locale) @@ -47,8 +57,11 @@ namespace std _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 = ""; // Day names, starting with "C"'s Sunday. _M_day1 = "Sunday"; @@ -98,9 +111,76 @@ namespace std } #ifdef _GLIBCPP_USE_WCHAR_T + template<> + void + __timepunct<wchar_t>:: + _M_put_helper(wchar_t* __s, size_t __maxlen, const wchar_t* __format, + const tm* __tm) const + { + setlocale(LC_ALL, _M_name_timepunct); + wcsftime(__s, __maxlen, __format, __tm); + } + template<> 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""; + + // 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"; + + // 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"; + + // 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"; + + // 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"; + } #endif } diff --git a/libstdc++-v3/config/locale/time_members_generic.h b/libstdc++-v3/config/locale/time_members_generic.h deleted file mode 100644 index 88b8208feab..00000000000 --- a/libstdc++-v3/config/locale/time_members_generic.h +++ /dev/null @@ -1,54 +0,0 @@ -// std::time_get, std::time_put implementation, generic version -*- C++ -*- - -// Copyright (C) 2001 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 -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions -// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions -// - -// Written by Benjamin Kosnik <bkoz@redhat.com> - - template<typename _CharT> - void - __timepunct<_CharT>:: - _M_put_helper(char* __s, size_t __maxlen, const char* __format, - const tm* __tm) const - { - setlocale(LC_ALL, _M_name_timepunct); - strftime(__s, __maxlen, __format, __tm); - } - - template<typename _CharT> - void - __timepunct<_CharT>:: - _M_get_helper(const char*, const char*, tm*) const - { - setlocale(LC_ALL, _M_name_timepunct); - // strptime(__s, __format, __tm); - } diff --git a/libstdc++-v3/config/locale/time_members_gnu.cc b/libstdc++-v3/config/locale/time_members_gnu.cc index 4f4789a3cad..74d89992095 100644 --- a/libstdc++-v3/config/locale/time_members_gnu.cc +++ b/libstdc++-v3/config/locale/time_members_gnu.cc @@ -38,6 +38,24 @@ namespace std { + template<> + void + __timepunct<char>:: + _M_put_helper(char* __s, size_t __maxlen, const char* __format, + const tm* __tm) const + { +#if 0 + // Requires glibc 2.3 + if (_M_c_locale_timepunct) + __strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); + else + strftime(__s, __maxlen, __format, __tm); +#else + setlocale(LC_ALL, _M_name_timepunct); + strftime(__s, __maxlen, __format, __tm); +#endif + } + template<> void __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc) @@ -45,13 +63,16 @@ namespace std if (!__cloc) { // "C" locale - _M_date_format = "%m/%d/%Y"; - _M_date_era_format = "%m/%d/%Y"; + _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 = ""; + // Day names, starting with "C"'s Sunday. _M_day1 = "Sunday"; _M_day2 = "Monday"; @@ -106,8 +127,11 @@ namespace std _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); // Day names, starting with "C"'s Sunday. _M_day1 = __nl_langinfo_l(DAY_1, __cloc); @@ -158,6 +182,24 @@ namespace std } #ifdef _GLIBCPP_USE_WCHAR_T + template<> + void + __timepunct<wchar_t>:: + _M_put_helper(wchar_t* __s, size_t __maxlen, const wchar_t* __format, + const tm* __tm) const + { +#if 0 + // Requires glibc 2.3 + if (_M_c_locale_timepunct) + __wcsftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); + else + wcsftime(__s, __maxlen, __format, __tm); +#else + setlocale(LC_ALL, _M_name_timepunct); + wcsftime(__s, __maxlen, __format, __tm); +#endif + } + template<> void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc) @@ -165,12 +207,122 @@ namespace std if (!__cloc) { // "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""; + + // 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"; + + // 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"; + + // 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"; + + // 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"; } 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)); + + // 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)); + + // 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)); + + // 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)); + + // 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)); } } #endif } - diff --git a/libstdc++-v3/config/locale/time_members_gnu.h b/libstdc++-v3/config/locale/time_members_gnu.h deleted file mode 100644 index 16c9ff39d18..00000000000 --- a/libstdc++-v3/config/locale/time_members_gnu.h +++ /dev/null @@ -1,70 +0,0 @@ -// std::time_get, std::time_put implementation, GNU version -*- C++ -*- - -// Copyright (C) 2001 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 -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions -// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions -// - -// Written by Benjamin Kosnik <bkoz@redhat.com> - - template<typename _CharT> - void - __timepunct<_CharT>:: - _M_put_helper(char* __s, size_t __maxlen, const char* __format, - const tm* __tm) const - { -#if 0 - // Requires glibc 2.3 - if (_M_c_locale_timepunct) - __strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); - else - strftime(__s, __maxlen, __format, __tm); -#else - setlocale(LC_ALL, _M_name_timepunct); - strftime(__s, __maxlen, __format, __tm); -#endif - } - - template<typename _CharT> - void - __timepunct<_CharT>:: - _M_get_helper(const char* __s, const char* __format, tm* __tm) const - { -#if 0 - // Requires glibc 2.3 - if (_M_c_locale_timepunct) - __strptime_l(__s, _M_c_locale_timepunct, __format, __tm); - else - strptime(__s, __format, __tm); -#else - setlocale(LC_ALL, _M_name_timepunct); - strptime(__s, __format, __tm); -#endif - } |