From: Bruno Haible Date: Sat, 12 May 2018 17:58:49 +0000 (+0200) Subject: libintl: Ensure the *printf function overrides are POSIX compatible. X-Git-Tag: v0.20~408 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3742239a2c237a4991429cf6bdd150289c178b72;p=thirdparty%2Fgettext.git libintl: Ensure the *printf function overrides are POSIX compatible. Reported by Eli Zaretskii . * gettext-runtime/intl/printf.c (USE_REPLACEMENT_CODE_ALWAYS): New macro. (libintl_vfprintf, libintl_vsprintf, libintl_vsnprintf, libintl_vfwprintf, libintl_vswprintf): Use it. * NEWS: Mention the change. --- diff --git a/NEWS b/NEWS index 7e59f2eaf..46edd51c3 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,12 @@ xgettext can now extract strings from .rsj files, produced by the Free Pascal compiler version 3.0.0 or newer. +* Runtime behaviour: + The replacements for the printf()/fprintf()/... functions that are + provided through on native Windows and NetBSD are now POSIX + compliant. There is no conflict any more between these replacements + and other possible replacements provided by gnulib or mingw. + Version 0.19.8 - June 2016 * Support for reproducible builds: diff --git a/gettext-runtime/intl/printf.c b/gettext-runtime/intl/printf.c index 5f657a65a..a0641ebfd 100644 --- a/gettext-runtime/intl/printf.c +++ b/gettext-runtime/intl/printf.c @@ -91,13 +91,21 @@ char *alloca (); #include "asnprintf.c" #endif +/* Users don't expect libintl_fprintf to be less POSIX compliant + than the fprintf implementation provided by gnulib or - on mingw - + the one provided by mingw libs when __USE_MINGW_ANSI_STDIO is in + effect. */ +#define USE_REPLACEMENT_CODE_ALWAYS 1 + DLL_EXPORTED int libintl_vfprintf (FILE *stream, const char *format, va_list args) { +#if !USE_REPLACEMENT_CODE_ALWAYS if (strchr (format, '$') == NULL) return vfprintf (stream, format, args); else +#endif { size_t length; char *result = libintl_vasnprintf (NULL, &length, format, args); @@ -155,9 +163,11 @@ DLL_EXPORTED int libintl_vsprintf (char *resultbuf, const char *format, va_list args) { +#if !USE_REPLACEMENT_CODE_ALWAYS if (strchr (format, '$') == NULL) return vsprintf (resultbuf, format, args); else +#endif { size_t length = (size_t) ~0 / (4 * sizeof (char)); char *result = libintl_vasnprintf (resultbuf, &length, format, args); @@ -208,9 +218,11 @@ DLL_EXPORTED int libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args) { +# if !USE_REPLACEMENT_CODE_ALWAYS if (strchr (format, '$') == NULL) return system_vsnprintf (resultbuf, length, format, args); else +# endif { size_t maxlength = length; char *result = libintl_vasnprintf (resultbuf, &length, format, args); @@ -322,9 +334,11 @@ DLL_EXPORTED int libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args) { +# if !USE_REPLACEMENT_CODE_ALWAYS if (wcschr (format, '$') == NULL) return vfwprintf (stream, format, args); else +# endif { size_t length; wchar_t *result = libintl_vasnwprintf (NULL, &length, format, args); @@ -385,9 +399,11 @@ DLL_EXPORTED int libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_list args) { +# if !USE_REPLACEMENT_CODE_ALWAYS if (wcschr (format, '$') == NULL) return system_vswprintf (resultbuf, length, format, args); else +# endif { size_t maxlength = length; wchar_t *result = libintl_vasnwprintf (resultbuf, &length, format, args);