Commit Graph
3459 Commits
Author SHA1 Message Date
Paul Eggert da184ab535 mktime: guess better near transitions where tm_isdst does not change
* 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.
2014-08-25 08:20:53 -07:00
Paul Eggert 7c681a8148 zdump: use localtime_r if available
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.
2014-08-25 08:20:52 -07:00
Paul Eggert ab1034cab1 zdump: don't use uninitialized storage
* zdump.c (main): Avoid use of uninitalized locals in rare cases.
* NEWS: Mention this.
2014-08-25 08:20:52 -07:00
Paul Eggert d0aac72175 zdump: use TM_ZONE if available
* zdump.c (abbr): Return pointer-to-const.  Use TM_ZONE if
available, as it's simpler, more reliable, and a tad faster.
2014-08-25 08:20:52 -07:00
Paul Eggert f50d254594 * Makefile (TZDOBJS): Remove ialloc.o.
* NEWS: Document this.
2014-08-25 08:20:52 -07:00
Paul Eggert f4948756b5 Remove CMUCS's gtime function.
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.
2014-08-25 08:20:52 -07:00
Paul Eggert b5296f12c9 * localtime.c: Lessen lock overhead for gmtime etc.
(gmtcheck): Lock only if !gmt_is_set.
(gmtime_r, offtime, timeoff): Do not lock; gmtcheck now does this.
2014-08-25 08:20:52 -07:00
Paul Eggert b3c8309836 * private.h (asctime_r): Qualify arguments with 'restrict'.
This is for compatibility with POSIX.
2014-08-25 08:20:52 -07:00
Paul Eggert 649397ecb4 Document thread-safe functions in man pages.
* NEWS, newctime.3, newstrftime.3, newtzset.3, time2posix.3:
Mention localtime_r etc.  Also, use function prototypes rather
than K&R style, and use 'restrict' where POSIX does.
2014-08-25 08:20:52 -07:00
Paul Eggert 730615ccad Improve commentary for time long ago in India.
* asia: Move commentary about Portuguese India from here ...
* backzone: ... to here. Add comment about 19th-century Madras time.
* NEWS: Document this.
2014-08-25 08:20:23 -07:00
Paul Eggert 9ccf0e74f1 zdump: Don't silently truncate too-long abbreviations.
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.
2014-08-25 08:19:48 -07:00
Paul Eggert 161539d6d9 * zdump.c: Avoid crashes on unlikely integer overflows.
(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.
2014-08-25 08:19:48 -07:00
Paul Eggert b2290be9d6 Prefer memcpy to strncpy when either will do.
* localtime.c (tzparse)
* zic.c (doabbr):
Use memcpy, as only nonzero bytes are being copied.
* zic.c (doabbr): Remove unnecessary test.
2014-08-25 08:19:48 -07:00
Paul Eggert 234c9c3b13 Fix unlikely buffer overrun when setting date across network.
* date.c (netsettime) [TSP_SETDATE]: Don't assume gethostname
returns a null-terminated string.
2014-08-25 08:19:48 -07:00
Paul Eggert 7eb7c7349c Use bool for boolean.
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.
2014-08-25 08:19:48 -07:00
Paul Eggert 96eff14f85 Simplify configuration of TM_GMTOFF and TM_ZONE.
* private.h, zdump.c (_GNU_SOURCE): New macro.
(TM_GMTOFF) [!NO_TM_GMTOFF]:
(TM_ZONE) [!NO_TM_ZONE]: Guess definition if not already defined.
* Makefile, NEWS: Document the above.
2014-08-25 08:19:48 -07:00
Paul Eggert 2f7599d358 Port to GCC 3.4.6, which does not define __LONG_LONG_MIN__ on Irix.
* private.h (INT_FAST64_MIN, INTMAX_MIN): Don't use
__LONG_LONG_MIN__ when defining backwards-compatibility workaround.
2014-08-25 08:19:48 -07:00
Paul Eggert 1f5348d829 Minor library fixes for signed integer overflow.
* localtime.c (localsub, time2sub): Don't assume that signed
integer overflow wraps around.
2014-08-25 08:19:48 -07:00
Paul Eggert 13a277175c Fix some bugs and potential crashes with bad data in zone files.
* 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.
2014-08-25 08:19:48 -07:00
Paul Eggert 10ac30643e * Makefile (check_time_t_alternatives): Pass REDO to submake. 2014-08-25 08:19:48 -07:00
Paul Eggert 6292f17b4f * localtime.c (tzload): Reject files with out-of-order transitions. 2014-08-25 08:19:48 -07:00
Paul Eggert aaebb8e386 Port to platforms with leap seconds and unsigned time_t.
* 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.
2014-08-25 08:19:48 -07:00
Paul Eggert 35bcc1d40a * NEWS: Fix sign typo in Turks & Caicos news. (Thanks to Matt Johnson.) 2014-08-25 08:19:48 -07:00
Paul Eggert 23fe9ad77a Simplify new Turks & Caicos rules.
* 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.
2014-08-25 08:19:48 -07:00
Paul Eggert d7c4d73ba3 * northamerica (TC, America/Grand_Turk): Switch from EST/EDT to AST.
* NEWS: Document this.
2014-08-25 08:19:48 -07:00
Paul Eggert 253d158c17 zic: check more consistently for I/O errors and improve diagnostics
* 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.
2014-08-25 08:19:48 -07:00
Paul Eggert 4ad336d57a zdump: check more consistently for output errors
* 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.
2014-08-25 08:19:48 -07:00
Paul Eggert 5bfa967c17 Avoid (void) before calls.
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'.
2014-08-25 08:19:47 -07:00
Paul Eggert 11f5ff1129 * Makefile (strftime.o): Depend on private.h. 2014-08-25 08:19:47 -07:00
Paul Eggert fe7e48bcf5 * localtime.c (tzsetwall): Define only if STD_INSPIRED.
This removes lint in the !STD_INSPIRED case, as this function
is now unused in that case.
2014-08-25 08:19:47 -07:00
Paul Eggert 64399fc596 Make the library thread-safe if THREAD_SAFE is defined.
* 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.
2014-08-25 08:19:47 -07:00
Paul Eggert 4d86b313aa * private.h (timegm, timelocal) [time_tz]: Define replacements.
Needed on Ubuntu 14.04 when compiling with -D_GNU_SOURCE -Dtime_tz=....
2014-08-25 08:19:47 -07:00
Paul Eggert aedcce3e83 Remove lint when debugging by compiling with -Dtime_tz='whatever'.
* 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.
2014-08-25 08:19:47 -07:00
Paul Eggert 6bc7f54afa * date.c, localtime.c, zdump.c: Simplify prototypes for static functions
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.
2014-08-25 08:19:47 -07:00
Paul Eggert a253a3f97e Port to GCC 4.1.3 + NetBSD 5.1.
* private.h (INT_FAST32_MAX, INT_FAST32_MIN):
Define if not already defined, since localtime.c uses them.
2014-08-25 08:19:47 -07:00
Paul Eggert ad6d5fe9e6 Port to NetBSD when using GCC_DEBUG_FLAGS or defining time_tz.
* 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.
2014-08-25 08:19:47 -07:00
Paul Eggert a95a6ddad1 date: port to Ubuntu 14.04 with -DHAVE_UTMPX_H=1
* 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.
2014-08-25 08:19:47 -07:00
Tim Parenti 3962fae49c Better align end-of-line comments within Zones.
Per a suggestion from Alan Barrett:
http://mm.icann.org/pipermail/tz/2014-August/021416.html

Also some minor commentary changes to fit within 80 columns.
2014-08-16 22:48:03 -07:00
Tim Parenti 247d909702 More spacing fixes within UNTIL fields. 2014-08-16 22:48:03 -07:00
Tim Parenti 78e3924ea4 Rename fields of Link lines for clarity.
* 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.
2014-08-16 22:48:03 -07:00
Paul Eggert c3800e77d6 * backzone: Explain Zone columns. 2014-08-16 22:48:03 -07:00
Tim Parenti 3b64b02631 * NEWS: Typo fix. 2014-08-14 14:23:09 -07:00
Paul Eggert 0a5fcf8d0d * asia, NEWS: Update Philippines commentary. 2014-08-14 13:32:53 -07:00
Paul Eggert 7217d26487 * backzone: Fix misspelling (Thanks to Michael Deckers). 2014-08-13 11:46:39 -07:00
Paul Eggert 0f4a8f01fc * CONTRIBUTING: Clarify how to repeat the git workflow.
* NEWS: Thanks.
2014-08-13 08:02:56 -07:00
Paul Eggert 198708147f Reword so that it does not matter whether the word "data" is plural. 2014-08-12 22:20:23 -07:00
Paul Eggert ad420e19ef * time2posix.3, tzfile.5: Use ASCII double-quote only for C strings. 2014-08-12 19:00:04 -07:00
Paul Eggert 11be44dce3 The word "data" is plural. 2014-08-12 18:03:14 -07:00
Paul Eggert 94f941ebd1 Move out-of-scope UTC+1 African zones to 'backzone'.
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.
2014-08-12 17:38:43 -07:00
Paul Eggert ac5bf48519 New data file 'backzone' for out-of-scope and/or poorly-sourced data.
* backzone: New file.
* Makefile (DATA): Add backzone.
(check_character_set): Check it.
(posix_packrat): New rule.
(.PHONY): Add it.
* NEWS: Document the above.
2014-08-12 17:38:35 -07:00