locale_facets.h (time_get::_M_extract_name): Add ctype argument.

2003-11-03  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/locale_facets.h (time_get::_M_extract_name): Add
	ctype argument.
	* include/bits/locale_facets.tcc: Same, use it to allow
	capitalized names.

	* include/bits/fstream.tcc: Spacing tweak.
	* include/bits/istream.tcc: Same.
	* include/bits/ostream.tcc: Same.

From-SVN: r73241
This commit is contained in:
Benjamin Kosnik 2003-11-04 02:06:59 +00:00 committed by Benjamin Kosnik
parent 1b64e33f3f
commit e0f05105f7
6 changed files with 41 additions and 16 deletions

View File

@ -1,3 +1,14 @@
2003-11-03 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/locale_facets.h (time_get::_M_extract_name): Add
ctype argument.
* include/bits/locale_facets.tcc: Same, use it to allow
capitalized names.
* include/bits/fstream.tcc: Spacing tweak.
* include/bits/istream.tcc: Same.
* include/bits/ostream.tcc: Same.
2003-10-30 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (time_get::_M_extract_via_format):

View File

@ -610,7 +610,6 @@ namespace std
__computed_off += _M_ext_buf + __gptr_off - _M_ext_end;
}
}
__ret = _M_seek(__computed_off, __way);
}
_M_last_overflowed = false;

View File

@ -63,7 +63,8 @@ namespace std
__c = __sb->snextc();
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 195. Should basic_istream::sentry's constructor ever set eofbit?
// 195. Should basic_istream::sentry's constructor ever
// 195. set eofbit?
if (traits_type::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
}

View File

@ -1519,6 +1519,7 @@ namespace std
void
_M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
const _CharT** __names, size_t __indexlen,
const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const;
// Extract on a component-by-component basis, via __format argument.

View File

@ -1533,7 +1533,7 @@ namespace std
const _CharT* __format) const
{
const locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const size_t __len = char_traits<_CharT>::length(__format);
@ -1556,14 +1556,14 @@ namespace std
const char_type* __days1[7];
__tp._M_days_abbreviated(__days1);
_M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7,
__err);
__ctype, __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);
__ctype, __err);
break;
case 'h':
case 'b':
@ -1571,14 +1571,14 @@ namespace std
const char_type* __months1[12];
__tp._M_months_abbreviated(__months1);
_M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12,
__err);
__ctype, __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);
__ctype, __err);
break;
case 'c':
// Default time and date representation.
@ -1697,7 +1697,7 @@ namespace std
int __tmp;
_M_extract_name(__beg, __end, __tmp,
__timepunct_cache<_CharT>::_S_timezones,
14, __err);
14, __ctype, __err);
// GMT requires special effort.
if (__beg != __end && !__err && __tmp == 0
@ -1764,6 +1764,7 @@ namespace std
time_get<_CharT, _InIter>::
_M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
const _CharT** __names, size_t __indexlen,
const ctype<_CharT>& __ctype,
ios_base::iostate& __err) const
{
typedef char_traits<_CharT> __traits_type;
@ -1774,12 +1775,16 @@ namespace std
bool __testvalid = true;
const char_type* __name;
// Look for initial matches.
// Look for initial matches.
// NB: Some of the locale data is in the form of all lowercase
// names, and some is in the form of initially-capitalized
// names. Look for both.
if (__beg != __end)
{
const char_type __c = *__beg;
for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
if (__c == __names[__i1][0])
if (__c == __names[__i1][0]
|| __c == __ctype.toupper(__names[__i1][0]))
__matches[__nmatches++] = __i1;
}
@ -1807,6 +1812,13 @@ namespace std
if (__nmatches == 1)
{
// If there was only one match, the first compare is redundant.
if (__pos == 0)
{
++__pos;
++__beg;
}
// Make sure found name is completely extracted.
__name = __names[__matches[0]];
const size_t __len = __traits_type::length(__name);
@ -1866,11 +1878,12 @@ namespace std
{
typedef char_traits<_CharT> __traits_type;
const locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const char_type* __days[7];
__tp._M_days_abbreviated(__days);
int __tmpwday;
_M_extract_name(__beg, __end, __tmpwday, __days, 7, __err);
_M_extract_name(__beg, __end, __tmpwday, __days, 7, __ctype, __err);
// Check to see if non-abbreviated name exists, and extract.
// NB: Assumes both _M_days and _M_days_abbreviated organized in
@ -1909,11 +1922,12 @@ namespace std
{
typedef char_traits<_CharT> __traits_type;
const locale __loc = __io.getloc();
__timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const char_type* __months[12];
__tp._M_months_abbreviated(__months);
int __tmpmon;
_M_extract_name(__beg, __end, __tmpmon, __months, 12, __err);
_M_extract_name(__beg, __end, __tmpmon, __months, 12, __ctype, __err);
// Check to see if non-abbreviated name exists, and extract.
// NB: Assumes both _M_months and _M_months_abbreviated organized in

View File

@ -673,8 +673,7 @@ namespace std
// 25. String operator<< uses width() value wrong
if (__w > __len)
{
_CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
_CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
__pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, __s,
__w, __len, false);
__s = __cs;