From: Paul Eggert Date: Wed, 5 Jun 2024 15:27:55 +0000 (-0700) Subject: nstrftime: don’t assume X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=81b9310c9ec55de7d7e52c5d6fd0cff98bac2e28;p=gnulib.git nstrftime: don’t assume * lib/strftime.c: Include only if needed, since Emacs attempts to be portable to platforms lacking so it avoids localename-unsafe-limited and defines REQUIRE_GNUISH_STRFTIME_AM_PM to false. --- diff --git a/ChangeLog b/ChangeLog index d04105378d..155fd88a05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-05 Paul Eggert + + nstrftime: don’t assume + * lib/strftime.c: Include only if needed, since Emacs + attempts to be portable to platforms lacking so it + avoids localename-unsafe-limited and defines + REQUIRE_GNUISH_STRFTIME_AM_PM to false. + 2024-06-05 Bruno Haible nstrftime: Make %c work on native Windows again. diff --git a/lib/strftime.c b/lib/strftime.c index 19a2d73ebd..4441584121 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -92,7 +92,12 @@ extern char *tzname[]; #include #include -#include +#if (((defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM) \ + || (defined _WIN32 && !defined __CYGWIN__) \ + || (USE_C_LOCALE && HAVE_STRFTIME_L)) +# include +#endif + #if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM # include "localename.h" #elif defined _WIN32 && !defined __CYGWIN__ @@ -1727,7 +1732,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #elif USE_C_LOCALE && !HAVE_STRFTIME_L subfmt = L_("%I:%M:%S %p"); goto subformat; -#elif (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || (defined _WIN32 && !defined __CYGWIN__) +#elif ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ \ + || (defined _WIN32 && !defined __CYGWIN__)) /* macOS, FreeBSD, native Windows strftime() may produce empty output for "%r". */ subfmt = L_("%I:%M:%S %p");