summaryrefslogtreecommitdiff
path: root/lib/libc/time/localtime.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-06-28 14:47:42 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-06-28 14:47:42 +0000
commit649064f54e1db5353b15212220a0f4820bc702e0 (patch)
treea15440db070e684b9ef6184884dc61ad194185b9 /lib/libc/time/localtime.c
parentd922b4f13ca6b3c833a086a78358151b7df3ff07 (diff)
merge in tzcode2004a
Diffstat (limited to 'lib/libc/time/localtime.c')
-rw-r--r--lib/libc/time/localtime.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c
index 997159bdb53..59615a97971 100644
--- a/lib/libc/time/localtime.c
+++ b/lib/libc/time/localtime.c
@@ -4,8 +4,8 @@
*/
#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID)
-static char elsieid[] = "@(#)localtime.c 7.76";
-static char rcsid[] = "$OpenBSD: localtime.c,v 1.23 2003/10/06 00:17:13 millert Exp $";
+static char elsieid[] = "@(#)localtime.c 7.78";
+static char rcsid[] = "$OpenBSD: localtime.c,v 1.24 2004/06/28 14:47:41 millert Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -1064,6 +1064,10 @@ struct tm * const tmp;
#endif /* defined TM_ZONE */
}
+/*
+** Re-entrant version of localtime.
+*/
+
struct tm *
localtime_r(timep, p_tm)
const time_t * const timep;
@@ -1130,6 +1134,10 @@ struct tm * const tmp;
#endif /* defined TM_ZONE */
}
+/*
+** Re-entrant version of gmtime.
+*/
+
struct tm *
gmtime_r(timep, p_tm)
const time_t * timep;
@@ -1531,6 +1539,11 @@ const long offset;
register time_t t;
register const struct state * sp;
register int samei, otheri;
+ register int sameind, otherind;
+ register int i;
+ register int nseen;
+ int seen[TZ_MAX_TYPES];
+ int types[TZ_MAX_TYPES];
int okay;
if (tmp->tm_isdst > 1)
@@ -1564,10 +1577,20 @@ const long offset;
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 -