From: Paolo Carlini Date: Thu, 29 Jan 2004 02:52:24 +0000 (+0000) Subject: re PR libstdc++/13369 (__verify_grouping (and __add_grouping?) not correct) X-Git-Tag: releases/gcc-3.3.3~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=708332c370b343ff2a1d00994aad437ec7c8a351;p=thirdparty%2Fgcc.git re PR libstdc++/13369 (__verify_grouping (and __add_grouping?) not correct) 2004-01-28 Paolo Carlini PR libstdc++/13369 * include/bits/locale_facets.tcc (__verify_grouping): Fix to deal properly with __grouping_tmp.size() > __grouping.size(). From-SVN: r76841 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1f85f76701ba..a1caca77c1f4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2004-01-28 Paolo Carlini + + 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 * Reverting Sylvain Pion's patch to libstdc++/10783, backported diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 7238e1907dcc..3dec34ecdaa3 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -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; }