time_members_gnu.h: Remove.

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.

From-SVN: r45966
This commit is contained in:
Benjamin Kosnik 2001-10-02 18:44:50 +00:00 committed by Benjamin Kosnik
parent 8a2b8c5abe
commit da5c0f6ef5
22 changed files with 2298 additions and 1099 deletions

View File

@ -1,3 +1,32 @@
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.
2001-10-01 Hans-Peter Nilsson <hp@axis.com>
* config/cpu/cris/bits/atomicity.h: Correct file header.

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXX = @CXX@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@

View File

@ -1063,7 +1063,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
CMESSAGES_CC=config/locale/messages_members_generic.cc
CMONEY_CC=config/locale/moneypunct_members_generic.cc
CNUMERIC_CC=config/locale/numpunct_members_generic.cc
CTIME_H=config/locale/time_members_generic.h
CTIME_CC=config/locale/time_members_generic.cc
;;
xgnu)
@ -1093,7 +1092,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
CMESSAGES_CC=config/locale/messages_members_gnu.cc
CMONEY_CC=config/locale/moneypunct_members_gnu.cc
CNUMERIC_CC=config/locale/numpunct_members_gnu.cc
CTIME_H=config/locale/time_members_gnu.h
CTIME_CC=config/locale/time_members_gnu.cc
;;
xieee_1003.1)
@ -1110,7 +1108,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
CMESSAGES_CC=config/locale/messages_members_ieee_1003.1-200x.cc
CMONEY_CC=config/locale/moneypunct_members_generic.cc
CNUMERIC_CC=config/locale/numpunct_members_generic.cc
CTIME_H=config/locale/time_members_generic.h
CTIME_CC=config/locale/time_members_generic.cc
;;
*)
@ -1128,7 +1125,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
AC_SUBST(CLOCALE_H)
AC_SUBST(CCODECVT_H)
AC_SUBST(CMESSAGES_H)
AC_SUBST(CTIME_H)
AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)

View File

@ -1075,7 +1075,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
CMESSAGES_CC=config/locale/messages_members_generic.cc
CMONEY_CC=config/locale/moneypunct_members_generic.cc
CNUMERIC_CC=config/locale/numpunct_members_generic.cc
CTIME_H=config/locale/time_members_generic.h
CTIME_CC=config/locale/time_members_generic.cc
;;
xgnu)
@ -1105,7 +1104,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
CMESSAGES_CC=config/locale/messages_members_gnu.cc
CMONEY_CC=config/locale/moneypunct_members_gnu.cc
CNUMERIC_CC=config/locale/numpunct_members_gnu.cc
CTIME_H=config/locale/time_members_gnu.h
CTIME_CC=config/locale/time_members_gnu.cc
;;
xieee_1003.1)
@ -1122,7 +1120,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
CMESSAGES_CC=config/locale/messages_members_ieee_1003.1-200x.cc
CMONEY_CC=config/locale/moneypunct_members_generic.cc
CNUMERIC_CC=config/locale/numpunct_members_generic.cc
CTIME_H=config/locale/time_members_generic.h
CTIME_CC=config/locale/time_members_generic.cc
;;
*)
@ -1140,7 +1137,6 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
AC_SUBST(CLOCALE_H)
AC_SUBST(CCODECVT_H)
AC_SUBST(CMESSAGES_H)
AC_SUBST(CTIME_H)
AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)

View File

@ -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
}

View File

@ -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);
}

View File

@ -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
}

View File

@ -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
}

1673
libstdc++-v3/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -335,7 +335,6 @@ stamp-target: ${target_headers} ${target_builddir}
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h ;\
@LN_S@ ${glibcpp_srcdir}/@CTIME_H@ time_members.h ;\
@LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h ;\
echo `date` > stamp-target; \
fi

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@
DATADIRNAME = @DATADIRNAME@
@ -577,7 +576,6 @@ stamp-target: ${target_headers} ${target_builddir}
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h ;\
@LN_S@ ${glibcpp_srcdir}/@CTIME_H@ time_members.h ;\
@LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h ;\
echo `date` > stamp-target; \
fi

View File

