Timezone stuff and System V Verification Suite
Here are excerpts from two notes from Mike Wescott (wescott@ncrcae.Columbia.NCR.COM); I'd appreciate comments on the changes Mike suggests. (Lines preceded by "> " in the second note are Mike quoting me.) --ado Date: Thu, 9 Jul 87 15:29:36 pdt Message-Id: <8707092229.AA00730@SCUBED.ARPA> Subject: Re: v08i085: Public Domain localtime We have uncovered a problem with the PD ctime with respect to the System V Verification Suite and SVID compatibility. The problem is with tzset(). Try the little program, xxx.c: #include <time.h> main() { tzset(); printf("%s\n%s\n", tzname[0], tzname[1]); } and try the following: TZ=PST8PDT ./xxx it produces: PST PWT and TZ=EST5EDT ./xxx produces EST EWT The problem is that tzname[1] become the (obsolete) EWT. The fix, I believe, would be to use the most recently used abbreviations to the value of time(0). Diff for such a fix follows and passes SVVS. -Mike Wescott wescott@ncrcae.Columbia.NCR.COM *** localtime.c.or Thu Jul 9 09:57:27 1987 --- localtime.c Thu Jul 9 14:31:38 1987 *************** *** 90,95 **** --- 90,96 ---- { register int i; register int fid; + time_t now; if (name == 0 && (name = TZDEFAULT) == 0) return -1; *************** *** 182,191 **** timezone = -s.ttis[0].tt_gmtoff; daylight = 0; #endif /* USG_COMPAT */ ! for (i = 1; i < s.typecnt; ++i) { register struct ttinfo * ttisp; ! ! ttisp = &s.ttis[i]; if (ttisp->tt_isdst) { tzname[1] = &s.chars[ttisp->tt_abbrind]; #ifdef USG_COMPAT --- 183,194 ---- timezone = -s.ttis[0].tt_gmtoff; daylight = 0; #endif /* USG_COMPAT */ ! now = time(0); ! for (i = 1; i < s.timecnt; ++i) { register struct ttinfo * ttisp; ! if (now < s.ats[i]) ! break; ! ttisp = &s.ttis[s.types[i]]; if (ttisp->tt_isdst) { tzname[1] = &s.chars[ttisp->tt_abbrind]; #ifdef USG_COMPAT ------------------------------------------------------------------------------- Date: Tue, 14 Jul 87 07:22:19 pdt Message-Id: <8707141422.AA27049@SCUBED.ARPA> Subject: Re: v08i085: Public Domain localtime
Many thanks for the note on the problem with SVVS. Would it be all right with you if I passed the note on to other interested folks?
No problem, I sent it to you with that in mind. The code could probably be made a little more efficient but it shouldn't have to run too often.
Also--the time zone files described in the "systemv" file were designed to provide System V compatibility. It looks as if you're in a position to check on whether they actually do; if you could, I'd appreciate it.
We ran SVVS (SysVr2 not r3 yet) and the only thing it complained about was the problem with the tzset() function. We are compiling with USG, USG_COMPAT, and STD_INSPIRED defined. I'll check the "systemv" file but it doesn't seem to be problem as far as SVVS goes.
I don't think that that mod is needed, the real problem is in the data files, which are allowing that EWT nonsense to creep into what should be pure EST/EDT stuff. I think the "right" fix is to remove the "Link" lines from the "northamerica" file (which provides the EST5EDT aliases) and put them in the "systemv" file, where the data should be an accurate System V emulation. Those files will always provide EST and EDT in tzname, no matter which happens to be the most recent zone name (if the user says he wants EST and EDT then that's what should be delivered, regardless of what the current zone name happens to be). Having said that, I have no real objection to the code either, though I think I'd do it in zic so it only needs to be done once (sort the ttis array so the "right" result is achieved in tzset()). Of course the "time(0)" should be "time((time_t *)0)". It makes more sense to fill in tzname[] with recent zone names in cases where there have been several that could fit. Or perhaps the "blessed" 2 zone names should be marked in the data file to avoid surprises. All this is just another nail in the coffin for tzname though as far as I'm concerned, pretending that there are two (or one) zone names, and that they can be characterised purely by whether its dst or not is hopeless. Both the Sys V and BSD standard timezone name stuff is trash, it all needs to be discarded completely. (Somehow I think I've said this before...) kre
participants (2)
-
ado -
Robert Elz