From: Jonathan Wakely Date: Wed, 8 Oct 2014 13:25:30 +0000 (+0100) Subject: locale_facets.tcc (num_put::_M_insert_float): Do not pass precision when using hexflo... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d07d890e6542570950e1b0bbbb231fac3249774;p=gcc.git locale_facets.tcc (num_put::_M_insert_float): Do not pass precision when using hexfloat format. * include/bits/locale_facets.tcc (num_put::_M_insert_float): Do not pass precision when using hexfloat format. * src/c++98/locale_facets.cc (__num_base::_S_format_float): Always output precision if C99 hexfloat conversion specifiers not available. From-SVN: r216001 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ab082d2503c..da92622d7b9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2014-10-08 Jonathan Wakely + + * include/bits/locale_facets.tcc (num_put::_M_insert_float): Do not + pass precision when using hexfloat format. + * src/c++98/locale_facets.cc (__num_base::_S_format_float): Always + output precision if C99 hexfloat conversion specifiers not available. + 2014-10-08 Jonathan Wakely * include/bits/regex.h (regex_token_iterator::_M_end_of_seq): Add diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index cf12a084173..88adc0d9832 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -988,20 +988,32 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL __num_base::_S_format_float(__io, __fbuf, __mod); #ifdef _GLIBCXX_USE_C99 + // Precision is always used except for hexfloat format. + const bool __use_prec = + (__io.flags() & ios_base::floatfield) != ios_base::floatfield; + // First try a buffer perhaps big enough (most probably sufficient // for non-ios_base::fixed outputs) int __cs_size = __max_digits * 3; char* __cs = static_cast(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, - __fbuf, __prec, __v); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { __cs_size = __len + 1; __cs = static_cast(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, - __fbuf, __prec, __v); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); } #else // Consider the possibility of long ios_base::fixed outputs diff --git a/libstdc++-v3/src/c++98/locale_facets.cc b/libstdc++-v3/src/c++98/locale_facets.cc index 7ed04e613e2..b3ca5dc8c9d 100644 --- a/libstdc++-v3/src/c++98/locale_facets.cc +++ b/libstdc++-v3/src/c++98/locale_facets.cc @@ -71,7 +71,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ios_base::fmtflags __fltfield = __flags & ios_base::floatfield; +#ifdef _GLIBCXX_USE_C99 + // Precision is always used except for hexfloat format. if (__fltfield != (ios_base::fixed | ios_base::scientific)) +#endif { // As per DR 231: not only when __flags & ios_base::fixed || __prec > 0 *__fptr++ = '.';