/* When threaded, h_errno may be a per-process variable. */
#ifdef __USE_REENTRANT
-int
+int *
weak_const_function
__h_errno_location (void)
{
CHECK_FILE (fp, NULL);
if (n <= 0)
return NULL;
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
- _IO_flockfile (fp);
+ __libc_cleanup_region_start (&__funlockfile, fp);
+ __flockfile (fp);
count = _IO_getline (fp, buf, n - 1, '\n', 1);
if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN))
result = NULL;
DEFINE_ELEMENT (D_FMT, "d_fmt", std, string)
DEFINE_ELEMENT (T_FMT, "t_fmt", std, string)
DEFINE_ELEMENT (T_FMT_AMPM, "t_fmt_ampm", std, string)
- DEFINE_ELEMENT (ERA, "era", opt, string)
+ DEFINE_ELEMENT (ERA, "era", opt, stringarray, 0, 100)/*XXX*/
DEFINE_ELEMENT (ERA_YEAR, "era_year", opt, string)
DEFINE_ELEMENT (ERA_D_FMT, "era_d_fmt", opt, string)
DEFINE_ELEMENT (ALT_DIGITS, "alt_digits", opt, stringarray, 0, 100)
DEFINE_ELEMENT (ERA_D_T_FMT, "era_d_t_fmt", opt, string)
DEFINE_ELEMENT (ERA_T_FMT, "era_t_fmt", opt, string)
+ DEFINE_ELEMENT (_NL_TIME_ERA_NUM_ENTRIES, "time-era-num-entries", opt, word)
+ DEFINE_ELEMENT (_NL_TIME_ERA_ENTRIES_EB, "time-era-entries-eb", opt, string)
+ DEFINE_ELEMENT (_NL_TIME_ERA_ENTRIES_EL, "time-era-entries-el", opt, string)
), NO_POSTLOAD, NULL, NULL, NULL)
ERA_D_T_FMT, /* Date and time in alternate era format. */
ERA_T_FMT, /* Time in alternate era format. */
+ _NL_TIME_ERA_NUM_ENTRIES, /* Number entries in the era arrays. */
+ _NL_TIME_ERA_ENTRIES_EB, /* Structure with era entries in usable form.*/
+ _NL_TIME_ERA_ENTRIES_EL,
+
_NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */
/* LC_COLLATE category: text sorting.
sort_mask
};
-/* We can map the types of the entries into four categories. */
+/* We can map the types of the entries into a few categories. */
enum value_type
{
none,
void *xmalloc (size_t __n);
+void *xrealloc (void *__p, size_t __n);
/* The real definition of the struct for the LC_TIME locale. */
const char *d_fmt;
const char *t_fmt;
const char *t_fmt_ampm;
- const char *era;
+ const char **era;
+ size_t era_num;
const char *era_year;
const char *era_d_t_fmt;
const char *era_t_fmt;
{
struct locale_time_t *time = locale->categories[LC_TIME].time;
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_TIME)
+ + (time->era_num > 0 ? time->era_num - 1 : 0)
+ time->cur_num_alt_digits];
struct locale_file data;
u_int32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_TIME)];
iov[2 + cnt].iov_base = (void *) (time->t_fmt_ampm ?: "");
iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
+ last_idx = ++cnt;
- iov[2 + cnt].iov_base = (void *) (time->era ?: "");
- iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
+ idx[1 + last_idx] = idx[last_idx];
+ for (num = 0; num < time->era_num; ++num, ++cnt)
+ {
+ iov[2 + cnt].iov_base = (void *) time->era[num];
+ iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
+ }
+ ++last_idx;
iov[2 + cnt].iov_base = (void *) (time->era_year ?: "");
iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
+ idx[1 + last_idx] = idx[last_idx] + iov[2 + cnt].iov_len;
++cnt;
+ ++last_idx;
iov[2 + cnt].iov_base = (void *) (time->era_d_fmt ?: "");
iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- last_idx = ++cnt;
+ idx[1 + last_idx] = idx[last_idx] + iov[2 + cnt].iov_len;
+ ++cnt;
+ ++last_idx;
idx[1 + last_idx] = idx[last_idx];
for (num = 0; num < time->cur_num_alt_digits; ++num, ++cnt)
time->cat[time->cur_num_##cat++] = ""; \
} \
else \
- time->cat[time->cur_num_##cat++] \
- = code->val.str.start; \
+ time->cat[time->cur_num_##cat++] = code->val.str.start; \
break
STRARR_ELEM (abday, 7);
STRARR_ELEM (am_pm, 2);
STRARR_ELEM (alt_digits, 100);
+ case tok_era:
+ if (code->val.str.start == NULL)
+ lr_error (lr, _("unknown character in field `%s' of category `%s'"),
+ "era", "LC_TIME");
+ else
+ {
+ ++time->era_num;
+ time->era = xrealloc (time->era, time->era_num * sizeof (char *));
+ time->era[time->era_num - 1] = code->val.str.start;
+ }
+ break;
+
#define STR_ELEM(cat) \
case tok_##cat: \
if (time->cat != NULL) \
STR_ELEM (d_fmt);
STR_ELEM (t_fmt);
STR_ELEM (t_fmt_ampm);
- STR_ELEM (era);
STR_ELEM (era_year);
STR_ELEM (era_d_t_fmt);
STR_ELEM (era_d_fmt);