tz package

Arthur David Olson ado
Mon May 30 16:52:46 UTC 1988


> I started looking over your tz package.  Thin[g]s look nice.  Have you had
> any patches since the posting?  My Patchlevel.h file shows I am at
> PATCHLEVEL #1.

No "released to a source moderator" patches yet, and nothing that's very big.
I've attached some "unofficial" diffs to the end of this letter:

	Makefile	the suggestion to remove "timezone.o" from "libc.a"
			is deleted
	tzfile.h	a redundant definition of TM_SUNDAY is deleted
	getopt.c	is now the latest version from Berkeley (with an elsie
			header on the front to keep sccs happy)
	localtime.c	has an added workaround for a bug in 3B1s.

The 3B1 workaround is the change I'm least sure of; after I made it I sent it
off to the person who originally reported the problem and asked for a blessing;
I've yet to receive a response.  In particular I'm not sure that conditioning
on "m68k" is right; this may just be a 3B1 problem.

A bit back Guy Harris sent along changes to allow localtime to handle
POSIX-style TZ environment variables; as soon as I confirm that it's okay to
do so, I can send these along.

> I suggest that you put a BIG warning around the use of 'leapseconds'
> in time calculations.  For a number of reasons, POSIX (IEEE standard
> Unix, soon to be ANSI and ISO standard unix) prohibits the standard
> conversion to/from "Seconds since the Epoch" functions from taking
> leapseconds into account.  This means that if anyone does use the
> timezone deltas, their system will be out of conformance.  If leapseconds
> are desired, then such systems need to use different time conversion
> functions to do this.

If you could work up a "chapter and verse" explanation, I'd be glad to add it
to the distribution.  Presumably the thing to do would be to have LEAPSECONDS
default to /dev/null in the Makefile, with a note in the Makefile on how to
get leapseconds accounted for and an explanation of why you might not want to.

				--ado

*** 4.1/Makefile	Mon May 30 12:26:20 1988
--- 4.2/Makefile	Mon May 30 12:26:33 1988
***************
*** 1,4 ****
! # @(#)Makefile	4.1
  
  # If you want something other than Eastern United States time used on your
  # system, change the line below (after finding the zone you want in the
--- 1,4 ----
! # @(#)Makefile	4.2
  
  # If you want something other than Eastern United States time used on your
  # system, change the line below (after finding the zone you want in the
***************
*** 14,20 ****
  
  # You may want to change this define if you're just testing the software.
  # Alternatively, you can put these functions in /lib/libc.a, removing
! # the old "ctime.o" (and "timezone.o" on a BSD system).  This is the
  # ideal solution if you are able.  Build libz.a, extract the files, and
  # then add them to libc.a.
  
--- 14,20 ----
  
  # You may want to change this define if you're just testing the software.
  # Alternatively, you can put these functions in /lib/libc.a, removing
! # the old "ctime.o".  This is the
  # ideal solution if you are able.  Build libz.a, extract the files, and
  # then add them to libc.a.
  
*** 4.1/getopt.c	Mon May 30 12:27:21 1988
--- 4.2/getopt.c	Mon May 30 12:27:22 1988
***************
*** 1,16 ****
  #ifndef lint
  #ifndef NOID
! static char	elsieid[] = "@(#)getopt.c	4.1";
  #endif /* !defined NOID */
  #endif /* !defined lint */
  
  /*LINTLIBRARY*/
  
! #include "string.h"
  
! #ifndef strchr
! #define index	strchr
! #endif /* !defined strchr */
  
  #include <stdio.h>
  
--- 1,28 ----
  #ifndef lint
  #ifndef NOID
! static char	elsieid[] = "@(#)getopt.c	4.2";
  #endif /* !defined NOID */
  #endif /* !defined lint */
  
  /*LINTLIBRARY*/
  
! /*
!  * Copyright (c) 1987 Regents of the University of California.
!  * All rights reserved.
!  *
!  * Redistribution and use in source and binary forms are permitted
!  * provided that this notice is preserved and that due credit is given
!  * to the University of California at Berkeley. The name of the University
!  * may not be used to endorse or promote products derived from this
!  * software without specific written prior permission. This software
!  * is provided ``as is'' without express or implied warranty.
!  */
  
! #ifdef LIBC_SCCS
! #ifndef lint
! static char sccsid[] = "@(#)getopt.c	4.5 (Berkeley) 11/24/87";
! #endif /* !defined lint */
! #endif /* defined LIBC_SCCS */
  
  #include <stdio.h>
  
***************
*** 17,23 ****
  /*
   * get option letter from argument vector
   */
! int	opterr = 1,		/* useless, never set or used */
  	optind = 1,		/* index into parent argv vector */
  	optopt;			/* character checked for validity */
  char	*optarg;		/* argument associated with option */
--- 29,35 ----
  /*
   * get option letter from argument vector
   */
! int	opterr = 1,		/* if error message should be printed */
  	optind = 1,		/* index into parent argv vector */
  	optopt;			/* character checked for validity */
  char	*optarg;		/* argument associated with option */
***************
*** 24,65 ****
  
  #define BADCH	(int)'?'
  #define EMSG	""
