[v3] num_get caching
Benjamin Kosnik
bkoz@redhat.com
Wed Jul 16 21:32:00 GMT 2003
Adds caching for numeric input.
tested x86/linux
2003-07-16 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/locale_facets.h (__num_base::_S_atoms_in): Add -+xX.
(num_get::_M_convert_int): To _M_insert_int.
(num_get::_M_convert_float): To _M_insert_float.
* include/bits/locale_facets.tcc (num_get::_M_extract_float):
Use caches for ctype, num_get.
(num_get::_M_extract_int): Same.
(num_get::get(bool)): Same.
(__verify_grouping): Use size_t.
* src/locale-inst.cc: Update.
* src/locale.cc: Adjust _S_atoms_in.
Index: include/bits/locale_facets.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.h,v
retrieving revision 1.62
diff -c -p -r1.62 locale_facets.h
*** include/bits/locale_facets.h 14 Jul 2003 02:52:04 -0000 1.62
--- include/bits/locale_facets.h 16 Jul 2003 21:30:55 -0000
*************** namespace std
*** 557,571 ****
static const char* _S_atoms_out;
// String literal of acceptable (narrow) input, for num_get.
! // "0123456789eEabcdfABCDF"
static const char* _S_atoms_in;
enum
{
_S_izero,
_S_ie = _S_izero + 10,
_S_iE = _S_izero + 11,
! _S_iend = 21 + 1
};
// num_put
--- 557,575 ----
static const char* _S_atoms_out;
// String literal of acceptable (narrow) input, for num_get.
! // "-+xX0123456789eEabcdfABCDF"
static const char* _S_atoms_in;
enum
{
+ _S_iminus,
+ _S_iplus,
+ _S_ix,
+ _S_iX,
_S_izero,
_S_ie = _S_izero + 10,
_S_iE = _S_izero + 11,
! _S_iend = 26
};
// num_put
*************** namespace std
*** 590,597 ****
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_out[__num_base::_S_oend + 1];
! // A list of valid numeric literals for output: in the standard
! // "C" locale, this is "0123456789eEabcdfABCDF"
// This array contains the chars after having been passed
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_in[__num_base::_S_iend + 1];
--- 594,601 ----
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_out[__num_base::_S_oend + 1];
! // A list of valid numeric literals for input: in the standard
! // "C" locale, this is "-+xX0123456789eEabcdfABCDF"
// This array contains the chars after having been passed
// through the current locale's ctype<_CharT>.widen().
_CharT _M_atoms_in[__num_base::_S_iend + 1];
*************** namespace std
*** 983,990 ****
protected:
template<typename _ValueT>
iter_type
! _M_convert_float(iter_type, ios_base& __io, char_type __fill,
! char __mod, _ValueT __v) const;
void
_M_group_float(const string& __grouping, char_type __sep,
--- 987,994 ----
protected:
template<typename _ValueT>
iter_type
! _M_insert_float(iter_type, ios_base& __io, char_type __fill,
! char __mod, _ValueT __v) const;
void
_M_group_float(const string& __grouping, char_type __sep,
*************** namespace std
*** 993,1000 ****
template<typename _ValueT>
iter_type
! _M_convert_int(iter_type, ios_base& __io, char_type __fill,
! _ValueT __v) const;
void
_M_group_int(const string& __grouping, char_type __sep,
--- 997,1004 ----
template<typename _ValueT>
iter_type
! _M_insert_int(iter_type, ios_base& __io, char_type __fill,
! _ValueT __v) const;
void
_M_group_int(const string& __grouping, char_type __sep,
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.108
diff -c -p -r1.108 locale_facets.tcc
*** include/bits/locale_facets.tcc 16 Jul 2003 16:12:45 -0000 1.108
--- include/bits/locale_facets.tcc 16 Jul 2003 21:30:56 -0000
*************** namespace std
*** 122,156 ****
}
};
- // Stage 1: Determine a conversion specifier.
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
_M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, string& __xtrc) const
{
! typedef char_traits<_CharT> __traits_type;
! const locale __loc = __io.getloc();
! const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
! const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
// First check for sign.
- const char_type __plus = __ctype.widen('+');
- const char_type __minus = __ctype.widen('-');
int __pos = 0;
char_type __c = *__beg;
! if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
&& __beg != __end)
{
! __xtrc += __ctype.narrow(__c, char());
++__pos;
__c = *(++__beg);
}
// Next, strip leading zeros.
- const char_type __zero = __ctype.widen(_S_atoms_in[_S_izero]);
bool __found_zero = false;
! while (__traits_type::eq(__c, __zero) && __beg != __end)
{
__c = *(++__beg);
__found_zero = true;
--- 122,155 ----
}
};
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
_M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, string& __xtrc) const
{
! typedef char_traits<_CharT> __traits_type;
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
! __use_cache<__cache_type> __uc;
! const locale& __loc = __io._M_getloc();
! const __cache_type* __lc = __uc(__loc);
! const _CharT* __lit = __lc->_M_atoms_in;
// First check for sign.
int __pos = 0;
char_type __c = *__beg;
! bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
! if ((__plus || __traits_type::eq(__c, __lit[_S_iminus]))
&& __beg != __end)
{
! __xtrc += __plus ? _S_atoms_in[_S_iplus] : _S_atoms_in[_S_iminus];
++__pos;
__c = *(++__beg);
}
// Next, strip leading zeros.
bool __found_zero = false;
! while (__traits_type::eq(__c, __lit[_S_izero]) && __beg != __end)
{
__c = *(++__beg);
__found_zero = true;
*************** namespace std
*** 162,196 ****
}
// Only need acceptable digits for floating point numbers.
- const size_t __len = _S_iE - _S_izero + 1;
- char_type __watoms[__len];
- __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
bool __found_dec = false;
bool __found_sci = false;
- const char_type __dec = __np.decimal_point();
-
string __found_grouping;
! const string __grouping = __np.grouping();
! bool __check_grouping = __grouping.size();
int __sep_pos = 0;
! const char_type __sep = __np.thousands_sep();
!
while (__beg != __end)
{
// Only look in digits.
! const char_type* __p = __traits_type::find(__watoms, 10, __c);
// NB: strchr returns true for __c == 0x0
if (__p && !__traits_type::eq(__c, char_type()))
{
// Try first for acceptable digit; record it if found.
++__pos;
! __xtrc += _S_atoms_in[__p - __watoms];
++__sep_pos;
__c = *(++__beg);
}
! else if (__traits_type::eq(__c, __sep)
! && __check_grouping && !__found_dec)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
--- 161,189 ----
}
// Only need acceptable digits for floating point numbers.
bool __found_dec = false;
bool __found_sci = false;
string __found_grouping;
! const size_t __len = _S_iE - _S_izero + 1;
int __sep_pos = 0;
! bool __e;
while (__beg != __end)
{
// Only look in digits.
! const char_type* __p = __traits_type::find(__lit + _S_izero, 10,
! __c);
// NB: strchr returns true for __c == 0x0
if (__p && !__traits_type::eq(__c, char_type()))
{
// Try first for acceptable digit; record it if found.
++__pos;
! __xtrc += _S_atoms_in[__p - __lit];
++__sep_pos;
__c = *(++__beg);
}
! else if (__traits_type::eq(__c, __lc->_M_thousands_sep)
! && __lc->_M_use_grouping && !__found_dec)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
*************** namespace std
*** 206,212 ****
break;
}
}
! else if (__traits_type::eq(__c, __dec) && !__found_dec)
{
// According to the standard, if no grouping chars are seen,
// no grouping check is applied. Therefore __found_grouping
--- 199,206 ----
break;
}
}
! else if (__traits_type::eq(__c, __lc->_M_decimal_point)
! && !__found_dec)
{
// According to the standard, if no grouping chars are seen,
// no grouping check is applied. Therefore __found_grouping
*************** namespace std
*** 218,238 ****
__c = *(++__beg);
__found_dec = true;
}
! else if ((__traits_type::eq(__c, __watoms[_S_ie])
! || __traits_type::eq(__c, __watoms[_S_iE]))
&& !__found_sci && __pos)
{
// Scientific notation.
++__pos;
! __xtrc += __ctype.narrow(__c, char());
__c = *(++__beg);
// Remove optional plus or minus sign, if they exist.
! if (__traits_type::eq(__c, __plus)
! || __traits_type::eq(__c, __minus))
{
++__pos;
! __xtrc += __ctype.narrow(__c, char());
__c = *(++__beg);
}
__found_sci = true;
--- 212,233 ----
__c = *(++__beg);
__found_dec = true;
}
! else if ((__e = __traits_type::eq(__c, __lit[_S_ie])
! || __traits_type::eq(__c, __lit[_S_iE]))
&& !__found_sci && __pos)
{
// Scientific notation.
++__pos;
! __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE];
__c = *(++__beg);
// Remove optional plus or minus sign, if they exist.
! bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
! if (__plus || __traits_type::eq(__c, __lit[_S_iminus]))
{
++__pos;
! __xtrc += __plus ? _S_atoms_in[_S_iplus]
! : _S_atoms_in[_S_iminus];
__c = *(++__beg);
}
__found_sci = true;
*************** namespace std
*** 244,276 ****
// Digit grouping is checked. If grouping and found_grouping don't
// match, then get very very upset, and set failbit.
! if (__check_grouping && __found_grouping.size())
{
// Add the ending grouping if a decimal wasn't found.
if (!__found_dec)
__found_grouping += static_cast<char>(__sep_pos);
if (!std::__verify_grouping(__grouping, __found_grouping))
__err |= ios_base::failbit;
}
! // Finish up
__xtrc += char();
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
- // Stage 1: Determine a conversion specifier.
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
_M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, string& __xtrc, int& __base) const
{
! typedef char_traits<_CharT> __traits_type;
! const locale __loc = __io.getloc();
! const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
! const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
// NB: Iff __basefield == 0, this can change based on contents.
ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
--- 239,274 ----
// Digit grouping is checked. If grouping and found_grouping don't
// match, then get very very upset, and set failbit.
! if (__lc->_M_use_grouping && __found_grouping.size())
{
// Add the ending grouping if a decimal wasn't found.
if (!__found_dec)
__found_grouping += static_cast<char>(__sep_pos);
+
+ const string __grouping = __lc->_M_grouping;
if (!std::__verify_grouping(__grouping, __found_grouping))
__err |= ios_base::failbit;
}
! // Finish up.
__xtrc += char();
if (__beg == __end)
__err |= ios_base::eofbit;
return __beg;
}
template<typename _CharT, typename _InIter>
_InIter
num_get<_CharT, _InIter>::
_M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
ios_base::iostate& __err, string& __xtrc, int& __base) const
{
! typedef char_traits<_CharT> __traits_type;
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
! __use_cache<__cache_type> __uc;
! const locale& __loc = __io._M_getloc();
! const __cache_type* __lc = __uc(__loc);
! const _CharT* __lit = __lc->_M_atoms_in;
// NB: Iff __basefield == 0, this can change based on contents.
ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
*************** namespace std
*** 284,308 ****
// First check for sign.
int __pos = 0;
char_type __c = *__beg;
! const char_type __plus = __ctype.widen('+');
! const char_type __minus = __ctype.widen('-');
!
! if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
&& __beg != __end)
{
! __xtrc += __ctype.narrow(__c, char());
++__pos;
__c = *(++__beg);
}
// Next, strip leading zeros and check required digits for base formats.
- const char_type __zero = __ctype.widen(_S_atoms_in[_S_izero]);
- const char_type __x = __ctype.widen('x');
- const char_type __X = __ctype.widen('X');
if (__base == 10)
{
bool __found_zero = false;
! while (__traits_type::eq(__c, __zero) && __beg != __end)
{
__c = *(++__beg);
__found_zero = true;
--- 282,301 ----
// First check for sign.
int __pos = 0;
char_type __c = *__beg;
! const bool __plus = __traits_type::eq(__c, __lit[_S_iplus]);
! if ((__plus || __traits_type::eq(__c, __lit[_S_iminus]))
&& __beg != __end)
{
! __xtrc += __plus ? _S_atoms_in[_S_iplus] : _S_atoms_in[_S_iminus];
++__pos;
__c = *(++__beg);
}
// Next, strip leading zeros and check required digits for base formats.
if (__base == 10)
{
bool __found_zero = false;
! while (__traits_type::eq(__c, __lit[_S_izero]) && __beg != __end)
{
__c = *(++__beg);
__found_zero = true;
*************** namespace std
*** 313,323 ****
++__pos;
if (__basefield == 0)
{
! if ((__traits_type::eq(__c, __x)
! || __traits_type::eq(__c, __X))
! && __beg != __end)
{
! __xtrc += __ctype.narrow(__c, char());
++__pos;
__c = *(++__beg);
__base = 16;
--- 306,316 ----
++__pos;
if (__basefield == 0)
{
! const bool __x = __traits_type::eq(__c, __lit[_S_ix]);
! const bool __X = __traits_type::eq(__c, __lit[_S_iX]);
! if ((__x || __X) && __beg != __end)
{
! __xtrc += __x ? _S_atoms_in[_S_ix] : _S_atoms_in[_S_iX];
++__pos;
__c = *(++__beg);
__base = 16;
*************** namespace std
*** 329,343 ****
}
else if (__base == 16)
{
! if (__traits_type::eq(__c, __zero) && __beg != __end)
{
__xtrc += _S_atoms_in[_S_izero];
++__pos;
__c = *(++__beg);
! if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
! && __beg != __end)
{
! __xtrc += __ctype.narrow(__c, char());
++__pos;
__c = *(++__beg);
}
--- 322,338 ----
}
else if (__base == 16)
{
! if (__traits_type::eq(__c, __lit[_S_izero]) && __beg != __end)
{
__xtrc += _S_atoms_in[_S_izero];
++__pos;
__c = *(++__beg);
!
! const bool __x = __traits_type::eq(__c, __lit[_S_ix]);
! const bool __X = __traits_type::eq(__c, __lit[_S_iX]);
! if ((__x || __X) && __beg != __end)
{
! __xtrc += __x ? _S_atoms_in[_S_ix] : _S_atoms_in[_S_iX];
++__pos;
__c = *(++__beg);
}
*************** namespace std
*** 353,379 ****
__len = __base;
// Extract.
- char_type __watoms[_S_iend];
- __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
string __found_grouping;
! const string __grouping = __np.grouping();
! bool __check_grouping = __grouping.size();
int __sep_pos = 0;
- const char_type __sep = __np.thousands_sep();
while (__beg != __end)
{
! const char_type* __p = __traits_type::find(__watoms, __len, __c);
// NB: strchr returns true for __c == 0x0
if (__p && !__traits_type::eq(__c, char_type()))
{
// Try first for acceptable digit; record it if found.
! __xtrc += _S_atoms_in[__p - __watoms];
++__pos;
++__sep_pos;
__c = *(++__beg);
}
! else if (__traits_type::eq(__c, __sep) && __check_grouping)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
--- 348,371 ----
__len = __base;
// Extract.
string __found_grouping;
! const char_type __sep = __lc->_M_thousands_sep;
int __sep_pos = 0;
while (__beg != __end)
{
! const char_type* __p = __traits_type::find(__lit + _S_izero,
! __len, __c);
// NB: strchr returns true for __c == 0x0
if (__p && !__traits_type::eq(__c, char_type()))
{
// Try first for acceptable digit; record it if found.
! __xtrc += _S_atoms_in[__p - __lit];
++__pos;
++__sep_pos;
__c = *(++__beg);
}
! else if (__traits_type::eq(__c, __sep) && __lc->_M_use_grouping)
{
// NB: Thousands separator at the beginning of a string
// is a no-no, as is two consecutive thousands separators.
*************** namespace std
*** 396,405 ****
// Digit grouping is checked. If grouping and found_grouping don't
// match, then get very very upset, and set failbit.
! if (__check_grouping && __found_grouping.size())
{
// Add the ending grouping.
__found_grouping += static_cast<char>(__sep_pos);
if (!std::__verify_grouping(__grouping, __found_grouping))
__err |= ios_base::failbit;
}
--- 388,399 ----
// Digit grouping is checked. If grouping and found_grouping don't
// match, then get very very upset, and set failbit.
! if (__lc->_M_use_grouping && __found_grouping.size())
{
// Add the ending grouping.
__found_grouping += static_cast<char>(__sep_pos);
+
+ const string __grouping = __lc->_M_grouping;
if (!std::__verify_grouping(__grouping, __found_grouping))
__err |= ios_base::failbit;
}
*************** namespace std
*** 419,427 ****
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, bool& __v) const
{
- // Parse bool values as unsigned long
if (!(__io.flags() & ios_base::boolalpha))
{
// NB: We can't just call do_get(long) here, as it might
// refer to a derived class.
string __xtrc;
--- 413,421 ----
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, bool& __v) const
{
if (!(__io.flags() & ios_base::boolalpha))
{
+ // Parse bool values as unsigned long.
// NB: We can't just call do_get(long) here, as it might
// refer to a derived class.
string __xtrc;
*************** namespace std
*** 429,474 ****
__beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
unsigned long __ul;
! std::__convert_to_v(__xtrc.c_str(), __ul, __err, _S_c_locale, __base);
if (!(__err & ios_base::failbit) && __ul <= 1)
__v = __ul;
else
__err |= ios_base::failbit;
}
-
- // Parse bool values as alphanumeric
else
{
typedef char_traits<_CharT> __traits_type;
! typedef basic_string<_CharT> __string_type;
!
! locale __loc = __io.getloc();
! const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
! const __string_type __true = __np.truename();
! const __string_type __false = __np.falsename();
! const char_type* __trues = __true.c_str();
! const char_type* __falses = __false.c_str();
! const size_t __truen = __true.size() - 1;
! const size_t __falsen = __false.size() - 1;
for (size_t __n = 0; __beg != __end; ++__n)
{
char_type __c = *__beg++;
! bool __testf = __n <= __falsen
! ? __traits_type::eq(__c, __falses[__n]) : false;
! bool __testt = __n <= __truen
! ? __traits_type::eq(__c, __trues[__n]) : false;
if (!(__testf || __testt))
{
__err |= ios_base::failbit;
break;
}
! else if (__testf && __n == __falsen)
{
__v = 0;
break;
}
! else if (__testt && __n == __truen)
{
__v = 1;
break;
--- 423,469 ----
__beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
unsigned long __ul;
! std::__convert_to_v(__xtrc.c_str(), __ul, __err,
! _S_c_locale, __base);
if (!(__err & ios_base::failbit) && __ul <= 1)
__v = __ul;
else
__err |= ios_base::failbit;
}
else
{
+ // Parse bool values as alphanumeric.
typedef char_traits<_CharT> __traits_type;
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
! __use_cache<__cache_type> __uc;
! const locale& __loc = __io._M_getloc();
! const __cache_type* __lc = __uc(__loc);
! const size_t __tn = __traits_type::length(__lc->_M_truename) - 1;
! const size_t __fn = __traits_type::length(__lc->_M_falsename) - 1;
+ bool __testf = false;
+ bool __testt = false;
for (size_t __n = 0; __beg != __end; ++__n)
{
char_type __c = *__beg++;
!
! if (__n <= __fn)
! __testf = __traits_type::eq(__c, __lc->_M_falsename[__n]);
!
! if (__n <= __tn)
! __testt = __traits_type::eq(__c, __lc->_M_truename[__n]);
!
if (!(__testf || __testt))
{
__err |= ios_base::failbit;
break;
}
! else if (__testf && __n == __fn)
{
__v = 0;
break;
}
! else if (__testt && __n == __tn)
{
__v = 1;
break;
*************** namespace std
*** 618,624 ****
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, void*& __v) const
{
! // Prepare for hex formatted input
typedef ios_base::fmtflags fmtflags;
fmtflags __fmt = __io.flags();
fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
--- 613,619 ----
do_get(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, void*& __v) const
{
! // Prepare for hex formatted input.
typedef ios_base::fmtflags fmtflags;
fmtflags __fmt = __io.flags();
fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield
*************** namespace std
*** 629,635 ****
int __base;
__beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
! // Reset from hex formatted input
__io.flags(__fmt);
unsigned long __ul;
--- 624,630 ----
int __base;
__beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
! // Reset from hex formatted input.
__io.flags(__fmt);
unsigned long __ul;
*************** namespace std
*** 660,666 ****
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{
unsigned long __ul = static_cast<unsigned long>(__v);
bool __neg = false;
--- 655,661 ----
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{
unsigned long __ul = static_cast<unsigned long>(__v);
bool __neg = false;
*************** namespace std
*** 675,688 ****
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, unsigned long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{ return __int_to_char(__out, __size, __v, __lit, __flags, false); }
#ifdef _GLIBCXX_USE_LONG_LONG
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, long long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{
unsigned long long __ull = static_cast<unsigned long long>(__v);
bool __neg = false;
--- 670,683 ----
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, unsigned long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{ return __int_to_char(__out, __size, __v, __lit, __flags, false); }
#ifdef _GLIBCXX_USE_LONG_LONG
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, long long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{
unsigned long long __ull = static_cast<unsigned long long>(__v);
bool __neg = false;
*************** namespace std
*** 697,703 ****
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, unsigned long long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{ return __int_to_char(__out, __size, __v, __lit, __flags, false); }
#endif
--- 692,698 ----
template<typename _CharT>
inline int
__int_to_char(_CharT* __out, const int __size, unsigned long long __v,
! const _CharT* __lit, ios_base::fmtflags __flags)
{ return __int_to_char(__out, __size, __v, __lit, __flags, false); }
#endif
*************** namespace std
*** 790,799 ****
*(__new + 1) = *(__cs + 1);
}
_CharT* __p;
! __p = std::__add_grouping(__new + __off, __sep,
! __grouping.c_str(),
! __grouping.c_str() + __grouping.size(),
! __cs + __off, __cs + __len);
__len = __p - __new;
}
--- 785,793 ----
*(__new + 1) = *(__cs + 1);
}
_CharT* __p;
! __p = std::__add_grouping(__new + __off, __sep, __grouping.c_str(),
! __grouping.c_str() + __grouping.size(),
! __cs + __off, __cs + __len);
__len = __p - __new;
}
*************** namespace std
*** 801,810 ****
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
! _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
--- 795,804 ----
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
! _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
*************** namespace std
*** 861,868 ****
// Add grouping, if necessary.
_CharT* __p2;
int __declen = __p ? __p - __cs : __len;
! __p2 = std::__add_grouping(__new, __sep,
! __grouping.c_str(),
__grouping.c_str() + __grouping.size(),
__cs, __cs + __declen);
--- 855,861 ----
// Add grouping, if necessary.
_CharT* __p2;
int __declen = __p ? __p - __cs : __len;
! __p2 = std::__add_grouping(__new, __sep, __grouping.c_str(),
__grouping.c_str() + __grouping.size(),
__cs, __cs + __declen);
*************** namespace std
*** 891,899 ****
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
! _M_convert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
// Note: digits10 is rounded down: add 1 to ensure the maximum
// available precision. Then, in general, one more 1 needs to
// be added since, when the %{g,G} conversion specifiers are
--- 884,897 ----
template<typename _ValueT>
_OutIter
num_put<_CharT, _OutIter>::
! _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
+ typedef typename numpunct<_CharT>::__cache_type __cache_type;
+ __use_cache<__cache_type> __uc;
+ const locale& __loc = __io._M_getloc();
+ const __cache_type* __lc = __uc(__loc);
+
// Note: digits10 is rounded down: add 1 to ensure the maximum
// available precision. Then, in general, one more 1 needs to
// be added since, when the %{g,G} conversion specifiers are
*************** namespace std
*** 910,920 ****
else if (__prec < static_cast<streamsize>(0))
__prec = static_cast<streamsize>(6);
- typedef typename numpunct<_CharT>::__cache_type __cache_type;
- __use_cache<__cache_type> __uc;
- const locale& __loc = __io._M_getloc();
- const __cache_type* __lc = __uc(__loc);
-
// [22.2.2.2.2] Stage 1, numeric conversion to character.
int __len;
// Long enough for the max format spec.
--- 908,913 ----
*************** namespace std
*** 943,948 ****
--- 936,942 ----
const bool __fixed = __io.flags() & ios_base::fixed;
const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
+ // The size of the output string is computed as follows.
// ios_base::fixed outputs may need up to __max_exp+1 chars
// for the integer part + up to __max_digits chars for the
// fractional part + 3 chars for sign, decimal point, '\0'. On
*************** namespace std
*** 953,959 ****
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
_S_format_float(__io, __fbuf, __mod);
! __len = std::__convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale, __prec);
#endif
// [22.2.2.2.2] Stage 2, convert to char_type, using correct
--- 947,954 ----
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
_S_format_float(__io, __fbuf, __mod);
! __len = std::__convert_from_v(__cs, 0, __fbuf, __v,
! _S_c_locale, __prec);
#endif
// [22.2.2.2.2] Stage 2, convert to char_type, using correct
*************** namespace std
*** 1009,1043 ****
if ((__flags & ios_base::boolalpha) == 0)
{
unsigned long __uv = __v;
! __s = _M_convert_int(__s, __io, __fill, __uv);
}
else
{
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
! typedef basic_string<_CharT> __string_type;
! __string_type __name;
if (__v)
__name = __lc->_M_truename;
else
__name = __lc->_M_falsename;
! const _CharT* __cs = __name.c_str();
! int __len = __name.size();
! _CharT* __cs3;
streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
! __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
! _M_pad(__fill, __w, __io, __cs3, __cs, __len);
! __cs = __cs3;
}
__io.width(0);
! __s = std::__write(__s, __cs, __len);
}
return __s;
}
--- 1004,1036 ----
if ((__flags & ios_base::boolalpha) == 0)
{
unsigned long __uv = __v;
! __s = _M_insert_int(__s, __io, __fill, __uv);
}
else
{
! typedef typename numpunct<_CharT>::__cache_type __cache_type;
__use_cache<__cache_type> __uc;
const locale& __loc = __io._M_getloc();
const __cache_type* __lc = __uc(__loc);
! const _CharT* __name;
if (__v)
__name = __lc->_M_truename;
else
__name = __lc->_M_falsename;
+ int __len = char_traits<_CharT>::length(__name);
! _CharT* __cs;
streamsize __w = __io.width();
if (__w > static_cast<streamsize>(__len))
{
! __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
! _M_pad(__fill, __w, __io, __cs, __name, __len);
! __name = __cs;
}
__io.width(0);
! __s = std::__write(__s, __name, __len);
}
return __s;
}
*************** namespace std
*** 1046,1087 ****
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
! { return _M_convert_int(__s, __io, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long __v) const
! { return _M_convert_int(__s, __io, __fill, __v); }
#ifdef _GLIBCXX_USE_LONG_LONG
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
! { return _M_convert_int(__s, __b, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long long __v) const
! { return _M_convert_int(__s, __io, __fill, __v); }
#endif
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
! { return _M_convert_float(__s, __io, __fill, char(), __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
long double __v) const
! { return _M_convert_float(__s, __io, __fill, 'L', __v); }
template<typename _CharT, typename _OutIter>
_OutIter
--- 1039,1080 ----
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
! { return _M_insert_int(__s, __io, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long __v) const
! { return _M_insert_int(__s, __io, __fill, __v); }
#ifdef _GLIBCXX_USE_LONG_LONG
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
! { return _M_insert_int(__s, __b, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long long __v) const
! { return _M_insert_int(__s, __io, __fill, __v); }
#endif
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
! { return _M_insert_float(__s, __io, __fill, char(), __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
long double __v) const
! { return _M_insert_float(__s, __io, __fill, 'L', __v); }
template<typename _CharT, typename _OutIter>
_OutIter
*************** namespace std
*** 1095,1102 ****
__io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
try
{
! __s = _M_convert_int(__s, __io, __fill,
! reinterpret_cast<unsigned long>(__v));
__io.flags(__flags);
}
catch (...)
--- 1088,1095 ----
__io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
try
{
! __s = _M_insert_int(__s, __io, __fill,
! reinterpret_cast<unsigned long>(__v));
__io.flags(__flags);
}
catch (...)
*************** namespace std
*** 2223,2229 ****
// Pad after the sign, if there is one.
// Pad after 0[xX], if there is one.
// Who came up with these rules, anyway? Jeeze.
! locale __loc = __io.getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const _CharT __minus = __ctype.widen('-');
const _CharT __plus = __ctype.widen('+');
--- 2216,2222 ----
// Pad after the sign, if there is one.
// Pad after 0[xX], if there is one.
// Who came up with these rules, anyway? Jeeze.
! const locale& __loc = __io._M_getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
const _CharT __minus = __ctype.widen('-');
const _CharT __plus = __ctype.widen('+');
*************** namespace std
*** 2268,2275 ****
__end = const_cast<_CharT*>(__olds);
}
_Traits::copy(__news, __beg, __beglen);
! _Traits::copy(__news + __beglen, __end,
! __newlen - __beglen - __mod);
}
template<typename _CharT>
--- 2261,2267 ----
__end = const_cast<_CharT*>(__olds);
}
_Traits::copy(__news, __beg, __beglen);
! _Traits::copy(__news + __beglen, __end, __newlen - __beglen - __mod);
}
template<typename _CharT>
*************** namespace std
*** 2277,2286 ****
__verify_grouping(const basic_string<_CharT>& __grouping,
basic_string<_CharT>& __grouping_tmp)
{
! int __i = 0;
! int __j = 0;
! const int __len = __grouping.size();
! const int __n = __grouping_tmp.size();
bool __test = true;
// Parsed number groupings have to match the
--- 2269,2278 ----
__verify_grouping(const basic_string<_CharT>& __grouping,
basic_string<_CharT>& __grouping_tmp)
{
! size_t __i = 0;
! size_t __j = 0;
! const size_t __len = __grouping.size();
! const size_t __n = __grouping_tmp.size();
bool __test = true;
// Parsed number groupings have to match the
Index: src/locale-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale-inst.cc,v
retrieving revision 1.40
diff -c -p -r1.40 locale-inst.cc
*** src/locale-inst.cc 5 Jul 2003 04:05:42 -0000 1.40
--- src/locale-inst.cc 16 Jul 2003 21:30:57 -0000
*************** namespace std
*** 64,103 ****
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
! long) const;
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
! unsigned long) const;
#ifdef _GLIBCXX_USE_LONG_LONG
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
! long long) const;
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
! unsigned long long) const;
#endif
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char,
! double) const;
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char,
! long double) const;
#ifdef _GLIBCXX_USE_WCHAR_T
template class numpunct<wchar_t>;
--- 64,103 ----
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_insert_int(ostreambuf_iterator<char>, ios_base&, char,
! long) const;
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_insert_int(ostreambuf_iterator<char>, ios_base&, char,
! unsigned long) const;
#ifdef _GLIBCXX_USE_LONG_LONG
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_insert_int(ostreambuf_iterator<char>, ios_base&, char,
! long long) const;
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_insert_int(ostreambuf_iterator<char>, ios_base&, char,
! unsigned long long) const;
#endif
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_insert_float(ostreambuf_iterator<char>, ios_base&, char, char,
! double) const;
template
ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >::
! _M_insert_float(ostreambuf_iterator<char>, ios_base&, char, char,
! long double) const;
#ifdef _GLIBCXX_USE_WCHAR_T
template class numpunct<wchar_t>;
*************** namespace std
*** 109,148 ****
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! long) const;
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! unsigned long) const;
#ifdef _GLIBCXX_USE_LONG_LONG
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! long long) const;
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! unsigned long long) const;
#endif
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_convert_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char,
! double) const;
!
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_convert_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char,
! long double) const;
#endif
// time_get and time_put
--- 109,148 ----
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_insert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! long) const;
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_insert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! unsigned long) const;
#ifdef _GLIBCXX_USE_LONG_LONG
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_insert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! long long) const;
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_insert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
! unsigned long long) const;
#endif
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_insert_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char,
! double) const;
!
template
ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
! _M_insert_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char,
! long double) const;
#endif
// time_get and time_put
Index: src/locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v
retrieving revision 1.90
diff -c -p -r1.90 locale.cc
*** src/locale.cc 14 Jul 2003 20:14:49 -0000 1.90
--- src/locale.cc 16 Jul 2003 21:30:57 -0000
*************** namespace std
*** 475,481 ****
const money_base::pattern
money_base::_S_default_pattern = { {symbol, sign, none, value} };
! const char* __num_base::_S_atoms_in = "0123456789eEabcdfABCDF";
const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
// _GLIBCXX_RESOLVE_LIB_DEFECTS
--- 475,481 ----
const money_base::pattern
money_base::_S_default_pattern = { {symbol, sign, none, value} };
! const char* __num_base::_S_atoms_in = "-+xX0123456789eEabcdfABCDF";
const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
// _GLIBCXX_RESOLVE_LIB_DEFECTS
More information about the Gcc-patches
mailing list