Instead, allocate a longer buffer, exiting if memory is exhausted.
* zdump.c (saveabbr): New function.
(main, loab): Use it.
(abbr): Arg is now a pointer-to-const, for saveabbr.
(longest): Now int, since it can't exceed INT_MAX.
(sumsize, settimezone): New functions.
(main): Don't let 'longest' exceed INT_MAX. Use settimezone.
(show): Remove no-longer-necessary cast that formerly had undefined
behavior if 'longest' exceeded INT_MAX.
* localtime.c (tzload): Avoid undefined behavior on integer overflow
when reading a file containing integers out of machine range.
Simplify some of the existing overflow checking.
Handle out-of-range leap-second transitions similarly to the
way we now handle out-of-range ordinary transitions.
* NEWS: Document this and other recent fixes.
* localtime.c (tzload): On platforms where time_t is unsigned,
don't mishandle zones that contain leap seconds but no ordinary
transitions after 1970. This problem can be reproduced by running
'zdump -v right/Asia/Dubai' on a platform where time_t is an
unsigned 32-bit integer.
* northamerica (TC): Remove, as it's now a duplicate of the US rules.
Remove obsolescent comment about this.
(America/Grand_Turk): Use US rather than TC.
* zic.c (warnings): New static var.
(warning): Set it here.
(size_product, growalloc, main): Translate diagnostic.
(verror): Don't increment errors here.
(error): Set it here.
(close_file): New function.
(usage, dolink, infile, writezone): Use it.
(usage): Fit diagnostic in output lines better.
(main): Prefer 'return X;' to 'exit(X);'.
(main, infile, mkdirs): Use 'warning' for warnings.
Check for stderr output error.
(dolink, mkdirs): Don't assume gettext preserves errno.
* zdump.c: Include <errno.h>.
(errout): New static var.
(my_localtime) [!TYPECHECK]
(abbrok): Set it.
(close_file): New function.
(usage, main): Use it.
(main): Prefer 'return X;' to 'exit(X);'.
Check for stderr output error.
Although the cast to void in usage like '(void) printf ("Hello")'
may have been helpful decades ago when Lint Was Your Friend,
nowadays such casts are not helpful. The tz code is currently not
consistent about this: sometimes the casts are present, and
sometimes absent. As they make the code harder to read, let's
remove them.
* asctime.c, date.c, ialloc.c, localtime.c, strftime.c, zdump.c, zic.c:
Don't cast calls to 'void'.
* localtime.c [THREAD_SAFE]: Include pthread.h.
(VOLATILE): New macro.
(locallock) [THREAD_SAFE]: New static var.
(lock, unlock): New functions.
(lcl_is_set, gmt_is_set): Now VOLATILE.
(tzsetwall): Move cleaned-up guts to new function tzsetwall_unlocked,
for which this is now merely a locking wrapper.
(tzset): Similarly, for new function tzset_unlocked.
(localsub): Don't set tzname here; that's not thread-safe.
This change can lose information on hosts without TM_ZONE,
but there is no reliable way to fix that in a thread-safe way.
(localtime_tzset): New function, which does proper locking.
(localtime, localtime_r): Use it.
(gmtsub): Do not worry about initializing gmtptr, as that's now
the caller's responsibility.
(gmtime): Reimplement in terms of gmtime_r.
(timegm): Reimplement in terms of timeoff.
(gmtime_r, offtime, mktime, timeoff, time2posix, posix2time):
Lock at start and unlock at end.
* Makefile, NEWS: Document this.
* localtime.c (LOCALTIME_IMPLEMENTATION): New macro.
(time) [time_tz]: Move here from private.h, and make external.
* private.h (sys_time) [time_tz]: Define only if
LOCALTIME_IMPLEMENTATION, so that the code doesn't define an unused
static function sys_time that the compiler might complain about.
(time) [time_tz]: Move to localtime.c.
* NEWS: Document this.
by removing prototypes that aren't needed, and by removing names
of arguments. This will make future changes simpler and easier to
follow.
* NEWS: Document this.
* private.h (offtime, posix2time, time2posix, timeoff) [time_tz]:
Define tz_* replacements for these functions too.
(asctime_r): Move to after time_tz definitions, to keep like
declarations together.
(tzsetwall) [STD_INSPIRED]: Declare if not defined.
(offtime, timeoff, time2posix, posix2time) [STD_INSPIRED]:
Declare if not defined, or if time_tz is defined.
* NEWS: Document this.
* date.c (WTMPX_FILE): Define to _PATH_WTMPX if not already defined
and if _PATH_WTMPX is defined.
(reset): Do not use WTMPX_FILE if it is not defined.
* NEWS: Document this.
* zic.8, zoneinfo2tdf.pl: Change names of Link line fields to be more
descriptive and more like the parameters of 'ln'. LINK-FROM becomes
TARGET, and LINK-TO becomes LINK-NAME.
* backward: Add a '# Link' header.
* europe, northamerica: Add a few '# Zone' headers where needed.
* NEWS: Document this.
This illustrates how 'backzone' can be used to migrate
out-of-scope data out of the database proper.
* africa (Africa/Luanda, Africa/Porto-Novo, Africa/Douala, Africa/Bangui)
(Africa/Kinshasa, Africa/Brazzaville, Africa/Malabo, Africa/Libreville)
(Africa/Niamey): Change these from zones to links (to Africa/Lagos).
Move their old data from here ...
* backzone: ... to here.
* checktab.awk (tztab): Remove special cases for these zones.
* NEWS: Document the above.
* backzone: New file.
* Makefile (DATA): Add backzone.
(check_character_set): Check it.
(posix_packrat): New rule.
(.PHONY): Add it.
* NEWS: Document the above.
Add the product of the longitude difference and the cosine of the
latitude farther from the equator to the distance measure. This
works better for the Congolese test case noted by Alan Barrett in:
http://mm.icann.org/pipermail/tz/2014-July/021229.html
The new heuristic is not perfect, but no heuristic is.
* tzselect.ksh (abs, min): New functions
(convert_coord): Rename local to avoid name clash.
(gcdist): Rename from dist.
(pardist, dist): New functions.
* NEWS: Document this.
(Thanks to Alan Barrett for the suggestion.)
* Makefile (SOURCES): Move workman.sh here, from $(MISC).
(COMMON): Move NEWS here, from $(DOCS).
(tzdata$(VERSION).tar.gz): Move $(MISC) here, from
tzcode$(VERSION).tar.gz.
* NEWS: Document the above.