From patchwork Tue Sep 19 10:41:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Luzynski X-Patchwork-Id: 815417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84714-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="xHpHxI3d"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxKDP0mvcz9s82 for ; Tue, 19 Sep 2017 20:41:24 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=cVY+LCCDH6YfMbNbmGMqLHKWHNK7QIrOUBi9sytUXrRfz2uz1Z2lY 0UH3anBF5Lyv1kl0dQNW3xXbc29CL72EjdDem9yqllmal1u2IbwtzPZFC4PPUXGM dkNkIr+OltrtnIYBdFJLhyORBFAmfvY1b7mietTua1xkK9PCytL34c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=hzhtcTjlJtoez+Z+DfL6lrB37R8=; b=xHpHxI3dDi1JqFHzM8LZmmXJ6A+d bSXU2b0rU54NutuwxYBw7Kjpl3W+hWVCAxex6QQOf4ud0i9iBf0746dlzjRc1Avy q4YtkOHP4OByzsuRo9i3HSyD0RZU2yIWiH6TNCHN0KJY5kbICZvSxCf1xUAQk3JB 3jxp31NC9gZ4lFU= Received: (qmail 80100 invoked by alias); 19 Sep 2017 10:41:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 71422 invoked by uid 89); 19 Sep 2017 10:41:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=H*MI:poczta, month, H*x:Mailer, H*UA:Mailer X-HELO: aev204.rev.netart.pl X-Spam-Score: 0 Date: Tue, 19 Sep 2017 12:41:04 +0200 (CEST) From: Rafal Luzynski Reply-To: Rafal Luzynski To: libc-alpha@sourceware.org Message-ID: <291099144.1094665.1505817664806@poczta.nazwa.pl> Subject: [RFC][PATCH v9 1/6] Correct the size of _nl_value_type_LC_... arrays. MIME-Version: 1.0 X-Originating-Client: com.openexchange.ox.gui.dhtml There were several problems with checking the array size in the past, for example BZ#356, caused by incorrectly assuming that every locale token represents one element. In fact, if a token represented a subarray, for example an array of month names or characters category and it appeared at the end of the array the compiler assumed that the array ends just after the first element of the subarray. Workarounds used in the past was to skip some categories while testing, for example LC_CTYPE. Now when we are about to add alternative month names to LC_TIME (BZ#10871) this will fail again. * locale/loadlocale.c: Correct size of _nl_value_type_LC_ arrays. --- ChangeLog | 5 +++++ locale/loadlocale.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 25b05f2..3b8e6c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-09-19 Rafal Luzynski + + * locale/loadlocale.c: Correct size of + _nl_value_type_LC_ arrays. + 2017-09-19 Rajalakshmi Srinivasaraghavan * sysdeps/powerpc/powerpc64/power8/memset.S: Avoid misaligned stores. diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 2bdb39b..cdc3dd4 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -45,7 +45,8 @@ static const size_t _nl_category_num_items[] = #define NO_PAREN(arg, rest...) arg, ##rest #define DEFINE_CATEGORY(category, category_name, items, a) \ -static const enum value_type _nl_value_type_##category[] = { NO_PAREN items }; +static const enum value_type _nl_value_type_##category \ + [_NL_ITEM_INDEX (_NL_NUM_##category)] = { NO_PAREN items }; #define DEFINE_ELEMENT(element, element_name, optstd, type, rest...) \ [_NL_ITEM_INDEX (element)] = type, #include "categories.def" From patchwork Tue Sep 19 10:42:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Luzynski X-Patchwork-Id: 815420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84715-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="s7t5At2p"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxKG65mV3z9s82 for ; Tue, 19 Sep 2017 20:42:54 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=gKZP6Etrbea/qitF0tgNba8sgXsayJ9OZCYSheLX6q4gcxohcij6k O/p+aja3bOIHE2c8qi+TPPug82AnBfwIDmnVSTekMuJugCdJcjQpvkNMA7rCZkCJ boiFArML0cquTLraUwseMJaR9P1YLZrVtuge6Eqo9TnmU2tdwqSnGg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=SGKXkxrVgFtQljdRHdL3j5fOW8I=; b=s7t5At2pudO0che1fP+YrEbu8zeI uEfFxhjrXh8eJxSFu1L2qudOH8mfib7lY2FTaNYYKTBuqqmPNBocv1AQxp1e6f4v K5my44sgtpuANKnkrsj+52c5/gdMzcACFSdGoPp0dKwri+xYVxv8dLWu/HCUoJOf wPcmoAMAHigPV1U= Received: (qmail 14303 invoked by alias); 19 Sep 2017 10:42:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 10127 invoked by uid 89); 19 Sep 2017 10:42:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=time, February, february, fulfilled X-HELO: aev204.rev.netart.pl X-Spam-Score: 0 Date: Tue, 19 Sep 2017 12:42:14 +0200 (CEST) From: Rafal Luzynski Reply-To: Rafal Luzynski To: libc-alpha@sourceware.org Message-ID: <742475879.1094767.1505817734249@poczta.nazwa.pl> Subject: [RFC][PATCH v9 2/6] Implement alternative month names (bug 10871). MIME-Version: 1.0 X-Originating-Client: com.openexchange.ox.gui.dhtml Some languages (Slavic, Baltic, etc.) require a genitive case of the month name when formatting a full date (with the day number) while they require a nominative case when referring to the month standalone. This requirement cannot be fulfilled without providing two forms for each month name. From now it is precised that nl_langinfo(MON_1) series (up to MON_12) and strftime("%B") generate the month names in the grammatical form used when the month forms part of a complete date. If the grammatical form used when the month is named by itself is needed, the new values nl_langinfo(ALTMON_1) (up to ALTMON_12) and strftime("%OB") are supported. This new feature is optional so the languages which do not need it or do not yet provide the updated locales simply do not use it and their behaviour is unchanged. [BZ #10871] * locale/C-time.c: Add alternative month names, define them as the same as mon explicitly. * locale/categories.def: alt_mon and wide-alt_mon added. * locale/langinfo.h: ALTMON_1 .. ALTMON_12 and similar contants defined. * locale/programs/ld-time.c: Alternative month names support added, they are a copy of mon if not specified explicitly. * locale/programs/locfile-kw.gperf: alt_mon defined. * locale/programs/locfile-token.h: tok_alt_mon defined. * localedata/tst-langinfo.c: Add tests for the new constants ALTMON_1 .. ALTMON_12. * time/strftime_l.c: %OB format for alternative month names added. * time/strptime_l.c: Alternative month names also recognized. --- ChangeLog | 18 +++++++++++++++ locale/C-time.c | 28 ++++++++++++++++++++-- locale/categories.def | 2 ++ locale/langinfo.h | 50 ++++++++++++++++++++++++++++++++++++++-- locale/programs/ld-time.c | 21 +++++++++++++++++ locale/programs/locfile-kw.gperf | 1 + locale/programs/locfile-token.h | 1 + localedata/tst-langinfo.c | 12 ++++++++++ time/strftime_l.c | 11 +++++++-- time/strptime_l.c | 24 +++++++++++++++++++ 10 files changed, 162 insertions(+), 6 deletions(-) # define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) @@ -402,6 +404,20 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, if (s.decided !=raw) { trp = rp; +#ifdef _LIBC + /* First check the alt month. */ + if (match_string (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt), trp) + && trp > rp_longest) + { + rp_longest = trp; + cnt_longest = cnt; + if (s.decided == not + && strcmp (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt), + alt_month_name[cnt])) + decided_longest = loc; + } + trp = rp; +#endif if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), trp) && trp > rp_longest) { @@ -428,6 +444,10 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, if (s.decided != loc && (((trp = rp, match_string (month_name[cnt], trp)) && trp > rp_longest) +#ifdef _LIBC + || ((trp = rp, match_string (alt_month_name[cnt], trp)) + && trp > rp_longest) +#endif || ((trp = rp, match_string (ab_month_name[cnt], trp)) && trp > rp_longest))) { @@ -1015,6 +1035,10 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, case 'O': switch (*fmt++) { + case 'B': + /* Undo the increment and continue. */ + fmt--; + break; case 'd': case 'e': /* Match day of month using alternate numeric symbols. */ diff --git a/ChangeLog b/ChangeLog index 3b8e6c5..b0636ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2017-09-19 Rafal Luzynski + [BZ #10871] + * locale/C-time.c: Add alternative month names, define them as the + same as mon explicitly. + * locale/categories.def: alt_mon and wide-alt_mon added. + * locale/langinfo.h: ALTMON_1 .. ALTMON_12 and similar contants + defined. + * locale/programs/ld-time.c: Alternative month names support + added, they are a copy of mon if not specified explicitly. + * locale/programs/locfile-kw.gperf: alt_mon defined. + * locale/programs/locfile-token.h: tok_alt_mon defined. + * localedata/tst-langinfo.c: Add tests for the new constants + ALTMON_1 .. ALTMON_12. + * time/strftime_l.c: %OB format for alternative month names + added. + * time/strptime_l.c: Alternative month names also recognized. + +2017-09-19 Rafal Luzynski + * locale/loadlocale.c: Correct size of _nl_value_type_LC_ arrays. diff --git a/locale/C-time.c b/locale/C-time.c index 31d8704..ee33652 100644 --- a/locale/C-time.c +++ b/locale/C-time.c @@ -30,7 +30,7 @@ const struct __locale_data _nl_C_LC_TIME attribute_hidden = { NULL, }, /* no cached data */ UNDELETABLE, 0, - 111, + 135, { { .string = "Sun" }, { .string = "Mon" }, @@ -142,6 +142,30 @@ const struct __locale_data _nl_C_LC_TIME attribute_hidden = { .string = "" }, { .string = "%a %b %e %H:%M:%S %Z %Y" }, { .wstr = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y" }, - { .string = _nl_C_codeset } + { .string = _nl_C_codeset }, + { .string = "January" }, + { .string = "February" }, + { .string = "March" }, + { .string = "April" }, + { .string = "May" }, + { .string = "June" }, + { .string = "July" }, + { .string = "August" }, + { .string = "September" }, + { .string = "October" }, + { .string = "November" }, + { .string = "December" }, + { .wstr = (const uint32_t *) L"January" }, + { .wstr = (const uint32_t *) L"February" }, + { .wstr = (const uint32_t *) L"March" }, + { .wstr = (const uint32_t *) L"April" }, + { .wstr = (const uint32_t *) L"May" }, + { .wstr = (const uint32_t *) L"June" }, + { .wstr = (const uint32_t *) L"July" }, + { .wstr = (const uint32_t *) L"August" }, + { .wstr = (const uint32_t *) L"September" }, + { .wstr = (const uint32_t *) L"October" }, + { .wstr = (const uint32_t *) L"November" }, + { .wstr = (const uint32_t *) L"December" } } }; diff --git a/locale/categories.def b/locale/categories.def index 27a6129..53ec8c5 100644 --- a/locale/categories.def +++ b/locale/categories.def @@ -249,6 +249,8 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_DATE_FMT, "date_fmt", opt, string) DEFINE_ELEMENT (_NL_W_DATE_FMT, "wide-date_fmt", opt, wstring) DEFINE_ELEMENT (_NL_TIME_CODESET, "time-codeset", std, string) + DEFINE_ELEMENT (ALTMON_1, "alt_mon", opt, stringarray, 12, 12) + DEFINE_ELEMENT (_NL_WALTMON_1, "wide-alt_mon", opt, wstringarray, 12, 12) ), NO_POSTLOAD) diff --git a/locale/langinfo.h b/locale/langinfo.h index 1403957..78103ce 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -100,7 +100,8 @@ enum ABMON_12, #define ABMON_12 ABMON_12 - /* Long month names. */ + /* Long month names, in the grammatical form used when the month + forms part of a complete date. */ MON_1, /* January */ #define MON_1 MON_1 MON_2, @@ -189,7 +190,8 @@ enum _NL_WABMON_11, _NL_WABMON_12, - /* Long month names. */ + /* Long month names, in the grammatical form used when the month + forms part of a complete date. */ _NL_WMON_1, /* January */ _NL_WMON_2, _NL_WMON_3, @@ -231,6 +233,50 @@ enum _NL_TIME_CODESET, + /* Long month names, in the grammatical form used when the month + is named by itself. */ + __ALTMON_1, /* January */ + __ALTMON_2, + __ALTMON_3, + __ALTMON_4, + __ALTMON_5, + __ALTMON_6, + __ALTMON_7, + __ALTMON_8, + __ALTMON_9, + __ALTMON_10, + __ALTMON_11, + __ALTMON_12, +#ifdef __USE_GNU +# define ALTMON_1 __ALTMON_1 +# define ALTMON_2 __ALTMON_2 +# define ALTMON_3 __ALTMON_3 +# define ALTMON_4 __ALTMON_4 +# define ALTMON_5 __ALTMON_5 +# define ALTMON_6 __ALTMON_6 +# define ALTMON_7 __ALTMON_7 +# define ALTMON_8 __ALTMON_8 +# define ALTMON_9 __ALTMON_9 +# define ALTMON_10 __ALTMON_10 +# define ALTMON_11 __ALTMON_11 +# define ALTMON_12 __ALTMON_12 +#endif + + /* Long month names, in the grammatical form used when the month + is named by itself. */ + _NL_WALTMON_1, /* January */ + _NL_WALTMON_2, + _NL_WALTMON_3, + _NL_WALTMON_4, + _NL_WALTMON_5, + _NL_WALTMON_6, + _NL_WALTMON_7, + _NL_WALTMON_8, + _NL_WALTMON_9, + _NL_WALTMON_10, + _NL_WALTMON_11, + _NL_WALTMON_12, + _NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */ /* LC_COLLATE category: text sorting. diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index 32e9c41..0383179 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -91,6 +91,9 @@ struct locale_time_t const char *date_fmt; const uint32_t *wdate_fmt; int alt_digits_defined; + const char *alt_mon[12]; + const uint32_t *walt_mon[12]; + int alt_mon_defined; unsigned char week_ndays; uint32_t week_1stday; unsigned char week_1stweek; @@ -652,6 +655,15 @@ time_output (struct localedef_t *locale, const struct charmap_t *charmap, add_locale_string (&file, time->date_fmt); add_locale_wstring (&file, time->wdate_fmt); add_locale_string (&file, charmap->code_set_name); + + /* The alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_string (&file, time->alt_mon[n] ?: ""); + + /* The wide character alt'mons. */ + for (n = 0; n < 12; ++n) + add_locale_wstring (&file, time->walt_mon[n] ?: empty_wstr); + write_locale_data (output_path, LC_TIME, "LC_TIME", &file); } @@ -795,6 +807,7 @@ time_read (struct linereader *ldfile, struct localedef_t *result, STRARR_ELEM (mon, 12, 12); STRARR_ELEM (am_pm, 2, 2); STRARR_ELEM (alt_digits, 0, 100); + STRARR_ELEM (alt_mon, 12, 12); case tok_era: /* Ignore the rest of the line if we don't need the input of @@ -947,6 +960,14 @@ time_read (struct linereader *ldfile, struct localedef_t *result, lr_error (ldfile, _("\ %1$s: definition does not end with `END %1$s'"), "LC_TIME"); lr_ignore_rest (ldfile, now->tok == tok_lc_time); + + /* If alt_mon was not specified, make it a copy of mon. */ + if (!ignore_content && !time->alt_mon_defined) + { + memcpy (time->alt_mon, time->mon, sizeof (time->mon)); + memcpy (time->walt_mon, time->wmon, sizeof (time->wmon)); + time->alt_mon_defined = 1; + } return; default: diff --git a/locale/programs/locfile-kw.gperf b/locale/programs/locfile-kw.gperf index 3605d15..3d11cc6 100644 --- a/locale/programs/locfile-kw.gperf +++ b/locale/programs/locfile-kw.gperf @@ -148,6 +148,7 @@ first_workday, tok_first_workday, 0 cal_direction, tok_cal_direction, 0 timezone, tok_timezone, 0 date_fmt, tok_date_fmt, 0 +alt_mon, tok_alt_mon, 0 LC_MESSAGES, tok_lc_messages, 0 yesexpr, tok_yesexpr, 0 noexpr, tok_noexpr, 0 diff --git a/locale/programs/locfile-token.h b/locale/programs/locfile-token.h index 0c32f2c..2a313b2 100644 --- a/locale/programs/locfile-token.h +++ b/locale/programs/locfile-token.h @@ -186,6 +186,7 @@ enum token_t tok_cal_direction, tok_timezone, tok_date_fmt, + tok_alt_mon, tok_lc_messages, tok_yesexpr, tok_noexpr, diff --git a/localedata/tst-langinfo.c b/localedata/tst-langinfo.c index 1012f56..c23d9e0 100644 --- a/localedata/tst-langinfo.c +++ b/localedata/tst-langinfo.c @@ -50,6 +50,18 @@ struct map VAL (ABMON_8), VAL (ABMON_9), VAL (ALT_DIGITS), + VAL (ALTMON_1), + VAL (ALTMON_10), + VAL (ALTMON_11), + VAL (ALTMON_12), + VAL (ALTMON_2), + VAL (ALTMON_3), + VAL (ALTMON_4), + VAL (ALTMON_5), + VAL (ALTMON_6), + VAL (ALTMON_7), + VAL (ALTMON_8), + VAL (ALTMON_9), VAL (AM_STR), VAL (CRNCYSTR), VAL (CURRENCY_SYMBOL), diff --git a/time/strftime_l.c b/time/strftime_l.c index b5ba9ca..1c4bed8 100644 --- a/time/strftime_l.c +++ b/time/strftime_l.c @@ -492,6 +492,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 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))) @@ -507,6 +510,7 @@ __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 f_altmonth f_month # define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11)) size_t aw_len = 3; @@ -785,7 +789,7 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, #endif case L_('B'): - if (modifier != 0) + if (modifier == L_('E')) goto bad_format; if (change_case) { @@ -793,7 +797,10 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, to_lowcase = 0; } #if defined _NL_CURRENT || !HAVE_STRFTIME - 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; diff --git a/time/strptime_l.c b/time/strptime_l.c index 3afc33a..b99f5d2 100644 --- a/time/strptime_l.c +++ b/time/strptime_l.c @@ -124,6 +124,8 @@ extern const struct __locale_data _nl_C_LC_TIME attribute_hidden; (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string) # define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string) # define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) +# define alt_month_name \ + (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string) # define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) # define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) From patchwork Tue Sep 19 10:43:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Luzynski X-Patchwork-Id: 815422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84716-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="OHhHH98p"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxKJ44fBtz9s82 for ; Tue, 19 Sep 2017 20:44:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=eTvxuQP23IJi30ihuVVK3muaWaDy2MYrFICMGdUE7fBWar7fNqsPJ EmggpSYqS4+hrzWUSVX1JjIwAxJHCIVKZvOE2jn2Nd0XH8gdHt0VW0CV3AN3bBVU hjO4P8IMyQ/Z38HQBjGjXxjWLXLNP0MkDKjMX/zJsaWWVcug0Pp6uQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=KEyAlvEAOWF0sd5mK8rI8UOyNlw=; b=OHhHH98pe4p5CptfhU2nTuscfdJ2 yRGggrTf3MLBnDoF1V7Wu0O37JZ5Q1huuoK+RVA631TLQBWCgbJAjfW0HcYZ49nR AWeAJu5i2eivZllOQl/nqplLGFCU9lsK/znU4vyh68aEzX6VyQL8Etz+j/j+wXor 5qqgM0PqfFh3P+A= Received: (qmail 21081 invoked by alias); 19 Sep 2017 10:44:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4657 invoked by uid 89); 19 Sep 2017 10:44:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=oct, Oct X-HELO: aev204.rev.netart.pl X-Spam-Score: 0 Date: Tue, 19 Sep 2017 12:43:55 +0200 (CEST) From: Rafal Luzynski Reply-To: Rafal Luzynski To: libc-alpha@sourceware.org Message-ID: <604461725.1094943.1505817835815@poczta.nazwa.pl> Subject: [RFC][PATCH v9 4/6] Abbreviated alternative month names (%Ob) also added (bug 10871). MIME-Version: 1.0 X-Originating-Client: com.openexchange.ox.gui.dhtml All the previous changes (except the backward compatibility) 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 feature the declension suffixes. [BZ #10871] * locale/C-time.c: Add abbreviated alternative month names, define them as the same as abbreviated month names explicitly. * locale/categories.def: ab_alt_mon and wide-ab_alt_mon added. * locale/langinfo.h: _NL_[W]ABALTMON_1 .. _NL_[W]ABALTMON_12 defined. * locale/programs/ld-time.c: Abbreviated alternative month names support added, they are a copy of abmon if not provided explicitly. * locale/programs/locfile-kw.gperf: ab_alt_mon defined. * locale/programs/locfile-token.h: tok_ab_alt_mon defined. * time/strftime_l.c: %Ob (%Oh) format for abbreviated alternative month names added. * time/strptime_l.c: Abbreviated alternative month names also recognized. --- ChangeLog | 18 ++++++++++++++++++ locale/C-time.c | 28 ++++++++++++++++++++++++++-- locale/categories.def | 6 ++++-- locale/langinfo.h | 36 ++++++++++++++++++++++++++++++++++-- locale/programs/ld-time.c | 19 +++++++++++++++++++ locale/programs/locfile-kw.gperf | 1 + locale/programs/locfile-token.h | 1 + time/strftime_l.c | 14 ++++++++++++-- time/strptime_l.c | 18 ++++++++++++++++++ 9 files changed, 133 insertions(+), 8 deletions(-) # define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) @@ -417,6 +419,18 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, decided_longest = loc; } trp = rp; + if (match_string (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt), + trp) + && trp > rp_longest) + { + rp_longest = trp; + cnt_longest = cnt; + if (s.decided == not + && strcmp (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt), + alt_month_name[cnt])) + decided_longest = loc; + } + trp = rp; #endif if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), trp) && trp > rp_longest) @@ -447,6 +461,8 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, #ifdef _LIBC || ((trp = rp, match_string (alt_month_name[cnt], trp)) && trp > rp_longest) + || ((trp = rp, match_string (ab_alt_month_name[cnt], trp)) + && trp > rp_longest) #endif || ((trp = rp, match_string (ab_month_name[cnt], trp)) && trp > rp_longest))) @@ -1035,7 +1051,9 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, case 'O': switch (*fmt++) { + case 'b': case 'B': + case 'h': /* Undo the increment and continue. */ fmt--; break; diff --git a/ChangeLog b/ChangeLog index 6e71fff..ca80d40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,24 @@ 2017-09-19 Rafal Luzynski [BZ #10871] + * locale/C-time.c: Add abbreviated alternative month names, define + them as the same as abbreviated month names explicitly. + * locale/categories.def: ab_alt_mon and wide-ab_alt_mon added. + * locale/langinfo.h: _NL_[W]ABALTMON_1 .. _NL_[W]ABALTMON_12 + defined. + * locale/programs/ld-time.c: Abbreviated alternative month names + support added, they are a copy of abmon if not provided + explicitly. + * locale/programs/locfile-kw.gperf: ab_alt_mon defined. + * locale/programs/locfile-token.h: tok_ab_alt_mon defined. + * time/strftime_l.c: %Ob (%Oh) format for abbreviated + alternative month names added. + * time/strptime_l.c: Abbreviated alternative month names also + recognized. + +2017-09-19 Rafal Luzynski + + [BZ #10871] * locale/programs/locfile-kw.h: Regenerated for alt_mon. 2017-09-19 Rafal Luzynski diff --git a/locale/C-time.c b/locale/C-time.c index ee33652..a03a6d5 100644 --- a/locale/C-time.c +++ b/locale/C-time.c @@ -30,7 +30,7 @@ const struct __locale_data _nl_C_LC_TIME attribute_hidden = { NULL, }, /* no cached data */ UNDELETABLE, 0, - 135, + 159, { { .string = "Sun" }, { .string = "Mon" }, @@ -166,6 +166,30 @@ const struct __locale_data _nl_C_LC_TIME attribute_hidden = { .wstr = (const uint32_t *) L"September" }, { .wstr = (const uint32_t *) L"October" }, { .wstr = (const uint32_t *) L"November" }, - { .wstr = (const uint32_t *) L"December" } + { .wstr = (const uint32_t *) L"December" }, + { .string = "Jan" }, + { .string = "Feb" }, + { .string = "Mar" }, + { .string = "Apr" }, + { .string = "May" }, + { .string = "Jun" }, + { .string = "Jul" }, + { .string = "Aug" }, + { .string = "Sep" }, + { .string = "Oct" }, + { .string = "Nov" }, + { .string = "Dec" }, + { .wstr = (const uint32_t *) L"Jan" }, + { .wstr = (const uint32_t *) L"Feb" }, + { .wstr = (const uint32_t *) L"Mar" }, + { .wstr = (const uint32_t *) L"Apr" }, + { .wstr = (const uint32_t *) L"May" }, + { .wstr = (const uint32_t *) L"Jun" }, + { .wstr = (const uint32_t *) L"Jul" }, + { .wstr = (const uint32_t *) L"Aug" }, + { .wstr = (const uint32_t *) L"Sep" }, + { .wstr = (const uint32_t *) L"Oct" }, + { .wstr = (const uint32_t *) L"Nov" }, + { .wstr = (const uint32_t *) L"Dec" } } }; diff --git a/locale/categories.def b/locale/categories.def index 53ec8c5..07b19b2 100644 --- a/locale/categories.def +++ b/locale/categories.def @@ -249,8 +249,10 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_DATE_FMT, "date_fmt", opt, string) DEFINE_ELEMENT (_NL_W_DATE_FMT, "wide-date_fmt", opt, wstring) DEFINE_ELEMENT (_NL_TIME_CODESET, "time-codeset", std, string) - DEFINE_ELEMENT (ALTMON_1, "alt_mon", opt, stringarray, 12, 12) - DEFINE_ELEMENT (_NL_WALTMON_1, "wide-alt_mon", opt, wstringarray, 12, 12) + DEFINE_ELEMENT (ALTMON_1, "alt_mon", opt, stringarray, 12, 12) + DEFINE_ELEMENT (_NL_WALTMON_1, "wide-alt_mon", opt, wstringarray, 12, 12) + DEFINE_ELEMENT (_NL_ABALTMON_1, "ab_alt_mon", opt, stringarray, 12, 12) + DEFINE_ELEMENT (_NL_WABALTMON_1, "wide-ab_alt_mon", opt, wstringarray, 12, 12) ), NO_POSTLOAD) diff --git a/locale/langinfo.h b/locale/langinfo.h index 78103ce..fb5aaa2 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -74,7 +74,8 @@ enum DAY_7, /* Saturday */ #define DAY_7 DAY_7 - /* Abbreviated month names. */ + /* Abbreviated month names, in the grammatical form used when the month + forms part of a complete date. */ ABMON_1, /* Jan */ #define ABMON_1 ABMON_1 ABMON_2, @@ -176,7 +177,8 @@ enum _NL_WDAY_6, /* Friday */ _NL_WDAY_7, /* Saturday */ - /* Abbreviated month names. */ + /* Abbreviated month names, in the grammatical form used when the month + forms part of a complete date. */ _NL_WABMON_1, /* Jan */ _NL_WABMON_2, _NL_WABMON_3, @@ -277,6 +279,36 @@ enum _NL_WALTMON_11, _NL_WALTMON_12, + /* Abbreviated month names, in the grammatical form used when the month + is named by itself. */ + _NL_ABALTMON_1, /* Jan */ + _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, + + /* Abbreviated month names, in the grammatical form used when the month + is named by itself. */ + _NL_WABALTMON_1, /* Jan */ + _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, + _NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */ /* LC_COLLATE category: text sorting. diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index 0383179..19f01f5 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; @@ -664,6 +667,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); } @@ -808,6 +819,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 @@ -968,6 +980,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: diff --git a/locale/programs/locfile-kw.gperf b/locale/programs/locfile-kw.gperf index 3d11cc6..cae0ad8 100644 --- a/locale/programs/locfile-kw.gperf +++ b/locale/programs/locfile-kw.gperf @@ -149,6 +149,7 @@ cal_direction, tok_cal_direction, 0 timezone, tok_timezone, 0 date_fmt, tok_date_fmt, 0 alt_mon, tok_alt_mon, 0 +ab_alt_mon, tok_ab_alt_mon, 0 LC_MESSAGES, tok_lc_messages, 0 yesexpr, tok_yesexpr, 0 noexpr, tok_noexpr, 0 diff --git a/locale/programs/locfile-token.h b/locale/programs/locfile-token.h index 2a313b2..6631796 100644 --- a/locale/programs/locfile-token.h +++ b/locale/programs/locfile-token.h @@ -187,6 +187,7 @@ enum token_t tok_timezone, tok_date_fmt, tok_alt_mon, + tok_ab_alt_mon, tok_lc_messages, tok_yesexpr, tok_noexpr, diff --git a/time/strftime_l.c b/time/strftime_l.c index 1c4bed8..412012f 100644 --- a/time/strftime_l.c +++ b/time/strftime_l.c @@ -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; diff --git a/time/strptime_l.c b/time/strptime_l.c index b99f5d2..7193dc8 100644 --- a/time/strptime_l.c +++ b/time/strptime_l.c @@ -126,6 +126,8 @@ extern const struct __locale_data _nl_C_LC_TIME attribute_hidden; # define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) # define alt_month_name \ (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string) +# define ab_alt_month_name \ + (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (_NL_ABALTMON_1)].string) # define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) # define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) From patchwork Tue Sep 19 10:45:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Luzynski X-Patchwork-Id: 815423 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84717-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="pHMVZ9aQ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxKL23GBDz9s82 for ; Tue, 19 Sep 2017 20:46:18 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=PuWkTEmGZWyIIECoQ7cTlcg8xzWreu4ZJtyS5owuBxHi9iVD73Hhi q0T4riYcQ+XLZc8dj63A79fXBueTs+AZE9llmDYfCzLriX/EtgyxRzoU5jgdX+rs oSBGbfHm2Krzdlx7xbBRRybI4d6qEHqFfl6VfT9ewQEcJTg+Cte0iE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:reply-to:to:message-id:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=S3ztYb0fm44cTCBYxJwjzQdYQE8=; b=pHMVZ9aQeJb1ohAoI0lEtnwUPGaC v4MSq0dbeMy+lPpxqHtBOnCVeaQlddLGrv5UPhfaUiwBEv7L0EsdCyGPD+A/P4Cy 81EPSnIX8Sq0jHQofYTkG22pdVu2jsXBOBxTqA/9DDouCS9TRsf5x/o9c7VwS01R 95PY/kmFzivFLsM= Received: (qmail 127569 invoked by alias); 19 Sep 2017 10:46:08 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 101600 invoked by uid 89); 19 Sep 2017 10:45:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=Major, month X-HELO: aev204.rev.netart.pl X-Spam-Score: 2.3 Date: Tue, 19 Sep 2017 12:45:31 +0200 (CEST) From: Rafal Luzynski Reply-To: Rafal Luzynski To: libc-alpha@sourceware.org Message-ID: <1489658352.1095088.1505817931266@poczta.nazwa.pl> Subject: [RFC][PATCH v9 6/6] Documentation to the above changes (bug 10871). MIME-Version: 1.0 X-Originating-Client: com.openexchange.ox.gui.dhtml [BZ#10871] * manual/locale.texi (nl_langinfo): Document ALTMON_1..12, precise details about ABMON_1..12 and MON_1..12. * manual/time.texi (strftime): Document "%OB" and "%Ob" format specifiers, precise details about "%B" and "%b". Reviewed-by: Zack Weinberg --- ChangeLog | 8 ++++++++ NEWS | 13 +++++++++++++ manual/locale.texi | 23 ++++++++++++++++++++++- manual/time.texi | 22 ++++++++++++++++++---- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ed2a8b..68b9e47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,14 @@ 2017-09-19 Rafal Luzynski [BZ #10871] + * manual/locale.texi (nl_langinfo): Document ALTMON_1..12, + precise details about ABMON_1..12 and MON_1..12. + * manual/time.texi (strftime): Document "%OB" and "%Ob" format + specifiers, precise details about "%B" and "%b". + +2017-09-19 Rafal Luzynski + + [BZ #10871] * locale/programs/locfile-kw.h: Regenerated for ab_alt_mon. 2017-09-19 Rafal Luzynski diff --git a/NEWS b/NEWS index dd381f8..552bb7e 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,19 @@ Major new features: leads to lower overall process restart latency, so there is benefit both from a security and performance perspective. +* Support of two grammatical forms of month names has been added. + It has been precised that the month names returned by nl_langinfo with + MON_1..12 and ABMON_1..12, and formatted by strftime with "%B" and "%b" + format specifiers are in the grammatical form used when the month forms + part of a complete date. New series of valid arguments have been added + to nl_langinfo: ALTMON_1..12 and _NL_ABALTMON_1..12 and the "O" modifier + is supported with "%B" and "%b" format specifiers by strftime, they + generate the month names in the grammatical form used when the month is + named by itself. This feature is required by several languages, mostly + Slavic and Baltic but also Greek and probably more. In other languages + which do not need this feature the output month names will be the same + for both old and new arguments of nl_langinfo and strftime. + Deprecated and removed features, and other changes affecting compatibility: * On GNU/Linux, the obsolete Linux constant PTRACE_SEIZE_DEVEL is no longer diff --git a/manual/locale.texi b/manual/locale.texi index f7a40c2..b61c709 100644 --- a/manual/locale.texi +++ b/manual/locale.texi @@ -937,7 +937,8 @@ unabbreviated weekday name. @itemx ABMON_10 @itemx ABMON_11 @itemx ABMON_12 -The return value is abbreviated name of the month. @code{ABMON_1} +The return value is abbreviated name of the month, in the grammatical form +used when the month forms part of a complete date. @code{ABMON_1} corresponds to January. @item MON_1 @itemx MON_2 @@ -953,6 +954,26 @@ corresponds to January. @itemx MON_12 Similar to @code{ABMON_1} etc., but here the month names are not abbreviated. Here the first value @code{MON_1} also corresponds to January. +@item ALTMON_1 +@itemx ALTMON_2 +@itemx ALTMON_3 +@itemx ALTMON_4 +@itemx ALTMON_5 +@itemx ALTMON_6 +@itemx ALTMON_7 +@itemx ALTMON_8 +@itemx ALTMON_9 +@itemx ALTMON_10 +@itemx ALTMON_11 +@itemx ALTMON_12 +Similar to @code{MON_1} etc., but here the month names are in the grammatical +form used when the month is named by itself. The @code{strftime} functions +use this information when the modifier @code{O} is used in a format specifier +@code{B}. Here the first value @code{ALTMON_1} also corresponds to January. + +Note that in locales which do not need different grammatical forms of the +month names (including English) the return values are identical to those +returned by the corresponding @code{MON_@dots{}} values. @item AM_STR @itemx PM_STR The return values are strings which can be used in the representation of time diff --git a/manual/time.texi b/manual/time.texi index 33aa221..396934e 100644 --- a/manual/time.texi +++ b/manual/time.texi @@ -1347,7 +1347,10 @@ Emperors' reigns. @item O Use the locale's alternate numeric symbols for numbers. This modifier -applies only to numeric format specifiers. +applies only to numeric format specifiers. Additionally, as a GNU extension, +this modifier also applies to the @code{%b} and @code{%B} format specifiers +and forces the use of month names in the grammatical form used when the month +is named by itself. @end table If the format supports the modifier but no alternate representation @@ -1366,12 +1369,21 @@ The full weekday name according to the current locale. @item %b The abbreviated month name according to the current locale. +As a GNU extension, it is specified that the abbreviated month name is +produced in the grammatical form used when the month forms part of a complete +date; applying the @code{O} modifier produces the abbreviated month name in +the grammatical form used when the month is named by itself. @item %B The full month name according to the current locale. +As a GNU extension, it is specified that the full month name is produced in +the grammatical form used when the month forms part of a complete date; +applying the @code{O} modifier produces the abbreviated month name in the +grammatical form used when the month is named by itself. -Using @code{%B} together with @code{%d} produces grammatically -incorrect results for some locales. +Note that most of the locales do not need different grammatical forms of the +month names. In these locales the @code{O} modifier does not change the +results of the @code{%b} and @code{%B} specifiers. @item %c The preferred calendar time representation for the current locale. @@ -1779,7 +1791,9 @@ the full name. @itemx %B @itemx %h The month name according to the current locale, in abbreviated form or -the full name. +the full name. If the current locale requires different grammatical forms of +the month names then both forms are accepted, does not matter if the @code{O} +modifier is present or not. @item %c The date and time representation for the current locale.