* lib/langinfo.in.h (ABALTMON_1...ABALTMON_12): New macros.
* m4/langinfo_h.m4 (gl_LANGINFO_H): Define HAVE_LANGINFO_ABALTMON.
* modules/langinfo-h (Makefile.am): Substitute HAVE_LANGINFO_ABALTMON.
* tests/test-langinfo-h.c (items): Add ABALTMON_1 to ABALTMON_12.
* lib/nl_langinfo.c (rpl_nl_langinfo): Treat ABALTMON_i like ABMON_i.
* tests/test-nl_langinfo.c (main): Test ABALTMON_*.
* doc/posix-headers/langinfo.texi: Document support of ABALTMON_*.
* doc/posix-functions/nl_langinfo.texi: Likewise.
+2025-02-21 Bruno Haible <bruno@clisp.org>
+
+ langinfo-h, nl_langinfo: Support abbreviated alternative month names.
+ * lib/langinfo.in.h (ABALTMON_1...ABALTMON_12): New macros.
+ * m4/langinfo_h.m4 (gl_LANGINFO_H): Define HAVE_LANGINFO_ABALTMON.
+ * modules/langinfo-h (Makefile.am): Substitute HAVE_LANGINFO_ABALTMON.
+ * tests/test-langinfo-h.c (items): Add ABALTMON_1 to ABALTMON_12.
+ * lib/nl_langinfo.c (rpl_nl_langinfo): Treat ABALTMON_i like ABMON_i.
+ * tests/test-nl_langinfo.c (main): Test ABALTMON_*.
+ * doc/posix-headers/langinfo.texi: Document support of ABALTMON_*.
+ * doc/posix-functions/nl_langinfo.texi: Likewise.
+
2025-02-21 Bruno Haible <bruno@clisp.org>
langinfo-h tests: Verify that ALTMON_* are defined.
The constant @code{CODESET} is not supported on some platforms:
OpenBSD 3.8.
@item
-The constants @code{ALTMON_1} to @code{ALTMON_12} are not defined on some
+The constants @code{ALTMON_1} to @code{ALTMON_12} are not supported on some
platforms:
glibc 2.26, musl libc, macOS 14, NetBSD 8.0, OpenBSD 7.5, AIX 7.2, HP-UX 11.31, Solaris 11.4, Haiku, Cygwin 2.9.
@item
+The constants @code{ABALTMON_1} to @code{ABALTMON_12} are not supported on many
+platforms:
+glibc 2.41, musl libc, macOS 14, NetBSD 10.0, OpenBSD 7.6, AIX 7.3, HP-UX 11.31, Solaris 11.4, Haiku, Cygwin 3.5.
+@item
The constants @code{ERA}, @code{ERA_D_FMT}, @code{ERA_D_T_FMT},
@code{ERA_T_FMT}, @code{ALT_DIGITS} are not supported on some platforms:
OpenBSD 7.5.
platforms:
glibc 2.26, musl libc, macOS 11.1, NetBSD 8.0, OpenBSD 7.5, AIX 7.2, HP-UX 11.31, Solaris 11.4, Haiku, Cygwin 2.9.
@item
+The constants @code{ABALTMON_1} to @code{ABALTMON_12} are not defined on many
+platforms:
+glibc 2.41, musl libc, macOS 14, NetBSD 10.0, OpenBSD 7.6, AIX 7.3, HP-UX 11.31, Solaris 11.4, Haiku, Cygwin 3.5.
+@item
The constants @code{ERA}, @code{ERA_D_FMT}, @code{ERA_D_T_FMT},
@code{ERA_T_FMT}, @code{ALT_DIGITS} are not defined on some platforms:
OpenBSD 7.5.
# define ABMON_10 (ABMON_1 + 9)
# define ABMON_11 (ABMON_1 + 10)
# define ABMON_12 (ABMON_1 + 11)
+# define ABALTMON_1 10220
+# define ABALTMON_2 (ABALTMON_1 + 1)
+# define ABALTMON_3 (ABALTMON_1 + 2)
+# define ABALTMON_4 (ABALTMON_1 + 3)
+# define ABALTMON_5 (ABALTMON_1 + 4)
+# define ABALTMON_6 (ABALTMON_1 + 5)
+# define ABALTMON_7 (ABALTMON_1 + 6)
+# define ABALTMON_8 (ABALTMON_1 + 7)
+# define ABALTMON_9 (ABALTMON_1 + 8)
+# define ABALTMON_10 (ABALTMON_1 + 9)
+# define ABALTMON_11 (ABALTMON_1 + 10)
+# define ABALTMON_12 (ABALTMON_1 + 11)
# define ERA 10047
# define ERA_D_FMT 10048
# define ERA_D_T_FMT 10049
# define GNULIB_defined_ALTMON 1
# endif
+# if !@HAVE_LANGINFO_ABALTMON@
+# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 27
+# define ABALTMON_1 _NL_ABALTMON_1
+# define ABALTMON_2 _NL_ABALTMON_2
+# define ABALTMON_3 _NL_ABALTMON_3
+# define ABALTMON_4 _NL_ABALTMON_4
+# define ABALTMON_5 _NL_ABALTMON_5
+# define ABALTMON_6 _NL_ABALTMON_6
+# define ABALTMON_7 _NL_ABALTMON_7
+# define ABALTMON_8 _NL_ABALTMON_8
+# define ABALTMON_9 _NL_ABALTMON_9
+# define ABALTMON_10 _NL_ABALTMON_10
+# define ABALTMON_11 _NL_ABALTMON_11
+# define ABALTMON_12 _NL_ABALTMON_12
+# else
+# define ABALTMON_1 10220
+# define ABALTMON_2 (ABALTMON_1 + 1)
+# define ABALTMON_3 (ABALTMON_1 + 2)
+# define ABALTMON_4 (ABALTMON_1 + 3)
+# define ABALTMON_5 (ABALTMON_1 + 4)
+# define ABALTMON_6 (ABALTMON_1 + 5)
+# define ABALTMON_7 (ABALTMON_1 + 6)
+# define ABALTMON_8 (ABALTMON_1 + 7)
+# define ABALTMON_9 (ABALTMON_1 + 8)
+# define ABALTMON_10 (ABALTMON_1 + 9)
+# define ABALTMON_11 (ABALTMON_1 + 10)
+# define ABALTMON_12 (ABALTMON_1 + 11)
+# define GNULIB_defined_ABALTMON 1
+# endif
+# endif
+
# if !@HAVE_LANGINFO_ERA@
# define ERA 10047
# define ERA_D_FMT 10048
return result[item - ALTMON_1];
}
}
- case ABMON_1:
- case ABMON_2:
- case ABMON_3:
- case ABMON_4:
- case ABMON_5:
- case ABMON_6:
- case ABMON_7:
- case ABMON_8:
- case ABMON_9:
- case ABMON_10:
- case ABMON_11:
- case ABMON_12:
- {
- static char result[12][30];
- static char const abmonths[][sizeof "Jan"] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
- "Aug", "Sep", "Oct", "Nov", "Dec"
- };
- tmm.tm_mon = item - ABMON_1;
- if (!strftime (buf, sizeof result[0], "%b", &tmm))
- return (char *) abmonths[item - ABMON_1];
- strcpy (result[item - ABMON_1], buf);
- return result[item - ABMON_1];
- }
+ {
+ static char const abmonths[][sizeof "Jan"] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+ case ABMON_1:
+ case ABMON_2:
+ case ABMON_3:
+ case ABMON_4:
+ case ABMON_5:
+ case ABMON_6:
+ case ABMON_7:
+ case ABMON_8:
+ case ABMON_9:
+ case ABMON_10:
+ case ABMON_11:
+ case ABMON_12:
+ {
+ static char result[12][30];
+ tmm.tm_mon = item - ABMON_1;
+ if (!strftime (buf, sizeof result[0], "%b", &tmm))
+ return (char *) abmonths[item - ABMON_1];
+ strcpy (result[item - ABMON_1], buf);
+ return result[item - ABMON_1];
+ }
+ case ABALTMON_1:
+ case ABALTMON_2:
+ case ABALTMON_3:
+ case ABALTMON_4:
+ case ABALTMON_5:
+ case ABALTMON_6:
+ case ABALTMON_7:
+ case ABALTMON_8:
+ case ABALTMON_9:
+ case ABALTMON_10:
+ case ABALTMON_11:
+ case ABALTMON_12:
+ {
+ static char result[12][50];
+ tmm.tm_mon = item - ABALTMON_1;
+ /* The platforms without nl_langinfo() don't support strftime with
+ %Ob. We don't even need to try. */
+ #if 0
+ if (!strftime (buf, sizeof result[0], "%Ob", &tmm))
+ #endif
+ if (!strftime (buf, sizeof result[0], "%b", &tmm))
+ return (char *) abmonths[item - ABALTMON_1];
+ strcpy (result[item - ABALTMON_1], buf);
+ return result[item - ABALTMON_1];
+ }
+ }
case ERA:
return (char *) "";
case ALT_DIGITS:
# langinfo_h.m4
-# serial 12
+# serial 13
dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_LANGINFO_CODESET=0
HAVE_LANGINFO_T_FMT_AMPM=0
HAVE_LANGINFO_ALTMON=0
+ HAVE_LANGINFO_ABALTMON=0
HAVE_LANGINFO_ERA=0
HAVE_LANGINFO_YESEXPR=0
AC_CHECK_HEADERS_ONCE([langinfo.h])
dnl ERA etc. are missing on OpenBSD 6.7.
dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
dnl ALTMON_* are missing on glibc 2.26 and many other systems.
+ dnl ABALTMON_* are missing on glibc 2.41 and many other systems.
AC_CACHE_CHECK([whether langinfo.h defines CODESET],
[gl_cv_header_langinfo_codeset],
[AC_COMPILE_IFELSE(
if test $gl_cv_header_langinfo_altmon = yes; then
HAVE_LANGINFO_ALTMON=1
fi
+ AC_CACHE_CHECK([whether langinfo.h defines ABALTMON_1],
+ [gl_cv_header_langinfo_abaltmon],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = ABALTMON_1;
+]])],
+ [gl_cv_header_langinfo_abaltmon=yes],
+ [gl_cv_header_langinfo_abaltmon=no])
+ ])
+ if test $gl_cv_header_langinfo_abaltmon = yes; then
+ HAVE_LANGINFO_ABALTMON=1
+ fi
AC_CACHE_CHECK([whether langinfo.h defines ERA],
[gl_cv_header_langinfo_era],
[AC_COMPILE_IFELSE(
AC_SUBST([HAVE_LANGINFO_CODESET])
AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
AC_SUBST([HAVE_LANGINFO_ALTMON])
+ AC_SUBST([HAVE_LANGINFO_ABALTMON])
AC_SUBST([HAVE_LANGINFO_ERA])
AC_SUBST([HAVE_LANGINFO_YESEXPR])
-e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
-e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
-e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
+ -e 's|@''HAVE_LANGINFO_ABALTMON''@|$(HAVE_LANGINFO_ABALTMON)|g' \
-e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
-e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
-e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
ABMON_10,
ABMON_11,
ABMON_12,
+ ABALTMON_1,
+ ABALTMON_2,
+ ABALTMON_3,
+ ABALTMON_4,
+ ABALTMON_5,
+ ABALTMON_6,
+ ABALTMON_7,
+ ABALTMON_8,
+ ABALTMON_9,
+ ABALTMON_10,
+ ABALTMON_11,
+ ABALTMON_12,
ERA,
ERA_D_FMT,
ERA_D_T_FMT,
ASSERT (strlen (nl_langinfo (ABMON_10)) > 0);
ASSERT (strlen (nl_langinfo (ABMON_11)) > 0);
ASSERT (strlen (nl_langinfo (ABMON_12)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_1)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_2)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_3)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_4)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_5)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_6)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_7)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_8)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_9)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_10)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_11)) > 0);
+ ASSERT (strlen (nl_langinfo (ABALTMON_12)) > 0);
+ /* In the tested locales, abbreviated alternate month names and abbreviated
+ month names ought to be the same. */
+ ASSERT (strcmp (nl_langinfo (ABALTMON_1), nl_langinfo (ABMON_1)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_2), nl_langinfo (ABMON_2)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_3), nl_langinfo (ABMON_3)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_4), nl_langinfo (ABMON_4)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_5), nl_langinfo (ABMON_5)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_6), nl_langinfo (ABMON_6)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_7), nl_langinfo (ABMON_7)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_8), nl_langinfo (ABMON_8)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_9), nl_langinfo (ABMON_9)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_10), nl_langinfo (ABMON_10)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_11), nl_langinfo (ABMON_11)) == 0);
+ ASSERT (strcmp (nl_langinfo (ABALTMON_12), nl_langinfo (ABMON_12)) == 0);
ASSERT (strlen (nl_langinfo (ERA)) >= 0);
ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0);
ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0);