@ -1078,9 +1078,12 @@ namespace std
const _CharT* _M_date_era_format;
const _CharT* _M_time_format;
const _CharT* _M_time_era_format;
const _CharT* _M_date_time_format;
const _CharT* _M_date_time_era_format;
const _CharT* _M_am;
const _CharT* _M_pm;
const _CharT* _M_am_pm_format;
// Day names, starting with "C"'s Sunday.
const _CharT* _M_day1;
const _CharT* _M_day2;
@ -1139,20 +1142,39 @@ namespace std
{ _M_initialize_timepunct(__cloc); }
void
_M_put_helper(char* __s, size_t __maxlen, const char* __format,
_M_put_helper(_CharT* __s, size_t __maxlen, const _CharT* __format,
const tm* __tm) const;
// Not used, at the moment. Likely to be strptime-ish.
void
_M_get_helper(const char* __s, const char* __format, tm* __tm) const;
_M_date_formats(const _CharT** __date) const
{
// Always have default first.
__date[0] = _M_date_format;
__date[1] = _M_date_era_format;
}
const _CharT*
_M_date_formats() const
{ return _M_date_format; }
void
_M_time_formats(const _CharT** __time) const
{
// Always have default first.
__time[0] = _M_time_format;
__time[1] = _M_time_era_format;
}
const _CharT*
_M_time_formats() const
{ return _M_time_format; }
void
_M_ampm(const _CharT** __ampm) const
{
__ampm[0] = _M_am;
__ampm[1] = _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;
}
void
_M_days(const _CharT** __days) const
@ -1176,7 +1198,7 @@ namespace std
__days[4] = _M_day_a5;
__days[5] = _M_day_a6;
__days[6] = _M_day_a7;
}
}
void
_M_months(const _CharT** __months) const
@ -1242,6 +1264,13 @@ namespace std
__timepunct<_CharT>::_M_initialize_timepunct(__c_locale)
{ }
// NB: Cannot be made generic.
template<typename _CharT>
void
__timepunct<_CharT>::_M_put_helper(_CharT*, size_t, const _CharT*,
const tm*) const
{ }
template<>
void
__timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
@ -1327,14 +1356,12 @@ namespace std
do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const;
// Extract time component in the form of
// [digitdigit][separator], with a maximum of two digits per
// separator. Used by do_get_time.
// Extract numeric component of length __len.
void
_M_extract_time(iter_type& __beg, iter_type& __end, int& __member,
int __min, int __max, const char_type __sep,
bool __extract, const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const;
_M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
int __min, int __max, size_t __len,
const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const;
// Extract day or month name, or any unique array of string
// literals in a const _CharT* array.
@ -1342,6 +1369,12 @@ namespace std
_M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
const _CharT** __names, size_t __indexlen,
ios_base::iostate& __err) const;
// Extract on a component-by-component basis, via __format argument.
void
_M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm,
const _CharT* __format) const;
};
template<typename _CharT, typename _InIter>
@ -1418,9 +1451,6 @@ namespace std
~time_put_byname() { }
};
// Include host and configuration specific messages virtual functions.
#include <bits/time_members.h>
struct money_base
{

View File

@ -1328,45 +1328,232 @@ namespace std
template<typename _CharT, typename _InIter>
void
time_get<_CharT, _InIter>::
_M_extract_time(iter_type& __beg, iter_type& __end, int& __member,
int __min, int __max, const char_type __sep,
bool __extract, const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const
{
if (__err == ios_base::goodbit)
_M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm,
const _CharT* __format) const
{
locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
size_t __len = char_traits<_CharT>::length(__format);
for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)
{
size_t __i = 0;
string __digits;
bool __testvalid = true;
const ctype_base::mask __digit = ctype_base::digit;
char_type __c = *__beg;
for (;__beg != __end && __ctype.is(__digit, __c) && __i < 2; ++__i)
char __c = __format[__i];
if (__c == '%')
{
__digits += __ctype.narrow(__c, 0);
__c = *(++__beg);
}
if (__i == 2)
{
int __value = atoi(__digits.c_str());
if (__min <= __value && __value <= __max)
__member = __value;
// Verify valid formatting code, attempt to extract.
__c = __format[++__i];
char __mod = 0;
int __mem = 0;
if (__c == 'E' || __c == 'O')
{
__mod = __c;
__c = __format[++__i];
}
switch (__c)
{
const char* __cs;
_CharT __wcs[10];
case 'a':
// Abbreviated weekday name [tm_wday]
const char_type* __days1[7];
__tp._M_days_abbreviated(__days1);
_M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
__err);
break;
case 'A':
// Weekday name [tm_wday].
const char_type* __days2[7];
__tp._M_days(__days2);
_M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7,
__err);
break;
case 'h':
case 'b':
// Abbreviated month name [tm_mon]
const char_type* __months1[12];
__tp._M_months_abbreviated(__months1);
_M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
__err);
break;
case 'B':
// Month name [tm_mon].
const char_type* __months2[12];
__tp._M_months(__months2);
_M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12,
__err);
break;
case 'c':
// Default time and date representation.
const char_type* __dt[2];
__tp._M_date_time_formats(__dt);
_M_extract_via_format(__beg, __end, __io, __err, __tm,
__dt[0]);
break;
case 'd':
// Day [01, 31]. [tm_mday]
_M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
__ctype, __err);
break;
case 'D':
// Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
__cs = "%m/%d/%y";
__ctype.widen(__cs, __cs + 9, __wcs);
_M_extract_via_format(__beg, __end, __io, __err, __tm,
__wcs);
break;
case 'H':
// Hour [00, 23]. [tm_hour]
_M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
__ctype, __err);
break;
case 'I':
// Hour [01, 12]. [tm_hour]
_M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
__ctype, __err);
break;
case 'm':
// Month [01, 12]. [tm_mon]
_M_extract_num(__beg, __end, __mem, 1, 12, 2,
__ctype, __err);
if (!__err)
__tm->tm_mon = __mem - 1;
break;
case 'M':
// Minute [00, 59]. [tm_min]
_M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
__ctype, __err);
break;
case 'n':
if (__ctype.narrow(*__beg, 0) == '\n')
++__beg;
else
__err |= ios_base::failbit;
break;
case 'R':
// Equivalent to (%H:%M).
__cs = "%H:%M";
__ctype.widen(__cs, __cs + 6, __wcs);
_M_extract_via_format(__beg, __end, __io, __err, __tm,
__wcs);
break;
case 'S':
// Seconds.
_M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2,
__ctype, __err);
break;
case 't':
if (__ctype.narrow(*__beg, 0) == '\t')
++__beg;
else
__err |= ios_base::failbit;
break;
case 'T':
// Equivalent to (%H:%M:%S).
__cs = "%H:%M:%S";
__ctype.widen(__cs, __cs + 9, __wcs);
_M_extract_via_format(__beg, __end, __io, __err, __tm,
__wcs);
break;
case 'x':
// Locale's date.
const char_type* __dates[2];
__tp._M_date_formats(__dates);
_M_extract_via_format(__beg, __end, __io, __err, __tm,
__dates[0]);
break;
case 'X':
// Locale's time.
const char_type* __times[2];
__tp._M_time_formats(__times);
_M_extract_via_format(__beg, __end, __io, __err, __tm,
__times[0]);
break;
case 'y':
// Two digit year. [tm_year]
_M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,
__ctype, __err);
break;
case 'Y':
// Year [1900). [tm_year]
_M_extract_num(__beg, __end, __mem, 0,
numeric_limits<int>::max(), 4,
__ctype, __err);
if (!__err)
__tm->tm_year = __mem - 1900;
break;
case 'Z':
// Timezone info.
if (__ctype.is(ctype_base::upper, *__beg))
{
int __tmp;
_M_extract_name(__beg, __end, __tmp,
__timepunct<_CharT>::_S_timezones,
14, __err);
// GMT requires special effort.
char_type __c = *__beg;
if (!__err && __tmp == 0
&& (__c == __ctype.widen('-')
|| __c == __ctype.widen('+')))
{
_M_extract_num(__beg, __end, __tmp, 0, 23, 2,
__ctype, __err);
_M_extract_num(__beg, __end, __tmp, 0, 59, 2,
__ctype, __err);
}
}
else
__err |= ios_base::failbit;
break;
default:
// Not recognized.
__err |= ios_base::failbit;
}
}
else
__testvalid = false;
}
{
// Verify format and input match, extract and discard.
if (__c == __ctype.narrow(*__beg, 0))
++__beg;
else
__err |= ios_base::failbit;
}
}
}
template<typename _CharT, typename _InIter>
void
time_get<_CharT, _InIter>::
_M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
int __min, int __max, size_t __len,
const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const
{
size_t __i = 0;
string __digits;
bool __testvalid = true;
char_type __c = *__beg;
while (__beg != __end && __i < __len
&& __ctype.is(ctype_base::digit, __c))
{
__digits += __ctype.narrow(__c, 0);
__c = *(++__beg);
++__i;
}
if (__i == __len)
{
int __value = atoi(__digits.c_str());
if (__min <= __value && __value <= __max)
__member = __value;
else
__testvalid = false;
// Extract and discard separator.
if (__extract && __testvalid)
{
if (__c == __sep)
++__beg;
else
__testvalid = false;
}
if (!__testvalid)
__err |= ios_base::failbit;
}
}
else
__testvalid = false;
if (!__testvalid)
__err |= ios_base::failbit;
}
// Assumptions:
@ -1439,51 +1626,12 @@ namespace std
do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* __tm) const
{
_CharT __wcs[3];
const char* __cs = "%X";
locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const char_type __sep = __ctype.widen(':');
_M_extract_time(__beg, __end, __tm->tm_hour, 0, 23, __sep, true,
__ctype, __err);
_M_extract_time(__beg, __end, __tm->tm_min, 0, 59, __sep, true,
__ctype, __err);
_M_extract_time(__beg, __end, __tm->tm_sec, 0, 59, __sep, false,
__ctype, __err);
// NB: Assume Ante- and Post-meridiem affixes not part of
// default time format.
// NB: Some locales have a timezone component as part of the
// default time formatting. In these cases, attempt to extract
// timezone parts.
const __string_type __format = __tp._M_time_formats();
if (__format.find(__ctype.widen('Z')) != __string_type::npos)
{
// Some valid timezone abbreviations are:
// HST, AKST, PST, MST, CST, EST, AST, NST, CET, IST, EET, CST, JST
// GMT, GMT[+-][hh:mm]
if (__ctype.is(ctype_base::space, *__beg))
++__beg;
if (__ctype.is(ctype_base::upper, *__beg))
{
int __tmp;
_M_extract_name(__beg, __end, __tmp,
__timepunct<_CharT>::_S_timezones, 14, __err);
char_type __c = *__beg;
if (!__err && __tmp == 0
&&(__c == __ctype.widen('-') || __c == __ctype.widen('-')))
{
// GMT requires special effort.
_M_extract_time(__beg, __end, __tmp, 0, 23, __sep, true,
__ctype, __err);
_M_extract_time(__beg, __end, __tmp, 0, 59, __sep, false,
__ctype, __err);
}
}
}
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__ctype.widen(__cs, __cs + 3, __wcs);
_M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
@ -1493,12 +1641,14 @@ namespace std
_InIter
time_get<_CharT, _InIter>::
do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, tm* /*__tm*/) const
ios_base::iostate& __err, tm* __tm) const
{
_CharT __wcs[3];
const char* __cs = "%x";
locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__ctype.widen(__cs, __cs + 3, __wcs);
_M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
@ -1663,39 +1813,40 @@ namespace std
do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
char __format, char __mod) const
{
locale __loc = __io.getloc();
ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
// NB: This size is arbitrary. Should this be a data member,
// initialized at construction?
const size_t __maxlen = 64;
char* __res = static_cast<char*>(__builtin_alloca(__maxlen));
char_type* __res = static_cast<char_type*>(__builtin_alloca(__maxlen));
// NB: In IEE 1003.1-200x, and perhaps other locale models, it
// is possible that the format character will be longer than one
// character. Possibilities include 'E' or 'O' followed by a
// format charcter: if __mod is not the default argument, assume
// it's a valid modifier.
char __fmt[4];
__fmt[0] = '%';
char_type __fmt[4];
__fmt[0] = __ctype.widen('%');
if (!__mod)
{
__fmt[1] = __format;
__fmt[2] = '\0';
__fmt[2] = char_type();
}
else
{
__fmt[1] = __mod;
__fmt[2] = __format;
__fmt[3] = '\0';
__fmt[3] = char_type();
}
locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
__tp._M_put_helper(__res, __maxlen, __fmt, __tm);
// Write resulting, fully-formatted string to output iterator.
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
size_t __len = strlen(__res);
size_t __len = char_traits<char_type>::length(__res);
for (size_t __i = 0; __i < __len; ++__i)
__s = __ctype.widen(__res[__i]);
__s = __res[__i];
return __s;
}

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXX = @CXX@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXX = @CXX@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@
DATADIRNAME = @DATADIRNAME@

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXX = @CXX@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@

