From: Bruno Haible Date: Sun, 24 Mar 2024 18:23:47 +0000 (+0100) Subject: nstrtime, c-nstrftime: Fix %c directive's result on glibc ≤ 2.30. X-Git-Tag: v1.0~237 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3978cc5adb34f3152f119d46f53e6e8e107158fa;p=gnulib.git nstrtime, c-nstrftime: Fix %c directive's result on glibc ≤ 2.30. * lib/strftime.c (__strftime_internal): On glibc ≤ 2.30, like on NetBSD and Solaris, remove the last word of the %c directive's result if it looks like a time zone. * doc/posix-functions/strftime.texi: Update platforms list. --- diff --git a/ChangeLog b/ChangeLog index 305da4bbbf..6953c94fe2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-03-24 Bruno Haible + + nstrtime, c-nstrftime: Fix %c directive's result on glibc ≤ 2.30. + * lib/strftime.c (__strftime_internal): On glibc ≤ 2.30, like on NetBSD + and Solaris, remove the last word of the %c directive's result if it + looks like a time zone. + * doc/posix-functions/strftime.texi: Update platforms list. + 2024-03-24 Bruno Haible gnulib-tool.py: Fix output of notices. diff --git a/doc/posix-functions/strftime.texi b/doc/posix-functions/strftime.texi index 1edd08e7f0..4bbfbabec7 100644 --- a/doc/posix-functions/strftime.texi +++ b/doc/posix-functions/strftime.texi @@ -19,7 +19,7 @@ Portability problems not fixed by Gnulib: The %c specifier does not work with a time retrieved through @code{gmtime} or @code{gmtime_r}, since it outputs also the current time zone, on some platforms: -NetBSD 9.3, Solaris 11.4. +glibc 2.30, NetBSD 9.3, Solaris 11.4. @item The %r specifier produces empty output, at least in a French locale, on some platforms: diff --git a/lib/strftime.c b/lib/strftime.c index 128176cad4..684d910771 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1336,7 +1336,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) # endif if (len != 0) { -# if defined __NetBSD__ || defined __sun /* NetBSD, Solaris */ +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 31) || defined __NetBSD__ || defined __sun /* glibc < 2.31, NetBSD, Solaris */ if (format_char == L_('c')) { /* The output of the strftime %c directive consists of the @@ -1374,7 +1374,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) } } } -# if REQUIRE_GNUISH_STRFTIME_AM_PM +# if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM /* The output of the strftime %p and %r directives contains an AM/PM indicator even for locales where it is not suitable, such as French. Remove this indicator. */