diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-01-23 00:42:04 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-01-23 00:45:00 -0800 |
commit | 4a236f16ce0ef97094ff2f6538d4dba90e72a523 (patch) | |
tree | 570d4374b081a8d18ba052482fbde5aaddecbd1a /lib/nstrftime.c | |
parent | d2d6b6044d41872e8f49a55f9fa5051bf5c8d000 (diff) | |
download | gnulib-4a236f16ce0ef97094ff2f6538d4dba90e72a523.tar.gz |
Merge strftime.c changes from glibc
This incorporates:
2017-11-14 [BZ #10871] Implement alternative month names
2017-11-14 [BZ #10871] Abbreviated alternative month names (%Ob)
2017-06-20 Use locale_t, not __locale_t, throughout glibc
* lib/nstrftime.c (ABALTMON_1) [!COMPILE_WIDE]: New macro.
(LOCALE_PARAM) [_LIBC && USE_IN_EXTENDED_LOCALE_MODEL]:
Use locale_t, not __locale_t.
(a_altmonth, f_altmonth, aam_len) [_NL_CURRENT]: New macros.
(__strftime_internal): Add support for alternate months.
Diffstat (limited to 'lib/nstrftime.c')
-rw-r--r-- | lib/nstrftime.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 6add8c35e6..e55cfda0a3 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c @@ -91,6 +91,7 @@ extern char *tzname[]; # define UCHAR_T unsigned char # define L_(Str) Str # define NLW(Sym) Sym +# define ABALTMON_1 _NL_ABALTMON_1 # define MEMCPY(d, s, n) memcpy (d, s, n) # define STRLEN(s) strlen (s) @@ -255,7 +256,7 @@ extern char *tzname[]; # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) -# define LOCALE_PARAM , __locale_t loc +# define LOCALE_PARAM , locale_t loc # define LOCALE_ARG , loc # define HELPER_LOCALE_ARG , current #else @@ -475,12 +476,19 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) # define f_month \ ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))) +# define a_altmonth \ + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(ABALTMON_1) + tp->tm_mon))) +# define f_altmonth \ + ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ + ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon))) # define ampm \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ ? NLW(PM_STR) : NLW(AM_STR))) # define aw_len STRLEN (a_wkday) # define am_len STRLEN (a_month) +# define aam_len STRLEN (a_altmonth) # define ap_len STRLEN (ampm) #endif #if HAVE_TZNAME @@ -808,17 +816,20 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) to_uppcase = true; to_lowcase = false; } - if (modifier != 0) + if (modifier == L_('E')) goto bad_format; #ifdef _NL_CURRENT - cpy (am_len, a_month); + if (modifier == L_('O')) + cpy (aam_len, a_altmonth); + else + cpy (am_len, a_month); break; #else goto underlying_strftime; #endif case L_('B'): - if (modifier != 0) + if (modifier == L_('E')) goto bad_format; if (change_case) { @@ -826,7 +837,10 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) to_lowcase = false; } #ifdef _NL_CURRENT - cpy (STRLEN (f_month), f_month); + if (modifier == L_('O')) + cpy (STRLEN (f_altmonth), f_altmonth); + else + cpy (STRLEN (f_month), f_month); break; #else goto underlying_strftime; |