View File

@ -77,7 +77,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@
DATADIRNAME = @DATADIRNAME@

View File

@ -481,11 +481,116 @@ void test04()
VERIFY( errorstate == ios_base::eofbit );
}
void test05()
{
using namespace std;
typedef time_base::dateorder dateorder;
typedef istreambuf_iterator<char> iterator_type;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<char>& time_c = use_facet<__timepunct<char> >(loc_c);
const __timepunct<char>& time_de = use_facet<__timepunct<char> >(loc_de);
const __timepunct<char>& time_hk = use_facet<__timepunct<char> >(loc_hk);
const __timepunct<char>& time_fr = use_facet<__timepunct<char> >(loc_fr);
const string empty;
// create an ostream-derived object, cache the time_get facet
iterator_type end;
istringstream iss;
const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
// create "C" time objects
const tm time_bday = { 0, 0, 12, 4, 3, 71 };
const char* all = "%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
"%w %W %x %X %y %Y %Z %%";
const char* date = "%A, the second of %B";
const char* date_ex = "%Ex";
// iter_type
// get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale
iss.str("04/04/71");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_date(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_year == time_bday.tm_year );
VERIFY( time01.tm_mon == time_bday.tm_mon );
VERIFY( time01.tm_mday == time_bday.tm_mday );
VERIFY( errorstate == ios_base::eofbit );
iss.str("04/04/71 ");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_date(is_it02, end, iss, errorstate, &time02);
VERIFY( time02.tm_year == time_bday.tm_year );
VERIFY( time02.tm_mon == time_bday.tm_mon );
VERIFY( time02.tm_mday == time_bday.tm_mday );
VERIFY( errorstate == good );
VERIFY( *is_it02 == ' ');
iss.str("04/04d/71 ");
iterator_type is_it03(iss);
tm time03;
time03.tm_year = 3;
errorstate = good;
tim_get.get_date(is_it03, end, iss, errorstate, &time03);
VERIFY( time03.tm_year == 3 );
VERIFY( time03.tm_mon == time_bday.tm_mon );
VERIFY( time03.tm_mday == time_bday.tm_mday );
VERIFY( errorstate == ios_base::failbit );
VERIFY( *is_it03 == 'd');
// inspection of named locales, de_DE
iss.imbue(loc_de);
iss.str("04.04.1971");
iterator_type is_it10(iss);
tm time10;
errorstate = good;
tim_get.get_date(is_it10, end, iss, errorstate, &time10);
VERIFY( time10.tm_mon == time_bday.tm_mon );
VERIFY( time10.tm_mday == time_bday.tm_mday );
VERIFY( time10.tm_year == time_bday.tm_year );
VERIFY( errorstate == ios_base::eofbit );
// inspection of named locales, en_HK
iss.imbue(loc_hk);
iss.str("Sunday, April 04, 1971");
iterator_type is_it20(iss);
tm time20;
errorstate = good;
tim_get.get_date(is_it20, end, iss, errorstate, &time20);
VERIFY( time20.tm_mon == time_bday.tm_mon );
VERIFY( time20.tm_mday == time_bday.tm_mday );
VERIFY( time20.tm_year == time_bday.tm_year );
VERIFY( errorstate == ios_base::eofbit );
}
int main()
{
test01();
test02();
test03();
test04();
test05();
return 0;
}

