The tz source code predates C99 and so used int, 0 and 1 for boolean, but nowadays bool is available and makes the code clearer. Include backwards-compatibility definitions for pre-C99 platforms, and don't go beyond what the backwards-compatibility defintions support. * date.c (main, reset, sametm, convert, checkfinal, iffy, netsettime): * localtime.c (struct ttinfo, struct state, gmt_is_set) (differ_by_repeat, tzload, typesequiv, getoffset, transtime) (tzparse, gmtload, tzsetwall_unlocked, tzset_unlocked, gmtcheck) (localtime_tzset, timesub, increment_overflow) (increment_overflow32, increment_overflow_time) (normalize_overflow, normalize_overflow32, time2sub, time2) (time1): * strftime.c (_fmt, _yconv, _loc): * zdump.c (warned, errout, is_alpha, my_localtime, abbrok) (main, hunt, show): * zic.c (struct rule, errors, warnings, leapseen, noise) (leap_types, ttisstds, ttisgmts, error, warning, main, dolink) (associate, infile, gethms, inzone, inzcont, inzsub, inleap) (rulesub, is32, writezone, doabbr, stringoffset, stringrule) (stringzone, outzone, addtype, leapadd, yearistype, is_space) (is_alpha, ciequal, itsabbr, mkdirs): Use bool for boolean. * localtime.c (tzload, tzparse): * zic.c (stringoffset, mkdirs): Return true for success and false for failure instead of 0 and -1. All callers changed. * private.h, zdump.c (TRUE, FALSE): Remove, replacing by ... (true, false, bool): Define by <stdbool.h> if C99 or later, by macros otherwise. * tzfile.h: Remove mention of TRUE and FALSE from commentary. * zic.c (addtype): Remove now-unnecessary checks that a bool is a boolean.
Most of this patch is to commentary, to distinguish better among the similar characters hyphen '-', minus sign '−', en dash '–' (used for ranges), and em dash '—'. Render ordinary dashes in text as spaced en dashes, as this gives better-looking results in monospaced fonts. * yearistype.sh, zic.c: Reword diagnostics so that they do not use hyphens as if they were dashes. Since we are sticking to ASCII in programs, we can't use proper dashes in diagnostics.
This lets localtime handle Troll station. Hack suggested by Zefram.
Further testing found that it was incompatible with Ubuntu 12.04 glibc so this feature requires redesign and more testing. * Makefile (ZFLAGS): Remove comment about name and version info. Make it an empty var instead. * tzfile.5, tzfile.h: Remove description of meta-information. * zic.8: Remove options -n and -o. * zic.c: Don't include <stddef.h>. (genoption, genoptions, genname, addgenoption, writevalue): Remove. (usage, main, writezone): Remove support for -n and -o.
Spelling problem reported by Nathan Stratton Treadway in <http://mm.icann.org/pipermail/tz/2013-September/020121.html>.
Also, improve the documentation and diagnostics in this area. Suggested by Arthur David Olson in <http://mm.icann.org/pipermail/tz/2013-September/020064.html>. * tzfile.5, tzfile.h: Bump tzfile format to version 3. * zic.8: Document -v better. * zic.c (ZIC_VERSION): Bump from '2' to '3'. (stringrule, stringzone, outzone): Report compatibility issues more carefully, mentioning client dates.
In several places the code and documentation incorrectly used "UTC" to describe time stamps that might precede the introduction of UTC and for which UTC is therefore undefined. Change these uses to "UT", as that's the correct term when talking about these time stamps. Problem reported by Steve Allen in <http://mm.icann.org/pipermail/tz/2013-September/019907.html>. The major compatibility issue here is with 'zdump -v'; it'll now output "UT" instead of the possibly-incorrect "UTC". Many files change in minor ways in the commentary. * zdump.c (show): * zic.c (inzsub, addtype): In output, say "UT" rather than "UTC", since the time stamp we're talking about might precede the introduction of UTC.
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.
Remove the SCCS keyword '%W%' from all files. Mostly this just remove comments. Remove trailing white space, too. * Makefile (TZCODE_VERSION): New macro. (version.h): New rule. (tzselect): Interpolate TZCODE_VERSION. (clean): Remove version.h. (zdump.o, zic.o): Depend on version.h. * asctime.c, date.c, difftime.c, ialloc.c, localtime.c, scheck.c: * strftime.c, zdump.c, zic.c: Remove elsieid. * private.h: Remove privatehid. * tzfile.h: Remove tzfilehid. * tzselect.h (TZCODE_VERSION): Rename from VERSION. * zdump.c, zic.c: Include "version.h", and use TZCODE_VERSION instead of elsieid.