Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Dec 2003 20:31:53 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        freebsd-standards@freebsd.org
Subject:   Re: mktime and tm_isdst
Message-ID:  <20031205023153.GC28388@dan.emsphone.com>
In-Reply-To: <200311220440.hAM4eckQ011677@khavrinen.lcs.mit.edu>
References:  <20031121191529.GD2146@dan.emsphone.com> <200311220440.hAM4eckQ011677@khavrinen.lcs.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

--FL5UXtIhxfXey3p5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

In the last episode (Nov 21), Garrett Wollman said:
> <<On Fri, 21 Nov 2003 13:15:29 -0600, Dan Nelson <dnelson@allantgroup.com> 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
> <ftp://elsie.nci.nih.gov/pub/>; 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--


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031205023153.GC28388>