View | Details | Raw Unified | Return to bug 10871 | Differences between
and this patch

Collapse All | Expand All

(-)a/ChangeLog (+18 lines)
Lines 1-5 Link Here
1
2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
1
2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
2
2
3
	[BZ #10871]
4
	* locale/C-time.c: Add alternative month names, define them as the
5
	same as mon explicitly.
6
	* locale/categories.def: alt_mon and wide-alt_mon added.
7
	* locale/langinfo.h: ALTMON_1 .. ALTMON_12 and similar contants
8
	defined.
9
	* locale/programs/ld-time.c: Alternative month names support
10
	added, they are a copy of mon if not specified explicitly.
11
	* locale/programs/locfile-kw.gperf: alt_mon defined.
12
	* locale/programs/locfile-token.h: tok_alt_mon defined.
13
	* localedata/tst-langinfo.c: Add tests for the new constants
14
	ALTMON_1 .. ALTMON_12.
15
	* time/strftime_l.c: %OB format for alternative month names
16
	added.
17
	* time/strptime_l.c: Alternative month names also recognized.
18
19
2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
20
3
	* locale/loadlocale.c: Correct size of
21
	* locale/loadlocale.c: Correct size of
4
	_nl_value_type_LC_<category> arrays.
22
	_nl_value_type_LC_<category> arrays.
5
23
(-)a/locale/C-time.c (-2 / +26 lines)
Lines 30-36 const struct __locale_data _nl_C_LC_TIME attribute_hidden = Link Here
30
  { NULL, },			/* no cached data */
30
  { NULL, },			/* no cached data */
31
  UNDELETABLE,
31
  UNDELETABLE,
32
  0,
32
  0,
33
  111,
33
  135,
34
  {
34
  {
35
    { .string = "Sun" },
35
    { .string = "Sun" },
36
    { .string = "Mon" },
36
    { .string = "Mon" },
Lines 142-147 const struct __locale_data _nl_C_LC_TIME attribute_hidden = Link Here
142
    { .string = "" },
142
    { .string = "" },
143
    { .string = "%a %b %e %H:%M:%S %Z %Y" },
143
    { .string = "%a %b %e %H:%M:%S %Z %Y" },
144
    { .wstr = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y" },
144
    { .wstr = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y" },
145
    { .string = _nl_C_codeset }
145
    { .string = _nl_C_codeset },
146
    { .string = "January" },
147
    { .string = "February" },
148
    { .string = "March" },
149
    { .string = "April" },
150
    { .string = "May" },
151
    { .string = "June" },
152
    { .string = "July" },
153
    { .string = "August" },
154
    { .string = "September" },
155
    { .string = "October" },
156
    { .string = "November" },
157
    { .string = "December" },
158
    { .wstr = (const uint32_t *) L"January" },
159
    { .wstr = (const uint32_t *) L"February" },
160
    { .wstr = (const uint32_t *) L"March" },
161
    { .wstr = (const uint32_t *) L"April" },
162
    { .wstr = (const uint32_t *) L"May" },
163
    { .wstr = (const uint32_t *) L"June" },
164
    { .wstr = (const uint32_t *) L"July" },
165
    { .wstr = (const uint32_t *) L"August" },
166
    { .wstr = (const uint32_t *) L"September" },
167
    { .wstr = (const uint32_t *) L"October" },
168
    { .wstr = (const uint32_t *) L"November" },
169
    { .wstr = (const uint32_t *) L"December" }
146
  }
170
  }
147
};
171
};
(-)a/locale/categories.def (+2 lines)
Lines 249-254 DEFINE_CATEGORY Link Here
249
  DEFINE_ELEMENT (_DATE_FMT,                "date_fmt",            opt, string)
249
  DEFINE_ELEMENT (_DATE_FMT,                "date_fmt",            opt, string)
250
  DEFINE_ELEMENT (_NL_W_DATE_FMT,           "wide-date_fmt",       opt, wstring)
250
  DEFINE_ELEMENT (_NL_W_DATE_FMT,           "wide-date_fmt",       opt, wstring)
251
  DEFINE_ELEMENT (_NL_TIME_CODESET,	    "time-codeset",	   std, string)
251
  DEFINE_ELEMENT (_NL_TIME_CODESET,	    "time-codeset",	   std, string)
252
  DEFINE_ELEMENT (ALTMON_1,       "alt_mon",       opt, stringarray, 12, 12)
253
  DEFINE_ELEMENT (_NL_WALTMON_1,  "wide-alt_mon",  opt, wstringarray, 12, 12)
252
  ), NO_POSTLOAD)
254
  ), NO_POSTLOAD)
