aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-06-14 10:49:36 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-06-14 10:49:36 +0000
commitce2a46a203b146e4cf3ebc23ea5de2dba3b4917f (patch)
tree5d8566d75eac68ad234ef33b527b79800c71a59a
parent93ae5495f56f08b888269b8fcf175cc7df8f1322 (diff)
downloadgcc-ce2a46a203b146e4cf3ebc23ea5de2dba3b4917f.zip
gcc-ce2a46a203b146e4cf3ebc23ea5de2dba3b4917f.tar.gz
gcc-ce2a46a203b146e4cf3ebc23ea5de2dba3b4917f.tar.bz2
locale_facets.tcc (time_get<>::_M_extract_name): Don't use the 'magic number' 10 in the computation of __minlen...
2004-06-14 Paolo Carlini <pcarlini@suse.de> * include/bits/locale_facets.tcc (time_get<>::_M_extract_name): Don't use the 'magic number' 10 in the computation of __minlen; never access __name past __minlen; in the loop over __i3, don't decrease __nmatches and increase __i3 at once, only either of the two; tidy. From-SVN: r83088
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc31
2 files changed, 21 insertions, 18 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 1454a0d..899ce98 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2004-06-14 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/locale_facets.tcc (time_get<>::_M_extract_name):
+ Don't use the 'magic number' 10 in the computation of __minlen;
+ never access __name past __minlen; in the loop over __i3, don't
+ decrease __nmatches and increase __i3 at once, only either of
+ the two; tidy.
+
2004-06-13 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (time_get<>::do_get_time,
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index c732e09..0c181cf 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -2002,35 +2002,30 @@ namespace std
while (__nmatches > 1)
{
// Find smallest matching string.
- size_t __minlen = 10;
- for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
+ size_t __minlen = __traits_type::length(__names[__matches[0]]);
+ for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
__minlen = std::min(__minlen,
__traits_type::length(__names[__matches[__i2]]));
+ ++__pos;
++__beg;
if (__pos < __minlen && __beg != __end)
- {
- ++__pos;
- for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
- {
- __name = __names[__matches[__i3]];
- if (__name[__pos] != *__beg)
- __matches[__i3] = __matches[--__nmatches];
- }
- }
+ for (size_t __i3 = 0; __i3 < __nmatches;)
+ {
+ __name = __names[__matches[__i3]];
+ if (__name[__pos] != *__beg)
+ __matches[__i3] = __matches[--__nmatches];
+ else
+ ++__i3;
+ }
else
break;
}
if (__nmatches == 1)
{
- // If there was only one match, the first compare is redundant.
- if (__pos == 0)
- {
- ++__pos;
- ++__beg;
- }
-
// Make sure found name is completely extracted.
+ ++__pos;
+ ++__beg;
__name = __names[__matches[0]];
const size_t __len = __traits_type::length(__name);
while (__pos < __len && __beg != __end && __name[__pos] == *__beg)