From 61fce72197c4cca0be196b069916087881ef9488 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 21 Jul 2012 11:35:27 +0200 Subject: [PATCH] Sync various files with tzcode2012c from ftp://ftp.iana.org/tz/releases Not much to see here. Mainly removal of RCS IDs and some minor adjustments in localtime(3). --- include/tzfile.h | 5 -- lib/libc/gen/tzset.3 | 2 - lib/libc/stdtime/asctime.c | 1 - lib/libc/stdtime/ctime.3 | 2 - lib/libc/stdtime/difftime.c | 2 - lib/libc/stdtime/localtime.c | 95 +++++++++++++++++++---------------- lib/libc/stdtime/private.h | 2 - lib/libc/stdtime/strftime.3 | 2 - lib/libc/stdtime/strftime.c | 7 --- lib/libc/stdtime/time2posix.3 | 2 - lib/libc/stdtime/tzfile.5 | 2 - lib/libc/stdtime/tzfile.h | 5 -- usr.sbin/zic/ialloc.c | 2 - usr.sbin/zic/private.h | 2 - usr.sbin/zic/scheck.c | 2 - usr.sbin/zic/zdump.8 | 2 - usr.sbin/zic/zdump.c | 2 - usr.sbin/zic/zic.8 | 2 - usr.sbin/zic/zic.c | 1 - 19 files changed, 53 insertions(+), 87 deletions(-) diff --git a/include/tzfile.h b/include/tzfile.h index ae5affca5e..f3a0543f67 100644 --- a/include/tzfile.h +++ b/include/tzfile.h @@ -1,8 +1,3 @@ -/* - * @(#)tzfile.h 8.1 - * $DragonFly: src/lib/libc/stdtime/tzfile.h,v 1.3 2008/10/19 20:15:58 swildner Exp $ - */ - #ifndef TZFILE_H #define TZFILE_H diff --git a/lib/libc/gen/tzset.3 b/lib/libc/gen/tzset.3 index f72958880a..de66084ba3 100644 --- a/lib/libc/gen/tzset.3 +++ b/lib/libc/gen/tzset.3 @@ -32,9 +32,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)newtzset.3 8.1 .\" $FreeBSD: src/lib/libc/gen/tzset.3,v 1.6.2.5 2001/12/14 18:33:51 ru Exp $ -.\" $DragonFly: src/lib/libc/gen/tzset.3,v 1.4 2008/10/19 20:15:58 swildner Exp $ .\" .Dd October 19, 2008 .Dt TZSET 3 diff --git a/lib/libc/stdtime/asctime.c b/lib/libc/stdtime/asctime.c index 84ac474574..3ab6e779a7 100644 --- a/lib/libc/stdtime/asctime.c +++ b/lib/libc/stdtime/asctime.c @@ -8,7 +8,6 @@ ** the output of strftime is supposed to be locale specific ** whereas the output of asctime is supposed to be constant. ** -** @(#)asctime.c 8.5 ** $FreeBSD: src/lib/libc/stdtime/asctime.c,v 1.7.6.1 2001/03/05 11:37:20 obrien Exp $ */ /*LINTLIBRARY*/ diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3 index 13919fe58b..0ebc2a136d 100644 --- a/lib/libc/stdtime/ctime.3 +++ b/lib/libc/stdtime/ctime.3 @@ -31,9 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)newctime.3 8.2 .\" $FreeBSD: src/lib/libc/stdtime/ctime.3,v 1.11.2.7 2003/05/23 23:53:40 keramida Exp $ -.\" $DragonFly: src/lib/libc/stdtime/ctime.3,v 1.4 2008/10/19 20:15:58 swildner Exp $ .\" .Dd October 19, 2008 .Dt CTIME 3 diff --git a/lib/libc/stdtime/difftime.c b/lib/libc/stdtime/difftime.c index 6b77f5e8eb..df2bee60ae 100644 --- a/lib/libc/stdtime/difftime.c +++ b/lib/libc/stdtime/difftime.c @@ -2,9 +2,7 @@ ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. ** -** @(#)difftime.c 7.7 ** $FreeBSD: src/lib/libc/stdtime/difftime.c,v 1.4.8.1 2001/03/05 11:37:21 obrien Exp $ -** $DragonFly: src/lib/libc/stdtime/difftime.c,v 1.5 2008/10/19 20:15:58 swildner Exp $ */ /*LINTLIBRARY*/ diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index c1db4a4a5e..189606e748 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -2,7 +2,6 @@ ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. ** -** @(#)localtime.c 8.15 ** $FreeBSD: src/lib/libc/stdtime/localtime.c,v 1.25.2.2 2002/08/13 16:08:07 bmilekic Exp $ */ @@ -318,12 +317,14 @@ tzload(const char *name, struct state * const sp, const int doextend) int fid; int stored; int nread; - union { + typedef union { struct tzhead tzhead; char buf[2 * sizeof(struct tzhead) + 2 * sizeof *sp + 4 * TZ_MAX_TIMES]; - } u; + } u_t; + u_t u; + u_t * const up = &u; sp->goback = sp->goahead = FALSE; @@ -333,7 +334,7 @@ tzload(const char *name, struct state * const sp, const int doextend) name[0] == '/' || strchr(name, '.')) name = NULL; if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; + goto oops; { int doaccess; struct stat stab; @@ -351,9 +352,9 @@ tzload(const char *name, struct state * const sp, const int doextend) doaccess = name[0] == '/'; if (!doaccess) { if ((p = TZDIR) == NULL) - return -1; + goto oops; if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname) - return -1; + goto oops; strcpy(fullname, p); strcat(fullname, "/"); strcat(fullname, name); @@ -365,36 +366,36 @@ tzload(const char *name, struct state * const sp, const int doextend) name = fullname; } if (doaccess && access(name, R_OK) != 0) - return -1; + goto oops; if ((fid = _open(name, O_RDONLY)) == -1) - return -1; + goto oops; if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) { _close(fid); return -1; } } - nread = _read(fid, u.buf, sizeof u.buf); + nread = _read(fid, up->buf, sizeof up->buf); if (_close(fid) < 0 || nread <= 0) - return -1; + goto oops; for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; - ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt); - ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt); - sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt); - sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt); - sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt); - sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt); - p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt; + ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt); + ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt); + sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt); + sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt); + sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt); + sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt); + p = up->tzhead.tzh_charcnt + sizeof up->tzhead.tzh_charcnt; if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) - return -1; - if (nread - (p - u.buf) < + goto oops; + if (nread - (p - up->buf) < sp->timecnt * stored + /* ats */ sp->timecnt + /* types */ sp->typecnt * 6 + /* ttinfos */ @@ -402,7 +403,7 @@ tzload(const char *name, struct state * const sp, const int doextend) sp->leapcnt * (stored + 4) + /* lsinfos */ ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ - return -1; + goto oops; for (i = 0; i < sp->timecnt; ++i) { sp->ats[i] = (stored == 4) ? detzcode(p) : detzcode64(p); @@ -411,7 +412,7 @@ tzload(const char *name, struct state * const sp, const int doextend) for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; if (sp->types[i] >= sp->typecnt) - return -1; + goto oops; } for (i = 0; i < sp->typecnt; ++i) { struct ttinfo * ttisp; @@ -421,11 +422,11 @@ tzload(const char *name, struct state * const sp, const int doextend) p += 4; ttisp->tt_isdst = (unsigned char) *p++; if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - return -1; + goto oops; ttisp->tt_abbrind = (unsigned char) *p++; if (ttisp->tt_abbrind < 0 || ttisp->tt_abbrind > sp->charcnt) - return -1; + goto oops; } for (i = 0; i < sp->charcnt; ++i) sp->chars[i] = *p++; @@ -450,7 +451,7 @@ tzload(const char *name, struct state * const sp, const int doextend) ttisp->tt_ttisstd = *p++; if (ttisp->tt_ttisstd != TRUE && ttisp->tt_ttisstd != FALSE) - return -1; + goto oops; } } for (i = 0; i < sp->typecnt; ++i) { @@ -463,7 +464,7 @@ tzload(const char *name, struct state * const sp, const int doextend) ttisp->tt_ttisgmt = *p++; if (ttisp->tt_ttisgmt != TRUE && ttisp->tt_ttisgmt != FALSE) - return -1; + goto oops; } } /* @@ -496,11 +497,11 @@ tzload(const char *name, struct state * const sp, const int doextend) /* ** If this is an old file, we're done. */ - if (u.tzhead.tzh_version[0] == '\0') + if (up->tzhead.tzh_version[0] == '\0') break; - nread -= p - u.buf; + nread -= p - up->buf; for (i = 0; i < nread; ++i) - u.buf[i] = p[i]; + up->buf[i] = p[i]; /* ** If this is a narrow integer time_t system, we're done. */ @@ -508,13 +509,13 @@ tzload(const char *name, struct state * const sp, const int doextend) break; } if (doextend && nread > 2 && - u.buf[0] == '\n' && u.buf[nread - 1] == '\n' && + up->buf[0] == '\n' && up->buf[nread - 1] == '\n' && sp->typecnt + 2 <= TZ_MAX_TYPES) { struct state ts; int result; - u.buf[nread - 1] = '\0'; - result = tzparse(&u.buf[1], &ts, FALSE); + up->buf[nread - 1] = '\0'; + result = tzparse(&up->buf[1], &ts, FALSE); if (result == 0 && ts.typecnt == 2 && sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { for (i = 0; i < 2; ++i) @@ -559,6 +560,8 @@ tzload(const char *name, struct state * const sp, const int doextend) } } return 0; +oops: + return -1; } static int @@ -1593,27 +1596,35 @@ ctime_r(const time_t * const timep, char *buf) #endif /* !defined WRONG */ /* -** Simplified normalize logic courtesy Paul Eggert. +** Normalize logic courtesy Paul Eggert. */ static int -increment_overflow(int *number, int delta) +increment_overflow(int * const ip, int j) { - int number0; + int const i = *ip; - number0 = *number; - *number += delta; - return (*number < number0) != (delta < 0); + /* + ** If i >= 0 there can only be overflow if i + j > INT_MAX + ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow. + ** If i < 0 there can only be overflow if i + j < INT_MIN + ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow. + */ + if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i)) + return TRUE; + *ip += j; + return FALSE; } static int -long_increment_overflow(long *number, int delta) +long_increment_overflow(long * const lp, int const m) { - long number0; + long const l = *lp; - number0 = *number; - *number += delta; - return (*number < number0) != (delta < 0); + if ((l >= 0) ? (m > LONG_MAX - l) : (m < LONG_MIN - l)) + return TRUE; + *lp += m; + return FALSE; } static int diff --git a/lib/libc/stdtime/private.h b/lib/libc/stdtime/private.h index cc27ccd9c8..49c28b79fd 100644 --- a/lib/libc/stdtime/private.h +++ b/lib/libc/stdtime/private.h @@ -1,7 +1,5 @@ /* - * @(#)private.h 8.6 * $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $ - * $DragonFly: src/lib/libc/stdtime/private.h,v 1.3 2008/10/19 20:15:58 swildner Exp $ */ #ifndef PRIVATE_H diff --git a/lib/libc/stdtime/strftime.3 b/lib/libc/stdtime/strftime.3 index e51475dc2b..2cd959b967 100644 --- a/lib/libc/stdtime/strftime.3 +++ b/lib/libc/stdtime/strftime.3 @@ -33,9 +33,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)newstrftime.3 8.1 .\" $FreeBSD: src/lib/libc/stdtime/strftime.3,v 1.18.2.10 2003/05/24 00:01:31 keramida Exp $ -.\" $DragonFly: src/lib/libc/stdtime/strftime.3,v 1.4 2008/10/19 20:15:58 swildner Exp $ .\" .Dd October 19, 2008 .Dt STRFTIME 3 diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 3fe24b67d6..823235cf52 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -1,14 +1,7 @@ /* - * @(#)strftime.c 8.3 * $NetBSD: strftime.c,v 1.19 2009/01/11 02:46:30 christos Exp $ - * $DragonFly: src/lib/libc/stdtime/strftime.c,v 1.7 2008/10/19 20:15:58 swildner Exp $ */ -/* -** Based on the UCB version with the ID appearing below. -** This is ANSIish only when "multibyte character == plain character". -*/ - /* ** We don't use these extensions in strftime operation even when ** supported by the local tzcode configuration. A strictly diff --git a/lib/libc/stdtime/time2posix.3 b/lib/libc/stdtime/time2posix.3 index 0a21743418..92c6b380b9 100644 --- a/lib/libc/stdtime/time2posix.3 +++ b/lib/libc/stdtime/time2posix.3 @@ -1,5 +1,4 @@ .\" $FreeBSD: src/lib/libc/stdtime/time2posix.3,v 1.9.2.4 2001/12/14 18:33:59 ru Exp $ -.\" $DragonFly: src/lib/libc/stdtime/time2posix.3,v 1.3 2008/10/19 20:15:58 swildner Exp $ .\" .Dd October 19, 2008 .Dt TIME2POSIX 3 @@ -119,6 +118,5 @@ degenerate to the identity function. .Xr localtime 3 , .Xr mktime 3 , .Xr time 3 -.\" @(#)time2posix.3 8.1 .\" This file is in the public domain, so clarified as of .\" 1996-06-05 by Arthur David Olson. diff --git a/lib/libc/stdtime/tzfile.5 b/lib/libc/stdtime/tzfile.5 index aae74d0307..f7be13eb5f 100644 --- a/lib/libc/stdtime/tzfile.5 +++ b/lib/libc/stdtime/tzfile.5 @@ -1,5 +1,4 @@ .\" $FreeBSD: src/lib/libc/stdtime/tzfile.5,v 1.8.2.2 2001/08/17 15:42:43 ru Exp $ -.\" $DragonFly: src/lib/libc/stdtime/tzfile.5,v 1.4 2008/10/19 20:15:58 swildner Exp $ .Dd October 19, 2008 .Dt TZFILE 5 .Os @@ -162,6 +161,5 @@ such instants). .Xr ctime 3 , .Xr time2posix 3 , .Xr zic 8 -.\" @(#)tzfile.5 8.2 .\" This file is in the public domain, so clarified as of .\" 1996-06-05 by Arthur David Olson. diff --git a/lib/libc/stdtime/tzfile.h b/lib/libc/stdtime/tzfile.h index ae5affca5e..f3a0543f67 100644 --- a/lib/libc/stdtime/tzfile.h +++ b/lib/libc/stdtime/tzfile.h @@ -1,8 +1,3 @@ -/* - * @(#)tzfile.h 8.1 - * $DragonFly: src/lib/libc/stdtime/tzfile.h,v 1.3 2008/10/19 20:15:58 swildner Exp $ - */ - #ifndef TZFILE_H #define TZFILE_H diff --git a/usr.sbin/zic/ialloc.c b/usr.sbin/zic/ialloc.c index 3c69147239..6bb8ae934c 100644 --- a/usr.sbin/zic/ialloc.c +++ b/usr.sbin/zic/ialloc.c @@ -4,9 +4,7 @@ */ /* - * @(#)ialloc.c 8.30 * $FreeBSD: src/usr.sbin/zic/ialloc.c,v 1.5 1999/08/28 01:21:18 peter Exp $ - * $DragonFly: src/usr.sbin/zic/ialloc.c,v 1.5 2008/10/19 20:15:58 swildner Exp $ */ /*LINTLIBRARY*/ diff --git a/usr.sbin/zic/private.h b/usr.sbin/zic/private.h index a33ea12cea..968db47b8e 100644 --- a/usr.sbin/zic/private.h +++ b/usr.sbin/zic/private.h @@ -1,7 +1,5 @@ /* - * @(#)private.h 8.6 * $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $ - * $DragonFly: src/usr.sbin/zic/private.h,v 1.4 2008/10/19 20:15:58 swildner Exp $ */ #ifndef PRIVATE_H diff --git a/usr.sbin/zic/scheck.c b/usr.sbin/zic/scheck.c index a6c11b12ef..b9ce3c5c95 100644 --- a/usr.sbin/zic/scheck.c +++ b/usr.sbin/zic/scheck.c @@ -1,7 +1,5 @@ /* - * @(#)scheck.c 8.19 * $FreeBSD: src/usr.sbin/zic/scheck.c,v 1.4 1999/08/28 01:21:19 peter Exp $ - * $DragonFly: src/usr.sbin/zic/scheck.c,v 1.4 2008/10/19 20:15:58 swildner Exp $ */ /*LINTLIBRARY*/ diff --git a/usr.sbin/zic/zdump.8 b/usr.sbin/zic/zdump.8 index 2fbdce0b59..e2715d8b5b 100644 --- a/usr.sbin/zic/zdump.8 +++ b/usr.sbin/zic/zdump.8 @@ -1,7 +1,5 @@ .\" -.\" @(#)zdump.8 8.1 .\" $FreeBSD: src/usr.sbin/zic/zdump.8,v 1.7.2.2 2003/03/11 22:31:35 trhodes Exp $ -.\" $DragonFly: src/usr.sbin/zic/zdump.8,v 1.3 2008/10/19 20:15:58 swildner Exp $ .\" .Dd October 19, 2008 .Dt ZDUMP 8 diff --git a/usr.sbin/zic/zdump.c b/usr.sbin/zic/zdump.c index a690704d2b..bc353fc24a 100644 --- a/usr.sbin/zic/zdump.c +++ b/usr.sbin/zic/zdump.c @@ -1,7 +1,5 @@ /* - * @(#)zdump.c 8.8 * $FreeBSD: src/usr.sbin/zic/zdump.c,v 1.7 1999/08/28 01:21:19 peter Exp $ - * $DragonFly: src/usr.sbin/zic/zdump.c,v 1.5 2008/10/19 20:15:58 swildner Exp $ */ /* ** This code has been made independent of the rest of the time diff --git a/usr.sbin/zic/zic.8 b/usr.sbin/zic/zic.8 index 20fb393d05..180007178b 100644 --- a/usr.sbin/zic/zic.8 +++ b/usr.sbin/zic/zic.8 @@ -1,5 +1,4 @@ .\" $FreeBSD: src/usr.sbin/zic/zic.8,v 1.11.2.4 2003/03/11 22:31:35 trhodes Exp $ -.\" $DragonFly: src/usr.sbin/zic/zic.8,v 1.5 2008/10/19 20:15:58 swildner Exp $ .Dd March 22, 2010 .Dt ZIC 8 .Os @@ -470,4 +469,3 @@ standard directory used for created files .Xr ctime 3 , .Xr tzfile 5 , .Xr zdump 8 -.\" @(#)zic.8 8.6 diff --git a/usr.sbin/zic/zic.c b/usr.sbin/zic/zic.c index c0886cd8f6..8e4a3c9884 100644 --- a/usr.sbin/zic/zic.c +++ b/usr.sbin/zic/zic.c @@ -2,7 +2,6 @@ ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. ** -** @(#)zic.c 8.24 ** $FreeBSD: src/usr.sbin/zic/zic.c,v 1.11 1999/08/28 01:21:20 peter Exp $ */ -- 2.41.0