>From 4a236f16ce0ef97094ff2f6538d4dba90e72a523 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 23 Jan 2018 00:42:04 -0800 Subject: [PATCH] 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. --- ChangeLog | 13 +++++++++++++ lib/nstrftime.c | 24 +++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7e1a23..71a23cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2018-01-23 Paul Eggert + + 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. + 2018-01-23 Bruno Haible doc: Mention another prerequisite for using Gnulib. diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 6add8c3..e55cfda 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; -- 2.7.4