This problem has come up before, and it's time to add a check to
catch this common error.
* Makefile (AWK_SCRIPTS): Add checklinks.awk.
(check, .PHONY): Add check_links.
(check_links): New rule.
* checklinks.awk: New file.
in: http://mm.icann.org/pipermail/tz/2014-October/021684.html
* localtime.c (tzload): Use ssize_t, not int. Redo comparison to
avoid the need for an ssize_t value less than -1, which POSIX does
not guarantee. Use memmove so that we needn't worry about an
ssize_t index.
(tzparse): Remove static always-zero var. Initialized fields
to zero by hand instead.
(zoneinit): Initialized more fields, to avoid undefined behavior
in tzalloc.
(leapcorr): Fix bug, a stray initialization of a local variable.
* Makefile: Add comment about ssize_t.
* NEWS: Document the above.
This is mostly for convenience, so that plain 'make' works out of
the box on Solaris, instead of having to run something awkward like
'make CFLAGS="-xc99=all -DHAVE_INCOMPATIBLE_CTIME_R=1"', and
similarly for Irix 6.5.
* private.h (_POSIX_PTHREAD_SEMANTICS):
* private.h, zdump.c (__EXTENSIONS__):
New macros, to make Solaris headers more like what we want out
of the box.
(LLONG_MAX, LLONG_MIN): Default from __LONG_LONG_MAX__ if it's defined.
This simplifies later code.
(SCNdFAST64, PRIdMAX): Don't assume they're defined when
INT_FAST64_MAX is, as that's not true on Solaris 10 + Sun C 5.12.
(PRIuMAX): Likewise, for Solaris 11 + Sun C 5.12.
* zdump.c (HAVE_LOCALTIME_RZ): Default to 1 only if TM_ZONE.
* Makefile, NEWS: Document this.
This is significantly faster and is cleaner internally.
* Makefile, NEWS: Document this.
* zdump.c (NETBSD_INSPIRED): Default to 1.
(HAVE_LOCALTIME_RZ): New macro; defaults to NETBSD_INSPIRED && USE_LTZ.
(timezone_t) [!HAVE_LOCALTIME_RZ]: New macro, as a substitute.
(localtime_r) [!HAVE_LOCALTIME_RZ && (!HAVE_LOCALTIME_R||!HAVE_TZSET)]:
(localtime_rz, tzalloc, tzfree) [!HAVE_LOCALTIME_RZ]:
(mktime_rz) [!HAVE_LOCALTIME_RZ && TYPECHECK]:
New substitute function and macro, compatible with NetBSD.
All other uses of localtime_r changed to use localtime_rz.
(settimezone): Remove; all uses replaced by tzalloc.
(tzalloc): Use most of the code of the old settimezone function,
but don't free the old storage.
(tzfree): Free it here instead.
(my_localtime_rz): Rename from my_localtime_r, and make it
compatible with localtime_rz. All uses changed.
(saveabbr): Return the abbreviation. If HAVE_LOCALTIME_RZ
simply return the output of abbr; that's faster.
(main): Diagnose any tzalloc failure. tzfree after use.
(hunt, show): New timezone_t arg. All uses changed.
* Makefile, NEWS: Document this.
* localtime.c (NETBSD_INSPIRED_EXTERN): New macro.
(zoneinit): New function, with tzset_unlocked's internals.
(tzset_unlocked): Use it.
(tzalloc, tzfree) [NETBSD_INSPIRED]: New functions.
(localsub, gmtsub, time2sub, time2, time1, leapcorr):
New time zone argument. All uses changed.
(localsub, gmtsub): Cast to char *, since the time zone argument
is a pointer-to-const.
(localtime_rz): New function, with localtime_tzset's internals.
(localtime_tzset): Use it.
(mktime_z): New function, with mktime's internals.
(mktime): Use it.
(leapcorr): Pass time_t by value, not by reference.
(time2posix_z): New function, with time2posix's internals.
(time2posix): Use it. Omit unnecessary local.
(posix2time_z): New function, with posix2time's internals.
(posix2time): Use it.
* private.h (NETBSD_INSPIRED): Default to 1.
(localtime_rz, mktime_z, timezone_t, strftime, tzalloc, tzfree):
Define if NETBSD_INSPIRED is defined.
Use macros to avoid any clashes with <time.h>.
(posiztime_z, time2posix_z): Likewise, but only if
STD_INSPIRED is also defined.
These files were removed from Solaris long ago,
and are not present on any current platforms.
* Makefile, NEWS: Document this.
* private.h (LOCALE_HOME): Remove.
* strftime.c: Assume LOCALE_HOME is not defined.
Do not include sys/stat.h.
(localebuf, _loc) [LOCALE_HOME]: Remove. All uses removed.
This fixes some schizophrenia in the build, which linked zdump to
the tz library code but did not compile zdump with the tz library API.
* zdump.c (USE_LTZ): New macro.
Use it, not time_tz, to decide whether to include private.h.
* Makefile, NEWS: Document this.
* Makefile (CHECK_TIME_T_ALTERNATIVES): New macro.
(public): Use it.
* localtime.c (SMALLEST): New macro.
(time2sub) [TM_GMTOFF && !UNINIT_TRAP]:
If the UTC offset doesn't match the request, try the requested offset.
This catches a problem caught by -DTYPECHECK with a time stamp
near a transition from LMT to standard time, where both sides of
the transition have tm_isdst == 0. If !defined TM_GMTOFF ||
UNINIT_TRAP you're out of luck: mktime will still conform
to its spec but it'll be more likely to guess wrong on these
ambiguous inputs.
* private.h (UNINIT_TRAP): New macro that defaults to 0.
* Makefile, NEWS: Document this.
This is a bit cleaner and faster.
* zdump.c (HAVE_LOCALTIME_R, HAVE_TZSET): Default to 1.
(tzset) [!HAVE_TZSET]:
(localtime_r) [!HAVE_LOCALTIME_R]: Provide a replacement.
(settimezone): Call tzset after changing environ.
(my_localtime_r): Rename from my_localtime, and change API to
be compatible with localtime_r, not localtime. All uses changed.
* Makefile, NEWS: Document this.
The Mach project has been inactive for decades,
and mktime has evidently replaced gtime.
* Makefile: Remove comment about CMUCS.
* localtime.c (gtime) [CMUCS]: Remove.
* NEWS: Document the above.
* 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.
* backzone: New file.
* Makefile (DATA): Add backzone.
(check_character_set): Check it.
(posix_packrat): New rule.
(.PHONY): Add it.
* NEWS: Document the above.
(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.
* Makefile (check_white_space): Rename from check_tabs; all uses
changed. Also check for trailing white space and for oddball
ASCII white space characters.
This harmless bug was introduced in release 2014f, which distributed
leapseconds.awk in both the code and the data tarballs.
It's code, so it should be in the code tarball.
* Makefile (DATA): Omit leapseconds.awk.
(check_character_set): Omit redundant check of $(LEAP_DEPS).
It allows multiple country codes per zone. Switch code and data to
use the new format, along with the recently-added Crozet Islands entry.
The old zone.tab file is still installed but is deprecated.
The new file uses UTF-8; add commentary saying that iso3166.tab is
planned to change to UTF-8.
* Theory, tzselect.8 (FILES): zone.tab -> time.tab.
* africa (Indian/Alfred_Faure): Remove link.
* antarctica: Mention Possession Island in comments.
* checktab.awk: Add support for checking time.tab.
* iso3166.tab: Mention planned switch to UTF-8.
Update ISO 3166-1 Newsletter from VI-15 to VI-16.
* time.tab: New file.
* tzselect.ksh (zonetabtype): New variable.
Add undocumented -t option, meant for developer testing.
(TZ_ZONE_TABLE): Use zonetabtype.
(output_distances, countries, regions, TZ): Support time.tab format.
(quoted_continents, distance_table, countries, regions)
(TZ, TZ_for_date): Quote shell strings more carefully.
* zone.tab: Refer to time.tab for detailed comments about format.
(Indian/Alfred_Faure): Remove.
* Makefile (TIMETABLES): New macro.
(TABDATA, install, check_tables): Use it.
(check_character_set, check_tables): Check time.tab too.
(check_time_t_alternatives): Use time.tab, not zone.tab.
* NEWS: Document the above.
For *.txt files, UTF-8 is not that important, and avoiding it
is better for users with older or misconfigured manpage readers.
* Makefile (check_character_set): Check that *.txt files
contain only safe characters.
($(MANTXTS)): Build *.txt files in the C locale, not in en_US.utf8.
* Makefile (NONSYM_CHAR, NONSYM_LINE): New macros.
(SAFE_SHARP_LINE): Don't let comments contain troublesome symbols.
(check_character_set): Don't let troublesome symbols appear in
source files, and don't let non-ASCII appear in .html files.
These changes pacify gcc 4.8.2-19ubuntu1 on Ubuntu 14.04,
and take advantage of recently-added GCC options when compiling
with GCC_DEBUG_FLAGS.
* Makefile (GCC_DEBUG_FLAGS): Add -Wdeclaration-after-statement,
-Wjump-misses-init, -Wsuggest-attribute=format.
* date.c (copyright, sccsid):
* strftime.c (sccsid):
Remove unused vars.
* date.c (main):
* localtime.c (tzparse):
Remove no-longer-needed uses of INITIALIZE; GCC is smart enough to
figure these out on its own now.
* localtime.c (gmtsub): Redo initialization of gmt_is_set to pacify GCC.
Retry malloc next time even if it failed this time.
* private.h, zdump.c (GNUC_or_lint): Remove, as it provoked a GCC
diagnostic about unused macros in some cases. Instead, just use
'lint'. All uses removed.
(TZ_DOMAIN): Don't define unless needed, as otherwise it provokes
a GCC diagnostic about unused macros.
* private.h (INITIALIZE): Simplify accordingly.
* NEWS: Document this.
In several cases our text files had commentary like this:
# Egypt to cancel daylight saving time
# <a href="http://www.almasryalyoum.com/en/node/407168">
# http://www.almasryalyoum.com/en/node/407168
# </a>
where lines 2 and 4 let the file be viewed by a browser with the
URL being clickable. In practice this approach does not work with
many modern browsers (I tested with Firefox and with Chrome) and
it clutters up the data, so in cases like the above this patch
removes lines 2 and 4.
(Problem reported by Steffen "Daode" Nurpmeso.)
This was appropriate before Unicode, where "`" and "'" often balanced
in visual output, but that's been obsolete for a while.
Overall, single-quote 'like this' instead of `like this', and
double-quote "like this" or (in typeset output) “like this”
instead of ``like this''. While we're at it, fix some glitches
with hyphens versus minus versus en dash versus em dash.
* Makefile ($(MANTXTS)): Use UTF-8 locale to produce *.txt output.
* checktab.awk, tzselect.ksh:
Quote 'like this' in diagnostics, instead of `like this'.
* date.1, newctime.3, newtzset.3, time2posix.3, zic.8 (q, lq, rq):
New macros. Use them for better double-quoting in output.
* workman.sh: Tell Perl that its stdin and stdout are UTF-8.
* NEWS: Document this.
* Makefile (DOCS): Move $(WEB_PAGES) here ...
(MISC): ... from here, so that they can contain UTF-8.
* tz-art.htm, tz-link.htm: Switch to UTF-8 encoding.
Prefer UTF-8 to HTML entities, e.g., prefer '–' to '–'.
* Makefile (INVALID_CHAR1): Rename to SAFE_CHARSET1.
(INVALID_CHAR2): Rename to SAFE_CHARSET2.
(INVALID_CHAR3): Rename to SAFE_CHARSET3.
(INVALID_CHAR): Remove.
(SAFE_CHARSET, SAFE_CHAR, SAFE_LINE, SAFE_SHARP_LINE, VALID_LINE):
New macros.
(check_character_set): Allow any UTF-8 character in some contexts,
including comments in the data, and in some auxiliary commentary files.