error "too many transitions"

Arthur David Olson olsona at lecserver.nci.nih.gov
Mon Nov 19 22:57:50 UTC 2007


That's not a feature, it's a bug. Here are changes to "zic.c" to eliminate
the error message, and to "localtime.c" to ensure correct handling of zones
to be treated as if they had long-ago DST (rather like proleptic calendars).

				--ado

------- zic.c -------
*** /tmp/geta13214	Mon Nov 19 17:41:38 2007
--- /tmp/getb13214	Mon Nov 19 17:41:39 2007
***************
*** 2012,2018 ****
  	}
  	for (i = 0; i < zonecount; ++i) {
  		zp = &zpfirst[i];
! 		updateminmax(zp->z_untilrule.r_loyear);
  		for (j = 0; j < zp->z_nrules; ++j) {
  			rp = &zp->z_rules[j];
  			if (rp->r_lowasnum)
--- 2012,2019 ----
  	}
  	for (i = 0; i < zonecount; ++i) {
  		zp = &zpfirst[i];
! 		if (i < zonecount - 1)
! 			updateminmax(zp->z_untilrule.r_loyear);
  		for (j = 0; j < zp->z_nrules; ++j) {
  			rp = &zp->z_rules[j];
  			if (rp->r_lowasnum)
***************
*** 2043,2050 ****
  		else	max_year = INT_MAX;
  	}
  	/*
! 	** For the benefit of older systems, generate data through 2037.
  	*/
  	if (max_year < 2037)
  		max_year = 2037;
  	for (i = 0; i < zonecount; ++i) {
--- 2044,2054 ----
  		else	max_year = INT_MAX;
  	}
  	/*
! 	** For the benefit of older systems,
! 	** generate data from 1900 through 2037.
  	*/
+ 	if (min_year > 1900)
+ 		min_year = 1900;
  	if (max_year < 2037)
  		max_year = 2037;
  	for (i = 0; i < zonecount; ++i) {

------- localtime.c -------
*** /tmp/geta13272	Mon Nov 19 17:43:30 2007
--- /tmp/getb13272	Mon Nov 19 17:43:30 2007
***************
*** 177,182 ****
--- 177,183 ----
  				const struct tm * btmp);
  static time_t		transtime(time_t janfirst, int year,
  				const struct rule * rulep, long offset);
+ static int		typesequiv(const struct state * sp, int a, int b);
  static int		tzload(const char * name, struct state * sp,
  				int doextend);
  static int		tzparse(const char * name, struct state * sp,
***************
*** 556,570 ****
  	}
  	i = 2 * YEARSPERREPEAT;
  	sp->goback = sp->goahead = sp->timecnt > i;
! 	sp->goback = sp->goback && sp->types[i] == sp->types[0] &&
  		differ_by_repeat(sp->ats[i], sp->ats[0]);
  	sp->goahead = sp->goahead &&
! 		sp->types[sp->timecnt - 1] == sp->types[sp->timecnt - 1 - i] &&
  		differ_by_repeat(sp->ats[sp->timecnt - 1],
  			 sp->ats[sp->timecnt - 1 - i]);
  	return 0;
  }
  
  static const int	mon_lengths[2][MONSPERYEAR] = {
  	{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
  	{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--- 557,598 ----
  	}
  	i = 2 * YEARSPERREPEAT;
  	sp->goback = sp->goahead = sp->timecnt > i;
! 	sp->goback = sp->goback &&
! 		typesequiv(sp, sp->types[i], sp->types[0]) &&
  		differ_by_repeat(sp->ats[i], sp->ats[0]);
  	sp->goahead = sp->goahead &&
! 		typesequiv(sp, sp->types[sp->timecnt - 1],
! 		sp->types[sp->timecnt - 1 - i]) &&
  		differ_by_repeat(sp->ats[sp->timecnt - 1],
  			 sp->ats[sp->timecnt - 1 - i]);
  	return 0;
  }
  
+ static int
+ typesequiv(sp, a, b)
+ const struct state * const	sp;
+ const int			a;
+ const int			b;
+ {
+ 	register int	result;
+ 
+ 	if (sp == NULL ||
+ 		a < 0 || a >= sp->typecnt ||
+ 		b < 0 || b >= sp->typecnt)
+ 			result = FALSE;
+ 	else {
+ 		register const struct ttinfo *	ap = &sp->ttis[a];
+ 		register const struct ttinfo *	bp = &sp->ttis[b];
+ 		result = ap->tt_gmtoff == bp->tt_gmtoff &&
+ 			ap->tt_isdst == bp->tt_isdst &&
+ 			ap->tt_ttisstd == bp->tt_ttisstd &&
+ 			ap->tt_ttisgmt == bp->tt_ttisgmt &&
+ 			strcmp(&sp->chars[ap->tt_abbrind],
+ 			&sp->chars[bp->tt_abbrind]) == 0;
+ 	}
+ 	return result;
+ }
+ 
  static const int	mon_lengths[2][MONSPERYEAR] = {
  	{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
  	{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }



More information about the tz mailing list