diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 499e498160fa..ef58d66586ac 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $NetBSD: localtime.c,v 1.12 1997/07/21 14:09:20 jtc Exp $ */ +/* $NetBSD: localtime.c,v 1.13 1997/09/05 02:11:55 jtc Exp $ */ /* ** This file is in the public domain, so clarified as of @@ -9,9 +9,9 @@ #ifndef lint #ifndef NOID #if 0 -static char elsieid[] = "@(#)localtime.c 7.61"; +static char elsieid[] = "@(#)localtime.c 7.62"; #else -__RCSID("$NetBSD: localtime.c,v 1.12 1997/07/21 14:09:20 jtc Exp $"); +__RCSID("$NetBSD: localtime.c,v 1.13 1997/09/05 02:11:55 jtc Exp $"); #endif #endif /* !defined NOID */ #endif /* !defined lint */ @@ -153,6 +153,10 @@ static time_t time2 P((struct tm *tmp, void(*funcp) P((const time_t *, long, struct tm*)), long offset, int * okayp)); +static time_t time2sub P((struct tm *tmp, + void(*funcp) P((const time_t *, + long, struct tm*)), + long offset, int * okayp, int do_norm_secs)); static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp)); static int tmcomp P((const struct tm * atmp, @@ -1318,11 +1322,12 @@ register const struct tm * const btmp; } static time_t -time2(tmp, funcp, offset, okayp) +time2sub(tmp, funcp, offset, okayp, do_norm_secs) struct tm * const tmp; void (* const funcp) P((const time_t*, long, struct tm*)); const long offset; int * const okayp; +const int do_norm_secs; { register const struct state * sp; register int dir; @@ -1335,6 +1340,11 @@ int * const okayp; *okayp = FALSE; yourtm = *tmp; + if (do_norm_secs) { + if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec, + SECSPERMIN)) + return WRONG; + } if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR)) return WRONG; if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) @@ -1463,6 +1473,24 @@ label: return t; } +static time_t +time2(tmp, funcp, offset, okayp) +struct tm * const tmp; +void (* const funcp) P((const time_t*, long, struct tm*)); +const long offset; +int * const okayp; +{ + time_t t; + + /* + ** First try without normalization of seconds + ** (in case tm_sec contains a value associated with a leap second). + ** If that fails, try with normalization of seconds. + */ + t = time2sub(tmp, funcp, offset, okayp, FALSE); + return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE); +} + static time_t time1(tmp, funcp, offset) struct tm * const tmp; diff --git a/lib/libc/time/private.h b/lib/libc/time/private.h index 238521fe9898..8cc1d3d2ba1d 100644 --- a/lib/libc/time/private.h +++ b/lib/libc/time/private.h @@ -1,4 +1,4 @@ -/* $NetBSD: private.h,v 1.9 1997/07/13 20:26:51 christos Exp $ */ +/* $NetBSD: private.h,v 1.10 1997/09/05 02:11:57 jtc Exp $ */ #ifndef PRIVATE_H #define PRIVATE_H @@ -29,7 +29,7 @@ #ifndef lint #ifndef NOID #if 0 -static char privatehid[] = "@(#)private.h 7.45"; +static char privatehid[] = "@(#)private.h 7.46"; #endif #endif /* !defined NOID */ #endif /* !defined lint */ @@ -191,7 +191,7 @@ char * imalloc P((int n)); void * irealloc P((void * pointer, int size)); void icfree P((char * pointer)); void ifree P((char * pointer)); -char * scheck P((const char *string, char *format)); +char * scheck P((const char *string, const char *format)); /* diff --git a/lib/libc/time/scheck.c b/lib/libc/time/scheck.c index dcc5824b456c..d86bb8534eac 100644 --- a/lib/libc/time/scheck.c +++ b/lib/libc/time/scheck.c @@ -1,12 +1,12 @@ -/* $NetBSD: scheck.c,v 1.5 1997/07/13 20:26:52 christos Exp $ */ +/* $NetBSD: scheck.c,v 1.6 1997/09/05 02:11:58 jtc Exp $ */ #include #ifndef lint #ifndef NOID #if 0 -static char elsieid[] = "@(#)scheck.c 8.14"; +static char elsieid[] = "@(#)scheck.c 8.15"; #else -__RCSID("$NetBSD: scheck.c,v 1.5 1997/07/13 20:26:52 christos Exp $"); +__RCSID("$NetBSD: scheck.c,v 1.6 1997/09/05 02:11:58 jtc Exp $"); #endif #endif /* !defined lint */ #endif /* !defined NOID */ @@ -18,7 +18,7 @@ __RCSID("$NetBSD: scheck.c,v 1.5 1997/07/13 20:26:52 christos Exp $"); char * scheck(string, format) const char * const string; -char * const format; +const char * const format; { register char * fbuf; register const char * fp;