Commit 9d07d890 by Jonathan Wakely Committed by Jonathan Wakely

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
parent c168f180
2014-10-08 Jonathan Wakely <jwakely@redhat.com> 2014-10-08 Jonathan Wakely <jwakely@redhat.com>
* 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 <jwakely@redhat.com>
* include/bits/regex.h (regex_token_iterator::_M_end_of_seq): Add * include/bits/regex.h (regex_token_iterator::_M_end_of_seq): Add
const qualifier. const qualifier.
......
...@@ -988,20 +988,32 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL ...@@ -988,20 +988,32 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL
__num_base::_S_format_float(__io, __fbuf, __mod); __num_base::_S_format_float(__io, __fbuf, __mod);
#ifdef _GLIBCXX_USE_C99 #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 // First try a buffer perhaps big enough (most probably sufficient
// for non-ios_base::fixed outputs) // for non-ios_base::fixed outputs)
int __cs_size = __max_digits * 3; int __cs_size = __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size)); char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, if (__use_prec)
__fbuf, __prec, __v); __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 the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size) if (__len >= __cs_size)
{ {
__cs_size = __len + 1; __cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size)); __cs = static_cast<char*>(__builtin_alloca(__cs_size));
__len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, if (__use_prec)
__fbuf, __prec, __v); __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 #else
// Consider the possibility of long ios_base::fixed outputs // Consider the possibility of long ios_base::fixed outputs
......
...@@ -71,7 +71,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -71,7 +71,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
ios_base::fmtflags __fltfield = __flags & ios_base::floatfield; 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)) if (__fltfield != (ios_base::fixed | ios_base::scientific))
#endif
{ {
// As per DR 231: not only when __flags & ios_base::fixed || __prec > 0 // As per DR 231: not only when __flags & ios_base::fixed || __prec > 0
*__fptr++ = '.'; *__fptr++ = '.';
......
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