! #define tell(s)	fputs(*nargv,stderr);fputs(s,stderr); \
! 		fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
  
! getopt(nargc,nargv,ostr)
! int	nargc;
! char	**nargv,
! 	*ostr;
  {
! 	static char	*place = EMSG;	/* option letter processing */
! 	register char	*oli;		/* option letter list index */
  	char	*index();
  
! 	if(!*place) {			/* update scanning pointer */
! 		if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
! 		if (*place == '-') {	/* found "--" */
  			++optind;
  			return(EOF);
  		}
! 	}				/* option letter okay? */
! 	if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr,optopt))) {
! 		if(!*place) ++optind;
  		tell(": illegal option -- ");
  	}
! 	if (*++oli != ':') {		/* don't need argument */
  		optarg = NULL;
! 		if (!*place) ++optind;
  	}
! 	else {				/* need an argument */
! 		if (*place) optarg = place;	/* no white space */
  		else if (nargc <= ++optind) {	/* no arg */
  			place = EMSG;
  			tell(": option requires an argument -- ");
  		}
! 	 	else optarg = nargv[optind];	/* white space */
  		place = EMSG;
  		++optind;
  	}
! 	return(optopt);			/* dump back option letter */
  }
--- 36,90 ----
  
  #define BADCH	(int)'?'
  #define EMSG	""
! #define tell(s)	{ \
! 	if (opterr) { \
! 		fputs(*nargv, stderr); \
! 		fputs(s, stderr); \
! 		fputc(optopt, stderr); \
! 		fputc((int)'\n', stderr); \
! 	} \
! 	return(BADCH); \
! }
  
! getopt(nargc, nargv, ostr)
! 	int	nargc;
! 	char	**nargv, *ostr;
  {
! 	static char	*place = EMSG;		/* option letter processing */
! 	register char	*oli;			/* option letter list index */
  	char	*index();
  
! 	if (!*place) {				/* update scanning pointer */
! 		if (optind >= nargc || *(place = nargv[optind]) != '-' ||
! 		    !*++place)
! 			return(EOF);
! 		if (*place == '-') {		/* found "--" */
  			++optind;
  			return(EOF);
  		}
! 	}					/* option letter okay? */
! 	if ((optopt = (int)*place++) == (int)':' ||
! 	    !(oli = index(ostr, optopt))) {
! 		if (!*place)
! 			++optind;
  		tell(": illegal option -- ");
  	}
! 	if (*++oli != ':') {			/* don't need argument */
  		optarg = NULL;
! 		if (!*place)
! 			++optind;
  	}
! 	else {					/* need an argument */
! 		if (*place)			/* no white space */
! 			optarg = place;
  		else if (nargc <= ++optind) {	/* no arg */
  			place = EMSG;
  			tell(": option requires an argument -- ");
  		}
! 	 	else				/* white space */
! 			optarg = nargv[optind];
  		place = EMSG;
  		++optind;
  	}
! 	return(optopt);				/* dump back option letter */
  }
*** 4.1/tzfile.h	Mon May 30 12:25:44 1988
--- 4.2/tzfile.h	Mon May 30 12:25:49 1988
***************
*** 2,8 ****
  #ifndef NOID
  #ifndef TZFILE_H
  #define TZFILE_H
! static char	tzfilehid[] = "@(#)tzfile.h	4.1";
  #endif /* !defined TZFILE_H */
  #endif /* !defined NOID */
  #endif /* !defined lint */
--- 2,8 ----
  #ifndef NOID
  #ifndef TZFILE_H
  #define TZFILE_H
! static char	tzfilehid[] = "@(#)tzfile.h	4.2";
  #endif /* !defined TZFILE_H */
  #endif /* !defined NOID */
  #endif /* !defined lint */
***************
*** 107,113 ****
  #define TM_OCTOBER	9
  #define TM_NOVEMBER	10
  #define TM_DECEMBER	11
- #define TM_SUNDAY	0
  
  #define TM_YEAR_BASE	1900
  
--- 107,112 ----
*** 4.1/localtime.c	Mon May 30 12:49:30 1988
--- 4.6/localtime.c	Mon May 30 12:49:47 1988
***************
*** 1,6 ****
  #ifndef lint
  #ifndef NOID
! static char	elsieid[] = "@(#)localtime.c	4.1";
  #endif /* !defined NOID */
  #endif /* !defined lint */
  
--- 1,6 ----
  #ifndef lint
  #ifndef NOID
! static char	elsieid[] = "@(#)localtime.c	4.6";
  #endif /* !defined NOID */
  #endif /* !defined lint */
  
***************
*** 389,394 ****
--- 389,403 ----
  	}
  	days = *clock / SECSPERDAY;
  	rem = *clock % SECSPERDAY;
+ #ifdef mc68k
+ 	if (*clock == 0x80000000) {
+ 		/*
+ 		** A 3B1 muffs the division on the most negative number.
+ 		*/
+ 		days = -24855;
+ 		rem = -11648;
+ 	}
+ #endif /* mc68k */
  	rem += (offset - corr);
  	while (rem < 0) {
  		rem += SECSPERDAY;



More information about the tz mailing list