Sourceware Bugzilla – Attachment 9124 Details for
Bug 10871
'mon' array should contain both nominative and genitive cases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed solution: implement the %OB format specifier
0003-Implement-the-OB-specifier-alternative-month-names-b.patch (text/plain), 5.55 KB, created by
Rafal Luzynski
on 2016-03-24 11:20:59 UTC
(
hide
)
Description:
Proposed solution: implement the %OB format specifier
Filename:
MIME Type:
Creator:
Rafal Luzynski
Created:
2016-03-24 11:20:59 UTC
Size:
5.55 KB
patch
obsolete
>From cdd24bb8f1ad2127c9baf79c3cdab43ae4abbc98 Mon Sep 17 00:00:00 2001 >From: Rafal Luzynski <digitalfreak@lingonborough.com> >Date: Thu, 24 Mar 2016 02:13:54 +0100 >Subject: [PATCH 3/6] Implement the %OB specifier - alternative month names (bug > 10871) > >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. > >strftime() now implements a %OB format specifier which generates an >alternative month name. For the languages which require both nominative >and genitive case of the month names it is expected that it outputs >the alternative month name which should be a nominative (sic!) case >or whatever is appropriate when formatting the month names standalone >(without a day). For those languages %B will return the basic month >name but from now it is expected to be a genitive case or whatever is >appropriate when formatting full dates (including both day and month). >This means that all applications using %B to retrieve the month >name standalone should use %OB from now. For those languages which >do not use different (nominative and genitive) cases of the month >name or do not yet have their locales updated %OB will retrieve >the same string as %B so moving to %OB will be harmless as long >as the version of glibc which supports this feature is used. > >strptime() now accepts both nominative and genitive month names. > >[BZ #10871] >* time/strftime_l.c: %OB format for alternative month names added. >* time/strptime_l.c: alternative month names also recognized. >--- > time/strftime_l.c | 12 ++++++++++-- > time/strptime_l.c | 28 ++++++++++++++++++++++++++++ > 2 files changed, 38 insertions(+), 2 deletions(-) > >diff --git a/time/strftime_l.c b/time/strftime_l.c >index 1205035..4d54e23 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 (L_("")) > # define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11)) > > size_t aw_len = 3; >@@ -775,7 +779,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) > { >@@ -783,7 +787,11 @@ __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); >+ /* Use f_altmonth only if f_altmonth is provided. */ >+ if (f_altmonth[0] && 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 3a56947..6d5520e 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) > # define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) >@@ -403,6 +405,22 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, > if (s.decided !=raw) > { > trp = rp; >+#ifdef _LIBC >+ /* First check if the alt month is provided. */ >+ if (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt) >+ && * (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt)) >+ && 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) > { >@@ -429,6 +447,12 @@ __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, alt_month_name[cnt] >+ && alt_month_name[cnt][0] >+ && match_string (alt_month_name[cnt], trp)) >+ && trp > rp_longest) >+#endif > || ((trp = rp, match_string (ab_month_name[cnt], trp)) > && trp > rp_longest))) > { >@@ -1016,6 +1040,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. */ >-- >2.5.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 10871
:
8795
|
8874
|
8875
|
8876
|
8877
|
8878
|
8879
|
8880
|
9122
|
9123
|
9124
|
9125
|
9126
|
9127
|
9569
|
9570
|
9571
|
9572
|
9573
|
9574
|
9575
|
9576
|
9577
|
9578
|
9579
|
9595
|
9596
|
9597
|
9598
|
9599
|
9709
|
9710
|
9711
|
9712
|
9713
|
9714
|
9715
|
9716
|
9717
|
9718
|
9719
|
9720
|
9721
|
9908
|
9909
|
9910
|
9911
|
9912
|
9913
|
9914
|
9915
|
9916
|
9917
|
9918
|
9919
|
10063
|
10064
|
10065
|
10225
|
10226
|
10227
|
10228
|
10229
|
10230
|
10231
|
10425
|
10426
|
10427
|
10428
|
10429
|
10430
|
10592
|
10593
|
10594
|
10595
|
10596
|
10597
|
10598
|
10599
|
10600
|
10601
|
10602
|
10731
|
10732
|
10733
|
10734
|
10735
|
10736
|
10737
|
10738
|
10739
|
10740
|
10741
|
10742