summaryrefslogtreecommitdiff
path: root/lib/libc/time/localtime.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-01-14 03:16:59 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-01-14 03:16:59 +0000
commit58e66d894986eb6bf05241d3b6ae57f7bdf1982b (patch)
tree32ad8563d033d64a714551305f310e7d1b10c0bb /lib/libc/time/localtime.c
parent8137e9ba8aee70bd7be4f781fb9e78eaf047520e (diff)
Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.
Diffstat (limited to 'lib/libc/time/localtime.c')
-rw-r--r--lib/libc/time/localtime.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c
index c25b4356049..a7cdae4a063 100644
--- a/lib/libc/time/localtime.c
+++ b/lib/libc/time/localtime.c
@@ -1,5 +1,14 @@
+/*
+** This file is in the public domain, so clarified as of
+** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+*/
+
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: localtime.c,v 1.7 1996/10/30 00:20:14 tholo Exp $";
+#if 0
+static char elsieid[] = "@(#)localtime.c 7.59";
+#else
+static char rcsid[] = "$OpenBSD: localtime.c,v 1.8 1997/01/14 03:16:47 millert Exp $";
+#endif
#endif /* LIBC_SCCS and not lint */
/*
@@ -285,7 +294,7 @@ register struct state * const sp;
if (!doaccess && issetugid() == 0) {
if ((p = TZDIR) == NULL)
return -1;
- if (strlen(p) + 1 + strlen(name) + 1 >= sizeof fullname)
+ if ((strlen(p) + strlen(name) + 2) >= sizeof fullname)
return -1;
(void) strcpy(fullname, p);
(void) strcat(fullname, "/");
@@ -878,6 +887,7 @@ const int lastditch;
sp->ttis[1].tt_gmtoff = -dstoffset;
sp->ttis[1].tt_isdst = TRUE;
sp->ttis[1].tt_abbrind = stdlen + 1;
+ sp->typecnt = 2;
}
} else {
dstlen = 0;
@@ -1223,7 +1233,8 @@ const time_t * const timep;
/*
** Adapted from code provided by Robert Elz, who writes:
** The "best" way to do mktime I think is based on an idea of Bob
-** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now).
+** Kridle's (so its said...) from a long time ago.
+** [kridle@xinet.com as of 1996-01-16.]
** It does a binary search of the time_t space. Since time_t's are
** just 32 bits, its a max of 32 iterations (even at 64 bits it
** would still be very reasonable).
@@ -1313,10 +1324,12 @@ int * const okayp;
while (yourtm.tm_mday <= 0) {
if (increment_overflow(&yourtm.tm_year, -1))
return WRONG;
- yourtm.tm_mday += year_lengths[isleap(yourtm.tm_year)];
+ i = yourtm.tm_year + (1 < yourtm.tm_mon);
+ yourtm.tm_mday += year_lengths[isleap(i)];
}
while (yourtm.tm_mday > DAYSPERLYEAR) {
- yourtm.tm_mday -= year_lengths[isleap(yourtm.tm_year)];
+ i = yourtm.tm_year + (1 < yourtm.tm_mon);
+ yourtm.tm_mday -= year_lengths[isleap(i)];
if (increment_overflow(&yourtm.tm_year, 1))
return WRONG;
}