]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libintl: Ensure the *printf function overrides are POSIX compatible.
authorBruno Haible <bruno@clisp.org>
Sat, 12 May 2018 17:58:49 +0000 (19:58 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 12 May 2018 18:28:13 +0000 (20:28 +0200)
Reported by Eli Zaretskii <eliz@gnu.org>.

* 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.

NEWS
gettext-runtime/intl/printf.c

diff --git a/NEWS b/NEWS
index 7e59f2eaf8c8b9e29ff5246d9038e32a6db0daf1..46edd51c3b6daa63c688ba18c8549550ff40f269 100644 (file)
--- a/NEWS
+++ b/NEWS
     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 <libintl.h> 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:
index 5f657a65a749e6c20085927b90a93eab98de23fa..a0641ebfd49eab599e4990e0fe51e052a6148a29 100644 (file)
@@ -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);