From 761a585ce9245d5ad968303b200eef1f26fd501c Mon Sep 17 00:00:00 2001 From: Rafal Luzynski Date: Tue, 14 Nov 2017 02:22:38 +0100 Subject: 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 --- locale/programs/ld-time.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'locale/programs/ld-time.c') diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index 41864482ec..a755792363 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -94,6 +94,9 @@ struct locale_time_t const char *alt_mon[12]; const uint32_t *walt_mon[12]; int alt_mon_defined; + const char *ab_alt_mon[12]; + const uint32_t *wab_alt_mon[12]; + int ab_alt_mon_defined; unsigned char week_ndays; uint32_t week_1stday; unsigned char week_1stweek; @@ -651,6 +654,14 @@ time_output (struct localedef_t *locale, const struct charmap_t *charmap, for (n = 0; n < 12; ++n) add_locale_wstring (&file, time->walt_mon[n] ?: empty_wstr); + /* The ab'alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_string (&file, time->ab_alt_mon[n] ?: ""); + + /* The wide character ab'alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_wstring (&file, time->wab_alt_mon[n] ?: empty_wstr); + write_locale_data (output_path, LC_TIME, "LC_TIME", &file); } @@ -795,6 +806,7 @@ time_read (struct linereader *ldfile, struct localedef_t *result, STRARR_ELEM (am_pm, 2, 2); STRARR_ELEM (alt_digits, 0, 100); STRARR_ELEM (alt_mon, 12, 12); + STRARR_ELEM (ab_alt_mon, 12, 12); case tok_era: /* Ignore the rest of the line if we don't need the input of @@ -955,6 +967,13 @@ time_read (struct linereader *ldfile, struct localedef_t *result, memcpy (time->walt_mon, time->wmon, sizeof (time->wmon)); time->alt_mon_defined = 1; } + /* The same for abbreviated versions. */ + if (!ignore_content && !time->ab_alt_mon_defined) + { + memcpy (time->ab_alt_mon, time->abmon, sizeof (time->abmon)); + memcpy (time->wab_alt_mon, time->wabmon, sizeof (time->wabmon)); + time->ab_alt_mon_defined = 1; + } return; default: -- cgit 1.4.1