comparison lib/nstrftime.c @ 39225:a188a4c517c4

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.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 23 Jan 2018 00:42:04 -0800
parents 24e347e0e326
children bd7126276a36
comparison
equal deleted inserted replaced
39224:d2880a59020a 39225:a188a4c517c4
89 #else 89 #else
90 # define CHAR_T char 90 # define CHAR_T char
91 # define UCHAR_T unsigned char 91 # define UCHAR_T unsigned char
92 # define L_(Str) Str 92 # define L_(Str) Str
93 # define NLW(Sym) Sym 93 # define NLW(Sym) Sym
94 # define ABALTMON_1 _NL_ABALTMON_1
94 95
95 # define MEMCPY(d, s, n) memcpy (d, s, n) 96 # define MEMCPY(d, s, n) memcpy (d, s, n)
96 # define STRLEN(s) strlen (s) 97 # define STRLEN(s) strlen (s)
97 98
98 #endif 99 #endif
253 # define strftime __strftime_l 254 # define strftime __strftime_l
254 # define wcsftime __wcsftime_l 255 # define wcsftime __wcsftime_l
255 # undef _NL_CURRENT 256 # undef _NL_CURRENT
256 # define _NL_CURRENT(category, item) \ 257 # define _NL_CURRENT(category, item) \
257 (current->values[_NL_ITEM_INDEX (item)].string) 258 (current->values[_NL_ITEM_INDEX (item)].string)
258 # define LOCALE_PARAM , __locale_t loc 259 # define LOCALE_PARAM , locale_t loc
259 # define LOCALE_ARG , loc 260 # define LOCALE_ARG , loc
260 # define HELPER_LOCALE_ARG , current 261 # define HELPER_LOCALE_ARG , current
261 #else 262 #else
262 # define LOCALE_PARAM 263 # define LOCALE_PARAM
263 # define LOCALE_ARG 264 # define LOCALE_ARG
473 ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ 474 ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
474 ? "?" : _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon))) 475 ? "?" : _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)))
475 # define f_month \ 476 # define f_month \
476 ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \ 477 ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
477 ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon))) 478 ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
479 # define a_altmonth \
480 ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
481 ? "?" : _NL_CURRENT (LC_TIME, NLW(ABALTMON_1) + tp->tm_mon)))
482 # define f_altmonth \
483 ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11 \
484 ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon)))
478 # define ampm \ 485 # define ampm \
479 ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ 486 ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \
480 ? NLW(PM_STR) : NLW(AM_STR))) 487 ? NLW(PM_STR) : NLW(AM_STR)))
481 488
482 # define aw_len STRLEN (a_wkday) 489 # define aw_len STRLEN (a_wkday)
483 # define am_len STRLEN (a_month) 490 # define am_len STRLEN (a_month)
491 # define aam_len STRLEN (a_altmonth)
484 # define ap_len STRLEN (ampm) 492 # define ap_len STRLEN (ampm)
485 #endif 493 #endif
486 #if HAVE_TZNAME 494 #if HAVE_TZNAME
487 char **tzname_vec = tzname; 495 char **tzname_vec = tzname;
488 #endif 496 #endif
806 if (change_case) 814 if (change_case)
807 { 815 {
808 to_uppcase = true; 816 to_uppcase = true;
809 to_lowcase = false; 817 to_lowcase = false;
810 } 818 }
811 if (modifier != 0) 819 if (modifier == L_('E'))
812 goto bad_format; 820 goto bad_format;
813 #ifdef _NL_CURRENT 821 #ifdef _NL_CURRENT
814 cpy (am_len, a_month); 822 if (modifier == L_('O'))
823 cpy (aam_len, a_altmonth);
824 else
825 cpy (am_len, a_month);
815 break; 826 break;
816 #else 827 #else
817 goto underlying_strftime; 828 goto underlying_strftime;
818 #endif 829 #endif
819 830
820 case L_('B'): 831 case L_('B'):
821 if (modifier != 0) 832 if (modifier == L_('E'))
822 goto bad_format; 833 goto bad_format;
823 if (change_case) 834 if (change_case)
824 { 835 {
825 to_uppcase = true; 836 to_uppcase = true;
826 to_lowcase = false; 837 to_lowcase = false;
827 } 838 }
828 #ifdef _NL_CURRENT 839 #ifdef _NL_CURRENT
829 cpy (STRLEN (f_month), f_month); 840 if (modifier == L_('O'))
841 cpy (STRLEN (f_altmonth), f_altmonth);
842 else
843 cpy (STRLEN (f_month), f_month);
830 break; 844 break;
831 #else 845 #else
832 goto underlying_strftime; 846 goto underlying_strftime;
833 #endif 847 #endif
834 848