diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-28 23:44:48 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-28 23:44:48 +0000 |
commit | ba6690e379a82d6ff3829f201a3f9dea833d6052 (patch) | |
tree | 684e546d2b29fa36fbd78496cc7dfc2128b47c0c /libstdc++-v3/config | |
parent | f9fb3b68bc19520741acbdb2fa69188b6f4afee3 (diff) |
2001-09-28 Benjamin Kosnik <bkoz@redhat.com>
* config/locale/time_members_gnu.h (__timepunct::_M_get_helper): Add.
(__timepunct::_M_put_helper): Add.
* config/locale/time_members_generic.h: Same.
* include/bits/locale_facets.h (__match_parallel): Remove. Format.
(__timepunct): Add data members.
(__timepunct::_M_days): Add.
(__timepunct::_M_days_abbreviated): Add.
(__timepunct::_M_months): Add.
(__timepunct::_M_months_abbreviated): Add.
(__timepunct::_M_initialize_timepunct): Add.
* include/bits/locale_facets.tcc: Same.
* src/locale-inst.cc: Remove instantiations for __match_parallel.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): Add CTIME_CC.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/22_locale/time_put_members_char.cc: Mark XFAIL.
* testsuite/22_locale/time_put_members_char.cc (test01): New file.
* testsuite/22_locale/time_get.cc: New file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45868 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/config')
-rw-r--r-- | libstdc++-v3/config/locale/time_members_generic.cc | 106 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/time_members_generic.h | 15 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/time_members_gnu.cc | 176 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/time_members_gnu.h | 23 |
4 files changed, 314 insertions, 6 deletions
diff --git a/libstdc++-v3/config/locale/time_members_generic.cc b/libstdc++-v3/config/locale/time_members_generic.cc new file mode 100644 index 00000000000..d1c10511ce5 --- /dev/null +++ b/libstdc++-v3/config/locale/time_members_generic.cc @@ -0,0 +1,106 @@ +// 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> + +#include <locale> + +namespace std +{ + template<> + 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_am = "AM"; + _M_pm = "PM"; + + // 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"; + + // 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"; + + // 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"; + + // 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"; + } + +#ifdef _GLIBCPP_USE_WCHAR_T + template<> + void + __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale) + { } +#endif +} diff --git a/libstdc++-v3/config/locale/time_members_generic.h b/libstdc++-v3/config/locale/time_members_generic.h index 325ffaaa000..88b8208feab 100644 --- a/libstdc++-v3/config/locale/time_members_generic.h +++ b/libstdc++-v3/config/locale/time_members_generic.h @@ -36,10 +36,19 @@ template<typename _CharT> void - __timepunct<_CharT>::_M_put_helper(char* __s, size_t __maxlen, - const char* __format, - const tm* __tm) const + __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 new file mode 100644 index 00000000000..4f4789a3cad --- /dev/null +++ b/libstdc++-v3/config/locale/time_members_gnu.cc @@ -0,0 +1,176 @@ +// 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> + +#include <locale> + +namespace std +{ + template<> + void + __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc) + { + if (!__cloc) + { + // "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_am = "AM"; + _M_pm = "PM"; + + // 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"; + + // 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"; + + // 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"; + + // 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"; + } + 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_am = __nl_langinfo_l(AM_STR, __cloc); + _M_pm = __nl_langinfo_l(PM_STR, __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); + + // 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); + + // 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); + + // 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); + } + } + +#ifdef _GLIBCPP_USE_WCHAR_T + template<> + void + __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc) + { + if (!__cloc) + { + // "C" locale + } + else + { + _M_c_locale_timepunct = _S_clone_c_locale(__cloc); + } + } +#endif +} + diff --git a/libstdc++-v3/config/locale/time_members_gnu.h b/libstdc++-v3/config/locale/time_members_gnu.h index 0b9a3a6543a..16c9ff39d18 100644 --- a/libstdc++-v3/config/locale/time_members_gnu.h +++ b/libstdc++-v3/config/locale/time_members_gnu.h @@ -36,9 +36,9 @@ template<typename _CharT> void - __timepunct<_CharT>::_M_put_helper(char* __s, size_t __maxlen, - const char* __format, - const tm* __tm) const + __timepunct<_CharT>:: + _M_put_helper(char* __s, size_t __maxlen, const char* __format, + const tm* __tm) const { #if 0 // Requires glibc 2.3 @@ -51,3 +51,20 @@ 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 + } |