View File

@ -0,0 +1,599 @@
// 2001-10-02 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// 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.
// 22.2.5.1.1 time_get members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// XXX This test is not working for non-glibc locale models.
// { dg-do run { xfail *-*-* } }
#ifdef _GLIBCPP_USE_WCHAR_T
void test01()
{
using namespace std;
typedef time_base::dateorder dateorder;
typedef istreambuf_iterator<wchar_t> iterator_type;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<wchar_t>& time_c = use_facet<__timepunct<wchar_t> >(loc_c);
const __timepunct<wchar_t>& time_de = use_facet<__timepunct<wchar_t> >(loc_de);
const __timepunct<wchar_t>& time_hk = use_facet<__timepunct<wchar_t> >(loc_hk);
const __timepunct<wchar_t>& time_fr = use_facet<__timepunct<wchar_t> >(loc_fr);
const wstring empty;
// create an ostream-derived object, cache the time_get facet
iterator_type end;
wistringstream iss;
const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
// create "C" time objects
const tm time_bday = { 0, 0, 12, 4, 3, 71 };
const wchar_t* all = L"%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
L"%w %W %x %X %y %Y %Z %%";
const wchar_t* date = L"%A, the second of %B";
const wchar_t* date_ex = L"%Ex";
// 1
// dateorder date_order() const
iss.imbue(loc_c);
dateorder do1 = tim_get.date_order();
// VERIFY( do1 == time_base::mdy );
VERIFY( do1 == time_base::no_order );
// 2
// iter_type
// get_time(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale
iss.str(L"12:00:00");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_time(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_sec == time_bday.tm_sec );
VERIFY( time01.tm_min == time_bday.tm_min );
VERIFY( time01.tm_hour == time_bday.tm_hour );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"12:00:00 ");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_time(is_it02, end, iss, errorstate, &time02);
VERIFY( time01.tm_sec == time_bday.tm_sec );
VERIFY( time01.tm_min == time_bday.tm_min );
VERIFY( time01.tm_hour == time_bday.tm_hour );
VERIFY( errorstate == good );
iss.str(L"12:61:00 ");
iterator_type is_it03(iss);
tm time03;
errorstate = good;
tim_get.get_time(is_it03, end, iss, errorstate, &time03);
VERIFY( time01.tm_hour == time_bday.tm_hour );
VERIFY( errorstate == ios_base::failbit );
iss.str(L"12:a:00 ");
iterator_type is_it04(iss);
tm time04;
errorstate = good;
tim_get.get_time(is_it04, end, iss, errorstate, &time04);
VERIFY( time01.tm_hour == time_bday.tm_hour );
VERIFY( *is_it04 == 'a');
VERIFY( errorstate == ios_base::failbit );
// inspection of named locales, de_DE
iss.imbue(loc_de);
iss.str(L"12:00:00");
iterator_type is_it10(iss);
tm time10;
errorstate = good;
tim_get.get_time(is_it10, end, iss, errorstate, &time10);
VERIFY( time10.tm_sec == time_bday.tm_sec );
VERIFY( time10.tm_min == time_bday.tm_min );
VERIFY( time10.tm_hour == time_bday.tm_hour );
VERIFY( errorstate == ios_base::eofbit );
// inspection of named locales, en_HK
iss.imbue(loc_hk);
iss.str(L"12:00:00 PST");
// Hong Kong in California! Well, they have Paris in Vegas... this
// is all a little disney-esque anyway. Besides, you can get decent
// Dim Sum in San Francisco.
iterator_type is_it20(iss);
tm time20;
errorstate = good;
tim_get.get_time(is_it20, end, iss, errorstate, &time20);
VERIFY( time10.tm_sec == time_bday.tm_sec );
VERIFY( time10.tm_min == time_bday.tm_min );
VERIFY( time10.tm_hour == time_bday.tm_hour );
VERIFY( errorstate == ios_base::eofbit );
}
void test02()
{
using namespace std;
typedef time_base::dateorder dateorder;
typedef istreambuf_iterator<wchar_t> iterator_type;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<wchar_t>& time_c = use_facet<__timepunct<wchar_t> >(loc_c);
const __timepunct<wchar_t>& time_de = use_facet<__timepunct<wchar_t> >(loc_de);
const __timepunct<wchar_t>& time_hk = use_facet<__timepunct<wchar_t> >(loc_hk);
const __timepunct<wchar_t>& time_fr = use_facet<__timepunct<wchar_t> >(loc_fr);
const wstring empty;
// create an ostream-derived object, cache the time_get facet
iterator_type end;
wistringstream iss;
const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
// create "C" time objects
const tm time_bday = { 0, 0, 12, 4, 3, 71 };
const wchar_t* all = L"%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
L"%w %W %x %X %y %Y %Z %%";
const wchar_t* date = L"%A, the second of %B";
const wchar_t* date_ex = L"%Ex";
// iter_type
// get_weekday(iter_type, iter_type, ios_base&,
// ios_base::iostate&, tm*) const
// sanity checks for "C" locale
iss.str(L"Sunday");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_weekday(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"Sun");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_weekday(is_it02, end, iss, errorstate, &time02);
VERIFY( time02.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"Sun ");
iterator_type is_it03(iss);
tm time03;
errorstate = good;
tim_get.get_weekday(is_it03, end, iss, errorstate, &time03);
VERIFY( time03.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == good );
VERIFY( *is_it03 == ' ');
iss.str(L"San");
iterator_type is_it04(iss);
tm time04;
time04.tm_wday = 4;
errorstate = good;
tim_get.get_weekday(is_it04, end, iss, errorstate, &time04);
VERIFY( time04.tm_wday == 4 );
VERIFY( *is_it04 == 'n');
VERIFY( errorstate == ios_base::failbit );
iss.str(L"Tuesday ");
iterator_type is_it05(iss);
tm time05;
errorstate = good;
tim_get.get_weekday(is_it05, end, iss, errorstate, &time05);
VERIFY( time05.tm_wday == 2 );
VERIFY( errorstate == good );
VERIFY( *is_it05 == ' ');
iss.str(L"Tuesducky "); // Kind of like Fryday, without the swirls.
iterator_type is_it06(iss);
tm time06;
time06.tm_wday = 4;
errorstate = good;
tim_get.get_weekday(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_wday == 4 );
VERIFY( errorstate == ios_base::failbit );
VERIFY( *is_it05 == 'u');
// inspection of named locales, de_DE
iss.imbue(loc_de);
iss.str(L"Sonntag");
iterator_type is_it10(iss);
tm time10;
errorstate = good;
tim_get.get_weekday(is_it10, end, iss, errorstate, &time10);
VERIFY( time10.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
// inspection of named locales, en_HK
iss.imbue(loc_hk);
iss.str(L"Sunday");
iterator_type is_it20(iss);
tm time20;
errorstate = good;
tim_get.get_weekday(is_it20, end, iss, errorstate, &time20);
VERIFY( time20.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
}
void test03()
{
using namespace std;
typedef time_base::dateorder dateorder;
typedef istreambuf_iterator<wchar_t> iterator_type;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<wchar_t>& time_c = use_facet<__timepunct<wchar_t> >(loc_c);
const __timepunct<wchar_t>& time_de = use_facet<__timepunct<wchar_t> >(loc_de);
const __timepunct<wchar_t>& time_hk = use_facet<__timepunct<wchar_t> >(loc_hk);
const __timepunct<wchar_t>& time_fr = use_facet<__timepunct<wchar_t> >(loc_fr);
const wstring empty;
// create an ostream-derived object, cache the time_get facet
iterator_type end;
wistringstream iss;
const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
// create "C" time objects
const tm time_bday = { 0, 0, 12, 4, 3, 71 };
const wchar_t* all = L"%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
L"%w %W %x %X %y %Y %Z %%";
const wchar_t* date = L"%A, the second of %B";
const wchar_t* date_ex = L"%Ex";
// iter_type
// get_monthname(iter_type, iter_type, ios_base&,
// ios_base::iostate&, tm*) const
// sanity checks for "C" locale
iss.str(L"April");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_monthname(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_wday == time_bday.tm_wday );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"Apr");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_monthname(is_it02, end, iss, errorstate, &time02);
VERIFY( time02.tm_mon == time_bday.tm_mon );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"Apr ");
iterator_type is_it03(iss);
tm time03;
errorstate = good;
tim_get.get_monthname(is_it03, end, iss, errorstate, &time03);
VERIFY( time03.tm_mon == time_bday.tm_mon );
VERIFY( errorstate == good );
VERIFY( *is_it03 == ' ');
iss.str(L"Aar");
iterator_type is_it04(iss);
tm time04;
time04.tm_mon = 5;
errorstate = good;
tim_get.get_monthname(is_it04, end, iss, errorstate, &time04);
VERIFY( time04.tm_mon == 5 );
VERIFY( *is_it04 == 'a');
VERIFY( errorstate == ios_base::failbit );
iss.str(L"December ");
iterator_type is_it05(iss);
tm time05;
errorstate = good;
tim_get.get_monthname(is_it05, end, iss, errorstate, &time05);
VERIFY( time05.tm_mon == 11 );
VERIFY( errorstate == good );
VERIFY( *is_it05 == ' ');
iss.str(L"Decelember ");
iterator_type is_it06(iss);
tm time06;
time06.tm_mon = 4;
errorstate = good;
tim_get.get_monthname(is_it06, end, iss, errorstate, &time06);
VERIFY( time06.tm_mon == 4 );
VERIFY( errorstate == ios_base::failbit );
VERIFY( *is_it05 == 'l');
// inspection of named locales, de_DE
iss.imbue(loc_de);
iss.str(L"April");
iterator_type is_it10(iss);
tm time10;
errorstate = good;
tim_get.get_monthname(is_it10, end, iss, errorstate, &time10);
VERIFY( time10.tm_mon == time_bday.tm_mon );
VERIFY( errorstate == ios_base::eofbit );
// inspection of named locales, en_HK
iss.imbue(loc_hk);
iss.str(L"April");
iterator_type is_it20(iss);
tm time20;
errorstate = good;
tim_get.get_monthname(is_it20, end, iss, errorstate, &time20);
VERIFY( time20.tm_mon == time_bday.tm_mon );
VERIFY( errorstate == ios_base::eofbit );
}
void test04()
{
using namespace std;
typedef time_base::dateorder dateorder;
typedef istreambuf_iterator<wchar_t> iterator_type;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<wchar_t>& time_c = use_facet<__timepunct<wchar_t> >(loc_c);
const __timepunct<wchar_t>& time_de = use_facet<__timepunct<wchar_t> >(loc_de);
const __timepunct<wchar_t>& time_hk = use_facet<__timepunct<wchar_t> >(loc_hk);
const __timepunct<wchar_t>& time_fr = use_facet<__timepunct<wchar_t> >(loc_fr);
const wstring empty;
// create an ostream-derived object, cache the time_get facet
iterator_type end;
wistringstream iss;
const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
// create "C" time objects
const tm time_bday = { 0, 0, 12, 4, 3, 71 };
const wchar_t* all = L"%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
L"%w %W %x %X %y %Y %Z %%";
const wchar_t* date = L"%A, the second of %B";
const wchar_t* date_ex = L"%Ex";
// iter_type
// get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale
iss.str(L"1971");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_year(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_year == time_bday.tm_year );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"1971 ");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_year(is_it02, end, iss, errorstate, &time02);
VERIFY( time02.tm_year == time_bday.tm_year );
VERIFY( errorstate == good );
VERIFY( *is_it02 == ' ');
iss.str(L"197d1 ");
iterator_type is_it03(iss);
tm time03;
time03.tm_year = 3;
errorstate = good;
tim_get.get_year(is_it03, end, iss, errorstate, &time03);
VERIFY( time03.tm_year == 3 );
VERIFY( errorstate == ios_base::failbit );
VERIFY( *is_it03 == 'd');
iss.str(L"71d71");
iterator_type is_it04(iss);
tm time04;
errorstate = good;
tim_get.get_year(is_it04, end, iss, errorstate, &time04);
VERIFY( time04.tm_year == time_bday.tm_year );
VERIFY( errorstate == good );
VERIFY( *is_it03 == 'd');
iss.str(L"71");
iterator_type is_it05(iss);
tm time05;
errorstate = good;
tim_get.get_year(is_it05, end, iss, errorstate, &time05);
VERIFY( time05.tm_year == time_bday.tm_year );
VERIFY( errorstate == ios_base::eofbit );
}
void test05()
{
using namespace std;
typedef time_base::dateorder dateorder;
typedef istreambuf_iterator<wchar_t> iterator_type;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<wchar_t>& time_c = use_facet<__timepunct<wchar_t> >(loc_c);
const __timepunct<wchar_t>& time_de = use_facet<__timepunct<wchar_t> >(loc_de);
const __timepunct<wchar_t>& time_hk = use_facet<__timepunct<wchar_t> >(loc_hk);
const __timepunct<wchar_t>& time_fr = use_facet<__timepunct<wchar_t> >(loc_fr);
const wstring empty;
// create an ostream-derived object, cache the time_get facet
iterator_type end;
wistringstream iss;
const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
const ios_base::iostate good = ios_base::goodbit;
ios_base::iostate errorstate = good;
// create "C" time objects
const tm time_bday = { 0, 0, 12, 4, 3, 71 };
const wchar_t* all = L"%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
L"%w %W %x %X %y %Y %Z %%";
const wchar_t* date = L"%A, the second of %B";
const wchar_t* date_ex = L"%Ex";
// iter_type
// get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale
iss.str(L"04/04/71");
iterator_type is_it01(iss);
tm time01;
errorstate = good;
tim_get.get_date(is_it01, end, iss, errorstate, &time01);
VERIFY( time01.tm_year == time_bday.tm_year );
VERIFY( time01.tm_mon == time_bday.tm_mon );
VERIFY( time01.tm_mday == time_bday.tm_mday );
VERIFY( errorstate == ios_base::eofbit );
iss.str(L"04/04/71 ");
iterator_type is_it02(iss);
tm time02;
errorstate = good;
tim_get.get_date(is_it02, end, iss, errorstate, &time02);
VERIFY( time02.tm_year == time_bday.tm_year );
VERIFY( time02.tm_mon == time_bday.tm_mon );
VERIFY( time02.tm_mday == time_bday.tm_mday );
VERIFY( errorstate == good );
VERIFY( *is_it02 == ' ');
iss.str(L"04/04d/71 ");
iterator_type is_it03(iss);
tm time03;
time03.tm_year = 3;
errorstate = good;
tim_get.get_date(is_it03, end, iss, errorstate, &time03);
VERIFY( time03.tm_year == 3 );
VERIFY( time03.tm_mon == time_bday.tm_mon );
VERIFY( time03.tm_mday == time_bday.tm_mday );
VERIFY( errorstate == ios_base::failbit );
VERIFY( *is_it03 == 'd');
// inspection of named locales, de_DE
iss.imbue(loc_de);
iss.str(L"04.04.1971");
iterator_type is_it10(iss);
tm time10;
errorstate = good;
tim_get.get_date(is_it10, end, iss, errorstate, &time10);
VERIFY( time10.tm_mon == time_bday.tm_mon );
VERIFY( time10.tm_mday == time_bday.tm_mday );
VERIFY( time10.tm_year == time_bday.tm_year );
VERIFY( errorstate == ios_base::eofbit );
// inspection of named locales, en_HK
iss.imbue(loc_hk);
iss.str(L"Sunday, April 04, 1971");
iterator_type is_it20(iss);
tm time20;
errorstate = good;
tim_get.get_date(is_it20, end, iss, errorstate, &time20);
VERIFY( time20.tm_mon == time_bday.tm_mon );
VERIFY( time20.tm_mday == time_bday.tm_mday );
VERIFY( time20.tm_year == time_bday.tm_year );
VERIFY( errorstate == ios_base::eofbit );
}
#endif
int main()
{
#ifdef _GLIBCPP_USE_WCHAR_T
test01();
test02();
test03();
test04();
test05();
#endif
return 0;
}

