Module Name: src
Committed By: christos
Date: Fri Nov 4 19:41:53 UTC 2016
Modified Files:
src/lib/libc/time: Makefile NEWS localtime.c private.h tz-art.htm
tz-link.htm version zic.c
Added Files:
src/lib/libc/time: LICENSE
Log Message:
tzcode2016i
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libc/time/LICENSE
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/time/Makefile
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/time/NEWS
cvs rdiff -u -r1.104 -r1.105 src/lib/libc/time/localtime.c
cvs rdiff -u -r1.47 -r1.48 src/lib/libc/time/private.h
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/time/tz-art.htm
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/time/tz-link.htm
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/time/version
cvs rdiff -u -r1.64 -r1.65 src/lib/libc/time/zic.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/time/Makefile
diff -u src/lib/libc/time/Makefile:1.35 src/lib/libc/time/Makefile:1.36
--- src/lib/libc/time/Makefile:1.35 Thu Oct 20 13:41:34 2016
+++ src/lib/libc/time/Makefile Fri Nov 4 15:41:53 2016
@@ -129,6 +129,10 @@ LDLIBS=
# -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
# -DHAVE_TZSET=0 if your system lacks a tzset function
# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
+# -DEPOCH_LOCAL=1 if the 'time' function returns local time not UT
+# -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
+# than what POSIX specifies, assuming local time is UT.
+# For example, N is 252460800 on AmigaOS.
# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
# if you do not want run time warnings about formats that may cause
# year 2000 grief
@@ -714,18 +718,12 @@ check_time_t_alternatives:
done
rm -fr time_t.dir
-tarballs signatures: version
- $(MAKE) VERSION="$$(cat version)" $@_version
-
tarballs_version: tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz \
tzdb-$(VERSION).tar.lz
tarballs traditional_tarballs signatures traditional_signatures: version
VERSION=`cat version` && \
$(MAKE) VERSION="$$VERSION" $@_version
-tarballs_version: traditional_tarballs_version tzdb-$(VERSION).tar.lz
-traditional_tarballs_version: \
- tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz
signatures_version: traditional_signatures_version tzdb-$(VERSION).tar.lz.asc
traditional_signatures_version: \
tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc \
Index: src/lib/libc/time/NEWS
diff -u src/lib/libc/time/NEWS:1.18 src/lib/libc/time/NEWS:1.19
--- src/lib/libc/time/NEWS:1.18 Thu Oct 20 13:41:34 2016
+++ src/lib/libc/time/NEWS Fri Nov 4 15:41:53 2016
@@ -1,5 +1,65 @@
News for the tz database
+Release 2016i - 2016-11-01 23:19:52 -0700
+
+ Briefly: Cyprus split into two time zones on 2016-10-30, and Tonga
+ reintroduces DST on 2016-11-06.
+
+ Changes to future time stamps
+
+ Pacific/Tongatapu begins DST on 2016-11-06 at 02:00, ending on
+ 2017-01-15 at 03:00. Assume future observances in Tonga will be
+ from the first Sunday in November through the third Sunday in
+ January, like Fiji. (Thanks to Pulu ʻAnau.) Switch to numeric
+ time zone abbreviations for this zone.
+
+ Changes to past and future time stamps
+
+ Northern Cyprus is now +03 year round, causing a split in Cyprus
+ time zones starting 2016-10-30 at 04:00. This creates a zone
+ Asia/Famagusta. (Thanks to Even Scharning and Matt Johnson.)
+
+ Antarctica/Casey switched from +08 to +11 on 2016-10-22.
+ (Thanks to Steffen Thorsen.)
+
+ Changes to past time stamps
+
+ Several corrections were made for pre-1975 time stamps in Italy.
+ These affect Europe/Malta, Europe/Rome, Europe/San_Marino, and
+ Europe/Vatican.
+
+ First, the 1893-11-01 00:00 transition in Italy used the new UT
+ offset (+01), not the old (+00:49:56). (Thanks to Michael
+ Deckers.)
+
+ Second, rules for daylight saving in Italy were changed to agree
+ with Italy's National Institute of Metrological Research (INRiM)
+ except for 1944, as follows (thanks to Pierpaolo Bernardi, Brian
+ Inglis, and Michael Deckers):
+
+ The 1916-06-03 transition was at 24:00, not 00:00.
+
+ The 1916-10-01, 1919-10-05, and 1920-09-19 transitions were at
+ 00:00, not 01:00.
+
+ The 1917-09-30 and 1918-10-06 transitions were at 24:00, not
+ 01:00.
+
+ The 1944-09-17 transition was at 03:00, not 01:00. This
+ particular change is taken from Italian law as INRiM's table,
+ (which says 02:00) appears to have a typo here. Also, keep the
+ 1944-04-03 transition for Europe/Rome, as Rome was controlled by
+ Germany then.
+
+ The 1967-1970 and 1972-1974 fallback transitions were at 01:00,
+ not 00:00.
+
+ Changes to code
+
+ The code should now be buildable on AmigaOS merely by setting the
+ appropriate Makefile variables. (From a patch by Carsten Larsen.)
+
+
Release 2016h - 2016-10-19 23:17:57 -0700
Changes to future time stamps
Index: src/lib/libc/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.104 src/lib/libc/time/localtime.c:1.105
--- src/lib/libc/time/localtime.c:1.104 Fri Oct 7 11:29:42 2016
+++ src/lib/libc/time/localtime.c Fri Nov 4 15:41:53 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.104 2016/10/07 15:29:42 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.105 2016/11/04 19:41:53 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.104 2016/10/07 15:29:42 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.105 2016/11/04 19:41:53 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1605,6 +1605,45 @@ offtime_r(const time_t *timep, long offs
#endif /* defined STD_INSPIRED */
+#if defined time_tz || EPOCH_LOCAL || EPOCH_OFFSET != 0
+
+# ifndef USG_COMPAT
+# define daylight 0
+# define timezone 0
+# endif
+# ifndef ALTZONE
+# define altzone 0
+# endif
+
+/* Convert from the underlying system's time_t to the ersatz time_tz,
+ which is called 'time_t' in this file. Typically, this merely
+ converts the time's integer width. On some platforms, the system
+ time is local time not UT, or uses some epoch other than the POSIX
+ epoch.
+
+ Although this code appears to define a function named 'time' that
+ returns time_t, the macros in private.h cause this code to actually
+ define a function named 'tz_time' that returns tz_time_t. The call
+ to sys_time invokes the underlying system's 'time' function. */
+
+time_t
+time(time_t *p)
+{
+ time_t r = sys_time(0);
+ if (r != (time_t) -1) {
+ int_fast32_t offset = EPOCH_LOCAL ? (daylight ? timezone : altzone) : 0;
+ if (increment_overflow32(&offset, -EPOCH_OFFSET)
+ || increment_overflow_time (&r, offset)) {
+ errno = EOVERFLOW;
+ r = -1;
+ }
+ }
+ if (p)
+ *p = r;
+ return r;
+}
+#endif
+
/*
** Return the number of leap years through the end of the given year
** where, to make the math easy, the answer for year zero is defined as zero.
Index: src/lib/libc/time/private.h
diff -u src/lib/libc/time/private.h:1.47 src/lib/libc/time/private.h:1.48
--- src/lib/libc/time/private.h:1.47 Thu Oct 20 13:41:34 2016
+++ src/lib/libc/time/private.h Fri Nov 4 15:41:53 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: private.h,v 1.47 2016/10/20 17:41:34 christos Exp $ */
+/* $NetBSD: private.h,v 1.48 2016/11/04 19:41:53 christos Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
@@ -225,14 +225,18 @@ typedef long int_fast64_t;
# endif
#endif
-#ifndef SCNdFAST64
+#ifndef PRIdFAST64
# if INT_FAST64_MAX == LLONG_MAX
-# define SCNdFAST64 "lld"
+# define PRIdFAST64 "lld"
# else
-# define SCNdFAST64 "ld"
+# define PRIdFAST64 "ld"
# endif
#endif
+#ifndef SCNdFAST64
+# define SCNdFAST64 PRIdFAST64
+#endif
+
#ifndef INT_FAST32_MAX
# if INT_MAX >> 31 == 0
typedef long int_fast32_t;
@@ -332,6 +336,13 @@ typedef unsigned long uintmax_t;
** Workarounds for compilers/systems.
*/
+#ifndef EPOCH_LOCAL
+# define EPOCH_LOCAL 0
+#endif
+#ifndef EPOCH_OFFSET
+# define EPOCH_OFFSET 0
+#endif
+
/*
** Compile with -Dtime_tz=T to build the tz package with a private
** time_t type equivalent to T rather than the system-supplied time_t.
@@ -339,7 +350,7 @@ typedef unsigned long uintmax_t;
** (e.g., time_t wider than 'long', or unsigned time_t) even on
** typical platforms.
*/
-#ifdef time_tz
+#if defined time_tz || EPOCH_LOCAL || EPOCH_OFFSET != 0
# ifdef LOCALTIME_IMPLEMENTATION
static time_t sys_time(time_t *x) { return time(x); }
# endif
@@ -527,10 +538,29 @@ time_t time2posix_z(timezone_t __restric
((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
#ifdef LOCALTIME_IMPLEMENTATION
-/* The minimum and maximum finite time values. This assumes no padding. */
+/* The minimum and maximum finite time values. This implementation
+ assumes no padding if time_t is signed and either the compiler is
+ pre-C11 or time_t is not one of the standard signed integer types. */
+#if (201112 <= __STDC_VERSION__) && !defined(__lint__)
+static time_t const time_t_min
+ = (TYPE_SIGNED(time_t)
+ ? _Generic((time_t) 0,
+ signed char: SCHAR_MIN, short: SHRT_MIN,
+ int: INT_MIN, long: LONG_MIN, long long: LLONG_MIN,
+ default: MINVAL(time_t, TYPE_BIT(time_t)))
+ : 0);
+static time_t const time_t_max
+ = (TYPE_SIGNED(time_t)
+ ? _Generic((time_t) 0,
+ signed char: SCHAR_MAX, short: SHRT_MAX,
+ int: INT_MAX, long: LONG_MAX, long long: LLONG_MAX,
+ default: MAXVAL(time_t, TYPE_BIT(time_t)))
+ : -1);
+#else
static time_t const time_t_min = MINVAL(time_t, TYPE_BIT(time_t));
static time_t const time_t_max = MAXVAL(time_t, TYPE_BIT(time_t));
#endif
+#endif
#ifndef INT_STRLEN_MAXIMUM
/*
Index: src/lib/libc/time/tz-art.htm
diff -u src/lib/libc/time/tz-art.htm:1.14 src/lib/libc/time/tz-art.htm:1.15
--- src/lib/libc/time/tz-art.htm:1.14 Fri Oct 7 11:29:42 2016
+++ src/lib/libc/time/tz-art.htm Fri Nov 4 15:41:53 2016
@@ -438,7 +438,8 @@ Supernaw.</td></tr>
The webcomic <em>xkcd</em> has the strip
"<a href='http://xkcd.com/673/'>The Sun</a>" (2009-12-09) and the panels
"<a href='http://xkcd.com/1017/'>Backward in Time</a>" (2012-02-14),
-"<a href='http://xkcd.com/1061/'>EST</a>" (2012-05-28), and
+"<a href='http://xkcd.com/1061/'>EST</a>" (2012-05-28),
+"<a href='http://xkcd.com/1179/'>ISO 8601</a>" (2013-02-27),
"<a href='http://xkcd.com/1335/'>Now</a>" (2014-02-26), and
"<a href='http://xkcd.com/1655/'>Doomsday Clock</a>" (2016-03-14).
The related book <em>What If?</em> has an entry
Index: src/lib/libc/time/tz-link.htm
diff -u src/lib/libc/time/tz-link.htm:1.28 src/lib/libc/time/tz-link.htm:1.29
--- src/lib/libc/time/tz-link.htm:1.28 Thu Oct 20 13:41:34 2016
+++ src/lib/libc/time/tz-link.htm Fri Nov 4 15:41:53 2016
@@ -10,7 +10,7 @@
content="Sources for time zone and daylight saving time data">
<meta name="DC.Creator" content="Eggert, Paul">
<meta name="DC.Contributor" content="Olson, Arthur David">
-<meta name="DC.Date" content="2016-10-19">
+<meta name="DC.Date" content="2016-11-01">
<meta name="DC.Description"
content="Sources of information about time zones and daylight saving time">
<meta name="DC.Identifier"
@@ -158,9 +158,7 @@ The <code><abbr>tz</abbr></code> code an
are by no means authoritative. If you find errors, please
send changes to the <a href="mailto:[email protected]">time zone
mailing list</a>. You can also <a
-href="http://news.gmane.org/gmane.comp.time.tz">browse recent
-messages</a> sent to the mailing list, <a
-href="https://mm.icann.org/mailman/listinfo/tz">subscribe</a> to it,
+href="https://mm.icann.org/mailman/listinfo/tz">subscribe</a> to it
and browse the <a
href="http://mm.icann.org/pipermail/tz/">archive of old
messages</a>.</p>
@@ -704,6 +702,10 @@ of Legal Time in Germany</a>.</dd>
<dd>The Interior Ministry periodically issues <a
href="ftp://ftp.cs.huji.ac.il/pub/tz/announcements"
hreflang="he">announcements (in Hebrew)</a>.</dd>
+<dt>Italy</dt>
+<dd>The National Institute of Metrological Research maintains a
+<a href="http://www.inrim.it/res/tf/ora_legale_i.shtml">table of civil time
+(in Italian)</a>.</dd>
<dt>Mexico</dt>
<dd>The Investigation and Analysis Service of the Mexican Library of
Congress has published a <a
@@ -732,7 +734,7 @@ href="https://www.polyomino.org.uk/briti
legal time in Britain</a> discusses in detail the country
with perhaps the best-documented history of clock adjustments.
The National Physical Laboratory also maintains an <a
-href="http://www.npl.co.uk/educate-explore/what-is-time/archive-of-summer-time-dates-1916-2006">Archive
+href="http://www.npl.co.uk/educate-explore/what-is-time/archive-of-summer-time-dates">Archive
of Summer time dates</a>.</dd>
<dt>United States</dt>
<dd>The Department of Transportation's <a
@@ -747,7 +749,7 @@ Science of Timekeeping</a> is a thorough
to the theory and practice of precision timekeeping.</li>
<li><a href="http://www.ntp.org"><abbr
title="Network Time Protocol">NTP</abbr>: The Network
-Time Protocol</a>
+Time Protocol</a> (Internet <abbr>RFC</abbr> 5905)
discusses how to synchronize clocks of
Internet hosts.</li>
<li>The <a
Index: src/lib/libc/time/version
diff -u src/lib/libc/time/version:1.1 src/lib/libc/time/version:1.2
--- src/lib/libc/time/version:1.1 Thu Oct 20 13:41:34 2016
+++ src/lib/libc/time/version Fri Nov 4 15:41:53 2016
@@ -1 +1 @@
-2016h
+2016i
Index: src/lib/libc/time/zic.c
diff -u src/lib/libc/time/zic.c:1.64 src/lib/libc/time/zic.c:1.65
--- src/lib/libc/time/zic.c:1.64 Fri Oct 7 15:47:16 2016
+++ src/lib/libc/time/zic.c Fri Nov 4 15:41:53 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: zic.c,v 1.64 2016/10/07 19:47:16 kre Exp $ */
+/* $NetBSD: zic.c,v 1.65 2016/11/04 19:41:53 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.64 2016/10/07 19:47:16 kre Exp $");
+__RCSID("$NetBSD: zic.c,v 1.65 2016/11/04 19:41:53 christos Exp $");
#endif /* !defined lint */
#include "private.h"
@@ -18,6 +18,7 @@ __RCSID("$NetBSD: zic.c,v 1.64 2016/10/0
#include "tzfile.h"
#include <stdarg.h>
+#include <stddef.h>
#include <unistd.h>
#include <util.h>
@@ -27,6 +28,7 @@ __RCSID("$NetBSD: zic.c,v 1.64 2016/10/0
typedef int_fast64_t zic_t;
#define ZIC_MIN INT_FAST64_MIN
#define ZIC_MAX INT_FAST64_MAX
+#define PRIdZIC PRIdFAST64
#define SCNdZIC SCNdFAST64
#ifndef ZIC_MAX_ABBR_LEN_WO_WARN
@@ -49,9 +51,18 @@ typedef int_fast64_t zic_t;
#define MKDIR_UMASK 0755
#endif
+/* The maximum ptrdiff_t value, for pre-C99 platforms. */
+#ifndef PTRDIFF_MAX
+static ptrdiff_t const PTRDIFF_MAX = MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t));
+#endif
+
+/* The type and printf format for line numbers. */
+typedef intmax_t lineno;
+#define PRIdLINENO PRIdMAX
+
struct rule {
const char * r_filename;
- int r_linenum;
+ lineno r_linenum;
const char * r_name;
zic_t r_loyear; /* for example, 1986 */
@@ -74,7 +85,7 @@ struct rule {
zic_t r_stdoff; /* offset from standard time */
const char * r_abbrvar; /* variable part of abbreviation */
- int r_todo; /* a rule to do (used in outzone) */
+ bool r_todo; /* a rule to do (used in outzone) */
zic_t r_temp; /* used in outzone */
};
@@ -88,7 +99,7 @@ struct rule {
struct zone {
const char * z_filename;
- int z_linenum;
+ lineno z_linenum;
const char * z_name;
zic_t z_gmtoff;
@@ -99,7 +110,7 @@ struct zone {
zic_t z_stdoff;
struct rule * z_rules;
- int z_nrules;
+ ptrdiff_t z_nrules;
struct rule z_untilrule;
zic_t z_untiltime;
@@ -144,14 +155,14 @@ static char lowerit(char);
static void mkdirs(char const *, bool);
static void newabbr(const char * abbr);
static zic_t oadd(zic_t t1, zic_t t2);
-static void outzone(const struct zone * zp, int ntzones);
+static void outzone(const struct zone * zp, ptrdiff_t ntzones);
static zic_t rpytime(const struct rule * rp, zic_t wantedy);
static void rulesub(struct rule * rp,
const char * loyearp, const char * hiyearp,
const char * typep, const char * monthp,
const char * dayp, const char * timep);
static zic_t tadd(zic_t t1, zic_t t2);
-static bool yearistype(int year, const char * type);
+static bool yearistype(zic_t year, const char * type);
/* Bound on length of what %z can expand to. */
enum { PERCENT_Z_LEN_BOUND = sizeof "+995959" - 1 };
@@ -171,17 +182,17 @@ static int leapcnt;
static bool leapseen;
static zic_t leapminyear;
static zic_t leapmaxyear;
-static int linenum;
+static lineno linenum;
static size_t max_abbrvar_len = PERCENT_Z_LEN_BOUND;
static size_t max_format_len;
static zic_t max_year;
static zic_t min_year;
static bool noise;
static const char * rfilename;
-static int rlinenum;
+static lineno rlinenum;
static const char * progname;
-static int timecnt;
-static int timecnt_alloc;
+static ptrdiff_t timecnt;
+static ptrdiff_t timecnt_alloc;
static int typecnt;
/*
@@ -266,23 +277,23 @@ static int typecnt;
#define YR_ONLY 2
static struct rule * rules;
-static int nrules; /* number of rules */
-static int nrules_alloc;
+static ptrdiff_t nrules; /* number of rules */
+static ptrdiff_t nrules_alloc;
static struct zone * zones;
-static int nzones; /* number of zones */
-static int nzones_alloc;
+static ptrdiff_t nzones; /* number of zones */
+static ptrdiff_t nzones_alloc;
struct link {
const char * l_filename;
- int l_linenum;
+ lineno l_linenum;
const char * l_from;
const char * l_to;
};
static struct link * links;
-static int nlinks;
-static int nlinks_alloc;
+static ptrdiff_t nlinks;
+static ptrdiff_t nlinks_alloc;
struct lookup {
const char * l_word;
@@ -436,17 +447,18 @@ ecpyalloc(char const *str)
}
static void *
-growalloc(void *ptr, size_t itemsize, int nitems, int *nitems_alloc)
+growalloc(void *ptr, size_t itemsize, ptrdiff_t nitems, ptrdiff_t *nitems_alloc)
{
if (nitems < *nitems_alloc)
return ptr;
else {
#define IMAX (INT_MAX < SIZE_MAX ? INT_MAX : (int)SIZE_MAX)
- int nitems_max = IMAX - WORK_AROUND_QTBUG_53071;
- int amax = nitems_max < IMAX ? nitems_max : IMAX;
+ ptrdiff_t nitems_max = PTRDIFF_MAX - WORK_AROUND_QTBUG_53071;
+ ptrdiff_t amax = nitems_max < (ptrdiff_t)SIZE_MAX ?
+ nitems_max : (ptrdiff_t)SIZE_MAX;
if ((amax - 1) / 3 * 2 < *nitems_alloc)
- memory_exhausted(_("int overflow"));
- *nitems_alloc = *nitems_alloc + (*nitems_alloc >> 1) + 1;
+ memory_exhausted(_("integer overflow"));
+ *nitems_alloc += (*nitems_alloc >> 1) + 1;
return zic_realloc(ptr, size_product(*nitems_alloc, itemsize));
}
}
@@ -456,8 +468,7 @@ growalloc(void *ptr, size_t itemsize, in
*/
static void
-eats(const char *const name, const int num, const char *const rname,
- const int rnum)
+eats(char const *name, lineno num, char const *rname, lineno rnum)
{
filename = name;
linenum = num;
@@ -466,7 +477,7 @@ eats(const char *const name, const int n
}
static void
-eat(const char *const name, const int num)
+eat(char const *name, lineno num)
{
eats(name, num, NULL, -1);
}
@@ -480,10 +491,10 @@ verror(const char *const string, va_list
** on BSD systems.
*/
if (filename)
- fprintf(stderr, _("\"%s\", line %d: "), filename, linenum);
+ fprintf(stderr, _("\"%s\", line %"PRIdLINENO": "), filename, linenum);
vfprintf(stderr, string, args);
if (rfilename != NULL)
- fprintf(stderr, _(" (rule from \"%s\", line %d)"),
+ fprintf(stderr, _(" (rule from \"%s\", line %"PRIdLINENO")"),
rfilename, rlinenum);
fprintf(stderr, "\n");
}
@@ -566,9 +577,8 @@ static const char * yitcommand;
int
main(int argc, char **argv)
{
- int i;
- int j;
- int c;
+ int c, k;
+ ptrdiff_t i, j;
#ifdef S_IWGRP
umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
@@ -586,12 +596,12 @@ main(int argc, char **argv)
_("wild compilation-time specification of zic_t"));
return EXIT_FAILURE;
}
- for (i = 1; i < argc; ++i)
- if (strcmp(argv[i], "--version") == 0) {
+ for (k = 1; k < argc; k++)
+ if (strcmp(argv[k], "--version") == 0) {
printf("zic %s%s\n", PKGVERSION, TZVERSION);
close_file(stdout, NULL, NULL);
return EXIT_SUCCESS;
- } else if (strcmp(argv[i], "--help") == 0) {
+ } else if (strcmp(argv[k], "--help") == 0) {
usage(stdout, EXIT_SUCCESS);
}
while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF && c != -1)
@@ -667,8 +677,8 @@ _("%s: More than one -L option specified
adjleap();
}
- for (i = optind; i < argc; ++i)
- infile(argv[i]);
+ for (k = optind; k < argc; k++)
+ infile(argv[k]);
if (errors)
return EXIT_FAILURE;
associate();
@@ -711,7 +721,7 @@ componentcheck(char const *name, char co
char const *component_end)
{
enum { component_len_max = 14 };
- size_t component_len = component_end - component;
+ ptrdiff_t component_len = component_end - component;
if (component_len == 0) {
if (!*name)
error (_("empty file name"));
@@ -726,8 +736,9 @@ componentcheck(char const *name, char co
}
if (0 < component_len && component_len <= 2
&& component[0] == '.' && component_end[-1] == '.') {
+ int len = component_len;
error(_("file name '%s' contains '%.*s' component"),
- name, (int) component_len, component);
+ name, len, component);
return false;
}
if (noise) {
@@ -896,8 +907,8 @@ dolink(char const *fromfield, char const
#define TIME_T_BITS_IN_FILE 64
-static zic_t const min_time = MINVAL (zic_t, TIME_T_BITS_IN_FILE);
-static zic_t const max_time = MAXVAL (zic_t, TIME_T_BITS_IN_FILE);
+static zic_t const min_time = MINVAL(zic_t, TIME_T_BITS_IN_FILE);
+static zic_t const max_time = MAXVAL(zic_t, TIME_T_BITS_IN_FILE);
/* Estimated time of the Big Bang, in seconds since the POSIX epoch.
rounded downward to the negation of a power of two that is
@@ -981,7 +992,7 @@ associate(void)
{
struct zone * zp;
struct rule * rp;
- int base, out;
+ ptrdiff_t base, out;
int i, j;
if (nrules != 0) {
@@ -1060,7 +1071,7 @@ infile(const char *name)
const struct lookup * lp;
int nfields;
bool wantcont;
- int num;
+ lineno num;
char buf[BUFSIZ];
if (strcmp(name, "-") == 0) {
@@ -1101,7 +1112,7 @@ infile(const char *name)
lp = byword(fields[0], line_codes);
if (lp == NULL)
error(_("input line of unknown type"));
- else switch ((int) (lp->l_value)) {
+ else switch (lp->l_value) {
case LC_RULE:
inrule(fields, nfields);
wantcont = false;
@@ -1213,7 +1224,7 @@ inrule(char **fields, int nfields)
static bool
inzone(char **fields, int nfields)
{
- int i;
+ ptrdiff_t i;
if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) {
error(_("wrong number of fields on Zone line"));
@@ -1233,13 +1244,13 @@ _("\"Zone %s\" line and -p option are mu
}
for (i = 0; i < nzones; ++i)
if (zones[i].z_name != NULL &&
- strcmp(zones[i].z_name, fields[ZF_NAME]) == 0) {
- error(
-_("duplicate zone name %s (file \"%s\", line %d)"),
- fields[ZF_NAME],
- zones[i].z_filename,
- zones[i].z_linenum);
- return false;
+ strcmp(zones[i].z_name, fields[ZF_NAME]) == 0) {
+ error(_("duplicate zone name %s"
+ " (file \"%s\", line %"PRIdLINENO")"),
+ fields[ZF_NAME],
+ zones[i].z_filename,
+ zones[i].z_linenum);
+ return false;
}
return inzsub(fields, nfields, false);
}
@@ -1347,7 +1358,7 @@ inleap(char **fields, int nfields)
{
const char * cp;
const struct lookup * lp;
- int i, j;
+ zic_t i, j;
zic_t year;
int month, day;
zic_t dayoff, tod;
@@ -1519,7 +1530,7 @@ rulesub(struct rule *rp, const char *loy
cp = loyearp;
lp = byword(cp, begin_years);
rp->r_lowasnum = lp == NULL;
- if (!rp->r_lowasnum) switch ((int) lp->l_value) {
+ if (!rp->r_lowasnum) switch (lp->l_value) {
case YR_MINIMUM:
rp->r_loyear = ZIC_MIN;
break;
@@ -1538,7 +1549,7 @@ rulesub(struct rule *rp, const char *loy
cp = hiyearp;
lp = byword(cp, end_years);
rp->r_hiwasnum = lp == NULL;
- if (!rp->r_hiwasnum) switch ((int) lp->l_value) {
+ if (!rp->r_hiwasnum) switch (lp->l_value) {
case YR_MINIMUM:
rp->r_hiyear = ZIC_MIN;
break;
@@ -1676,16 +1687,16 @@ static void
writezone(const char *const name, const char *const string, char version)
{
FILE * fp;
- int i, j;
+ ptrdiff_t i, j;
int leapcnt32, leapi32;
- int timecnt32, timei32;
+ ptrdiff_t timecnt32, timei32;
int pass;
static const struct tzhead tzh0;
static struct tzhead tzh;
bool dir_checked = false;
zic_t one = 1;
zic_t y2038_boundary = one << 31;
- int nats = timecnt + WORK_AROUND_QTBUG_53071;
+ ptrdiff_t nats = timecnt + WORK_AROUND_QTBUG_53071;
zic_t *ats = zic_malloc(size_product(nats, sizeof *ats + 1));
void *typesptr = ats + nats;
unsigned char *types = typesptr;
@@ -1699,8 +1710,7 @@ writezone(const char *const name, const
** Optimize.
*/
{
- int fromi;
- int toi;
+ ptrdiff_t fromi, toi;
toi = 0;
fromi = 0;
@@ -1722,9 +1732,16 @@ writezone(const char *const name, const
}
timecnt = toi;
}
- if (noise && timecnt > 1200)
+
+ if (noise && timecnt > 1200) {
+ if (timecnt > TZ_MAX_TIMES)
+ warning(_("reference clients mishandle"
+ " more than %d transition times"),
+ TZ_MAX_TIMES);
+ else
warning(_("pre-2014 clients may mishandle"
" more than 1200 transition times"));
+ }
/*
** Transfer.
*/
@@ -1809,27 +1826,31 @@ writezone(const char *const name, const
}
}
for (pass = 1; pass <= 2; ++pass) {
- int thistimei, thistimecnt;
- int thisleapi, thisleapcnt;
- int thistimelim, thisleaplim;
+ ptrdiff_t thistimei, thistimecnt, thistimelim;
+ int thisleapi, thisleapcnt, thisleaplim;
int writetype[TZ_MAX_TYPES];
int typemap[TZ_MAX_TYPES];
int thistypecnt;
char thischars[TZ_MAX_CHARS];
- char thischarcnt;
+ int thischarcnt;
+ bool toomanytimes;
int indmap[TZ_MAX_CHARS];
if (pass == 1) {
thistimei = timei32;
thistimecnt = timecnt32;
+ toomanytimes = thistimecnt >> 31 >> 1 != 0;
thisleapi = leapi32;
thisleapcnt = leapcnt32;
} else {
thistimei = 0;
thistimecnt = timecnt;
+ toomanytimes = thistimecnt >> 31 >> 31 >> 2 != 0;
thisleapi = 0;
thisleapcnt = leapcnt;
}
+ if (toomanytimes)
+ error(_("too many transition times"));
thistimelim = thistimei + thistimecnt;
thisleaplim = thisleapi + thisleapcnt;
for (i = 0; i < typecnt; ++i)
@@ -1919,8 +1940,7 @@ writezone(const char *const name, const
if (strcmp(&thischars[j], thisabbr) == 0)
break;
if (j == thischarcnt) {
- strcpy(&thischars[(int) thischarcnt],
- thisabbr);
+ strcpy(&thischars[thischarcnt], thisabbr);
thischarcnt += strlen(thisabbr) + 1;
}
indmap[abbrinds[i]] = j;
@@ -2211,7 +2231,7 @@ stringzone(char *result, const int resul
struct rule * rp;
struct rule * stdrp;
struct rule * dstrp;
- int i;
+ ptrdiff_t i;
const char * abbrvar;
int compat = 0;
int c;
@@ -2324,11 +2344,11 @@ stringzone(char *result, const int resul
}
static void
-outzone(const struct zone *zpfirst, int zonecount)
+outzone(const struct zone *zpfirst, ptrdiff_t zonecount)
{
const struct zone * zp;
struct rule * rp;
- int i, j;
+ ptrdiff_t i, j;
bool usestart, useuntil;
zic_t starttime, untiltime;
zic_t gmtoff;
@@ -2347,7 +2367,7 @@ outzone(const struct zone *zpfirst, int
int compat;
bool do_extend;
int version;
- int lastatmax = -1;
+ ptrdiff_t lastatmax = -1;
max_abbr_len = 2 + max_format_len + max_abbrvar_len;
max_envvar_len = 2 * max_abbr_len + 5 * 9;
@@ -2492,7 +2512,7 @@ outzone(const struct zone *zpfirst, int
rp->r_temp = rpytime(rp, year);
}
for ( ; ; ) {
- int k;
+ ptrdiff_t k;
zic_t jtime, ktime;
zic_t offset;
@@ -2766,28 +2786,49 @@ adjleap(void)
}
}
+static char *
+shellquote(char *b, char const *s)
+{
+ *b++ = '\'';
+ while (*s) {
+ if (*s == '\'')
+ *b++ = '\'', *b++ = '\\', *b++ = '\'';
+ *b++ = *s++;
+ }
+ *b++ = '\'';
+ return b;
+}
+
static bool
-yearistype(int year, const char *type)
+yearistype(zic_t year, const char *type)
{
- static char * buf;
- int result;
+ char *buf;
+ char *b;
+ int result;
+ size_t len;
if (type == NULL || *type == '\0')
return true;
- buf = zic_realloc(buf, 132 + strlen(yitcommand) + strlen(type));
- sprintf(buf, "%s %d %s", yitcommand, year, type); /* XXX: sprintf is safe */
+ buf = zic_malloc(len = 1 + 4 * strlen(yitcommand) + 2
+ + INT_STRLEN_MAXIMUM(zic_t) + 2 + 4 * strlen(type) + 2);
+ b = shellquote(buf, yitcommand);
+ *b++ = ' ';
+ b += snprintf(b, len - (b - buf), "%"PRIdZIC, year);
+ *b++ = ' ';
+ b = shellquote(b, type);
+ *b = '\0';
result = system(buf);
- if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
- case 0:
- return true;
- case 1:
- return false;
+ if (WIFEXITED(result)) {
+ int status = WEXITSTATUS(result);
+ if (status <= 1) {
+ free(buf);
+ return status == 0;
+ }
}
error(_("Wild result from command execution"));
fprintf(stderr, _("%s: command was '%s', result was %d\n"),
progname, buf, result);
- for ( ; ; )
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
/* Is A a space character in the C locale? */
@@ -2915,10 +2956,8 @@ getfields(char *cp)
if (*dp != '\0')
++dp;
else {
- error(_(
- "Odd number of quotation marks"
- ));
- exit(1);
+ error(_("Odd number of quotation marks"));
+ exit(EXIT_FAILURE);
}
} while (*cp && *cp != '#' && !is_space(*cp));
if (is_space(*cp))
Added files:
Index: src/lib/libc/time/LICENSE
diff -u /dev/null src/lib/libc/time/LICENSE:1.1
--- /dev/null Fri Nov 4 15:41:53 2016
+++ src/lib/libc/time/LICENSE Fri Nov 4 15:41:53 2016
@@ -0,0 +1,4 @@
+With a few exceptions, all files in the tz code and data (including
+this one) are in the public domain. The exceptions are date.c,
+newstrftime.3, and strftime.c, which contain material derived from BSD
+and which use the BSD 3-clause license.