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

Collapse All | Expand All

(-)a/ChangeLog (+18 lines)
Lines 1-6 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]
3
	[BZ #10871]
4
	* locale/C-time.c: Add abbreviated alternative month names, define
5
	them as the same as abbreviated month names explicitly.
6
	* locale/categories.def: ab_alt_mon and wide-ab_alt_mon added.
7
	* locale/langinfo.h: _NL_[W]ABALTMON_1 .. _NL_[W]ABALTMON_12
8
	defined.
9
	* locale/programs/ld-time.c: Abbreviated alternative month names
10
	support added, they are a copy of abmon if not provided
11
	explicitly.
12
	* locale/programs/locfile-kw.gperf: ab_alt_mon defined.
13
	* locale/programs/locfile-token.h: tok_ab_alt_mon defined.
14
	* time/strftime_l.c: %Ob (%Oh) format for abbreviated
15
	alternative month names added.
16
	* time/strptime_l.c: Abbreviated alternative month names also
17
	recognized.
18
19
2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
20
21
	[BZ #10871]
4
	* locale/programs/locfile-kw.h: Regenerated for alt_mon.
22
	* locale/programs/locfile-kw.h: Regenerated for alt_mon.
5
23
6
2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
24
2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
(-)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
  135,
33
  159,
34
  {
34
  {
35
    { .string = "Sun" },
35
    { .string = "Sun" },
36
    { .string = "Mon" },
36
    { .string = "Mon" },
Lines 166-171 const struct __locale_data _nl_C_LC_TIME attribute_hidden = Link Here
166
    { .wstr = (const uint32_t *) L"September" },
166
    { .wstr = (const uint32_t *) L"September" },
167
    { .wstr = (const uint32_t *) L"October" },
167
    { .wstr = (const uint32_t *) L"October" },
168
    { .wstr = (const uint32_t *) L"November" },
168
    { .wstr = (const uint32_t *) L"November" },
169
    { .wstr = (const uint32_t *) L"December" }
169
    { .wstr = (const uint32_t *) L"December" },
170
    { .string = "Jan" },
171
    { .string = "Feb" },
172
    { .string = "Mar" },
173
    { .string = "Apr" },
174
    { .string = "May" },
175
    { .string = "Jun" },
176
    { .string = "Jul" },
177
    { .string = "Aug" },
178
    { .string = "Sep" },
179
    { .string = "Oct" },
180
    { .string = "Nov" },
181
    { .string = "Dec" },
182
    { .wstr = (const uint32_t *) L"Jan" },
183
    { .wstr = (const uint32_t *) L"Feb" },
184
    { .wstr = (const uint32_t *) L"Mar" },
185
    { .wstr = (const uint32_t *) L"Apr" },
186
    { .wstr = (const uint32_t *) L"May" },
187
    { .wstr = (const uint32_t *) L"Jun" },
188
    { .wstr = (const uint32_t *) L"Jul" },
189
    { .wstr = (const uint32_t *) L"Aug" },
190
    { .wstr = (const uint32_t *) L"Sep" },
191
    { .wstr = (const uint32_t *) L"Oct" },
192
    { .wstr = (const uint32_t *) L"Nov" },
193
    { .wstr = (const uint32_t *) L"Dec" }
170
  }
194
  }
171
};
195
};
(-)a/locale/categories.def (-2 / +4 lines)
Lines 249-256 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)
252
  DEFINE_ELEMENT (ALTMON_1,        "alt_mon",         opt, stringarray,  12, 12)
253
  DEFINE_ELEMENT (_NL_WALTMON_1,  "wide-alt_mon",  opt, wstringarray, 12, 12)
253
  DEFINE_ELEMENT (_NL_WALTMON_1,   "wide-alt_mon",    opt, wstringarray, 12, 12)
254
  DEFINE_ELEMENT (_NL_ABALTMON_1,  "ab_alt_mon",      opt, stringarray,  12, 12)
255
  DEFINE_ELEMENT (_NL_WABALTMON_1, "wide-ab_alt_mon", opt, wstringarray, 12, 12)
254
  ), NO_POSTLOAD)
256
  ), NO_POSTLOAD)
255
257
256
258
(-)a/locale/langinfo.h (-2 / +34 lines)
Lines 74-80 enum Link Here
74
  DAY_7,			/* Saturday */
74
  DAY_7,			/* Saturday */
75
#define DAY_7			DAY_7
75
#define DAY_7			DAY_7
76
76
77
  /* Abbreviated month names.  */