253
255
254
256
(-)a/locale/langinfo.h (-2 / +48 lines)
Lines 100-106 enum Link Here
100
  ABMON_12,
100
  ABMON_12,
101
#define ABMON_12		ABMON_12
101
#define ABMON_12		ABMON_12
102
102
103
  /* Long month names.  */
103
  /* Long month names, in the grammatical form used when the month
104
     forms part of a complete date.  */
104
  MON_1,			/* January */
105
  MON_1,			/* January */
105
#define MON_1			MON_1
106
#define MON_1			MON_1
106
  MON_2,
107
  MON_2,
Lines 189-195 enum Link Here
189
  _NL_WABMON_11,
190
  _NL_WABMON_11,
190
  _NL_WABMON_12,
191
  _NL_WABMON_12,
191
192
192
  /* Long month names.  */
193
  /* Long month names, in the grammatical form used when the month
194
     forms part of a complete date.  */
193
  _NL_WMON_1,		/* January */
195
  _NL_WMON_1,		/* January */
194
  _NL_WMON_2,
196
  _NL_WMON_2,
195
  _NL_WMON_3,
197
  _NL_WMON_3,
Lines 231-236 enum Link Here
231
233
232
  _NL_TIME_CODESET,
234
  _NL_TIME_CODESET,
233
235
236
  /* Long month names, in the grammatical form used when the month
237
     is named by itself.  */
238
  __ALTMON_1,			/* January */
239
  __ALTMON_2,
240
  __ALTMON_3,
241
  __ALTMON_4,
242
  __ALTMON_5,
243
  __ALTMON_6,
244
  __ALTMON_7,
245
  __ALTMON_8,
246
  __ALTMON_9,
247
  __ALTMON_10,
248
  __ALTMON_11,
249
  __ALTMON_12,
250
#ifdef __USE_GNU
251
# define ALTMON_1		__ALTMON_1
252
# define ALTMON_2		__ALTMON_2
253
# define ALTMON_3		__ALTMON_3
254
# define ALTMON_4		__ALTMON_4
255
# define ALTMON_5		__ALTMON_5
256
# define ALTMON_6		__ALTMON_6
257
# define ALTMON_7		__ALTMON_7
258
# define ALTMON_8		__ALTMON_8
259
# define ALTMON_9		__ALTMON_9
260
# define ALTMON_10		__ALTMON_10
261
# define ALTMON_11		__ALTMON_11
262
# define ALTMON_12		__ALTMON_12
263
#endif
264
265
  /* Long month names, in the grammatical form used when the month
266
     is named by itself.  */
267
  _NL_WALTMON_1,			/* January */
268
  _NL_WALTMON_2,
269
  _NL_WALTMON_3,
270
  _NL_WALTMON_4,
271
  _NL_WALTMON_5,
272
  _NL_WALTMON_6,
273
  _NL_WALTMON_7,
274
  _NL_WALTMON_8,
275
  _NL_WALTMON_9,
276
  _NL_WALTMON_10,
277
  _NL_WALTMON_11,
278
  _NL_WALTMON_12,
279
234
  _NL_NUM_LC_TIME,	/* Number of indices in LC_TIME category.  */
280
  _NL_NUM_LC_TIME,	/* Number of indices in LC_TIME category.  */
235
281
236
  /* LC_COLLATE category: text sorting.
282
  /* LC_COLLATE category: text sorting.
(-)a/locale/programs/ld-time.c (+21 lines)
Lines 91-96 struct locale_time_t Link Here
91
  const char *date_fmt;
91
  const char *date_fmt;
92
  const uint32_t *wdate_fmt;
92
  const uint32_t *wdate_fmt;
93
  int alt_digits_defined;
93
  int alt_digits_defined;
94
  const char *alt_mon[12];
95
  const uint32_t *walt_mon[12];
96
  int alt_mon_defined;
94
  unsigned char week_ndays;
97
  unsigned char week_ndays;
95
  uint32_t week_1stday;
98
  uint32_t week_1stday;
96
  unsigned char week_1stweek;
99
  unsigned char week_1stweek;
Lines 652-657 time_output (struct localedef_t *locale, const struct charmap_t *charmap, Link Here
652
  add_locale_string (&file, time->date_fmt);
655
  add_locale_string (&file, time->date_fmt);
653
  add_locale_wstring (&file, time->wdate_fmt);
656
  add_locale_wstring (&file, time->wdate_fmt);
654
  add_locale_string (&file, charmap->code_set_name);
657
  add_locale_string (&file, charmap->code_set_name);
658
659
  /* The alt'mons.  */
