From: Jonathan Wakely Date: Mon, 28 Jan 2019 23:58:57 +0000 (+0000) Subject: PR libstdc++/68737 Do not use vsnprintf on HPUX X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c98f255154798847bdd1fc6ce33266c1a1ddc13a;p=gcc.git PR libstdc++/68737 Do not use vsnprintf on HPUX It doesn't conform to the spec, so use vsprintf with a large buffer instead. PR libstdc++/68737 * config/locale/generic/c_locale.h (__convert_from_v) [_GLIBCXX_USE_C99_STDIO]: Also check _GLIBCXX_HAVE_BROKEN_VSNPRINTF. * config/os/hpux/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSNPRINTF. * include/bits/locale_facets.tcc (num_put::_M_insert_float) [_GLIBCXX_USE_C99_STDIO]: Also check _GLIBCXX_HAVE_BROKEN_VSNPRINTF. From-SVN: r268350 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7a1deca18cb..89b94a88cce 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2019-01-28 Jonathan Wakely + + PR libstdc++/68737 + * config/locale/generic/c_locale.h (__convert_from_v) + [_GLIBCXX_USE_C99_STDIO]: Also check _GLIBCXX_HAVE_BROKEN_VSNPRINTF. + * config/os/hpux/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSNPRINTF. + * include/bits/locale_facets.tcc (num_put::_M_insert_float) + [_GLIBCXX_USE_C99_STDIO]: Also check _GLIBCXX_HAVE_BROKEN_VSNPRINTF. + 2019-01-24 Jonathan Wakely PR libstdc++/88840 diff --git a/libstdc++-v3/config/locale/generic/c_locale.h b/libstdc++-v3/config/locale/generic/c_locale.h index 3b95a43160e..625a61c8bb2 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.h +++ b/libstdc++-v3/config/locale/generic/c_locale.h @@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __builtin_va_list __args; __builtin_va_start(__args, __fmt); -#if _GLIBCXX_USE_C99_STDIO +#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); #else const int __ret = __builtin_vsprintf(__out, __fmt, __args); diff --git a/libstdc++-v3/config/os/hpux/os_defines.h b/libstdc++-v3/config/os/hpux/os_defines.h index 04834b0cd0c..20a8b3ed30b 100644 --- a/libstdc++-v3/config/os/hpux/os_defines.h +++ b/libstdc++-v3/config/os/hpux/os_defines.h @@ -109,4 +109,9 @@ typedef long int __padding_type; #if defined (__hppa__) #define _GLIBCXX_HAVE_BROKEN_STRTOLD 1 #endif + +// The vnsprintf function returns -1 when the buffer is too small. +// See PR libstdc++/68737. +#define _GLIBCXX_HAVE_BROKEN_VSNPRINTF 1 + #endif diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index c387fdfdbfb..2eb8167db9a 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -992,7 +992,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL char __fbuf[16]; __num_base::_S_format_float(__io, __fbuf, __mod); -#if _GLIBCXX_USE_C99_STDIO +#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF // Precision is always used except for hexfloat format. const bool __use_prec = (__io.flags() & ios_base::floatfield) != ios_base::floatfield;