From 3978cc5adb34f3152f119d46f53e6e8e107158fa Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 24 Mar 2024 19:23:47 +0100 Subject: [PATCH] =?utf8?q?nstrtime,=20c-nstrftime:=20Fix=20%c=20directive'?= =?utf8?q?s=20result=20on=20glibc=20=E2=89=A4=202.30.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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. --- ChangeLog | 8 ++++++++ doc/posix-functions/strftime.texi | 2 +- lib/strftime.c | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) 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. */ -- 2.39.5