This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
diffs for locale_facet files
- To: Benjamin Kosnik <bkoz@cygnus.com>
- Subject: diffs for locale_facet files
- From: Russell Davidson <russell@ehess.cnrs-mrs.fr>
- Date: Thu, 12 Aug 1999 17:52:37 +0200 (CEST)
- cc: libstdc++@sourceware.cygnus.com
Hi Benjamin,
Thanks for your notes, and sorry that I was not up to date enough in my
diffs. Here are two diffs, one for locale_facets.h, the other for
locale_facets.tcc. I tried to do it using cvs diff, but there have been
enough changes since last Sunday that the diff was full of unnecessary
stuff. This is just the diff for what I did last weekend. If this is still
not enough, tell me and I'll try to follow instructions: cvs is still very
new to me.
First, for locale_facets.h:
*** locale_facets.h.save Sun Aug 8 20:27:59 1999
--- locale_facets.h Sun Aug 8 20:37:20 1999
*************** namespace std
*** 939,945 ****
// functions. NB: this is specialized for char.
void
_M_extract(iter_type __beg, iter_type __end, ios_base& __io,
! ios_base::iostate& __err, char* __xtrc, int& __base) const;
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
--- 939,945 ----
// functions. NB: this is specialized for char.
void
_M_extract(iter_type __beg, iter_type __end, ios_base& __io,
! ios_base::iostate& __err, char* __xtrc, int& __base, bool fl = true) const;
virtual iter_type
do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
*************** namespace std
*** 993,1000 ****
void
num_get<char, istreambuf_iterator<char> >::
_M_extract(istreambuf_iterator<char> __beg,
! istreambuf_iterator<char> __end, ios_base& __io,
! ios_base::iostate& __err, char* __xtrc, int& __base) const;
// _Numeric_put is used by num_put, money_put, and time_put
// to help in formatting out numbers.
--- 993,1000 ----
void
num_get<char, istreambuf_iterator<char> >::
_M_extract(istreambuf_iterator<char> __beg,
! istreambuf_iterator<char> __end, ios_base& __io,
! ios_base::iostate& __err, char* __xtrc, int& __base, bool fl) const;
// _Numeric_put is used by num_put, money_put, and time_put
// to help in formatting out numbers.
**************************************************************************
and then, for locale_facets.tcc:
**************************************************************************
*** locale_facets.tcc.save Mon Aug 9 17:51:02 1999
--- locale_facets.tcc.new Mon Aug 9 18:01:17 1999
*************** namespace std
*** 289,294 ****
--- 289,296 ----
istreambuf_iterator<char> __end, ios_base& __io,
ios_base::iostate& __err, char* __xtrc, int& __base) const
{
+ typedef _Format_cache<char> __format_type;
+
// Stage 1: determine a conversion specifier.
ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
if (__basefield == ios_base::oct)
*************** namespace std
*** 310,334 ****
{
__valid = false;
char __c = *__beg;
! if (strchr(__fmt->_S_literals, __c))
! {
! __xtrc[__pos] = __c;
! ++__pos;
! __valid = true;
! }
else if (__c == __fmt->_M_thousands_sep)
{
if (__fmt->_M_use_grouping)
__grp += static_cast<char>(__i);
__valid = true;
}
! else if (__c == __fmt->_M_decimal_point)
! {
! __xtrc[__pos] = '.';
! ++__pos;
! __valid = true;
! }
! }
__xtrc[__pos] = '\0';
if (__beg == __end)
__err |= ios_base::eofbit;
--- 312,351 ----
{
__valid = false;
char __c = *__beg;
! char* __p;
! const char* __lits = __fmt->_S_literals;
!
! if ((__p = strchr(__fmt->_S_literals, __c)))
! {
! if (!__c) break; // strchr returns true for __c == 0x0
! if ((__p >= &__lits[__format_type::_S_digits+__base]
! && __p < &__lits[__format_type::_S_digits_end]) ||
! (__p >= &__lits[__format_type::_S_udigits+__base]
! && __p < &__lits[__format_type::_S_udigits_end]))
! {
! if (!(fl && (__p == &__lits[__format_type::_S_ee] ||
! __p == &__lits[__format_type::_S_Ee]))) break;
! }
! __xtrc[__pos] = __c;
! ++__pos;
! __valid = true;
! }
else if (__c == __fmt->_M_thousands_sep)
{
if (__fmt->_M_use_grouping)
__grp += static_cast<char>(__i);
__valid = true;
}
!
! else if (__c == __fmt->_M_decimal_point)
! {
! if (!fl) break;
! __xtrc[__pos] = '.';
! ++__pos;
! __valid = true;
! }
! if (!__valid) break; // for otherwise we consume another character
! }
__xtrc[__pos] = '\0';
if (__beg == __end)
__err |= ios_base::eofbit;
*************** namespace std
*** 338,343 ****
--- 355,362 ----
if (__fmt->_M_use_grouping && __grp != __fmt->_M_grouping)
__err |= ios_base::failbit;
}
+
+
template<typename _CharT, typename _InIter>
_InIter
*************** namespace std
*** 449,468 ****
// integral types.
char __xtrc[32] = {'\0'};
int __base;
! _M_extract(__beg, __end, __io, __err, __xtrc, __base);
// Stage 2: convert and store results.
char* __sanity;
errno = 0;
long __vl = strtol(__xtrc, &__sanity, __base);
if (__sanity != __xtrc && *__sanity == '\0' && errno == 0
! && __vl >= INT_MIN && __vl <= INT_MAX)
! {
! __v = static_cast<int>(__vl);
! __err = ios_base::goodbit;
! }
else
! __err |= ios_base::failbit;
return __beg;
}
--- 468,488 ----
// integral types.
char __xtrc[32] = {'\0'};
int __base;
! // Call _M_extract with last argument false, for int
! _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);
// Stage 2: convert and store results.
char* __sanity;
errno = 0;
long __vl = strtol(__xtrc, &__sanity, __base);
if (__sanity != __xtrc && *__sanity == '\0' && errno == 0
! && __vl >= INT_MIN && __vl <= INT_MAX)
! {
! __v = static_cast<int>(__vl);
! __err = ios_base::goodbit;
! }
else
! __err |= ios_base::failbit;
return __beg;
}
Hope this does it.
Regards, Russell.
Russell Davidson email: russell@ehess.cnrs-mrs.fr
GREQAM,
Centre de la Vieille Charite, telephone: +33-4.91.14.07.40
F-13002 Marseille fax: +33-4.91.90.02.27