From: Johannes Schindelin Date: Sat, 25 Jun 2022 20:32:49 +0000 (+0200) Subject: intl: On native Windows, actually define the *wprintf functions. X-Git-Tag: v0.21.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6e5c00c6a9b07c405e37d6fd5491802a1d04e32;p=thirdparty%2Fgettext.git intl: On native Windows, actually define the *wprintf functions. 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 [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. --- diff --git a/gettext-runtime/intl/printf.c b/gettext-runtime/intl/printf.c index 7c07ed759..b84daf073 100644 --- a/gettext-runtime/intl/printf.c +++ b/gettext-runtime/intl/printf.c @@ -1,5 +1,5 @@ /* Formatted output to strings, using POSIX/XSI format strings with positions. - Copyright (C) 2003, 2006-2007, 2009-2011, 2018, 2020 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2011, 2018, 2020-2022 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -303,7 +303,7 @@ libintl_asprintf (char **resultp, const char *format, ...) #endif -#if HAVE_FWPRINTF +#if HAVE_WPRINTF #include