summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-02-27 10:12:01 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-02-27 10:12:01 +0000
commit3ceb660caff72246cbb55f77b76a148d21f13e1c (patch)
tree573d60da293db9dc5e30cf1961f83d9bf0d701bc /libstdc++-v3
parenta49a878ff6716082594ee19b7a9aa083afb0b272 (diff)
downloadppe42-gcc-3ceb660caff72246cbb55f77b76a148d21f13e1c.tar.gz
ppe42-gcc-3ceb660caff72246cbb55f77b76a148d21f13e1c.zip
2004-02-27 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.h (money_get<>::_M_extract): Change signature: now takes a plain string&. * include/bits/locale_facets.tcc (money_get<>::_M_extract): Update consistently the definition; use the moneypunct cache to parse the value; use swap to change __units. (money_get<>::do_get(long double&)): Update call of _M_extract, avoid ctype::narrow, not correct wrt the standard. (money_get<>::do_get(string_type&)): Likewise, update call of _M_extract, use ctype::widen. * src/locale-inst.cc: Tweak instantiations of _M_extract. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78562 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog13
-rw-r--r--libstdc++-v3/include/bits/locale_facets.h2
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc56
-rw-r--r--libstdc++-v3/src/locale-inst.cc4
4 files changed, 53 insertions, 22 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 00f73289110..4fbf39cc57b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,16 @@
+2004-02-27 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/locale_facets.h (money_get<>::_M_extract):
+ Change signature: now takes a plain string&.
+ * include/bits/locale_facets.tcc (money_get<>::_M_extract):
+ Update consistently the definition; use the moneypunct cache
+ to parse the value; use swap to change __units.
+ (money_get<>::do_get(long double&)): Update call of _M_extract,
+ avoid ctype::narrow, not correct wrt the standard.
+ (money_get<>::do_get(string_type&)): Likewise, update call
+ of _M_extract, use ctype::widen.
+ * src/locale-inst.cc: Tweak instantiations of _M_extract.
+
2004-02-26 Ian Lance Taylor <ian@wasabisystems.com>
* testsuite/demangle/abi_examples/01.cc: Expect error -2.
diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h
index e4735a82c8b..cd725f52ad1 100644
--- a/libstdc++-v3/include/bits/locale_facets.h
+++ b/libstdc++-v3/include/bits/locale_facets.h
@@ -4128,7 +4128,7 @@ namespace std
template<bool _Intl>
iter_type
_M_extract(iter_type __s, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, string_type& __digits) const;
+ ios_base::iostate& __err, string& __digits) const;
};
template<typename _CharT, typename _InIter>
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index c9e1e7f1ec5..b5bd407bdce 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -1163,8 +1163,9 @@ namespace std
_InIter
money_get<_CharT, _InIter>::
_M_extract(iter_type __beg, iter_type __end, ios_base& __io,
- ios_base::iostate& __err, string_type& __units) const
+ ios_base::iostate& __err, string& __units) const
{
+ typedef char_traits<_CharT> __traits_type;
typedef typename string_type::size_type size_type;
typedef money_base::part part;
typedef moneypunct<_CharT, _Intl> __moneypunct_type;
@@ -1193,12 +1194,13 @@ namespace std
bool __testdecfound = false;
// The tentative returned string is stored here.
- string_type __res;
- __res.reserve(20);
+ string __res;
+ __res.reserve(32);
+ const char_type* __lit_zero = __lit + _S_zero;
+ const char_type* __q;
for (int __i = 0; __beg != __end && __i < 4 && __testvalid; ++__i)
{
- char_type __c;
const part __which = static_cast<part>(__p.field[__i]);
switch (__which)
{
@@ -1257,12 +1259,12 @@ namespace std
// Extract digits, remove and stash away the
// grouping of found thousands separators.
for (; __beg != __end; ++__beg)
- if (__ctype.is(ctype_base::digit, __c = *__beg))
+ if (__q = __traits_type::find(__lit_zero, 10, *__beg))
{
- __res += __c;
+ __res += _S_atoms[__q - __lit];
++__sep_pos;
}
- else if (__c == __lc->_M_decimal_point && !__testdecfound)
+ else if (*__beg == __lc->_M_decimal_point && !__testdecfound)
{
// If no grouping chars are seen, no grouping check
// is applied. Therefore __grouping_tmp is adjusted
@@ -1272,7 +1274,7 @@ namespace std
__sep_pos = 0;
__testdecfound = true;
}
- else if (__c == __lc->_M_thousands_sep && !__testdecfound)
+ else if (*__beg == __lc->_M_thousands_sep && !__testdecfound)
{
if (__lc->_M_grouping_size)
{
@@ -1358,7 +1360,7 @@ namespace std
if (!__testvalid)
__err |= ios_base::failbit;
else
- __units.assign(__res.data(), __res.size());
+ __units.swap(__res);
return __beg;
}
@@ -1369,19 +1371,15 @@ namespace std
do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, long double& __units) const
{
- string_type __str;
+ string __str;
if (__intl)
__beg = _M_extract<true>(__beg, __end, __io, __err, __str);
else
__beg = _M_extract<false>(__beg, __end, __io, __err, __str);
- const int __cs_size = __str.size() + 1;
- char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- const locale __loc = __io.getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- const _CharT* __wcs = __str.c_str();
- __ctype.narrow(__wcs, __wcs + __cs_size, char(), __cs);
- std::__convert_to_v(__cs, __units, __err, _S_get_c_locale());
+ if (__str.size())
+ std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
+
return __beg;
}
@@ -1390,8 +1388,28 @@ namespace std
money_get<_CharT, _InIter>::
do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
ios_base::iostate& __err, string_type& __units) const
- { return __intl ? _M_extract<true>(__beg, __end, __io, __err, __units)
- : _M_extract<false>(__beg, __end, __io, __err, __units); }
+ {
+ typedef typename string_type::size_type size_type;
+
+ const locale& __loc = __io._M_getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+
+ string __str;
+ const iter_type __ret = __intl ? _M_extract<true>(__beg, __end, __io,
+ __err, __str)
+ : _M_extract<false>(__beg, __end, __io,
+ __err, __str);
+ const size_type __len = __str.size();
+ if (__len)
+ {
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ __ctype.widen(__str.data(), __str.data() + __len, __ws);
+ __units.assign(__ws, __len);
+ }
+
+ return __ret;
+ }
template<typename _CharT, typename _OutIter>
template<bool _Intl>
diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc
index 030b630f612..3aeb55366f9 100644
--- a/libstdc++-v3/src/locale-inst.cc
+++ b/libstdc++-v3/src/locale-inst.cc
@@ -54,13 +54,13 @@ namespace std
istreambuf_iterator<C>
money_get<C, istreambuf_iterator<C> >::
_M_extract<true>(istreambuf_iterator<C>, istreambuf_iterator<C>,
- ios_base&, ios_base::iostate&, string_type&) const;
+ ios_base&, ios_base::iostate&, string&) const;
template
istreambuf_iterator<C>
money_get<C, istreambuf_iterator<C> >::
_M_extract<false>(istreambuf_iterator<C>, istreambuf_iterator<C>,
- ios_base&, ios_base::iostate&, string_type&) const;
+ ios_base&, ios_base::iostate&, string&) const;
template
ostreambuf_iterator<C>
OpenPOWER on IntegriCloud