77
  /* Abbreviated month names, in the grammatical form used when the month
78
     forms part of a complete date.  */
78
  ABMON_1,			/* Jan */
79
  ABMON_1,			/* Jan */
79
#define ABMON_1			ABMON_1
80
#define ABMON_1			ABMON_1
80
  ABMON_2,
81
  ABMON_2,
Lines 176-182 enum Link Here
176
  _NL_WDAY_6,		/* Friday */
177
  _NL_WDAY_6,		/* Friday */
177
  _NL_WDAY_7,		/* Saturday */
178
  _NL_WDAY_7,		/* Saturday */
178
179
179
  /* Abbreviated month names.  */
180
  /* Abbreviated month names, in the grammatical form used when the month
181
     forms part of a complete date.  */
180
  _NL_WABMON_1,		/* Jan */
182
  _NL_WABMON_1,		/* Jan */
181
  _NL_WABMON_2,
183
  _NL_WABMON_2,
182
  _NL_WABMON_3,
184
  _NL_WABMON_3,
Lines 277-282 enum Link Here
277
  _NL_WALTMON_11,
279
  _NL_WALTMON_11,
278
  _NL_WALTMON_12,
280
  _NL_WALTMON_12,
279
281
282
  /* Abbreviated month names, in the grammatical form used when the month
283
     is named by itself.  */
284
  _NL_ABALTMON_1,			/* Jan */
285
  _NL_ABALTMON_2,
286
  _NL_ABALTMON_3,
287
  _NL_ABALTMON_4,
288
  _NL_ABALTMON_5,
289
  _NL_ABALTMON_6,
290
  _NL_ABALTMON_7,
291
  _NL_ABALTMON_8,
292
  _NL_ABALTMON_9,
293
  _NL_ABALTMON_10,
294
  _NL_ABALTMON_11,
295
  _NL_ABALTMON_12,
296
297
  /* Abbreviated month names, in the grammatical form used when the month
298
     is named by itself.  */
299
  _NL_WABALTMON_1,			/* Jan */
300
  _NL_WABALTMON_2,
301
  _NL_WABALTMON_3,
302
  _NL_WABALTMON_4,
303
  _NL_WABALTMON_5,
304
  _NL_WABALTMON_6,
305
  _NL_WABALTMON_7,
306
  _NL_WABALTMON_8,
307
  _NL_WABALTMON_9,
308
  _NL_WABALTMON_10,
309
  _NL_WABALTMON_11,
310
  _NL_WABALTMON_12,
311
280
  _NL_NUM_LC_TIME,	/* Number of indices in LC_TIME category.  */
312
  _NL_NUM_LC_TIME,	/* Number of indices in LC_TIME category.  */
281
313
282
  /* LC_COLLATE category: text sorting.
314
  /* LC_COLLATE category: text sorting.
(-)a/locale/programs/ld-time.c (+19 lines)
Lines 94-99 struct locale_time_t Link Here
94
  const char *alt_mon[12];
94
  const char *alt_mon[12];
95
  const uint32_t *walt_mon[12];
95
  const uint32_t *walt_mon[12];
96
  int alt_mon_defined;
96
  int alt_mon_defined;
97
  const char *ab_alt_mon[12];
98
  const uint32_t *wab_alt_mon[12];
99
  int ab_alt_mon_defined;
97
  unsigned char week_ndays;
100
  unsigned char week_ndays;
98
  uint32_t week_1stday;
101
  uint32_t week_1stday;
99
  unsigned char week_1stweek;
102
  unsigned char week_1stweek;
Lines 664-669 time_output (struct localedef_t *locale, const struct charmap_t *charmap, Link Here
664
  for (n = 0; n < 12; ++n)
667
  for (n = 0; n < 12; ++n)
665
    add_locale_wstring (&file, time->walt_mon[n] ?: empty_wstr);
668
    add_locale_wstring (&file, time->walt_mon[n] ?: empty_wstr);
666
669
670
  /* The ab'alt'mons.  */
671
  for (n = 0; n < 12; ++n)
672
    add_locale_string (&file, time->ab_alt_mon[n] ?: "");
673
674
  /* The wide character ab'alt'mons.  */
675
  for (n = 0; n < 12; ++n)
676
    add_locale_wstring (&file, time->wab_alt_mon[n] ?: empty_wstr);
677
667
  write_locale_data (output_path, LC_TIME, "LC_TIME", &file);
