diff options
| author | christos <christos@NetBSD.org> | 2015-10-09 17:21:45 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2015-10-09 17:21:45 +0000 |
| commit | b795dabe604dd834e3961dfd06e5162715ac60cf (patch) | |
| tree | 17e042d99ee9dcff0233010511ed9e9962c7e715 /lib | |
| parent | 33d5cb2d6ea7a691f0121ad353f980f45118b73f (diff) | |
Release 2015g - 2015-10-01 00:39:51 -0700
Changes affecting code
localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)
The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)
On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)
Changes affecting documentation
The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/time/Makefile | 2 | ||||
| -rw-r--r-- | lib/libc/time/NEWS | 42 | ||||
| -rw-r--r-- | lib/libc/time/localtime.c | 80 | ||||
| -rw-r--r-- | lib/libc/time/private.h | 15 | ||||
| -rw-r--r-- | lib/libc/time/strftime.c | 8 | ||||
| -rw-r--r-- | lib/libc/time/strptime.c | 8 | ||||
| -rw-r--r-- | lib/libc/time/tz-art.htm | 5 | ||||
| -rw-r--r-- | lib/libc/time/tz-link.htm | 4 | ||||
| -rw-r--r-- | lib/libc/time/tzfile.5 | 11 | ||||
| -rw-r--r-- | lib/libc/time/zic.c | 23 |
10 files changed, 135 insertions, 63 deletions
diff --git a/lib/libc/time/Makefile b/lib/libc/time/Makefile index 8564c001200..1d0a66fe0da 100644 --- a/lib/libc/time/Makefile +++ b/lib/libc/time/Makefile @@ -5,7 +5,7 @@ PACKAGE= tzcode # Version numbers of the code and data distributions. -VERSION= 2015f +VERSION= 2015g # Email address for bug reports. BUGEMAIL= tz@iana.org diff --git a/lib/libc/time/NEWS b/lib/libc/time/NEWS index b47725013c7..00d07cbb203 100644 --- a/lib/libc/time/NEWS +++ b/lib/libc/time/NEWS @@ -1,5 +1,47 @@ News for the tz database +Release 2015g - 2015-10-01 00:39:51 -0700 + + Changes affecting future time stamps + + Turkey's 2015 fall-back transition is scheduled for Nov. 8, not Oct. 25. + (Thanks to Fatih.) + + Norfolk moves from +1130 to +1100 on 2015-10-04 at 02:00 local time. + (Thanks to Alexander Krivenyshev.) + + Fiji's 2016 fall-back transition is scheduled for January 17, not 24. + (Thanks to Ken Rylander.) + + Fort Nelson, British Columbia will not fall back on 2015-11-01. It has + effectively been on MST (-0700) since it advanced its clocks on 2015-03-08. + New zone America/Fort_Nelson. (Thanks to Matt Johnson.) + + Changes affecting past time stamps + + Norfolk observed DST from 1974-10-27 02:00 to 1975-03-02 02:00. + + Changes affecting code + + localtime no longer mishandles America/Anchorage after 2037. + (Thanks to Bradley White for reporting the bug.) + + The localtime module allows the variables 'timezone', 'daylight', + and 'altzone' to be in common storage shared with other modules, + and declares them in case the system <time.h> does not. + (Problems reported by Kees Dekker.) + + On platforms with tm_zone, strftime.c now assumes it is not NULL. + This simplifies the code and is consistent with zdump.c. + (Problem reported by Christos Zoulas.) + + Changes affecting documentation + + The tzfile man page now documents that transition times denote the + starts (not the ends) of the corresponding time periods. + (Ambiguity reported by Bill Seymour.) + + Release 2015f - 2015-08-10 18:06:56 -0700 Changes affecting future time stamps diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index a82630622bc..d385db367fd 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $NetBSD: localtime.c,v 1.97 2015/08/18 16:54:27 riz Exp $ */ +/* $NetBSD: localtime.c,v 1.98 2015/10/09 17:21:45 christos Exp $ */ /* ** This file is in the public domain, so clarified as of @@ -10,7 +10,7 @@ #if 0 static char elsieid[] = "@(#)localtime.c 8.17"; #else -__RCSID("$NetBSD: localtime.c,v 1.97 2015/08/18 16:54:27 riz Exp $"); +__RCSID("$NetBSD: localtime.c,v 1.98 2015/10/09 17:21:45 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -588,11 +588,6 @@ tzloadbody(char const *name, struct state *sp, bool doextend, break; nread -= p - up->buf; memmove(up->buf, p, (size_t)nread); - /* - ** If this is a signed narrow time_t system, we're done. - */ - if (TYPE_SIGNED(time_t) && stored >= (int) sizeof(time_t)) - break; } if (doextend && nread > 2 && up->buf[0] == '\n' && up->buf[nread - 1] == '\n' && @@ -601,31 +596,52 @@ tzloadbody(char const *name, struct state *sp, bool doextend, up->buf[nread - 1] = '\0'; if (tzparse(&up->buf[1], ts, false) - && ts->typecnt == 2 - && sp->charcnt + ts->charcnt <= TZ_MAX_CHARS) { - for (i = 0; i < 2; ++i) - ts->ttis[i].tt_abbrind += - sp->charcnt; - for (i = 0; i < ts->charcnt; ++i) - sp->chars[sp->charcnt++] = - ts->chars[i]; - i = 0; - while (i < ts->timecnt && - ts->ats[i] <= - sp->ats[sp->timecnt - 1]) - ++i; - while (i < ts->timecnt && - sp->timecnt < TZ_MAX_TIMES) { - sp->ats[sp->timecnt] = - ts->ats[i]; - sp->types[sp->timecnt] = - sp->typecnt + - ts->types[i]; - ++sp->timecnt; - ++i; - } - sp->ttis[sp->typecnt++] = ts->ttis[0]; - sp->ttis[sp->typecnt++] = ts->ttis[1]; + && ts->typecnt == 2) { + + /* Attempt to reuse existing abbreviations. + Without this, America/Anchorage would stop + working after 2037 when TZ_MAX_CHARS is 50, as + sp->charcnt equals 42 (for LMT CAT CAWT CAPT AHST + AHDT YST AKDT AKST) and ts->charcnt equals 10 + (for AKST AKDT). Reusing means sp->charcnt can + stay 42 in this example. */ + int gotabbr = 0; + int charcnt = sp->charcnt; + for (i = 0; i < 2; i++) { + char *tsabbr = ts->chars + ts->ttis[i].tt_abbrind; + int j; + for (j = 0; j < charcnt; j++) + if (strcmp(sp->chars + j, tsabbr) == 0) { + ts->ttis[i].tt_abbrind = j; + gotabbr++; + break; + } + if (! (j < charcnt)) { + int tsabbrlen = strlen(tsabbr); + if (j + tsabbrlen < TZ_MAX_CHARS) { + strcpy(sp->chars + j, tsabbr); + charcnt = j + tsabbrlen + 1; + ts->ttis[i].tt_abbrind = j; + gotabbr++; + } + } + } + if (gotabbr == 2) { + sp->charcnt = charcnt; + for (i = 0; i < ts->timecnt; i++) + if (sp->ats[sp->timecnt - 1] < ts->ats[i]) + break; + while (i < ts->timecnt + && sp->timecnt < TZ_MAX_TIMES) { + sp->ats[sp->timecnt] = ts->ats[i]; + sp->types[sp->timecnt] = (sp->typecnt + + ts->types[i]); + sp->timecnt++; + i++; + } + sp->ttis[sp->typecnt++] = ts->ttis[0]; + sp->ttis[sp->typecnt++] = ts->ttis[1]; + } } } if (sp->timecnt > 1) { diff --git a/lib/libc/time/private.h b/lib/libc/time/private.h index b3d0ebc567c..eaf526e9993 100644 --- a/lib/libc/time/private.h +++ b/lib/libc/time/private.h @@ -1,4 +1,4 @@ -/* $NetBSD: private.h,v 1.43 2015/08/13 11:21:18 christos Exp $ */ +/* $NetBSD: private.h,v 1.44 2015/10/09 17:21:45 christos Exp $ */ #ifndef PRIVATE_H #define PRIVATE_H @@ -399,12 +399,25 @@ void tzset(void); ** Some time.h implementations don't declare asctime_r. ** Others might define it as a macro. ** Fix the former without affecting the latter. +** Similarly for timezone, daylight, and altzone. */ #ifndef asctime_r extern char * asctime_r(struct tm const *restrict, char *restrict); #endif +#if defined(USG_COMPAT) && !defined(__NetBSD__) +# ifndef timezone +extern long timezone; +# endif +# ifndef daylight +extern int daylight; +# endif +#endif +#if defined ALTZONE && !defined altzone +extern long altzone; +#endif + /* ** The STD_INSPIRED functions are similar, but most also need ** declarations if time_tz is defined. diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 19d0a05c43a..4c99c663e74 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -1,4 +1,4 @@ -/* $NetBSD: strftime.c,v 1.34 2015/08/13 11:21:18 christos Exp $ */ +/* $NetBSD: strftime.c,v 1.35 2015/10/09 17:21:45 christos Exp $ */ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) @@ -6,7 +6,7 @@ static char elsieid[] = "@(#)strftime.c 7.64"; static char elsieid[] = "@(#)strftime.c 8.3"; #else -__RCSID("$NetBSD: strftime.c,v 1.34 2015/08/13 11:21:18 christos Exp $"); +__RCSID("$NetBSD: strftime.c,v 1.35 2015/10/09 17:21:45 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -487,9 +487,7 @@ label: continue; case 'Z': #ifdef TM_ZONE - if (t->TM_ZONE != NULL) - pt = _add(t->TM_ZONE, pt, ptlim); - else + pt = _add(t->TM_ZONE, pt, ptlim); #endif /* defined TM_ZONE */ if (t->tm_isdst >= 0) pt = _add((sp ? diff --git a/lib/libc/time/strptime.c b/lib/libc/time/strptime.c index 84988b8cfc0..51cbc912121 100644 --- a/lib/libc/time/strptime.c +++ b/lib/libc/time/strptime.c @@ -1,4 +1,4 @@ -/* $NetBSD: strptime.c,v 1.48 2015/07/29 20:32:54 ginsbach Exp $ */ +/* $NetBSD: strptime.c,v 1.49 2015/10/09 17:21:45 christos Exp $ */ /*- * Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strptime.c,v 1.48 2015/07/29 20:32:54 ginsbach Exp $"); +__RCSID("$NetBSD: strptime.c,v 1.49 2015/10/09 17:21:45 christos Exp $"); #endif #include "namespace.h" @@ -533,7 +533,7 @@ literal: tm->TM_GMTOFF = (int)*bp - 'M'; #endif #ifdef TM_ZONE - tm->TM_ZONE = NULL; /* XXX */ + tm->TM_ZONE = utc; /* XXX */ #endif bp++; continue; @@ -574,7 +574,7 @@ literal: tm->TM_GMTOFF = offs; #endif #ifdef TM_ZONE - tm->TM_ZONE = NULL; /* XXX */ + tm->TM_ZONE = utc; /* XXX */ #endif continue; diff --git a/lib/libc/time/tz-art.htm b/lib/libc/time/tz-art.htm index d8325aba774..86f381e75e6 100644 --- a/lib/libc/time/tz-art.htm +++ b/lib/libc/time/tz-art.htm @@ -496,6 +496,11 @@ yesterday daylight [saving] time ended. Right now it's basically midnight." (Conan O'Brien on the 2010-11-08 premiere of <em>Conan</em>.) </li> <li> +"Well, in my time zone that's all the time I have, +but maybe in your time zone I haven't finished yet. So stay tuned!" +(Goldie Hawn, <em>Rowan & Martin's Laugh-In</em> No. 65, 1970-03-09) +</li> +<li> Peppermint Patty: "What if the world comes to an end tonight, Marcie?" <br> Marcie: "I promise there'll be a tomorrow, sir ... in fact, diff --git a/lib/libc/time/tz-link.htm b/lib/libc/time/tz-link.htm index cc44768a9da..63ec3854662 100644 --- a/lib/libc/time/tz-link.htm +++ b/lib/libc/time/tz-link.htm @@ -8,7 +8,7 @@ <meta http-equiv="Content-type" content='text/html; charset="UTF-8"'> <meta name="DC.Creator" content="Eggert, Paul"> <meta name="DC.Contributor" content="Olson, Arthur David"> -<meta name="DC.Date" content="2015-08-10"> +<meta name="DC.Date" content="2015-10-01"> <meta name="DC.Description" content="Sources of information about time zones and daylight saving time"> <meta name="DC.Identifier" @@ -731,7 +731,7 @@ Schema: Datatypes – dateTime</a> specifies a format inspired by <a href="http://tools.ietf.org/html/rfc5322">Internet Message Format</a> (Internet <abbr>RFC</abbr> 5322) §3.3 specifies the time notation used in email and <a -href="http://www.w3.org/Protocols/"><abbr>HTTP</abbr></a> +href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol"><abbr>HTTP</abbr></a> headers.</li> <li> <a href="http://tools.ietf.org/html/rfc3339">Date and Time diff --git a/lib/libc/time/tzfile.5 b/lib/libc/time/tzfile.5 index d1bfc3d6920..1dfa459bc7c 100644 --- a/lib/libc/time/tzfile.5 +++ b/lib/libc/time/tzfile.5 @@ -1,4 +1,4 @@ -.\" $NetBSD: tzfile.5,v 1.22 2014/10/07 21:51:03 christos Exp $ +.\" $NetBSD: tzfile.5,v 1.23 2015/10/09 17:21:45 christos Exp $ .\" .\" This file is in the public domain, so clarified as of .\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). @@ -8,8 +8,6 @@ .Sh NAME .Nm tzfile .Nd time zone information -.Sh SYNOPSIS -.In tzfile.h .Sh DESCRIPTION The time zone information files used by .Xr tzset 3 @@ -54,8 +52,8 @@ Next come .Va tzh_timecnt one-byte unsigned integer values; each one tells which of the different types of local time types -described in the file is associated with the same-indexed -transition time. +described in the file is associated with the time period +starting with the same-indexed transition time. These values serve as indices into an array of .Fa ttinfo structures (with @@ -99,7 +97,8 @@ the first value of each pair gives the time at which a leap second occurs; the second gives the .Em total -number of leap seconds to be applied after the given time. +number of leap seconds to be applied during the time period +starting at the given time. The pairs of values are sorted in ascending order by time. .Pp Then there are diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index 0cd86476a89..cd9441c4710 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,4 +1,4 @@ -/* $NetBSD: zic.c,v 1.55 2015/08/13 11:21:18 christos Exp $ */ +/* $NetBSD: zic.c,v 1.56 2015/10/09 17:21:45 christos Exp $ */ /* ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. @@ -10,7 +10,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: zic.c,v 1.55 2015/08/13 11:21:18 christos Exp $"); +__RCSID("$NetBSD: zic.c,v 1.56 2015/10/09 17:21:45 christos Exp $"); #endif /* !defined lint */ #include "private.h" @@ -1955,7 +1955,7 @@ abbroffset(char *buf, zic_t offset) static size_t doabbr(char *abbr, int abbrlen, struct zone const *zp, const char *letters, - bool isdst, bool doquotes) + zic_t stdoff, bool doquotes) { char * cp; char * slashp; @@ -1966,11 +1966,11 @@ doabbr(char *abbr, int abbrlen, struct zone const *zp, const char *letters, if (slashp == NULL) { char letterbuf[PERCENT_Z_LEN_BOUND + 1]; if (zp->z_format_specifier == 'z') - letters = abbroffset(letterbuf, -zp->z_gmtoff); + letters = abbroffset(letterbuf, -zp->z_gmtoff + stdoff); else if (!letters) letters = "%s"; (void) snprintf(abbr, abbrlen, format, letters); - } else if (isdst) { + } else if (stdoff != 0) { (void) strlcpy(abbr, slashp + 1, abbrlen); } else { (void) memcpy(abbr, format, slashp - format); @@ -2195,7 +2195,7 @@ stringzone(char *result, const int resultlen, const struct zone *const zpfirst, if (stdrp == NULL && (zp->z_nrules != 0 || zp->z_stdoff != 0)) return -1; abbrvar = (stdrp == NULL) ? "" : stdrp->r_abbrvar; - len = doabbr(result, resultlen, zp, abbrvar, false, true); + len = doabbr(result, resultlen, zp, abbrvar, 0, true); offsetlen = stringoffset(result + len, -zp->z_gmtoff); if (! offsetlen) { result[0] = '\0'; @@ -2204,7 +2204,7 @@ stringzone(char *result, const int resultlen, const struct zone *const zpfirst, len += offsetlen; if (dstrp == NULL) return compat; - len += doabbr(result + len, resultlen - len, zp, dstrp->r_abbrvar, true, true); + len += doabbr(result + len, resultlen - len, zp, dstrp->r_abbrvar, dstrp->r_stdoff, true); if (dstrp->r_stdoff != SECSPERMIN * MINSPERHOUR) { offsetlen = stringoffset(result + len, -(zp->z_gmtoff + dstrp->r_stdoff)); @@ -2376,7 +2376,7 @@ outzone(const struct zone *zpfirst, int zonecount) if (zp->z_nrules == 0) { stdoff = zp->z_stdoff; doabbr(startbuf, max_abbr_len + 1, zp, - NULL, stdoff != 0, false); + NULL, stdoff, false); type = addtype(oadd(zp->z_gmtoff, stdoff), startbuf, stdoff != 0, startttisstd, startttisgmt); @@ -2472,7 +2472,7 @@ outzone(const struct zone *zpfirst, int zonecount) max_abbr_len + 1, zp, rp->r_abbrvar, - rp->r_stdoff != 0, + rp->r_stdoff, false); continue; } @@ -2483,15 +2483,14 @@ outzone(const struct zone *zpfirst, int zonecount) max_abbr_len + 1, zp, rp->r_abbrvar, - rp->r_stdoff != - 0, + rp->r_stdoff, false); } } eats(zp->z_filename, zp->z_linenum, rp->r_filename, rp->r_linenum); doabbr(ab, max_abbr_len + 1, zp, rp->r_abbrvar, - rp->r_stdoff != 0, false); + rp->r_stdoff, false); offset = oadd(zp->z_gmtoff, rp->r_stdoff); type = addtype(offset, ab, rp->r_stdoff != 0, rp->r_todisstd, rp->r_todisgmt); |
