aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-07-31 09:00:09 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-07-31 09:00:09 +0000
commit2347da644d23390399cc060fe3f2358314efc1b6 (patch)
treec8321aab61f962489c31967acd6d221fec368d73
parentbdc6aa1b275833c791562e7baa42a41d3b7c3e64 (diff)
downloadgcc-2347da644d23390399cc060fe3f2358314efc1b6.zip
gcc-2347da644d23390399cc060fe3f2358314efc1b6.tar.gz
gcc-2347da644d23390399cc060fe3f2358314efc1b6.tar.bz2
locale_facets.tcc (num_get<>::_M_extract_float, [...]): In the main parsing loop delay the life of __q to the actual use point.
2004-07-30 Paolo Carlini <pcarlini@suse.de> * include/bits/locale_facets.tcc (num_get<>::_M_extract_float, num_get<>::_M_extract_int): In the main parsing loop delay the life of __q to the actual use point. From-SVN: r85380
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc137
2 files changed, 79 insertions, 64 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 4a2381a..f56c60f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2004-07-30 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/locale_facets.tcc (num_get<>::_M_extract_float,
+ num_get<>::_M_extract_int): In the main parsing loop delay the
+ life of __q to the actual use point.
+
2004-07-29 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/14220
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 94a2cb8..ee5ea7d 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -330,7 +330,6 @@ namespace std
// According to 22.2.2.1.2, p8-9, first look for thousands_sep
// and decimal_point.
const char_type __c = *__beg;
- const char_type* __q = __traits_type::find(__lit_zero, 10, __c);
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
{
if (!__found_dec && !__found_sci)
@@ -368,40 +367,44 @@ namespace std
else
break;
}
- else if (__q != 0)
+ else
{
- __xtrc += __num_base::_S_atoms_in[__q - __lit];
- __found_mantissa = true;
- ++__sep_pos;
- ++__beg;
- }
- else if ((__c == __lit[__num_base::_S_ie]
- || __c == __lit[__num_base::_S_iE])
- && __found_mantissa && !__found_sci)
- {
- // Scientific notation.
- if (__found_grouping.size() && !__found_dec)
- __found_grouping += static_cast<char>(__sep_pos);
- __xtrc += 'e';
- __found_sci = true;
-
- // Remove optional plus or minus sign, if they exist.
- if (++__beg != __end)
+ const char_type* __q = __traits_type::find(__lit_zero, 10, __c);
+ if (__q)
{
- const bool __plus = *__beg == __lit[__num_base::_S_iplus];
- if ((__plus || *__beg == __lit[__num_base::_S_iminus])
- && !(__lc->_M_use_grouping
- && *__beg == __lc->_M_thousands_sep)
- && !(*__beg == __lc->_M_decimal_point))
+ __xtrc += __num_base::_S_atoms_in[__q - __lit];
+ __found_mantissa = true;
+ ++__sep_pos;
+ ++__beg;
+ }
+ else if ((__c == __lit[__num_base::_S_ie]
+ || __c == __lit[__num_base::_S_iE])
+ && __found_mantissa && !__found_sci)
+ {
+ // Scientific notation.
+ if (__found_grouping.size() && !__found_dec)
+ __found_grouping += static_cast<char>(__sep_pos);
+ __xtrc += 'e';
+ __found_sci = true;
+
+ // Remove optional plus or minus sign, if they exist.
+ if (++__beg != __end)
{
- __xtrc += __plus ? '+' : '-';
- ++__beg;
+ const bool __plus = *__beg == __lit[__num_base::_S_iplus];
+ if ((__plus || *__beg == __lit[__num_base::_S_iminus])
+ && !(__lc->_M_use_grouping
+ && *__beg == __lc->_M_thousands_sep)
+ && !(*__beg == __lc->_M_decimal_point))
+ {
+ __xtrc += __plus ? '+' : '-';
+ ++__beg;
+ }
}
}
+ else
+ // Not a valid input item.
+ break;
}
- else
- // Not a valid input item.
- break;
}
// Digit grouping is checked. If grouping and found_grouping don't
@@ -516,8 +519,6 @@ namespace std
// According to 22.2.2.1.2, p8-9, first look for thousands_sep
// and decimal_point.
const char_type __c = *__beg;
- const char_type* __q = __traits_type::find(__lit_zero,
- __len, __c);
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
{
// NB: Thousands separator at the beginning of a string
@@ -535,26 +536,31 @@ namespace std
}
else if (__c == __lc->_M_decimal_point)
break;
- else if (__q != 0)
+ else
{
- int __digit = __q - __lit_zero;
- if (__digit > 15)
- __digit -= 6;
- if (__result < __min)
- __overflow = true;
- else
+ const char_type* __q = __traits_type::find(__lit_zero,
+ __len, __c);
+ if (__q)
{
- const _ValueT __new_result = __result * __base
- - __digit;
- __overflow |= __new_result > __result;
- __result = __new_result;
- ++__sep_pos;
- __found_num = true;
+ int __digit = __q - __lit_zero;
+ if (__digit > 15)
+ __digit -= 6;
+ if (__result < __min)
+ __overflow = true;
+ else
+ {
+ const _ValueT __new_result = (__result * __base
+ - __digit);
+ __overflow |= __new_result > __result;
+ __result = __new_result;
+ ++__sep_pos;
+ __found_num = true;
+ }
}
+ else
+ // Not a valid input item.
+ break;
}
- else
- // Not a valid input item.
- break;
}
}
else
@@ -563,8 +569,6 @@ namespace std
for (; __beg != __end; ++__beg)
{
const char_type __c = *__beg;
- const char_type* __q = __traits_type::find(__lit_zero,
- __len, __c);
if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
{
if (__sep_pos)
@@ -580,25 +584,30 @@ namespace std
}
else if (__c == __lc->_M_decimal_point)
break;
- else if (__q != 0)
+ else
{
- int __digit = __q - __lit_zero;
- if (__digit > 15)
- __digit -= 6;
- if (__result > __max)
- __overflow = true;
- else
+ const char_type* __q = __traits_type::find(__lit_zero,
+ __len, __c);
+ if (__q)
{
- const _ValueT __new_result = __result * __base
- + __digit;
- __overflow |= __new_result < __result;
- __result = __new_result;
- ++__sep_pos;
- __found_num = true;
+ int __digit = __q - __lit_zero;
+ if (__digit > 15)
+ __digit -= 6;
+ if (__result > __max)
+ __overflow = true;
+ else
+ {
+ const _ValueT __new_result = (__result * __base
+ + __digit);
+ __overflow |= __new_result < __result;
+ __result = __new_result;
+ ++__sep_pos;
+ __found_num = true;
+ }
}
+ else
+ break;
}
- else
- break;
}
}