View File

@ -0,0 +1,200 @@
// 2001-10-02 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// 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.
// 22.2.5.3.1 time_put members
#include <locale>
#include <sstream>
#include <testsuite_hooks.h>
// XXX This test is not working for non-glibc locale models.
// { dg-do run { xfail *-*-* } }
#ifdef _GLIBCPP_USE_WCHAR_T
void test01()
{
using namespace std;
typedef ostreambuf_iterator<wchar_t> iterator_type;
typedef char_traits<wchar_t> traits;
bool test = true;
// basic construction and sanity checks.
locale loc_c = locale::classic();
locale loc_hk("en_HK");
locale loc_fr("fr_FR@euro");
locale loc_de("de_DE");
VERIFY( loc_hk != loc_c );
VERIFY( loc_hk != loc_fr );
VERIFY( loc_hk != loc_de );
VERIFY( loc_de != loc_fr );
// cache the __timepunct facets, for quicker gdb inspection
const __timepunct<wchar_t>& time_c = use_facet<__timepunct<wchar_t> >(loc_c);
const __timepunct<wchar_t>& time_de = use_facet<__timepunct<wchar_t> >(loc_de);
const __timepunct<wchar_t>& time_hk = use_facet<__timepunct<wchar_t> >(loc_hk);
const __timepunct<wchar_t>& time_fr = use_facet<__timepunct<wchar_t> >(loc_fr);
// create an ostream-derived object, cache the time_put facet
const wstring empty;
wostringstream oss;
const time_put<wchar_t>& tim_put = use_facet<time_put<wchar_t> >(oss.getloc());
// create "C" time objects
tm time1 = { 0, 0, 12, 4, 3, 71 };
const wchar_t* all = L"%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
L"%w %W %x %X %y %Y %Z %%";
const wchar_t* date = L"%A, the second of %B";
const wchar_t* date_ex = L"%Ex";
// 1
// iter_type
// put(iter_type s, ios_base& str, char_type fill, const tm* t,
// char format, char modifier = 0) const;
oss.str(empty);
oss.imbue(loc_c);
iterator_type os_it01 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
wstring result1 = oss.str();
VERIFY( result1 == L"Sun" );
oss.str(empty);
iterator_type os_it21 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x');
wstring result21 = oss.str(); // "04/04/71"
oss.str(empty);
iterator_type os_it22 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X');
wstring result22 = oss.str(); // "12:00:00"
oss.str(empty);
iterator_type os_it31 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x', 'E');
wstring result31 = oss.str(); // "04/04/71"
oss.str(empty);
iterator_type os_it32 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X', 'E');
wstring result32 = oss.str(); // "12:00:00"
oss.str(empty);
oss.imbue(loc_de);
iterator_type os_it02 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
wstring result2 = oss.str();
VERIFY( result2 == L"Son" );
oss.str(empty); // "%d.%m.%Y"
iterator_type os_it23 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x');
wstring result23 = oss.str(); // "04.04.1971"
oss.str(empty); // "%T"
iterator_type os_it24 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X');
wstring result24 = oss.str(); // "12:00:00"
oss.str(empty);
iterator_type os_it33 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x', 'E');
wstring result33 = oss.str(); // "04.04.1971"
oss.str(empty);
iterator_type os_it34 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X', 'E');
wstring result34 = oss.str(); // "12:00:00"
oss.str(empty);
oss.imbue(loc_hk);
iterator_type os_it03 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
wstring result3 = oss.str();
VERIFY( result3 == L"Sun" );
oss.str(empty); // "%A, %B %d, %Y"
iterator_type os_it25 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x');
wstring result25 = oss.str(); // "Sunday, April 04, 1971"
oss.str(empty); // "%I:%M:%S %Z"
iterator_type os_it26 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X');
wstring result26 = oss.str(); // "12:00:00 PST"
oss.str(empty);
iterator_type os_it35 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x', 'E');
wstring result35 = oss.str(); // "Sunday, April 04, 1971"
oss.str(empty);
iterator_type os_it36 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X', 'E');
wstring result36 = oss.str(); // "12:00:00 PST"
oss.str(empty);
oss.imbue(loc_fr);
iterator_type os_it04 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
wstring result4 = oss.str();
VERIFY( result4 == L"dim" );
oss.str(empty); // "%d.%m.%Y"
iterator_type os_it27 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x');
wstring result27 = oss.str(); // "04.04.1971"
oss.str(empty); // "%T"
iterator_type os_it28 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X');
wstring result28 = oss.str(); // "12:00:00"
oss.str(empty);
iterator_type os_it37 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'x', 'E');
wstring result37 = oss.str(); // "04.04.1971"
oss.str(empty);
iterator_type os_it38 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'X', 'E');
wstring result38 = oss.str(); // "12:00:00"
// 2
oss.str(empty);
oss.imbue(loc_c);
iterator_type os_it05 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date, date + traits::length(date));
wstring result5 = oss.str();
VERIFY( result5 == L"Sunday, the second of April");
iterator_type os_it06 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date_ex, date_ex + traits::length(date));
wstring result6 = oss.str();
VERIFY( result6 != result5 );
oss.str(empty);
oss.imbue(loc_de);
iterator_type os_it07 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date, date + traits::length(date));
wstring result7 = oss.str();
VERIFY( result7 == L"Sonntag, the second of April");
iterator_type os_it08 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date_ex, date_ex + traits::length(date));
wstring result8 = oss.str();
VERIFY( result8 != result7 );
oss.str(empty);
oss.imbue(loc_hk);
iterator_type os_it09 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date, date + traits::length(date));
wstring result9 = oss.str();
VERIFY( result9 == L"Sunday, the second of April");
iterator_type os_it10 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date_ex, date_ex + traits::length(date));
wstring result10 = oss.str();
VERIFY( result10 != result9 );
oss.str(empty);
oss.imbue(loc_fr);
iterator_type os_it11 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date, date + traits::length(date));
wstring result11 = oss.str();
VERIFY( result11 == L"dimanche, the second of avril");
iterator_type os_it12 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
date_ex, date_ex + traits::length(date));
wstring result12 = oss.str();
VERIFY( result12 != result11 );
}
#endif
int main()
{
#ifdef _GLIBCPP_USE_WCHAR_T
test01();
#endif
return 0;
}

View File

@ -78,7 +78,6 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
CTIME_H = @CTIME_H@
CXX = @CXX@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@