diff options
author | Paolo Carlini <pcarlini@suse.de> | 2003-10-29 12:21:58 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2003-10-29 12:21:58 +0000 |
commit | 6bf0b59cbfea56724632a81aa5a0623e2e6d3297 (patch) | |
tree | f1f39a67b8a640ad13cab7f25e359a43456d9fd6 | |
parent | 9c9081ae918ff0873d692348b88b00d83ab0f509 (diff) | |
download | gcc-6bf0b59cbfea56724632a81aa5a0623e2e6d3297.zip gcc-6bf0b59cbfea56724632a81aa5a0623e2e6d3297.tar.gz gcc-6bf0b59cbfea56724632a81aa5a0623e2e6d3297.tar.bz2 |
locale_facets.tcc (time_put::put): Absolutely avoid dereferencing end iterators; clean up.
2003-10-29 Paolo Carlini <pcarlini@suse.de>
* include/bits/locale_facets.tcc (time_put::put): Absolutely
avoid dereferencing end iterators; clean up.
* include/bits/locale_facets.tcc (num_get::_M_extract_float,
num_get::_M_extract_int): Minor tweak.
From-SVN: r73035
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/locale_facets.tcc | 33 |
2 files changed, 24 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f5b6c79..264136d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2003-10-29 Paolo Carlini <pcarlini@suse.de> + * include/bits/locale_facets.tcc (time_put::put): Absolutely + avoid dereferencing end iterators; clean up. + + * include/bits/locale_facets.tcc (num_get::_M_extract_float, + num_get::_M_extract_int): Minor tweak. + +2003-10-29 Paolo Carlini <pcarlini@suse.de> + * include/bits/locale_facets.tcc: Remove some unnecessary includes. * config/locale/generic/c_locale.cc: Include <cerrno> here. diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 6e1760d..681a4c3 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -219,10 +219,9 @@ namespace std { // Scientific notation. __xtrc += __e ? _S_atoms_in[_S_ie] : _S_atoms_in[_S_iE]; - ++__beg; // Remove optional plus or minus sign, if they exist. - if (__beg != __end) + if (++__beg != __end) { const bool __plus = __traits_type::eq(*__beg, __lit[_S_iplus]); if (__plus || __traits_type::eq(*__beg, __lit[_S_iminus])) @@ -327,9 +326,8 @@ namespace std if (__beg != __end && __traits_type::eq(*__beg, __lit[_S_izero])) { __xtrc += _S_atoms_in[_S_izero]; - ++__beg; - if (__beg != __end) + if (++__beg != __end) { const bool __x = __traits_type::eq(*__beg, __lit[_S_ix]); if (__x || __traits_type::eq(*__beg, __lit[_S_iX])) @@ -1995,31 +1993,32 @@ namespace std { const locale __loc = __io.getloc(); ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc); - while (__beg != __end) + for (; __beg != __end; ++__beg) { - const _CharT __tmp = *__beg; - ++__beg; - if (__ctype.narrow(__tmp, 0) == '%' && __beg != __end) + if (__ctype.narrow(*__beg, 0) != '%') + { + *__s = *__beg; + ++__s; + } + else if (++__beg != __end) { char __format; char __mod = 0; const char __c = __ctype.narrow(*__beg, 0); - ++__beg; - if (__c == 'E' || __c == 'O') + if (__c != 'E' && __c != 'O') + __format = __c; + else if (++__beg != __end) { __mod = __c; __format = __ctype.narrow(*__beg, 0); - ++__beg; } else - __format = __c; - __s = this->do_put(__s, __io, __fill, __tm, __format, __mod); + break; + __s = this->do_put(__s, __io, __fill, __tm, + __format, __mod); } else - { - *__s = __tmp; - ++__s; - } + break; } return __s; } |