about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
Diffstat (limited to 'locale')
-rw-r--r--locale/categories.def5
-rw-r--r--locale/langinfo.h4
-rw-r--r--locale/localeinfo.h2
-rw-r--r--locale/programs/ld-time.c42
4 files changed, 39 insertions, 14 deletions
diff --git a/locale/categories.def b/locale/categories.def
index 7c47fd4662..5e72319774 100644
--- a/locale/categories.def
+++ b/locale/categories.def
@@ -137,12 +137,15 @@ DEFINE_CATEGORY
   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)
 
 
diff --git a/locale/langinfo.h b/locale/langinfo.h
index 90aee3d745..82bd51024a 100644
--- a/locale/langinfo.h
+++ b/locale/langinfo.h
@@ -101,6 +101,10 @@ typedef enum
   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.
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index 7a035c8739..2b7c6faa84 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -64,7 +64,7 @@ enum coll_sort_rule
   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,
diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c
index 00f288f69b..75f6021109 100644
--- a/locale/programs/ld-time.c
+++ b/locale/programs/ld-time.c
@@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA.  */
 
 
 void *xmalloc (size_t __n);
+void *xrealloc (void *__p, size_t __n);
 
 
 /* The real definition of the struct for the LC_TIME locale.  */
@@ -53,7 +54,8 @@ struct locale_time_t
   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;
@@ -115,6 +117,7 @@ time_output (struct localedef_t *locale, const char *output_path)
 {
   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)];
@@ -203,22 +206,27 @@ time_output (struct localedef_t *locale, const char *output_path)
   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)
@@ -267,8 +275,7 @@ too many values for field `%s' in category `LC_TIME'"),			      \
 	  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);
@@ -278,6 +285,18 @@ too many values for field `%s' in category `LC_TIME'"),			      \
     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)						      \
@@ -298,7 +317,6 @@ field `%s' in category `%s' declared more than once"),			      \
     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);