+2024-02-13 Paul Eggert <eggert@cs.ucla.edu>
+
+ nstrftime: allow opt-out of AM/PM adjustment
+ For Emacs I would rather avoid bringing in the Gnulib locking code,
+ since Emacs has its own idea about locks and its main engine is
+ single-threaded anyway.
+ Provide a way to use the nstrftime module while avoiding its
+ recently-added localename dependency, which entails locking code.
+ (It’s not clear to me that the locking code is needed for nstrftime,
+ as NetBSD has strftime_z and Solaris locales could be inspected in
+ some thread-safe way, e.g., by probing strftime month names.
+ Anyway, all that’s more hassle than I want to put up with right now
+ for the trivial matter of AM/PM behavior.)
+ * lib/strftime.c (REQUIRE_GNUISH_STRFTIME_AM_PM):
+ New macro, which can be overridden by config.h.
+ (should_remove_ampm, __strftime_internal):
+ Use it instead of !USE_C_LOCALE when deciding to
+ implement Gnuish AM/PM behavior.
+
2024-02-13 Bruno Haible <bruno@clisp.org>
uniwidth/width tests: Update unit test for last commit.
# include "time-internal.h"
#endif
+/* Whether to require GNU behavior for AM and PM indicators, even on
+ other platforms. This matters only in non-C locales.
+ The default is to require it; you can override this via
+ AC_DEFINE([REQUIRE_GNUISH_STRFTIME_AM_PM], 1) and if you do that
+ you may be able to omit Gnulib's localename module and its dependencies. */
+#ifndef REQUIRE_GNUISH_STRFTIME_AM_PM
+# define REQUIRE_GNUISH_STRFTIME_AM_PM true
+#endif
+#if USE_C_LOCALE
+# undef REQUIRE_GNUISH_STRFTIME_AM_PM
+# define REQUIRE_GNUISH_STRFTIME_AM_PM false
+#endif
+
#if USE_C_LOCALE
# include "c-ctype.h"
#else
# include <locale.h>
#endif
-#if (defined __NetBSD__ || defined __sun) && !USE_C_LOCALE
+#if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM
# include <locale.h>
# include "localename.h"
#endif
#endif
-#if (defined __NetBSD__ || defined __sun) && !USE_C_LOCALE
+#if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM
/* Return true if an AM/PM indicator should be removed. */
static bool
}
}
}
-# if !USE_C_LOCALE
+# if 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. */