Commit ce2a46a2 by Paolo Carlini Committed by Paolo Carlini

locale_facets.tcc (time_get<>::_M_extract_name): Don't use the 'magic number' 10…

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
parent 93ae5495
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> 2004-06-13 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (time_get<>::do_get_time, * include/bits/locale_facets.tcc (time_get<>::do_get_time,
......
...@@ -2002,20 +2002,20 @@ namespace std ...@@ -2002,20 +2002,20 @@ namespace std
while (__nmatches > 1) while (__nmatches > 1)
{ {
// Find smallest matching string. // Find smallest matching string.
size_t __minlen = 10; size_t __minlen = __traits_type::length(__names[__matches[0]]);
for (size_t __i2 = 0; __i2 < __nmatches; ++__i2) for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
__minlen = std::min(__minlen, __minlen = std::min(__minlen,
__traits_type::length(__names[__matches[__i2]])); __traits_type::length(__names[__matches[__i2]]));
++__pos;
++__beg; ++__beg;
if (__pos < __minlen && __beg != __end) if (__pos < __minlen && __beg != __end)
{ for (size_t __i3 = 0; __i3 < __nmatches;)
++__pos;
for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
{ {
__name = __names[__matches[__i3]]; __name = __names[__matches[__i3]];
if (__name[__pos] != *__beg) if (__name[__pos] != *__beg)
__matches[__i3] = __matches[--__nmatches]; __matches[__i3] = __matches[--__nmatches];
} else
++__i3;
} }
else else
break; break;
...@@ -2023,14 +2023,9 @@ namespace std ...@@ -2023,14 +2023,9 @@ namespace std
if (__nmatches == 1) if (__nmatches == 1)
{ {
// If there was only one match, the first compare is redundant. // Make sure found name is completely extracted.
if (__pos == 0)
{
++__pos; ++__pos;
++__beg; ++__beg;
}
// Make sure found name is completely extracted.
__name = __names[__matches[0]]; __name = __names[__matches[0]];
const size_t __len = __traits_type::length(__name); const size_t __len = __traits_type::length(__name);
while (__pos < __len && __beg != __end && __name[__pos] == *__beg) while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment