locale_facets.tcc (num_get<>::_M_extract_float, [...]): In the main parsing loop...
authorPaolo Carlini <pcarlini@suse.de>
Sat, 31 Jul 2004 09:00:09 +0000 (09:00 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 31 Jul 2004 09:00:09 +0000 (09:00 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc

index 4a2381afe6969b4e31566ab5b3d6dbd5e26af368..f56c60f509311bf8508a253b7ce61a6a988b93f7 100644 (file)
@@ -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
index 94a2cb8d81d0a5a2723875a66ae1a8baf352c7b5..ee5ea7d1def6ec49d894b2b83e3fafccce509d45 100644 (file)
@@ -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;
              }
          }