1 /* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
27 /* Undefine following line in production version. */
28 /* #define NDEBUG 1 */
33 #include "localeinfo.h"
34 #include "stringtrans.h"
37 (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
40 extern void *xmalloc (size_t __n
);
41 extern void *xrealloc (void *__p
, size_t __n
);
44 /* Entry describing an entry of the era specification. */
49 int32_t start_date
[3];
56 /* The real definition of the struct for the LC_TIME locale. */
63 const char *abmon
[12];
72 const char *t_fmt_ampm
;
74 u_int32_t cur_num_era
;
76 const char *era_d_t_fmt
;
77 const char *era_t_fmt
;
78 const char *era_d_fmt
;
79 const char *alt_digits
[100];
80 u_int32_t cur_num_alt_digits
;
82 struct era_data
*era_entries
;
83 struct era_data
*era_entries_ob
;
88 time_startup (struct linereader
*lr
, struct localedef_t
*locale
,
89 struct charset_t
*charset
)
91 struct locale_time_t
*time
;
93 /* We have a definition for LC_TIME. */
94 copy_posix
.mask
&= ~(1 << LC_TIME
);
96 /* It is important that we always use UCS1 encoding for strings now. */
97 encoding_method
= ENC_UCS1
;
99 locale
->categories
[LC_TIME
].time
= time
=
100 (struct locale_time_t
*) xmalloc (sizeof (struct locale_time_t
));
102 memset (time
, '\0', sizeof (struct locale_time_t
));
107 time_finish (struct localedef_t
*locale
)
109 struct locale_time_t
*time
= locale
->categories
[LC_TIME
].time
;
111 #define TESTARR_ELEM(cat, max) \
112 if (time->cur_num_##cat == 0 && !be_quiet) \
113 error (0, 0, _("field `%s' in category `%s' undefined"), \
115 else if (time->cur_num_##cat != max && !be_quiet) \
116 error (0, 0, _("field `%s' in category `%s' has not enough values"), \
119 TESTARR_ELEM (abday
, 7);
120 TESTARR_ELEM (day
, 7);
121 TESTARR_ELEM (abmon
, 12);
122 TESTARR_ELEM (mon
, 12);
123 TESTARR_ELEM (am_pm
, 2);
125 #define TEST_ELEM(cat) \
126 if (time->cat == NULL && !be_quiet) \
127 error (0, 0, _("field `%s' in category `%s' undefined"), \
134 /* According to C.Y.Alexis Cheng <alexis@vnet.ibm.com> the T_FMT_AMPM
135 field is optional. */
136 if (time
->t_fmt_ampm
== NULL
)
137 /* Use the 24h format as default. */
138 time
->t_fmt_ampm
= time
->t_fmt
;
140 /* Now process the era entries. */
141 if (time
->cur_num_era
!= 0)
143 const int days_per_month
[12] = { 31, 29, 31, 30, 31, 30,
144 31, 31, 30, 31 ,30, 31 };
148 (struct era_data
*) xmalloc (time
->cur_num_era
149 * sizeof (struct era_data
));
151 for (idx
= 0; idx
< time
->cur_num_era
; ++idx
)
153 size_t era_len
= strlen (time
->era
[idx
]);
154 char *str
= xmalloc ((era_len
+ 1 + 3) & ~3);
157 memcpy (str
, time
->era
[idx
], era_len
+ 1);
159 /* First character must be + or - for the direction. */
160 if (*str
!= '+' && *str
!= '-')
163 error (0, 0, _("direction flag in string %d in `era' field"
164 " in category `%s' is not '+' nor '-'"),
166 /* Default arbitrarily to '+'. */
167 time
->era_entries
[idx
].direction
= '+';
170 time
->era_entries
[idx
].direction
= *str
;
174 error (0, 0, _("direction flag in string %d in `era' field"
175 " in category `%s' is not a single character"),
177 (void) strsep (&str
, ":");
182 /* Now the offset year. */
183 time
->era_entries
[idx
].offset
= strtol (str
, &endp
, 10);
187 error (0, 0, _("illegal number for offset in string %d in"
188 " `era' field in category `%s'"),
190 (void) strsep (&str
, ":");
192 else if (*endp
!= ':')
195 error (0, 0, _("garbage at end of offset value in string %d in"
196 " `era' field in category `%s'"),
198 (void) strsep (&str
, ":");
203 /* Next is the starting date in ISO format. */
204 if (strncmp (str
, "-*", 2) == 0)
206 time
->era_entries
[idx
].start_date
[0] =
207 time
->era_entries
[idx
].start_date
[1] =
208 time
->era_entries
[idx
].start_date
[2] = 0x80000000;
210 goto garbage_start_date
;
213 else if (strncmp (str
, "+*", 2) == 0)
215 time
->era_entries
[idx
].start_date
[0] =
216 time
->era_entries
[idx
].start_date
[1] =
217 time
->era_entries
[idx
].start_date
[2] = 0x7fffffff;
219 goto garbage_start_date
;
224 time
->era_entries
[idx
].start_date
[0] = strtol (str
, &endp
, 10);
225 if (endp
== str
|| *endp
!= '/')
226 goto invalid_start_date
;
229 time
->era_entries
[idx
].start_date
[0] -= 1900;
231 time
->era_entries
[idx
].start_date
[1] = strtol (str
, &endp
, 10);
232 if (endp
== str
|| *endp
!= '/')
233 goto invalid_start_date
;
236 time
->era_entries
[idx
].start_date
[1] -= 1;
238 time
->era_entries
[idx
].start_date
[2] = strtol (str
, &endp
, 10);
243 error (0, 0, _("illegal starting date in string %d in"
244 " `era' field in category `%s'"),
246 (void) strsep (&str
, ":");
248 else if (*endp
!= ':')
252 error (0, 0, _("garbage at end of starting date "
253 "in string %d in `era' field "
256 (void) strsep (&str
, ":");
262 /* Check for valid value. */
263 if ((time
->era_entries
[idx
].start_date
[1] < 0
264 || time
->era_entries
[idx
].start_date
[1] >= 12
265 || time
->era_entries
[idx
].start_date
[2] < 0
266 || (time
->era_entries
[idx
].start_date
[2]
267 > days_per_month
[time
->era_entries
[idx
].start_date
[1]])
268 || (time
->era_entries
[idx
].start_date
[1] == 2
269 && time
->era_entries
[idx
].start_date
[2] == 29
270 && !__isleap (time
->era_entries
[idx
].start_date
[0])))
272 error (0, 0, _("starting date is illegal in"
273 " string %d in `era' field in"
279 /* Next is the stopping date in ISO format. */
280 if (strncmp (str
, "-*", 2) == 0)
282 time
->era_entries
[idx
].stop_date
[0] =
283 time
->era_entries
[idx
].stop_date
[1] =
284 time
->era_entries
[idx
].stop_date
[2] = 0x80000000;
286 goto garbage_stop_date
;
289 else if (strncmp (str
, "+*", 2) == 0)
291 time
->era_entries
[idx
].stop_date
[0] =
292 time
->era_entries
[idx
].stop_date
[1] =
293 time
->era_entries
[idx
].stop_date
[2] = 0x7fffffff;
295 goto garbage_stop_date
;
300 time
->era_entries
[idx
].stop_date
[0] = strtol (str
, &endp
, 10);
301 if (endp
== str
|| *endp
!= '/')
302 goto invalid_stop_date
;
305 time
->era_entries
[idx
].stop_date
[0] -= 1900;
307 time
->era_entries
[idx
].stop_date
[1] = strtol (str
, &endp
, 10);
308 if (endp
== str
|| *endp
!= '/')
309 goto invalid_stop_date
;
312 time
->era_entries
[idx
].stop_date
[1] -= 1;
314 time
->era_entries
[idx
].stop_date
[2] = strtol (str
, &endp
, 10);
319 error (0, 0, _("illegal stopping date in string %d in"
320 " `era' field in category `%s'"),
322 (void) strsep (&str
, ":");
324 else if (*endp
!= ':')
328 error (0, 0, _("garbage at end of stopping date "
329 "in string %d in `era' field "
332 (void) strsep (&str
, ":");
338 /* Check for valid value. */
339 if ((time
->era_entries
[idx
].stop_date
[1] < 0
340 || time
->era_entries
[idx
].stop_date
[1] >= 12
341 || time
->era_entries
[idx
].stop_date
[2] < 0
342 || (time
->era_entries
[idx
].stop_date
[2]
343 > days_per_month
[time
->era_entries
[idx
].stop_date
[1]])
344 || (time
->era_entries
[idx
].stop_date
[1] == 2
345 && time
->era_entries
[idx
].stop_date
[2] == 29
346 && !__isleap (time
->era_entries
[idx
].stop_date
[0])))
348 error (0, 0, _("stopping date is illegal in"
349 " string %d in `era' field in"
355 if (str
== NULL
|| *str
== '\0')
358 error (0, 0, _("missing era name in string %d in `era' field"
359 " in category `%s'"), idx
+ 1, "LC_TIME");
360 /* Make sure that name and format are adjacent strings
362 time
->era_entries
[idx
].name
= "\0";
363 time
->era_entries
[idx
].format
364 = time
->era_entries
[idx
].name
+ 1;
368 time
->era_entries
[idx
].name
= strsep (&str
, ":");
370 if (str
== NULL
|| *str
== '\0')
373 error (0, 0, _("missing era format in string %d in `era'"
374 " field in category `%s'"),
376 /* Make sure that name and format are adjacent strings
378 time
->era_entries
[idx
].name
= "\0";
379 time
->era_entries
[idx
].format
380 = time
->era_entries
[idx
].name
+ 1;
383 time
->era_entries
[idx
].format
= str
;
387 /* Construct the array for the other byte order. */
388 time
->era_entries_ob
=
389 (struct era_data
*) xmalloc (time
->cur_num_era
390 * sizeof (struct era_data
));
392 for (idx
= 0; idx
< time
->cur_num_era
; ++idx
)
394 time
->era_entries_ob
[idx
].direction
=
395 SWAPU32 (time
->era_entries
[idx
].direction
);
396 time
->era_entries_ob
[idx
].offset
=
397 SWAPU32 (time
->era_entries
[idx
].offset
);
398 time
->era_entries_ob
[idx
].start_date
[0] =
399 SWAPU32 (time
->era_entries
[idx
].start_date
[0]);
400 time
->era_entries_ob
[idx
].start_date
[1] =
401 SWAPU32 (time
->era_entries
[idx
].start_date
[1]);
402 time
->era_entries_ob
[idx
].start_date
[2] =
403 SWAPU32 (time
->era_entries
[idx
].stop_date
[2]);
404 time
->era_entries_ob
[idx
].stop_date
[0] =
405 SWAPU32 (time
->era_entries
[idx
].stop_date
[0]);
406 time
->era_entries_ob
[idx
].stop_date
[1] =
407 SWAPU32 (time
->era_entries
[idx
].stop_date
[1]);
408 time
->era_entries_ob
[idx
].stop_date
[2] =
409 SWAPU32 (time
->era_entries
[idx
].stop_date
[2]);
410 time
->era_entries_ob
[idx
].name
=
411 time
->era_entries
[idx
].name
;
412 time
->era_entries_ob
[idx
].format
=
413 time
->era_entries
[idx
].format
;
420 time_output (struct localedef_t
*locale
, const char *output_path
)
422 struct locale_time_t
*time
= locale
->categories
[LC_TIME
].time
;
423 struct iovec iov
[2 + _NL_ITEM_INDEX (_NL_NUM_LC_TIME
)
424 + time
->cur_num_era
- 1
425 + time
->cur_num_alt_digits
- 1
426 + 1 + (time
->cur_num_era
* 9 - 1) * 2
427 + (time
->cur_num_era
== 0)];
428 struct locale_file data
;
429 u_int32_t idx
[_NL_ITEM_INDEX (_NL_NUM_LC_TIME
)];
430 size_t cnt
, last_idx
, num
;
432 if ((locale
->binary
& (1 << LC_TIME
)) != 0)
434 iov
[0].iov_base
= time
;
435 iov
[0].iov_len
= locale
->len
[LC_TIME
];
437 write_locale_data (output_path
, "LC_TIME", 1, iov
);
442 data
.magic
= LIMAGIC (LC_TIME
);
443 data
.n
= _NL_ITEM_INDEX (_NL_NUM_LC_TIME
);
444 iov
[0].iov_base
= (void *) &data
;
445 iov
[0].iov_len
= sizeof (data
);
447 iov
[1].iov_base
= (void *) idx
;
448 iov
[1].iov_len
= sizeof (idx
);
450 idx
[0] = iov
[0].iov_len
+ iov
[1].iov_len
;
453 for (cnt
= 0; cnt
<= _NL_ITEM_INDEX (ABDAY_7
); ++cnt
)
455 iov
[2 + cnt
].iov_base
=
456 (void *) (time
->abday
[cnt
- _NL_ITEM_INDEX (ABDAY_1
)] ?: "");
457 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
458 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
462 for (; cnt
<= _NL_ITEM_INDEX (DAY_7
); ++cnt
)
464 iov
[2 + cnt
].iov_base
=
465 (void *) (time
->day
[cnt
- _NL_ITEM_INDEX (DAY_1
)] ?: "");
466 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
467 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
471 for (; cnt
<= _NL_ITEM_INDEX (ABMON_12
); ++cnt
)
473 iov
[2 + cnt
].iov_base
=
474 (void *) (time
->abmon
[cnt
- _NL_ITEM_INDEX (ABMON_1
)] ?: "");
475 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
476 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
480 for (; cnt
<= _NL_ITEM_INDEX (MON_12
); ++cnt
)
482 iov
[2 + cnt
].iov_base
=
483 (void *) (time
->mon
[cnt
- _NL_ITEM_INDEX (MON_1
)] ?: "");
484 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
485 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
489 for (; cnt
<= _NL_ITEM_INDEX (PM_STR
); ++cnt
)
491 iov
[2 + cnt
].iov_base
=
492 (void *) (time
->am_pm
[cnt
- _NL_ITEM_INDEX (AM_STR
)] ?: "");
493 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
494 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
497 iov
[2 + cnt
].iov_base
= (void *) (time
->d_t_fmt
?: "");
498 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
499 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
502 iov
[2 + cnt
].iov_base
= (void *) (time
->d_fmt
?: "");
503 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
504 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
507 iov
[2 + cnt
].iov_base
= (void *) (time
->t_fmt
?: "");
508 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
509 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
512 iov
[2 + cnt
].iov_base
= (void *) (time
->t_fmt_ampm
?: "");
513 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
514 idx
[1 + cnt
] = idx
[cnt
] + iov
[2 + cnt
].iov_len
;
517 idx
[1 + last_idx
] = idx
[last_idx
];
518 for (num
= 0; num
< time
->cur_num_era
; ++num
, ++cnt
)
520 iov
[2 + cnt
].iov_base
= (void *) time
->era
[num
];
521 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
522 idx
[1 + last_idx
] += iov
[2 + cnt
].iov_len
;
526 iov
[2 + cnt
].iov_base
= (void *) (time
->era_year
?: "");
527 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
528 idx
[1 + last_idx
] = idx
[last_idx
] + iov
[2 + cnt
].iov_len
;
532 iov
[2 + cnt
].iov_base
= (void *) (time
->era_d_fmt
?: "");
533 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
534 idx
[1 + last_idx
] = idx
[last_idx
] + iov
[2 + cnt
].iov_len
;
538 idx
[1 + last_idx
] = idx
[last_idx
];
539 for (num
= 0; num
< time
->cur_num_alt_digits
; ++num
, ++cnt
)
541 iov
[2 + cnt
].iov_base
= (void *) (time
->alt_digits
[num
] ?: "");
542 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
543 idx
[1 + last_idx
] += iov
[2 + cnt
].iov_len
;
547 iov
[2 + cnt
].iov_base
= (void *) (time
->era_d_t_fmt
?: "");
548 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
549 idx
[1 + last_idx
] = idx
[last_idx
] + iov
[2 + cnt
].iov_len
;
553 iov
[2 + cnt
].iov_base
= (void *) (time
->era_t_fmt
?: "");
554 iov
[2 + cnt
].iov_len
= strlen (iov
[2 + cnt
].iov_base
) + 1;
555 idx
[1 + last_idx
] = idx
[last_idx
] + iov
[2 + cnt
].iov_len
;
560 /* We must align the following data. */
561 iov
[2 + cnt
].iov_base
= (void *) "\0\0";
562 iov
[2 + cnt
].iov_len
= ((idx
[last_idx
] + 3) & ~3) - idx
[last_idx
];
563 idx
[last_idx
] = (idx
[last_idx
] + 3) & ~3;
566 iov
[2 + cnt
].iov_base
= (void *) &time
->cur_num_alt_digits
;
567 iov
[2 + cnt
].iov_len
= sizeof (u_int32_t
);
568 idx
[1 + last_idx
] = idx
[last_idx
] + iov
[2 + cnt
].iov_len
;
572 /* The `era' data in usable form. */
573 iov
[2 + cnt
].iov_base
= (void *) &time
->cur_num_era
;
574 iov
[2 + cnt
].iov_len
= sizeof (u_int32_t
);
575 idx
[1 + last_idx
] = idx
[last_idx
] + iov
[2 + cnt
].iov_len
;
579 #if __BYTE_ORDER == __LITTLE_ENDIAN
580 # define ERA_B1 time->era_entries_ob
581 # define ERA_B2 time->era_entries
583 # define ERA_B1 time->era_entries
584 # define ERA_B2 time->era_entries_ob
586 idx
[1 + last_idx
] = idx
[last_idx
];
587 for (num
= 0; num
< time
->cur_num_era
; ++num
)
591 iov
[2 + cnt
].iov_base
= (void *) &ERA_B1
[num
].direction
;
592 iov
[2 + cnt
].iov_len
= sizeof (int32_t);
594 iov
[2 + cnt
].iov_base
= (void *) &ERA_B1
[num
].offset
;
595 iov
[2 + cnt
].iov_len
= sizeof (int32_t);
597 iov
[2 + cnt
].iov_base
= (void *) &ERA_B1
[num
].start_date
[0];
598 iov
[2 + cnt
].iov_len
= 3 * sizeof (int32_t);
600 iov
[2 + cnt
].iov_base
= (void *) &ERA_B1
[num
].stop_date
[0];
601 iov
[2 + cnt
].iov_len
= 3 * sizeof (int32_t);
604 l
= (strchr (ERA_B1
[num
].format
, '\0') - ERA_B1
[num
].name
) + 1;
606 iov
[2 + cnt
].iov_base
= (void *) ERA_B1
[num
].name
;
607 iov
[2 + cnt
].iov_len
= l
;
610 idx
[1 + last_idx
] += 8 * sizeof (int32_t) + l
;
612 assert (idx
[1 + last_idx
] % 4 == 0);
616 /* idx[1 + last_idx] = idx[last_idx]; */
617 for (num
= 0; num
< time
->cur_num_era
; ++num
)
621 iov
[2 + cnt
].iov_base
= (void *) &ERA_B2
[num
].direction
;
622 iov
[2 + cnt
].iov_len
= sizeof (int32_t);
624 iov
[2 + cnt
].iov_base
= (void *) &ERA_B2
[num
].offset
;
625 iov
[2 + cnt
].iov_len
= sizeof (int32_t);
627 iov
[2 + cnt
].iov_base
= (void *) &ERA_B2
[num
].start_date
[0];
628 iov
[2 + cnt
].iov_len
= 3 * sizeof (int32_t);
630 iov
[2 + cnt
].iov_base
= (void *) &ERA_B2
[num
].stop_date
[0];
631 iov
[2 + cnt
].iov_len
= 3 * sizeof (int32_t);
634 l
= (strchr (ERA_B2
[num
].format
, '\0') - ERA_B2
[num
].name
) + 1;
636 iov
[2 + cnt
].iov_base
= (void *) ERA_B2
[num
].name
;
637 iov
[2 + cnt
].iov_len
= l
;
640 /* idx[1 + last_idx] += 8 * sizeof (int32_t) + l; */
643 /* We have a problem when no era data is present. In this case the
644 data pointer for _NL_TIME_ERA_ENTRIES_EB and
645 _NL_TIME_ERA_ENTRIES_EL point after the end of the file. So we
646 introduce some dummy data here. */
647 if (time
->cur_num_era
== 0)
649 static u_int32_t dummy
= 0;
650 iov
[2 + cnt
].iov_base
= (void *) &dummy
;
651 iov
[2 + cnt
].iov_len
= 4;
655 assert (cnt
== (_NL_ITEM_INDEX (_NL_NUM_LC_TIME
)
656 + time
->cur_num_era
- 1
657 + time
->cur_num_alt_digits
- 1
658 + 1 + (time
->cur_num_era
* 9 - 1) * 2
659 + (time
->cur_num_era
== 0))
660 && last_idx
+ 1 == _NL_ITEM_INDEX (_NL_NUM_LC_TIME
));
662 write_locale_data (output_path
, "LC_TIME", 2 + cnt
, iov
);
667 time_add (struct linereader
*lr
, struct localedef_t
*locale
,
668 enum token_t tok
, struct token
*code
,
669 struct charset_t
*charset
)
671 struct locale_time_t
*time
= locale
->categories
[LC_TIME
].time
;
675 #define STRARR_ELEM(cat, max) \
677 if (time->cur_num_##cat >= max) \
679 too many values for field `%s' in category `%s'"), \
681 else if (code->val.str.start == NULL) \
683 lr_error (lr, _("unknown character in field `%s' of category `%s'"),\
685 time->cat[time->cur_num_##cat++] = ""; \
688 time->cat[time->cur_num_##cat++] = code->val.str.start; \
691 STRARR_ELEM (abday
, 7);
692 STRARR_ELEM (day
, 7);
693 STRARR_ELEM (abmon
, 12);
694 STRARR_ELEM (mon
, 12);
695 STRARR_ELEM (am_pm
, 2);
696 STRARR_ELEM (alt_digits
, 100);
699 if (code
->val
.str
.start
== NULL
)
700 lr_error (lr
, _("unknown character in field `%s' of category `%s'"),
705 time
->era
= xrealloc (time
->era
,
706 time
->cur_num_era
* sizeof (char *));
707 time
->era
[time
->cur_num_era
- 1] = code
->val
.str
.start
;
711 #define STR_ELEM(cat) \
713 if (time->cat != NULL) \
715 field `%s' in category `%s' declared more than once"), \
717 else if (code->val.str.start == NULL) \
719 lr_error (lr, _("unknown character in field `%s' of category `%s'"),\
724 time->cat = code->val.str.start; \
730 STR_ELEM (t_fmt_ampm
);
732 STR_ELEM (era_d_t_fmt
);
733 STR_ELEM (era_d_fmt
);
734 STR_ELEM (era_t_fmt
);
737 assert (! "unknown token in category `LC_TIME': should not happen");