mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Abbreviated alternative month names (%Ob) also added (bug 10871).
All the previous changes also repeated to support abbreviated alternative month names. In most languages which have declension and need nominative/genitive month names the abbreviated forms for both cases are the same. An example where they do differ is May in Russian: this name is too short to be abbreviated so even the abbreviated form features the declension suffixes. [BZ #10871] * locale/C-time.c (_nl_C_LC_TIME): Add abbreviated alternative month names, define them as the same as abbreviated month names explicitly. * locale/categories.def (LC_TIME): Add ab_alt_mon and wide-ab_alt_mon. * locale/langinfo.h: (_NL_ABALTMON_1, _NL_ABALTMON_2, _NL_ABALTMON_3, _NL_ABALTMON_4, _NL_ABALTMON_5, _NL_ABALTMON_6, _NL_ABALTMON_7, _NL_ABALTMON_8, _NL_ABALTMON_9, _NL_ABALTMON_10, _NL_ABALTMON_11, _NL_ABALTMON_12, _NL_WABALTMON_1, _NL_WABALTMON_2, _NL_WABALTMON_3, _NL_WABALTMON_4, _NL_WABALTMON_5, _NL_WABALTMON_6, _NL_WABALTMON_7, _NL_WABALTMON_8, _NL_WABALTMON_9, _NL_WABALTMON_10, _NL_WABALTMON_11, _NL_WABALTMON_12): New enum constants. * locale/programs/ld-time.c (struct locale_time_t): Add ab_alt_mon, wab_alt_mon, and ab_alt_mon_defined members. (time_output): Output ab_alt_mon and wab_alt_mon members. (time_read): Read them, initialize them as copies of abmon and wabmon respectively if they are missing, initialize ab_alt_mon_defined. * locale/programs/locfile-kw.gperf (ab_alt_mon): Define. * locale/programs/locfile-kw.h: Regenerate. * locale/programs/locfile-token.h (tok_ab_alt_mon): New enum constant. * time/Makefile [$(run-built-tests) = yes] (LOCALES): Add es_ES.UTF-8 and ru_RU.UTF-8. * time/strftime_l.c (a_altmonth, aam_len): New macros. [!COMPILE_WIDE] (ABALTMON_1): New macro. (__strftime_internal): Handle %Ob and %Oh formats. * time/strptime_l.c [_LIBC] (ab_alt_month_name): New macro. (__strptime_internal): Handle %Ob and %Oh formats. * time/tst-strptime.c (day_tests): Add more tests to parse different forms of month names including the new %Ob format specifier. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
@ -106,6 +106,7 @@ 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))
|
||||
@ -492,6 +493,9 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
|
||||
# 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)))
|
||||
@ -501,6 +505,7 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
|
||||
|
||||
# define aw_len STRLEN (a_wkday)
|
||||
# define am_len STRLEN (a_month)
|
||||
# define aam_len STRLEN (a_altmonth)
|
||||
# define ap_len STRLEN (ampm)
|
||||
#else
|
||||
# if !HAVE_STRFTIME
|
||||
@ -510,11 +515,13 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
|
||||
? "?" : month_name[tp->tm_mon])
|
||||
# define a_wkday f_wkday
|
||||
# define a_month f_month
|
||||
# define a_altmonth a_month
|
||||
# define f_altmonth f_month
|
||||
# define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
|
||||
|
||||
size_t aw_len = 3;
|
||||
size_t am_len = 3;
|
||||
size_t aam_len = 3;
|
||||
size_t ap_len = 2;
|
||||
# endif
|
||||
#endif
|
||||
@ -779,10 +786,13 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
|
||||
to_uppcase = 1;
|
||||
to_lowcase = 0;
|
||||
}
|
||||
if (modifier != 0)
|
||||
if (modifier == L_('E'))
|
||||
goto bad_format;
|
||||
#if defined _NL_CURRENT || !HAVE_STRFTIME
|
||||
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;
|
||||
|
Reference in New Issue
Block a user