diff options
Diffstat (limited to 'contrib/libstdc++/include/bits/locale_facets.tcc')
-rw-r--r-- | contrib/libstdc++/include/bits/locale_facets.tcc | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/contrib/libstdc++/include/bits/locale_facets.tcc b/contrib/libstdc++/include/bits/locale_facets.tcc index f0f5e3a..4f65844 100644 --- a/contrib/libstdc++/include/bits/locale_facets.tcc +++ b/contrib/libstdc++/include/bits/locale_facets.tcc @@ -1151,8 +1151,8 @@ namespace std const ios_base::fmtflags __flags = __io.flags(); if ((__flags & ios_base::boolalpha) == 0) { - unsigned long __uv = __v; - __s = _M_insert_int(__s, __io, __fill, __uv); + const long __l = __v; + __s = _M_insert_int(__s, __io, __fill, __l); } else { @@ -1229,8 +1229,7 @@ namespace std const void* __v) const { const ios_base::fmtflags __flags = __io.flags(); - const ios_base::fmtflags __fmt = ~(ios_base::showpos - | ios_base::basefield + const ios_base::fmtflags __fmt = ~(ios_base::basefield | ios_base::uppercase | ios_base::internal); __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase)); @@ -1674,22 +1673,22 @@ namespace std char* __cs = static_cast<char*>(__builtin_alloca(__cs_size)); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 328. Bad sprintf format modifier in money_put<>::do_put() - int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units, - _S_get_c_locale()); + int __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units, + _S_get_c_locale(), 0); // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { __cs_size = __len + 1; __cs = static_cast<char*>(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units, - _S_get_c_locale()); + __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units, + _S_get_c_locale(), 0); } #else // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'. const int __cs_size = numeric_limits<long double>::max_exponent10 + 3; char* __cs = static_cast<char*>(__builtin_alloca(__cs_size)); - int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units, - _S_get_c_locale()); + int __len = std::__convert_from_v(__cs, 0, "%.*Lf", __units, + _S_get_c_locale(), 0); #endif _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __cs_size)); @@ -1837,8 +1836,13 @@ namespace std __tm, __wcs); break; case 'S': - // Seconds. - __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2, + // Seconds. [tm_sec] + // [00, 60] in C99 (one leap-second), [00, 61] in C89. +#ifdef _GLIBCXX_USE_C99 + __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2, +#else + __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2, +#endif __io, __err); break; case 't': @@ -1998,8 +2002,7 @@ namespace std for (size_t __i2 = 1; __i2 < __nmatches; ++__i2) __minlen = std::min(__minlen, __traits_type::length(__names[__matches[__i2]])); - ++__pos; - ++__beg; + ++__beg, ++__pos; if (__pos < __minlen && __beg != __end) for (size_t __i3 = 0; __i3 < __nmatches;) { @@ -2016,8 +2019,7 @@ namespace std if (__nmatches == 1) { // Make sure found name is completely extracted. - ++__pos; - ++__beg; + ++__beg, ++__pos; __name = __names[__matches[0]]; const size_t __len = __traits_type::length(__name); while (__pos < __len && __beg != __end && __name[__pos] == *__beg) @@ -2090,7 +2092,7 @@ namespace std // __days array with the same index points to a day, and that // day's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err) + if (!__err && __beg != __end) { size_t __pos = __traits_type::length(__days[__tmpwday]); __tp._M_days(__days); @@ -2105,9 +2107,10 @@ namespace std if (__len != __pos) __err |= ios_base::failbit; } - if (!__err) - __tm->tm_wday = __tmpwday; } + if (!__err) + __tm->tm_wday = __tmpwday; + if (__beg == __end) __err |= ios_base::eofbit; return __beg; @@ -2135,7 +2138,7 @@ namespace std // __months array with the same index points to a month, and that // month's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err) + if (!__err && __beg != __end) { size_t __pos = __traits_type::length(__months[__tmpmon]); __tp._M_months(__months); @@ -2150,9 +2153,9 @@ namespace std if (__len != __pos) __err |= ios_base::failbit; } - if (!__err) - __tm->tm_mon = __tmpmon; } + if (!__err) + __tm->tm_mon = __tmpmon; if (__beg == __end) __err |= ios_base::eofbit; @@ -2234,7 +2237,7 @@ namespace std // NB: This size is arbitrary. Should this be a data member, // initialized at construction? - const size_t __maxlen = 64; + const size_t __maxlen = 128; char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen)); |