From 1f3adac20cbb63ef83ddca5548b67a97bfb2c8ee Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 9 Dec 2003 20:02:58 +0000 Subject: [PATCH] locale_facets.tcc (num_get::_M_extract_int): Slightly streamline the code dealing with overflows and the parsing of the sign. 2003-12-09 Paolo Carlini * include/bits/locale_facets.tcc (num_get::_M_extract_int): Slightly streamline the code dealing with overflows and the parsing of the sign. From-SVN: r74476 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/bits/locale_facets.tcc | 16 +++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ba57e35b8e8..04c3b1a61ca 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2003-12-09 Paolo Carlini + + * include/bits/locale_facets.tcc (num_get::_M_extract_int): + Slightly streamline the code dealing with overflows and the + parsing of the sign. + 2003-12-09 Bernardo Innocenti * include/ext/algorithm, include/ext/debug_allocator.h, diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index efd7fd378d9..ae0a4e43616 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -283,9 +283,9 @@ namespace std bool __negative = false; if (__beg != __end) { - __negative = __traits_type::eq(*__beg, __lit[_S_iminus]); - if (__negative && numeric_limits<_ValueT>::is_signed - || __traits_type::eq(*__beg, __lit[_S_iplus])) + if (numeric_limits<_ValueT>::is_signed) + __negative = __traits_type::eq(*__beg, __lit[_S_iminus]); + if (__negative || __traits_type::eq(*__beg, __lit[_S_iplus])) ++__beg; } @@ -353,8 +353,7 @@ namespace std else { const _ValueT __new_result = __result * __base - __digit; - if (__result) - __overflow |= __new_result >= __result; + __overflow |= __new_result > __result; __result = __new_result; ++__sep_pos; __found_num = true; @@ -398,8 +397,7 @@ namespace std else { const _ValueT __new_result = __result * __base + __digit; - if (__result) - __overflow |= __new_result <= __result; + __overflow |= __new_result < __result; __result = __new_result; ++__sep_pos; __found_num = true; @@ -436,8 +434,8 @@ namespace std __err |= ios_base::failbit; } - if (!(__err & ios_base::failbit) - && !__overflow && __found_num) + if (!(__err & ios_base::failbit) && !__overflow + && __found_num) __v = __result; else __err |= ios_base::failbit;