660
  for (n = 0; n < 12; ++n)
661
    add_locale_string (&file, time->alt_mon[n] ?: "");
662
663
  /* The wide character alt'mons.  */
664
  for (n = 0; n < 12; ++n)
665
    add_locale_wstring (&file, time->walt_mon[n] ?: empty_wstr);
666
655
  write_locale_data (output_path, LC_TIME, "LC_TIME", &file);
667
  write_locale_data (output_path, LC_TIME, "LC_TIME", &file);
656
}
668
}
657
669
Lines 795-800 time_read (struct linereader *ldfile, struct localedef_t *result, Link Here
795
	  STRARR_ELEM (mon, 12, 12);
807
	  STRARR_ELEM (mon, 12, 12);
796
	  STRARR_ELEM (am_pm, 2, 2);
808
	  STRARR_ELEM (am_pm, 2, 2);
797
	  STRARR_ELEM (alt_digits, 0, 100);
809
	  STRARR_ELEM (alt_digits, 0, 100);
810
	  STRARR_ELEM (alt_mon, 12, 12);
798
811
799
	case tok_era:
812
	case tok_era:
800
	  /* Ignore the rest of the line if we don't need the input of
813
	  /* Ignore the rest of the line if we don't need the input of
Lines 947-952 time_read (struct linereader *ldfile, struct localedef_t *result, Link Here
947
	    lr_error (ldfile, _("\
960
	    lr_error (ldfile, _("\
948
%1$s: definition does not end with `END %1$s'"), "LC_TIME");
961
%1$s: definition does not end with `END %1$s'"), "LC_TIME");
949
	  lr_ignore_rest (ldfile, now->tok == tok_lc_time);
962
	  lr_ignore_rest (ldfile, now->tok == tok_lc_time);
963
964
	  /* If alt_mon was not specified, make it a copy of mon.  */
965
	  if (!ignore_content && !time->alt_mon_defined)
966
	    {
967
	      memcpy (time->alt_mon, time->mon, sizeof (time->mon));
968
	      memcpy (time->walt_mon, time->wmon, sizeof (time->wmon));
969
	      time->alt_mon_defined = 1;
970
	    }
950
	  return;
971
	  return;
951
972
952
	default:
973
	default:
(-)a/locale/programs/locfile-kw.gperf (+1 lines)
Lines 148-153 first_workday, tok_first_workday, 0 Link Here
148
cal_direction,          tok_cal_direction,          0
148
cal_direction,          tok_cal_direction,          0
149
timezone,               tok_timezone,               0
149
timezone,               tok_timezone,               0
150
date_fmt,               tok_date_fmt,               0
150
date_fmt,               tok_date_fmt,               0
151
alt_mon,                tok_alt_mon,                0
151
LC_MESSAGES,            tok_lc_messages,            0
152
LC_MESSAGES,            tok_lc_messages,            0
152
yesexpr,                tok_yesexpr,                0
153
yesexpr,                tok_yesexpr,                0
153
noexpr,                 tok_noexpr,                 0
154
noexpr,                 tok_noexpr,                 0
(-)a/locale/programs/locfile-token.h (+1 lines)
Lines 186-191 enum token_t Link Here
186
  tok_cal_direction,
186
  tok_cal_direction,
187
  tok_timezone,
187
  tok_timezone,
188
  tok_date_fmt,
188
  tok_date_fmt,
189
  tok_alt_mon,
189
  tok_lc_messages,
190
  tok_lc_messages,
190
  tok_yesexpr,
191
  tok_yesexpr,
191
  tok_noexpr,
192
  tok_noexpr,
(-)a/localedata/tst-langinfo.c (+12 lines)
Lines 50-55 struct map Link Here
50
  VAL (ABMON_8),
50
  VAL (ABMON_8),
51
  VAL (ABMON_9),
51
  VAL (ABMON_9),
52
  VAL (ALT_DIGITS),
52
  VAL (ALT_DIGITS),
53
  VAL (ALTMON_1),
54
  VAL (ALTMON_10),
55
  VAL (ALTMON_11),
56
  VAL (ALTMON_12),
57
  VAL (ALTMON_2),
58
  VAL (ALTMON_3),
59
  VAL (ALTMON_4),
60
  VAL (ALTMON_5),
61
  VAL (ALTMON_6),
62
  VAL (ALTMON_7),
63
  VAL (ALTMON_8),
64
  VAL (ALTMON_9),
53
  VAL (AM_STR),
65
  VAL (AM_STR),
54
  VAL (CRNCYSTR),
66
  VAL (CRNCYSTR),
55
  VAL (CURRENCY_SYMBOL),
67
  VAL (CURRENCY_SYMBOL),
(-)a/time/strftime_l.c (-2 / +9 lines)
Lines 492-497 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
492
# define f_month \
492
# define f_month \
493
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
493
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
494
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
494
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
495
# define f_altmonth \
496
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
497
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon)))
495
# define ampm \
498
# define ampm \
496
  ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11		      \
