]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: On native Windows, actually define the *wprintf functions.
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 25 Jun 2022 20:32:49 +0000 (22:32 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 25 Jun 2022 20:32:49 +0000 (22:32 +0200)
In dcaf8c4d7 (Cygwin portability., 2003-09-17), the *wprintf() family of
functions in `gettext-runtime/intl/printf.c` were no longer guarded by
the constant `HAVE_WPRINTF`, but instead by `HAVE_FWPRINTF`.

This apparently worked even if the corresponding part in
`gettext-runtime/intl/libgnuintl.h.in` uses `HAVE_WPRINTF` to guard the
declarations of those functions.

However, in d84f20745 (Make sure that libintl.h declares the *wprintf
overrides on Windows., 2019-04-08), gettext introduced a change where it
would look for `wprintf()` instead of `fwprintf()`. As a consequence it
would no longer define the `HAVE_FWPRINTF` constant at all.

GCC apparently interprets `#if HAVE_FWPRINTF` as `#if 0` if the constant
has not even been defined.

This leads to the funny situation that previously, the *wprintf()
functions would be defined, but not be declared. Whereas now the
functions are not defined, but declared.

Also funny: Cygwin did not even export the `fwprintf()` function until
2009, as per Cygwin's 45e20e47ba (cygwin.din: Export wprintf,
fwprintf, swprintf, vwprintf, vfwprintf, vswprintf. [...] , 2009-03-06),
while the `wprintf()` function was exported already in 2003. So the
Cygwin portability patch from 2003 seems to have turned off all of the
*wprintf() functions in gettext.

Let's revert that "portability" patch, as it now only does harm and has
no benefit anymore.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
[Bruno's summary]
Thank you for the analysis and explanation, Johannes!

The commits dcaf8c4d7 and f5ca7696d (2003-09-17) introduced a test for
fwprintf rather than wprintf. This was designed as a workaround to a
Cygwin problem that existed from 2003 to 2009.

The commit d84f20745 (2019-04-08) switched back from testing fwprintf
to testing wprintf, but did so incompletely: I forgot to modify printf.c.
So, since then, the *wprintf functions are declared but not defined.

gettext-runtime/intl/printf.c

index d327c5ebcef9e9fd730e19ea41cf984e285cfd86..8ff75e5125dc9bfc41494441755be03c90f8a60b 100644 (file)
@@ -1,5 +1,5 @@
 /* Formatted output to strings, using POSIX/XSI format strings with positions.
-   Copyright (C) 2003, 2006-2007, 2009-2011, 2018, 2020-2021 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006-2007, 2009-2011, 2018, 2020-2022 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -310,7 +310,7 @@ libintl_asprintf (char **resultp, const char *format, ...)
 
 #endif
 
-#if HAVE_FWPRINTF
+#if HAVE_WPRINTF
 
 #include <wchar.h>