Thanks, looks good except that Emacs attempts to be portable to platforms lacking <locale.h>. It's easy for nstrftime to support that, via the attached patch which I installed.
From 81b9310c9ec55de7d7e52c5d6fd0cff98bac2e28 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 5 Jun 2024 08:27:55 -0700
Subject: [PATCH] =?UTF-8?q?nstrftime:=20don=E2=80=99t=20assume=20<locale.h?=
 =?UTF-8?q?>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lib/strftime.c: Include <locale.h> only if needed, since Emacs
attempts to be portable to platforms lacking <locale.h> so it
avoids localename-unsafe-limited and defines
REQUIRE_GNUISH_STRFTIME_AM_PM to false.
---
 ChangeLog      |  8 ++++++++
 lib/strftime.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d04105378d..155fd88a05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-06-05  Paul Eggert  <egg...@cs.ucla.edu>
+
+	nstrftime: don’t assume <locale.h>
+	* lib/strftime.c: Include <locale.h> only if needed, since Emacs
+	attempts to be portable to platforms lacking <locale.h> so it
+	avoids localename-unsafe-limited and defines
+	REQUIRE_GNUISH_STRFTIME_AM_PM to false.
+
 2024-06-05  Bruno Haible  <br...@clisp.org>
 
 	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 <stdlib.h>
 #include <string.h>
 
-#include <locale.h>
+#if (((defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM) \
+     || (defined _WIN32 && !defined __CYGWIN__) \
+     || (USE_C_LOCALE && HAVE_STRFTIME_L))
+# include <locale.h>
+#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");
-- 
2.43.0

Reply via email to