zdump -v crashes with 64-bit time_t

Olson, Arthur David (NIH/NCI) olsona at dc37a.nci.nih.gov
Mon Jun 14 15:51:48 UTC 2004


Here's a proposed change to zdump to avoid crashes when NULL is returned by
asctime.

				--ado

------- zdump.c -------
*** /tmp/geta13866	Mon Jun 14 11:47:06 2004
--- /tmp/getb13866	Mon Jun 14 11:47:06 2004
***************
*** 1,4 ****
! static char	elsieid[] = "@(#)zdump.c	7.31";
  
  /*
  ** This code has been made independent of the rest of the time
--- 1,4 ----
! static char	elsieid[] = "@(#)zdump.c	7.32";
  
  /*
  ** This code has been made independent of the rest of the time
***************
*** 334,339 ****
--- 334,346 ----
  	return result;
  }
  
+ static char *
+ nonnull(s)
+ const char * const	s;
+ {
+ 	return (s == NULL) ? "NULL" : s;
+ }
+ 
  static void
  show(zone, t, v)
  char *	zone;
***************
*** 344,352 ****
  
  	(void) printf("%-*s  ", (int) longest, zone);
  	if (v)
! 		(void) printf("%.24s UTC = ", asctime(gmtime(&t)));
  	tmp = localtime(&t);
! 	(void) printf("%.24s", asctime(tmp));
  	if (*abbr(tmp) != '\0')
  		(void) printf(" %s", abbr(tmp));
  	if (v) {
--- 351,359 ----
  
  	(void) printf("%-*s  ", (int) longest, zone);
  	if (v)
! 		(void) printf("%.24s UTC = ", nonnull(asctime(gmtime(&t))));
  	tmp = localtime(&t);
! 	(void) printf("%.24s", nonnull(asctime(tmp)));
  	if (*abbr(tmp) != '\0')
  		(void) printf(" %s", abbr(tmp));
  	if (v) {



More information about the tz mailing list