This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Two minor issues with locale_facets
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 05 Dec 2003 11:34:12 +0100
- Subject: [Patch] Two minor issues with locale_facets
Hi,
noticed while working on the fast num_get::do_get for integer types two
minor things:
1- Keeping the S_atoms_in chars in the natural will make the
job *much* easier!
2- According to a strict interpretation of the standard, bool
values are parsed as long, not unsigned long (when !boolalpha).
Tested x86-linux, will commit later today if nobody objects...
Paolo.
//////////
2003-12-05 Paolo Carlini <pcarlini@suse.de>
* src/locale_facets.cc (__num_base::_S_atoms_in): Reorder
the chars in the natural order: abcdefABCDEF.
* include/bits/locale_facets.h (class __num_base): Tweak
_S_ie and _S_iE accordingly.
* include/bits/locale_facets.tcc (num_get::do_get(..., bool&):
According to the standard, if !boolapha the input proceeds as
it would be for a long (not an unsigned long, that is).
diff -urN libstdc++-v3-orig/include/bits/locale_facets.h libstdc++-v3/include/bits/locale_facets.h
--- libstdc++-v3-orig/include/bits/locale_facets.h 2003-11-26 12:47:01.000000000 +0100
+++ libstdc++-v3/include/bits/locale_facets.h 2003-12-05 10:47:08.000000000 +0100
@@ -586,7 +586,7 @@
static const char* _S_atoms_out;
// String literal of acceptable (narrow) input, for num_get.
- // "-+xX0123456789eEabcdfABCDF"
+ // "-+xX0123456789abcdefABCDEF"
static const char* _S_atoms_in;
enum
@@ -596,8 +596,8 @@
_S_ix,
_S_iX,
_S_izero,
- _S_ie = _S_izero + 10,
- _S_iE = _S_izero + 11,
+ _S_ie = _S_izero + 14,
+ _S_iE = _S_izero + 20,
_S_iend = 26
};
diff -urN libstdc++-v3-orig/include/bits/locale_facets.tcc libstdc++-v3/include/bits/locale_facets.tcc
--- libstdc++-v3-orig/include/bits/locale_facets.tcc 2003-12-03 10:17:20.000000000 +0100
+++ libstdc++-v3/include/bits/locale_facets.tcc 2003-12-05 11:11:37.000000000 +0100
@@ -414,12 +414,12 @@
int __base;
__beg = _M_extract_int(__beg, __end, __io, __err, __xtrc, __base);
- unsigned long __ul;
- std::__convert_to_v(__xtrc.c_str(), __ul, __err,
+ long __l;
+ std::__convert_to_v(__xtrc.c_str(), __l, __err,
_S_get_c_locale(), __base);
- if (!(__err & ios_base::failbit) && __ul <= 1)
- __v = __ul;
- else
+ if (!(__err & ios_base::failbit) && (__l == 0 || __l == 1))
+ __v = __l;
+ else
__err |= ios_base::failbit;
}
else
diff -urN libstdc++-v3-orig/src/locale_facets.cc libstdc++-v3/src/locale_facets.cc
--- libstdc++-v3-orig/src/locale_facets.cc 2003-10-17 16:47:30.000000000 +0200
+++ libstdc++-v3/src/locale_facets.cc 2003-12-05 10:47:28.000000000 +0100
@@ -53,7 +53,7 @@
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_in = "-+xX0123456789abcdefABCDEF";
const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
// _GLIBCXX_RESOLVE_LIB_DEFECTS