]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/13369 (__verify_grouping (and __add_grouping?) not correct)
authorPaolo Carlini <pcarlini@suse.de>
Thu, 29 Jan 2004 02:52:24 +0000 (02:52 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 29 Jan 2004 02:52:24 +0000 (02:52 +0000)
2004-01-28  Paolo Carlini  <pcarlini@suse.de>

PR libstdc++/13369
* include/bits/locale_facets.tcc (__verify_grouping):
Fix to deal properly with __grouping_tmp.size() >
__grouping.size().

From-SVN: r76841

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

index 1f85f76701ba58d3b4c03791580b653b585d5634..a1caca77c1f43ab6a6d62f77fdc10dd2232d10d1 100644 (file)
@@ -1,3 +1,10 @@
+2004-01-28  Paolo Carlini  <pcarlini@suse.de>
+
+       PR libstdc++/13369
+       * include/bits/locale_facets.tcc (__verify_grouping):
+       Fix to deal properly with __grouping_tmp.size() >
+       __grouping.size().
+
 2004-01-29  Paolo Carlini  <pcarlini@suse.de>
 
        * Reverting Sylvain Pion's patch to libstdc++/10783, backported
index 7238e1907dcca50e2675c81edc98b3df59c6d506..3dec34ecdaa3f48e3d4378375f5997adc37bae5c 100644 (file)
@@ -2229,23 +2229,22 @@ namespace std
     bool
     __verify_grouping(const basic_string<_CharT>& __grouping, 
                      basic_string<_CharT>& __grouping_tmp)
-    {         
-      int __i = 0;
-      int __j = 0;
-      const int __len = __grouping.size();
-      const int __n = __grouping_tmp.size();
+    { 
+      const size_t __n = __grouping_tmp.size() - 1;
+      const size_t __min = std::min(__n, __grouping.size() - 1);
+      size_t __i = __n;
       bool __test = true;
-      
+
       // Parsed number groupings have to match the
       // numpunct::grouping string exactly, starting at the
       // right-most point of the parsed sequence of elements ...
-      while (__test && __i < __n - 1)
-       for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j,++__i)
-         __test &= __grouping[__j] == __grouping_tmp[__n - __i - 1];
+      for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
+       __test = __grouping_tmp[__i] == __grouping[__j];
+      for (; __i && __test; --__i)
+       __test = __grouping_tmp[__i] == __grouping[__min];
       // ... but the last parsed grouping can be <= numpunct
       // grouping.
-      __j == __len ? __j = 0 : __j;
-      __test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
+      __test &= __grouping_tmp[0] <= __grouping[__min];
       return __test;
     }