]> Savannah Git Hosting - gnulib.git/commitdiff
nstrtime, c-nstrftime: Fix %c directive's result on glibc ≤ 2.30.
authorBruno Haible <bruno@clisp.org>
Sun, 24 Mar 2024 18:23:47 +0000 (19:23 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 24 Mar 2024 18:23:47 +0000 (19:23 +0100)
* 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
doc/posix-functions/strftime.texi
lib/strftime.c

index 305da4bbbf2e70a6c4e7e00305c4c60acb845758..6953c94fe204d4ff1548d6c88e3ffe2bc3bd2fb2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-03-24  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        gnulib-tool.py: Fix output of notices.
index 1edd08e7f05d5af024f38c54cd036ea6c091a98b..4bbfbabec72ddcb0746330dfe08563362a34d02d 100644 (file)
@@ -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:
index 128176cad40c9b93b4d7193ffcc21295d9616cd6..684d910771f758b63c265d6cfca5a5d0bdcaf080 100644 (file)
@@ -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.  */