678
  write_locale_data (output_path, LC_TIME, "LC_TIME", &file);
668
}
679
}
669
680
Lines 808-813 time_read (struct linereader *ldfile, struct localedef_t *result, Link Here
808
	  STRARR_ELEM (am_pm, 2, 2);
819
	  STRARR_ELEM (am_pm, 2, 2);
809
	  STRARR_ELEM (alt_digits, 0, 100);
820
	  STRARR_ELEM (alt_digits, 0, 100);
810
	  STRARR_ELEM (alt_mon, 12, 12);
821
	  STRARR_ELEM (alt_mon, 12, 12);
822
	  STRARR_ELEM (ab_alt_mon, 12, 12);
811
823
812
	case tok_era:
824
	case tok_era:
813
	  /* Ignore the rest of the line if we don't need the input of
825
	  /* Ignore the rest of the line if we don't need the input of
Lines 968-973 time_read (struct linereader *ldfile, struct localedef_t *result, Link Here
968
	      memcpy (time->walt_mon, time->wmon, sizeof (time->wmon));
980
	      memcpy (time->walt_mon, time->wmon, sizeof (time->wmon));
969
	      time->alt_mon_defined = 1;
981
	      time->alt_mon_defined = 1;
970
	    }
982
	    }
983
	  /* The same for abbreviated versions.  */
984
	  if (!ignore_content && !time->ab_alt_mon_defined)
985
	    {
986
	      memcpy (time->ab_alt_mon, time->abmon, sizeof (time->abmon));
987
	      memcpy (time->wab_alt_mon, time->wabmon, sizeof (time->wabmon));
988
	      time->ab_alt_mon_defined = 1;
989
	    }
971
	  return;
990
	  return;
972
991
973
	default:
992
	default:
(-)a/locale/programs/locfile-kw.gperf (+1 lines)
Lines 149-154 cal_direction, tok_cal_direction, 0 Link Here
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
alt_mon,                tok_alt_mon,                0
152
ab_alt_mon,             tok_ab_alt_mon,             0
152
LC_MESSAGES,            tok_lc_messages,            0
153
LC_MESSAGES,            tok_lc_messages,            0
153
yesexpr,                tok_yesexpr,                0
154
yesexpr,                tok_yesexpr,                0
154
noexpr,                 tok_noexpr,                 0
155
noexpr,                 tok_noexpr,                 0
(-)a/locale/programs/locfile-token.h (+1 lines)
Lines 187-192 enum token_t Link Here
187
  tok_timezone,
187
  tok_timezone,
188
  tok_date_fmt,
188
  tok_date_fmt,
189
  tok_alt_mon,
189
  tok_alt_mon,
190
  tok_ab_alt_mon,
190
  tok_lc_messages,
191
  tok_lc_messages,
191
  tok_yesexpr,
192
  tok_yesexpr,
192
  tok_noexpr,
193
  tok_noexpr,
(-)a/time/strftime_l.c (-2 / +12 lines)
Lines 106-111 extern char *tzname[]; Link Here
106
# define UCHAR_T unsigned char
106
# define UCHAR_T unsigned char
107
# define L_(Str) Str
107
# define L_(Str) Str
108
# define NLW(Sym) Sym
108
# define NLW(Sym) Sym
109
# define ABALTMON_1 _NL_ABALTMON_1
109
110
110
# if !defined STDC_HEADERS && !defined HAVE_MEMCPY
111
# if !defined STDC_HEADERS && !defined HAVE_MEMCPY
111
#  define MEMCPY(d, s, n) bcopy ((s), (d), (n))
112
#  define MEMCPY(d, s, n) bcopy ((s), (d), (n))
Lines 492-497 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
492
# define f_month \
493
# define f_month \
493
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
494
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
494
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
495
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)))
496
# define a_altmonth \
497
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
498
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(ABALTMON_1) + tp->tm_mon)))
495
# define f_altmonth \
499
# define f_altmonth \
496
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
500
  ((const CHAR_T *) (tp->tm_mon < 0 || tp->tm_mon > 11			     \
497
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon)))
501
		     ? "?" : _NL_CURRENT (LC_TIME, NLW(ALTMON_1) + tp->tm_mon)))