499
  ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11		      \
497
				 ? NLW(PM_STR) : NLW(AM_STR)))
500
				 ? NLW(PM_STR) : NLW(AM_STR)))
Lines 507-512 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
507
		   ? "?" : month_name[tp->tm_mon])
510
		   ? "?" : month_name[tp->tm_mon])
508
#  define a_wkday f_wkday
511
#  define a_wkday f_wkday
509
#  define a_month f_month
512
#  define a_month f_month
513
#  define f_altmonth f_month
510
#  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
514
#  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
511
515
512
  size_t aw_len = 3;
516
  size_t aw_len = 3;
Lines 785-791 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
785
#endif
789
#endif
786
790
787
	case L_('B'):
791
	case L_('B'):
788
	  if (modifier != 0)
792
	  if (modifier == L_('E'))
789
	    goto bad_format;
793
	    goto bad_format;
790
	  if (change_case)
794
	  if (change_case)
791
	    {
795
	    {
Lines 793-799 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
793
	      to_lowcase = 0;
797
	      to_lowcase = 0;
794
	    }
798
	    }
795
#if defined _NL_CURRENT || !HAVE_STRFTIME
799
#if defined _NL_CURRENT || !HAVE_STRFTIME
796
	  cpy (STRLEN (f_month), f_month);
800
	  if (modifier == L_('O'))
801
	    cpy (STRLEN (f_altmonth), f_altmonth);
802
	  else
803
	    cpy (STRLEN (f_month), f_month);
797
	  break;
804
	  break;
798
#else
805
#else
799
	  goto underlying_strftime;
806
	  goto underlying_strftime;
(-)a/time/strptime_l.c (-1 / +24 lines)
Lines 124-129 extern const struct __locale_data _nl_C_LC_TIME attribute_hidden; Link Here
124
  (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string)
124
  (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string)
125
# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string)
125
# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string)
126
# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string)
126
# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string)
127
# define alt_month_name \
128
  (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string)
127
# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
129
# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
128
# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
130
# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
129
# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
131
# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
Lines 402-407 __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, Link Here
402
	      if (s.decided !=raw)
404
	      if (s.decided !=raw)
403
		{
405
		{
404
		  trp = rp;
406
		  trp = rp;
407
#ifdef _LIBC
408
		  /* First check the alt month.  */
409
		  if (match_string (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt), trp)
410
		      && trp > rp_longest)
411
		    {
412
		      rp_longest = trp;
413
		      cnt_longest = cnt;
414
		      if (s.decided == not
415
			  && strcmp (_NL_CURRENT (LC_TIME, ALTMON_1 + cnt),
416
				     alt_month_name[cnt]))
417
			decided_longest = loc;
418
		    }
419
		  trp = rp;
420
#endif
405
		  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), trp)
421
		  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), trp)
406
		      && trp > rp_longest)
422
		      && trp > rp_longest)
407
		    {
423
		    {
Lines 428-433 __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, Link Here
428
	      if (s.decided != loc
444
	      if (s.decided != loc
429
		  && (((trp = rp, match_string (month_name[cnt], trp))
445
		  && (((trp = rp, match_string (month_name[cnt], trp))
430
		       && trp > rp_longest)
446
		       && trp > rp_longest)
447
#ifdef _LIBC
448
		      || ((trp = rp, match_string (alt_month_name[cnt], trp))
449
			  && trp > rp_longest)
450
#endif
431
		      || ((trp = rp, match_string (ab_month_name[cnt], trp))
451
		      || ((trp = rp, match_string (ab_month_name[cnt], trp))
432
			  && trp > rp_longest)))
452
			  && trp > rp_longest)))
433
		{
453
		{
Lines 1015-1020 __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, Link Here
1015
	case 'O':
1035
	case 'O':
1016
	  switch (*fmt++)
1036
	  switch (*fmt++)
1017
	    {
1037
	    {
1038
	    case 'B':
1039
	      /* Undo the increment and continue.  */
1040
	      fmt--;
1041
	      break;
1018
	    case 'd':
1042
	    case 'd':
1019
	    case 'e':
1043
	    case 'e':
1020
	      /* Match day of month using alternate numeric symbols.  */
1044
	      /* Match day of month using alternate numeric symbols.  */
1021
- 

Return to bug 10871