error (0, 0, _("garbage at end of starting date in string %d" " in `era' field in category `%s'"), idx + 1, "LC_TIME");
if (!be_quiet) error (0, 0, _("garbage at end of starting date " "in string %d in `era' field " "in category `%s'"), idx + 1, "LC_TIME");
time_finish (struct localedef_t *locale){  struct locale_time_t *time = locale->categories[LC_TIME].time;#define TESTARR_ELEM(cat, max)						      \  if (time->cur_num_##cat == 0 && !be_quiet)				      \    error (0, 0, _("field `%s' in category `%s' not defined"),		      \	   #cat, "LC_TIME");						      \  else if (time->cur_num_##cat != max && !be_quiet)			      \    error (0, 0, _("field `%s' in category `%s' has not enough values"),      \	   #cat, "LC_TIME")  TESTARR_ELEM (abday, 7);  TESTARR_ELEM (day, 7);  TESTARR_ELEM (abmon, 12);  TESTARR_ELEM (mon, 12);  TESTARR_ELEM (am_pm, 2);#define TEST_ELEM(cat)							      \  if (time->cat == NULL && !be_quiet)					      \    error (0, 0, _("field `%s' in category `%s' not defined"),		      \	   #cat, "LC_TIME")  TEST_ELEM (d_t_fmt);  TEST_ELEM (d_fmt);  TEST_ELEM (t_fmt);  /* According to C.Y.Alexis Cheng <alexis@vnet.ibm.com> the T_FMT_AMPM     field is optional.  */  if (time->t_fmt_ampm == NULL)    /* Use the 24h format as default.  */    time->t_fmt_ampm = time->t_fmt;  /* Now process the era entries.  */  if (time->cur_num_era != 0)    {      const int days_per_month[12] = { 31, 29, 31, 30, 31, 30,				       31, 31, 30, 31 ,30, 31 };      size_t idx;      time->era_entries =	(struct era_data *) xmalloc (time->cur_num_era				     * sizeof (struct era_data));      for (idx = 0; idx < time->cur_num_era; ++idx)	{	  size_t era_len = strlen (time->era[idx]);	  char *str = xmalloc ((era_len + 1 + 3) & ~3);	  char *endp;	  memcpy (str, time->era[idx], era_len + 1);	  /* First character must be + or - for the direction.  */	  if (*str != '+' && *str != '-' && !be_quiet)	    {	      error (0, 0, _("direction flag in string %d in `era' field"			     " in category `%s' is not '+' nor '-'"),		     idx + 1, "LC_TIME");	      /* Default arbitrarily to '+'.  */	      time->era_entries[idx].direction = '+';	    }	  else	    time->era_entries[idx].direction = *str;	  if (*++str != ':' && !be_quiet)	    {	      error (0, 0, _("direction flag in string %d in `era' field"			     " in category `%s' is not a single character"),		     idx + 1, "LC_TIME");	      (void) strsep (&str, ":");	    }	  else	    ++str;	  /* Now the offset year.  */	  time->era_entries[idx].offset = strtol (str, &endp, 10);	  if (endp == str && !be_quiet)	    {	      error (0, 0, _("illegal number for offset in string %d in"			     " `era' field in category `%s'"),		     idx + 1, "LC_TIME");	      (void) strsep (&str, ":");	    }	  else if (*endp != ':' && !be_quiet)	    {	      error (0, 0, _("garbage at end of offset value in string %d in"			     " `era' field in category `%s'"),		     idx + 1, "LC_TIME");	      (void) strsep (&str, ":");	    }	  else	    str = endp + 1;	  /* Next is the starting date in ISO format.  */	  if (strncmp (str, "-*", 2) == 0)	    {	      time->era_entries[idx].start_date[0] =		time->era_entries[idx].start_date[1] =		time->era_entries[idx].start_date[2] = 0x80000000;	      if (str[2] != ':')		goto garbage_start_date;	      str += 3;	    }	  else if (strncmp (str, "+*", 2) == 0)	    {	      time->era_entries[idx].start_date[0] =		time->era_entries[idx].start_date[1] =		time->era_entries[idx].start_date[2] = 0x7fffffff;	      if (str[2] != ':')		goto garbage_start_date;	      str += 3;	    }	  else	    {	      time->era_entries[idx].start_date[0] = strtol (str, &endp, 10);	      if (endp == str || *endp != '/')		goto invalid_start_date;	      else		str = endp + 1;	      time->era_entries[idx].start_date[0] -= 1900;	      time->era_entries[idx].start_date[1] = strtol (str, &endp, 10);	      if (endp == str || *endp != '/')		goto invalid_start_date;	      else		str = endp + 1;	      time->era_entries[idx].start_date[1] -= 1;	      time->era_entries[idx].start_date[2] = strtol (str, &endp, 10);	      if (endp == str && !be_quiet)		{		invalid_start_date:		  error (0, 0, _("illegal starting date in string %d in"				 " `era' field in category `%s'"),			 idx + 1, "LC_TIME");		  (void) strsep (&str, ":");		}	      else if (*endp != ':' && !be_quiet)		{		garbage_start_date:		  error (0, 0, _("garbage at end of starting date in string %d"				 " in `era' field in category `%s'"),			 idx + 1, "LC_TIME");		  (void) strsep (&str, ":");		}	      else		{		  str = endp + 1;		  /* Check for valid value.  */		  if ((time->era_entries[idx].start_date[1] < 0		       || time->era_entries[idx].start_date[1] >= 12		       || time->era_entries[idx].start_date[2] < 0		       || (time->era_entries[idx].start_date[2]			   > days_per_month[time->era_entries[idx].start_date[1]])		       || (time->era_entries[idx].start_date[1] == 2			   && time->era_entries[idx].start_date[2] == 29			   && !__isleap (time->era_entries[idx].start_date[0])))		      && !be_quiet)			  error (0, 0, _("starting date is illegal in"					 " string %d in `era' field in"					 " category `%s'"),				 idx + 1, "LC_TIME");		}	    }	  /* Next is the stopping date in ISO format.  */	  if (strncmp (str, "-*", 2) == 0)	    {	      time->era_entries[idx].stop_date[0] =		time->era_entries[idx].stop_date[1] =		time->era_entries[idx].stop_date[2] = 0x80000000;	      if (str[2] != ':')		goto garbage_stop_date;	      str += 3;	    }	  else if (strncmp (str, "+*", 2) == 0)	    {	      time->era_entries[idx].stop_date[0] =		time->era_entries[idx].stop_date[1] =		time->era_entries[idx].stop_date[2] = 0x7fffffff;	      if (str[2] != ':')		goto garbage_stop_date;	      str += 3;	    }	  else	    {	      time->era_entries[idx].stop_date[0] = strtol (str, &endp, 10);	      if (endp == str || *endp != '/')		goto invalid_stop_date;	      else		str = endp + 1;	      time->era_entries[idx].stop_date[0] -= 1900;	      time->era_entries[idx].stop_date[1] = strtol (str, &endp, 10);	      if (endp == str || *endp != '/')		goto invalid_stop_date;	      else		str = endp + 1;	      time->era_entries[idx].stop_date[1] -= 1;	      time->era_entries[idx].stop_date[2] = strtol (str, &endp, 10);	      if (endp == str && !be_quiet)		{		invalid_stop_date:		  error (0, 0, _("illegal stopping date in string %d in"				 " `era' field in category `%s'"),			 idx + 1, "LC_TIME");		  (void) strsep (&str, ":");		}	      else if (*endp != ':' && !be_quiet)		{		garbage_stop_date:		  error (0, 0, _("garbage at end of stopping date in string %d"				 " in `era' field in category `%s'"),			 idx + 1, "LC_TIME");		  (void) strsep (&str, ":");		}	      else		{		  str = endp + 1;		  /* Check for valid value.  */		  if ((time->era_entries[idx].stop_date[1] < 0		       || time->era_entries[idx].stop_date[1] >= 12		       || time->era_entries[idx].stop_date[2] < 0		       || (time->era_entries[idx].stop_date[2]			   > days_per_month[time->era_entries[idx].stop_date[1]])		       || (time->era_entries[idx].stop_date[1] == 2			   && time->era_entries[idx].stop_date[2] == 29			   && !__isleap (time->era_entries[idx].stop_date[0])))		      && !be_quiet)			  error (0, 0, _("stopping date is illegal in"					 " string %d in `era' field in"					 " category `%s'"),				 idx + 1, "LC_TIME");		}	    }	  if ((str == NULL || *str == '\0') && !be_quiet)	    {	      error (0, 0, _("missing era name in string %d in `era' field"			     " in category `%s'"), idx + 1, "LC_TIME");	      time->era_entries[idx].name =		time->era_entries[idx].format = "";	    }	  else	    {	      time->era_entries[idx].name = strsep (&str, ":");	      if ((str == NULL || *str == '\0') && !be_quiet)		{		  error (0, 0, _("missing era format in string %d in `era'"				 " field in category `%s'"),			 idx + 1, "LC_TIME");		  time->era_entries[idx].name =		    time->era_entries[idx].format = "";		}	      else		time->era_entries[idx].format = str;	    }	}      /* Construct the array for the other byte order.  */      time->era_entries_ob =	(struct era_data *) xmalloc (time->cur_num_era				      * sizeof (struct era_data));      for (idx = 0; idx < time->cur_num_era; ++idx)	{	  time->era_entries_ob[idx].direction =	    SWAPU32 (time->era_entries[idx].direction);	  time->era_entries_ob[idx].offset =	    SWAPU32 (time->era_entries[idx].offset);	  time->era_entries_ob[idx].start_date[0] =	    SWAPU32 (time->era_entries[idx].start_date[0]);	  time->era_entries_ob[idx].start_date[1] =	    SWAPU32 (time->era_entries[idx].start_date[1]);	  time->era_entries_ob[idx].start_date[2] =	    SWAPU32 (time->era_entries[idx].stop_date[2]);	  time->era_entries_ob[idx].stop_date[0] =	    SWAPU32 (time->era_entries[idx].stop_date[0]);	  time->era_entries_ob[idx].stop_date[1] =	    SWAPU32 (time->era_entries[idx].stop_date[1]);	  time->era_entries_ob[idx].stop_date[2] =	    SWAPU32 (time->era_entries[idx].stop_date[2]);	  time->era_entries_ob[idx].name =	    time->era_entries[idx].name;	  time->era_entries_ob[idx].format =	    time->era_entries[idx].format;	}    }}