tz behavior difference TZif vs. TZif2 (potential fix)

Olson, Arthur David (NIH/NCI) [E] olsona at dc37a.nci.nih.gov
Thu Mar 23 21:16:34 UTC 2006


Here are changes to zic.c to eliminate unused abbreviations from output
files. This at-first-blush gratuitous optimization avoids problems with
old versions of the time zone package misinterpreting the binary files.

I'd love to know if this solves the problems with Indian/Cocos and such.

				--ado

------- zic.c -------
*** /tmp/geta28731	Thu Mar 23 16:13:23 2006
--- /tmp/getb28731	Thu Mar 23 16:13:23 2006
***************
*** 1,4 ****
! static char	elsieid[] = "@(#)zic.c	8.1";
  
  #include "private.h"
  #include "locale.h"
--- 1,4 ----
! static char	elsieid[] = "@(#)zic.c	8.2";
  
  #include "private.h"
  #include "locale.h"
***************
*** 1587,1592 ****
--- 1587,1595 ----
  		int		writetype[TZ_MAX_TIMES];
  		int		typemap[TZ_MAX_TYPES];
  		register int	thistypecnt;
+ 		char		thischars[TZ_MAX_CHARS];
+ 		char		thischarcnt;
+ 		int 		indmap[TZ_MAX_CHARS];
  
  		if (pass == 1) {
  			thistimei = timei32;
***************
*** 1618,1623 ****
--- 1621,1639 ----
  		thistypecnt = 0;
  		for (i = 0; i < typecnt; ++i)
  			typemap[i] = writetype[i] ?  thistypecnt++ : -1;
+ 		for (i = 0; i < sizeof indmap / sizeof indmap[0]; ++i)
+ 			indmap[i] = -1;
+ 		thischarcnt = 0;
+ 		for (i = 0; i < typecnt; ++i) {
+ 			if (!writetype[i])
+ 				continue;
+ 			if (indmap[abbrinds[i]] >= 0)
+ 				continue;
+ 			indmap[abbrinds[i]] = thischarcnt;
+ 			(void) strcpy(&thischars[thischarcnt],
+ 				&chars[abbrinds[i]]);
+ 			thischarcnt += strlen(&chars[abbrinds[i]]) + 1;
+ 		}
  #define DO(field)	(void) fwrite((void *) tzh.field, \
  				(size_t) sizeof tzh.field, (size_t) 1,
fp)
  		tzh = tzh0;
***************
*** 1628,1634 ****
  		convert(eitol(thisleapcnt), tzh.tzh_leapcnt);
  		convert(eitol(thistimecnt), tzh.tzh_timecnt);
  		convert(eitol(thistypecnt), tzh.tzh_typecnt);
! 		convert(eitol(charcnt), tzh.tzh_charcnt);
  		DO(tzh_magic);
  		DO(tzh_version);
  		DO(tzh_reserved);
--- 1644,1650 ----
  		convert(eitol(thisleapcnt), tzh.tzh_leapcnt);
  		convert(eitol(thistimecnt), tzh.tzh_timecnt);
  		convert(eitol(thistypecnt), tzh.tzh_typecnt);
! 		convert(eitol(thischarcnt), tzh.tzh_charcnt);
  		DO(tzh_magic);
  		DO(tzh_version);
  		DO(tzh_reserved);
***************
*** 1656,1666 ****
  			if (writetype[i]) {
  				puttzcode(gmtoffs[i], fp);
  				(void) putc(isdsts[i], fp);
! 				(void) putc(abbrinds[i], fp);
  			}
! 		if (charcnt != 0)
! 			(void) fwrite((void *) chars, (size_t) sizeof
chars[0],
! 				(size_t) charcnt, fp);
  		for (i = thisleapi; i < thisleaplim; ++i) {
  			register zic_t	todo;
  
--- 1672,1683 ----
  			if (writetype[i]) {
  				puttzcode(gmtoffs[i], fp);
  				(void) putc(isdsts[i], fp);
! 				(void) putc((unsigned char)
indmap[abbrinds[i]], fp);
  			}
! 		if (thischarcnt != 0)
! 			(void) fwrite((void *) thischars,
! 				(size_t) sizeof thischars[0],
! 				(size_t) thischarcnt, fp);
  		for (i = thisleapi; i < thisleaplim; ++i) {
  			register zic_t	todo;
  




More information about the tz mailing list