I audited the code and fixed as many width-asssumptions as I could
find, including several places where the code assumed that 'time_t'
was no wider than 'long'; this assumption is not true on 32-bit
NetBSD platforms. This caught every problem that is already fixed
in the NetBSD zic.c, and caught quite a few more.
* Makefile: Add comments re HAVE_DOS_FILE_NAMES and HAVE_INTTYPES_H.
* date.c (checkfinal, netsettime): Don't use 'long' where 'int' will do.
* difftime.c (difftime): Mark with ATTRIBUTE_CONST.
Use uintmax_t, not unsigned long, for the widest unsigned integer type.
Use long double, not double, if time_t is wider than uintmax_t;
this can in theory help on nonstandard platforms, such as GCC
with 64-bit uintmax_t and 128-bit __int128_t.
* localtime.c (struct ttinfo.tt_gmtoff, struct rule.r_time)
(detzcode, getsecs, getoffset, gmtsub, localsub, increment_overflow32)
(normalize_overflow32, time1, time2, timesub, transtime, tzparse)
(time2sub, timeoff, gtime):
* tzfile.h (SECSPERDAY):
* zdump.c (SECSPERDAY):
* zic.c (convert, puttzcode):
Use int_fast32_t, not long, when all we care is that values up to
2**31 can be stored. This doesn't fix any bugs, but it allows
more opportunity for compiler optimization.
(struct lsinfo.ls_corr, timesub, leapcorr):
Use int_fast64_t, not long, when values up to 2**63 can be stored.
(timesub): Make it clearer when we are truncating 0.5 to 0.
(increment_overflow32): Rename from long_increment_overflow.
All uses changed.
(normalize_overflow32): Rename from long_normalize_overflow.
All uses changed.
* private.h (HAVE_INTTYPES_H, ATTRIBUTE_CONST): New macros.
Include <inttypes.h> if HAVE_INTTYPES_H.
(INT_FAST64_MIN, INT_FAST64_MAX, SCNdFAST64, int_fast32_t, PRIdMAX)
(uintmax_t, PRIuMAX, _Noreturn):
Define to reasonable values if it's an older compiler.
* scheck.c (scheck): Add support for arbitrary formats, such as
those that SCNdFAST64 can expand to, at the price of no longer
supporting weird conversion specs like "%[%]".
* strftime.c (_fmt): Use intmax_t and uintmax_t to format time_t,
not long and unsigned long.
* zdump.c (int_fast32_t, intmax_t, PRIdMAX, SCNdMAX):
Define for pre-C99 compilers, like private.h does.
(delta, yeartot, main): Use intmax_t, not long.
(hunt): Use time_t, not long, since the diff must be nonnegative.
(tformat): Allow for time_t wider than long.
* zic.c (ZIC_MIN, ZIC_MAX, SCNdZIC): New macros.
(OFFSET_STRLEN_MAXIMUM, RULE_STRLEN_MAXIMUM): Remove.
(struct rule): Make r_loyear, r_hiyear, r_tod, r_stdoff, z_gmtoff,
z_stdoff zic_t, not long.
(addtype, gethms, oadd, rpytime, tadd, gmtoffs, corr, inleap)
(stringoffset, stringrule, outzone, addtype, adjleap, rpytime)
(LDAYSPERWEEK):
Use zic_t, not long.
(leapminyear, leapmaxyear, min_year, max_year, rulesub, updateminmax)
(outzone, rpytime):
Use zic_t, not int.
(usage): Now _Noreturn.
(main): Use S_IWGRP, not 'unix', to determine whether to call umask.
(writezone): Omit unnecessary cast.
(mkdirs): Use HAVE_DOS_FILE_NAMES, not 'unix', to determine
whether to parse DOS file anmes.
(eitol): Remove; no longer needed.
* Makefile (TIME_T_ALTERNATIVES): New macro.
(check_time_t_alternatives, clean_misc): New rules.
(clean): Split out into clean_misc and removing tzpublic.
(public): Add check_time_t.
This makes it easier to test on (say) Debian, even if we're
testing the time_t type on (say) NetBSD. NetBSD uses 64-bit
time_t on 32-bit hosts, and this lets us test a NetBSD-style
implementation (32-bit 'long', 64-bit time_t) on a 32-bit Debian host.
* Makefile: Update comments to talk about TIME_T_FLOATING and time_tz.
Sort the comments.
* private.h (restrict): Define to empty with older compilers.
'restrict' is now needed, to define gmtime_r and localtime_r in
standard ways when time_tz is defined.
Make the following changes if time_tz is defined:
(sys_time, time): New static functions. The former is the system
'time' function that applies to the system time_t, the latter
our function that applies to our time_t.
(time_t, ctime, ctime_r, difftime, gmtime, gmtime_r, localtime)
(localtime_r, mktime): Rename to tz_time_t, tz_ctime, etc.,
via macros. Declare the renamed versions.
* zdump.8: Document new options -V, -t.
* zdump.c: Include private.h if time_tz is defined.
(INITIALIZE): Remove; no longer needed.
(absolute_min_time, absolute_max_time): Work even if time_t
is wider than intmax_t, which can be true with GCC and __int128_t.
Use the new TIME_T_FLOATING macro for this.
(usage): Document new flags.
(main): Support them.
Based on a patch by Joseph S. Myers in
<http://mm.icann.org/pipermail/tz/2012-November/018452.html>.
* Makefile (BUGEMAIL): New macro.
(version.h, tzselect): Use it to define REPORT_BUGS_TO.
* tzselect.ksh (REPORT_BUGS_TO): New variable, used for --help.
* zdump.c, zic.c (usage): Use REPORT_BUGS_TO for --help.
E.g., "zic (tzcode) 2012i" instead of "tzcode2012i".
Thread started by Joseph S. Myers in
<http://mm.icann.org/pipermail/tz/2012-November/018439.html>.
* Makefile (PACKAGE): New macro.
(version.h, tzselect): New constant PKGVERSION, derived from PACKAGE.
(tzselect): TZVERSION is now simply VERSION, since PACKAGE is also
output.
* tzselect.ksh (PKGVERSION): New var, which Makefile substitutes for.
(--usage, --version): Exit with nonzero status if we can't
output the help or version number.
* tzselect.ksh (--version):
* zdump.c, zic.c (main):
Output versions like this: "zdump (tzcode) 2012i".
* Makefile (ZFLAGS): Remove obsolete comment.
(check_public): Put temporary directory under this directory, not
under /tmp, as that's better if one is doing multiple builds in
parallel. Also, use the just-built zic rather than the system zic.
(clean): Remove temporary directory.
* Makefile (maintainer-clean): Clean *.asc files and *.tar.gz files.
(signatures): Use .asc instead of .sign as the extension for signatures
as this works better with other software. Reported by Phil Pennock.
* .gitignore: Also ignore .asc files.
* Makefile (public): Rewrite in terms of new rules, below.
(check_public): New rule, containing the old checking part of
'make public'.
(tarballs): New rule, containing the old tarball-making part of
'make public'. Do not run checktab twice.
(signatures, tzcode$(VERSION).tar.gz.sign, tzdata$(VERSION).tar.gz.sign):
New rules.
* Makefile (KSHELL): New macro.
(tzselect): Use it.
* tzselect.ksh: Use "#!/bin/bash", not "#! /bin/ksh". The Makefile
can override this. No need for a space after "!'; that was put in
years ago only because of an urban legend.
* Makefile (LDFLAGS): Rename from LFLAGS, with backwards compatibility.
All uses changed. Suggested by Mike Frysinger in
<http://mm.icann.org/pipermail/tz/2012-October/018396.html>.
(zdump, zic, date): Use $(CC) -o $@ ... rather than $(CC) ... -o $@,
for portability to strict older POSIX hosts.
($(TZLIB)): Don't use [ ... -o ... ], as it's not portable.
* Makefile (VERSION): Increase to 2012g.
(COMMON): New macro.
(DOCS): Remove Makefile.
(ENCHILADA): Adjust to above changes.
(public): Put $(COMMON) in both tarballs, so that the version
number is in both distributions.
* Makefile (VERSION): New macro, superseding ...
(TZCODE_VERSION, TZDATA_VERSION): Remove. All uses changed.
(version.h): Call the variable TZVERSION, not TZCODE_VERSION.
All uses changed.
(tzselect): Interpolate TZVERSION, not TZCODE_VERSION.
(public): Adjust to new versioning scheme.
* tzselect.ksh (TZVERSION): Rename from TZCODE_VERSION.
* zdump.c, zic.c (main): Use TZVERSION, not TZCODE_VERSION.
* Makefile (TZCODE_VERSION): Increase to tzcode2012c.
(TZDATA_VERSION, GNUTARFLAGS, TARFLAGS, GZIPFLAGS): New macros.
(maintainer-clean): Remove all the old tar.gz files.
(set-timestamps): New rule.
(public): Use it. Create distribution files that are more
reproducible, by omitting irrelevant information such as the time
of checkout or build, the builder's user name, the builder's
locale, and so forth. Be more careful about file permissions in /tmp.