Lines 501-506 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
501
505
502
# define aw_len STRLEN (a_wkday)
506
# define aw_len STRLEN (a_wkday)
503
# define am_len STRLEN (a_month)
507
# define am_len STRLEN (a_month)
508
# define aam_len STRLEN (a_altmonth)
504
# define ap_len STRLEN (ampm)
509
# define ap_len STRLEN (ampm)
505
#else
510
#else
506
# if !HAVE_STRFTIME
511
# if !HAVE_STRFTIME
Lines 510-520 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
510
		   ? "?" : month_name[tp->tm_mon])
515
		   ? "?" : month_name[tp->tm_mon])
511
#  define a_wkday f_wkday
516
#  define a_wkday f_wkday
512
#  define a_month f_month
517
#  define a_month f_month
518
#  define a_altmonth a_month
513
#  define f_altmonth f_month
519
#  define f_altmonth f_month
514
#  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
520
#  define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11))
515
521
516
  size_t aw_len = 3;
522
  size_t aw_len = 3;
517
  size_t am_len = 3;
523
  size_t am_len = 3;
524
  size_t aam_len = 3;
518
  size_t ap_len = 2;
525
  size_t ap_len = 2;
519
# endif
526
# endif
520
#endif
527
#endif
Lines 779-788 __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, Link Here
779
	      to_uppcase = 1;
786
	      to_uppcase = 1;
780
	      to_lowcase = 0;
787
	      to_lowcase = 0;
781
	    }
788
	    }
782
	  if (modifier != 0)
789
	  if (modifier == L_('E'))
783
	    goto bad_format;
790
	    goto bad_format;
784
#if defined _NL_CURRENT || !HAVE_STRFTIME
791
#if defined _NL_CURRENT || !HAVE_STRFTIME
785
	  cpy (am_len, a_month);
792
	  if (modifier == L_('O'))
793
	    cpy (aam_len, a_altmonth);
794
	  else
795
	    cpy (am_len, a_month);
786
	  break;
796
	  break;
787
#else
797
#else
788
	  goto underlying_strftime;
798
	  goto underlying_strftime;
(-)a/time/strptime_l.c (-1 / +18 lines)
Lines 126-131 extern const struct __locale_data _nl_C_LC_TIME attribute_hidden; Link Here
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 \
127
# define alt_month_name \
128
  (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string)
128
  (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ALTMON_1)].string)
129
# define ab_alt_month_name \
130
  (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (_NL_ABALTMON_1)].string)
129
# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
131
# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string)
130
# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
132
# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string)
131
# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
133
# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string)
Lines 417-422 __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, Link Here
417
			decided_longest = loc;
419
			decided_longest = loc;
418
		    }
420
		    }
419
		  trp = rp;
421
		  trp = rp;
422
		  if (match_string (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt),
423
				    trp)
424
		      && trp > rp_longest)
425
		    {
426
		      rp_longest = trp;
427
		      cnt_longest = cnt;
428
		      if (s.decided == not
429
			  && strcmp (_NL_CURRENT (LC_TIME, _NL_ABALTMON_1 + cnt),
430
				     alt_month_name[cnt]))
431
			decided_longest = loc;
432
		    }
433
		  trp = rp;
420
#endif
434
#endif
421
		  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), trp)
435
		  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), trp)
422
		      && trp > rp_longest)
436
		      && trp > rp_longest)
Lines 447-452 __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, Link Here
447
#ifdef _LIBC
461
#ifdef _LIBC
448
		      || ((trp = rp, match_string (alt_month_name[cnt], trp))
462
		      || ((trp = rp, match_string (alt_month_name[cnt], trp))
449
			  && trp > rp_longest)
463
			  && trp > rp_longest)
464
		      || ((trp = rp, match_string (ab_alt_month_name[cnt], trp))
465
			  && trp > rp_longest)
450
#endif
466
#endif
451
		      || ((trp = rp, match_string (ab_month_name[cnt], trp))
467
		      || ((trp = rp, match_string (ab_month_name[cnt], trp))
452
			  && trp > rp_longest)))
468
			  && trp > rp_longest)))
Lines 1035-1041 __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, Link Here
1035
	case 'O':
1051
	case 'O':
1036
	  switch (*fmt++)
1052
	  switch (*fmt++)
1037
	    {
1053
	    {
1054
	    case 'b':
1038
	    case 'B':
1055
	    case 'B':
1056
	    case 'h':
1039
	      /* Undo the increment and continue.  */
1057
	      /* Undo the increment and continue.  */
1040
	      fmt--;
1058
	      fmt--;
1041
	      break;
1059
	      break;
1042
- 

Return to bug 10871