From e5c64212810bf4d84769fa70e4b0959e0e9714b6 Mon Sep 17 00:00:00 2001
From: Rical Jasan <ricaljasan@deathguild.net>
Date: Sat, 20 Jan 2018 02:23:32 -0800
Subject: [PATCH] Support ABALTMON_* constants.
ABALTMON is a natural addition to the MON, ABMON, and ALTMON constants
used for formatting month names. The functionality for abbreviated
alternative months names is already implemented, but the corresponding
constants weren't defined. This commit adds them as a GNU extension.
* NEWS: Update recommended nl_langinfo constants for
abbreviated alternative month names.
* locale/categories.def (LC_TIME): Change _NL_ABALTMON_1 to
ABALTMON_1.
* locale/langinfo.h [__USE_GNU] (ABALTMON_1, ABALTMON_2,
ABALTMON_3, ABALTMON_4, ABALTMON_5, ABALTMON_6, ABALTMON_7,
ABALTMON_8, ABALTMON_9, ABALTMON_10, ABALTMON_11,
ABALTMON_12): New macros.
* locale/nl_langinfo_l.c (__nl_langinfo_noaltmon_l): Convert
use of _NL_ABALTMON_1 to ABALTMON_1.
* manual/locale.texi (nl_langinfo): Document the new
ABALTMON_* constants.
* time/strftime_l.c: Remove unnecessary define of ABALTMON_1.
* time/strptime_l.c (ab_alt_month_name): Convert use of
_NL_ABALTMON_1 to ABALTMON_1.
(__strptime_internal): Likewise.
---
NEWS | 2 +-
locale/categories.def | 2 +-
locale/langinfo.h | 14 ++++++++++++++
locale/nl_langinfo_l.c | 6 +++---
manual/locale.texi | 24 ++++++++++++++++++++----
time/strftime_l.c | 1 -
time/strptime_l.c | 6 +++---
7 files changed, 42 insertions(+), 13 deletions(-)
@@ -82,7 +82,7 @@ Major new features:
name---standalone or complete, abbreviated or full. In a call to
nl_langinfo, the query constants MON_1..12 and ABMON_1..12 return
the strings used by "%B" and "%b", respectively. New query
- constants ALTMON_1..12 and _NL_ABALTMON_1..12 return the strings
+ constants ALTMON_1..12 and ABALTMON_1..12 return the strings
used by "%OB" and "%Ob", respectively.
In a locale definition file, use "alt_mon" and "ab_alt_mon" to
@@ -251,7 +251,7 @@ DEFINE_CATEGORY
DEFINE_ELEMENT (_NL_TIME_CODESET, "time-codeset", std, string)
DEFINE_ELEMENT (ALTMON_1, "alt_mon", opt, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WALTMON_1, "wide-alt_mon", opt, wstringarray, 12, 12)
- DEFINE_ELEMENT (_NL_ABALTMON_1, "ab_alt_mon", opt, stringarray, 12, 12)
+ DEFINE_ELEMENT (ABALTMON_1, "ab_alt_mon", opt, stringarray, 12, 12)
DEFINE_ELEMENT (_NL_WABALTMON_1, "wide-ab_alt_mon", opt, wstringarray, 12, 12)
), NO_POSTLOAD)
@@ -293,6 +293,20 @@ enum
_NL_ABALTMON_10,
_NL_ABALTMON_11,
_NL_ABALTMON_12,
+#ifdef __USE_GNU
+# 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
+#endif
/* Abbreviated month names, in the grammatical form used when the month
is named by itself. */
@@ -82,7 +82,7 @@ __nl_langinfo_noaltmon_l (nl_item item, locale_t l)
{
if ((item >= ALTMON_1 && item <= ALTMON_12)
|| (item >= _NL_WALTMON_1 && item <= _NL_WALTMON_12)
- || (item >= _NL_ABALTMON_1 && item <= _NL_ABALTMON_12)
+ || (item >= ABALTMON_1 && item <= ABALTMON_12)
|| (item >= _NL_WABALTMON_1 && item <= _NL_WABALTMON_12))
/* Pretend it's a bogus index for this category: bogus item. */
return (char *) "";
@@ -98,8 +98,8 @@ __nl_langinfo_noaltmon_l (nl_item item, locale_t l)
}
else if (item >= ABMON_1 && item <= ABMON_12)
{
- /* _NL_ABALTMON... item contains what ABMON_... item contained before. */
- return __nl_langinfo_l (item + _NL_ABALTMON_1 - ABMON_1, l);
+ /* ABALTMON... item contains what ABMON_... item contained before. */
+ return __nl_langinfo_l (item + ABALTMON_1 - ABMON_1, l);
}
else if (item >= _NL_WABMON_1 && item <= _NL_WABMON_12)
{
@@ -974,11 +974,27 @@ use these month names for the conversion specifier @code{%OB}
Note that not all languages need two different forms of the month names,
so the strings returned for @code{MON_@dots{}} and @code{ALTMON_@dots{}}
may or may not be the same, depending on the locale.
+@item ABALTMON_1
+@itemx ABALTMON_2
+@itemx ABALTMON_3
+@itemx ABALTMON_4
+@itemx ABALTMON_5
+@itemx ABALTMON_6
+@itemx ABALTMON_7
+@itemx ABALTMON_8
+@itemx ABALTMON_9
+@itemx ABALTMON_10
+@itemx ABALTMON_11
+@itemx ABALTMON_12
+Similar to @code{ALTMON_1}, etc.,@: but here the month names are abbreviated.
+The @code{strftime} functions use these month names for the conversion
+specifiers @code{%Ob} and @code{%Oh} (@pxref{Formatting Calendar Time}).
-@strong{NB:} @code{ABALTMON_@dots{}} constants corresponding to the @code{%Ob}
-conversion specifier are not currently provided, but are expected to be in a
-future release. In the meantime, it is possible to use
-@code{_NL_ABALTMON_@dots{}}.
+Note that not all languages need two different forms of the month names,
+so the strings returned for @code{ABMON_@dots{}} and @code{ABALTMON_@dots{}}
+may or may not be the same, depending on the locale.
+
+These constants are a GNU extension.
@item AM_STR
@itemx PM_STR
The return values are strings which can be used in the representation of time
@@ -108,7 +108,6 @@ extern char *tzname[];
# define UCHAR_T unsigned char
# define L_(Str) Str
# define NLW(Sym) Sym
-# define ABALTMON_1 _NL_ABALTMON_1
# if !defined STDC_HEADERS && !defined HAVE_MEMCPY
# define MEMCPY(d, s, n) bcopy ((s), (d), (n))
@@ -127,7 +127,7 @@ extern const struct __locale_data _nl_C_LC_TIME attribute_hidden;
# define alt_month_name \
(&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string)
# define ab_alt_month_name \
- (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (_NL_ABALTMON_1)].string)
+ (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABALTMON_1)].string)
# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
@@ -440,14 +440,14 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
decided_longest = loc;
}
trp = rp;
- if (match_string (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt),
+ if (match_string (_NL_CURRENT (LC_TIME, ABALTMON_1 + cnt),
trp)
&& trp > rp_longest)
{
rp_longest = trp;
cnt_longest = cnt;
if (s.decided == not
- && strcmp (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt),
+ && strcmp (_NL_CURRENT (LC_TIME, ABALTMON_1 + cnt),
alt_month_name[cnt]))
decided_longest = loc;
}
--
2.14.3