From owner-freebsd-standards@FreeBSD.ORG Thu Dec 4 18:31:56 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F23BB16A4CE for ; Thu, 4 Dec 2003 18:31:55 -0800 (PST) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7CA843FE5 for ; Thu, 4 Dec 2003 18:31:54 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id hB52Vsuc099262; Thu, 4 Dec 2003 20:31:54 -0600 (CST) (envelope-from dan) Date: Thu, 4 Dec 2003 20:31:53 -0600 From: Dan Nelson To: Garrett Wollman Message-ID: <20031205023153.GC28388@dan.emsphone.com> References: <20031121191529.GD2146@dan.emsphone.com> <200311220440.hAM4eckQ011677@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline In-Reply-To: <200311220440.hAM4eckQ011677@khavrinen.lcs.mit.edu> X-OS: FreeBSD 5.2-BETA X-message-flag: Outlook Error User-Agent: Mutt/1.5.5.1i cc: freebsd-standards@freebsd.org Subject: Re: mktime and tm_isdst X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2003 02:31:56 -0000 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In the last episode (Nov 21), Garrett Wollman said: > < said: > > > I've got a question about mktime and FreeBSD's use of the tm_isdst > > flag. > > Suggest you compare with the original code at > and bring up any unresolved issues on > the tz@elsie.nci.nih.gov list. While the two codebases have evolved > in somewhat different directions, the basic implementation should > still be the same (and ours is probably wrong to the extent that it > isn't). It's an interaction with a bug in the original tzcode code and the America/Chicago zone; it doesn't trigger for any other zone afaik. I'd give an url for the patch, but there apparently is no web archive of the list :( Patch attached instead; it's short. -- Dan Nelson dnelson@allantgroup.com --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="localtime.c.diff" Index: localtime.c =================================================================== RCS file: /home/ncvs/src/lib/libc/stdtime/localtime.c,v retrieving revision 1.36 diff -u -r1.36 localtime.c --- localtime.c 16 Feb 2003 17:29:11 -0000 1.36 +++ localtime.c 4 Dec 2003 04:17:11 -0000 @@ -1559,6 +1559,11 @@ time_t t; const struct state * sp; int samei, otheri; + int sameind, otherind; + int i; + int nseen; + int seen[TZ_MAX_TYPES]; + int types[TZ_MAX_TYPES]; int okay; if (tmp->tm_isdst > 1) @@ -1592,10 +1597,20 @@ if (sp == NULL) return WRONG; #endif /* defined ALL_STATE */ - for (samei = sp->typecnt - 1; samei >= 0; --samei) { + for (i = 0; i < sp->typecnt; ++i) + seen[i] = FALSE; + nseen = 0; + for (i = sp->timecnt - 1; i >= 0; --i) + if (!seen[sp->types[i]]) { + seen[sp->types[i]] = TRUE; + types[nseen++] = sp->types[i]; + } + for (sameind = 0; sameind < nseen; ++sameind) { + samei = types[sameind]; if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) continue; - for (otheri = sp->typecnt - 1; otheri >= 0; --otheri) { + for (otherind = 0; otherind < nseen; ++otherind) { + otheri = types[otherind]; if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) continue; tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - --FL5UXtIhxfXey3p5--