Module Name: src
Committed By: christos
Date: Tue Mar 15 15:16:01 UTC 2016
Modified Files:
src/lib/libc/time: Makefile NEWS README Theory localtime.c private.h
strftime.c tz-art.htm tz-link.htm tzselect.ksh zdump.c zic.c
Added Files:
src/lib/libc/time: CONTRIBUTING
Log Message:
Sync with 2016b
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libc/time/CONTRIBUTING
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/time/Makefile
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/time/NEWS \
src/lib/libc/time/tzselect.ksh
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/time/README
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/time/Theory
cvs rdiff -u -r1.101 -r1.102 src/lib/libc/time/localtime.c
cvs rdiff -u -r1.44 -r1.45 src/lib/libc/time/private.h
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/time/strftime.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/time/tz-art.htm
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/time/tz-link.htm
cvs rdiff -u -r1.42 -r1.43 src/lib/libc/time/zdump.c
cvs rdiff -u -r1.56 -r1.57 src/lib/libc/time/zic.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/time/Makefile
diff -u src/lib/libc/time/Makefile:1.31 src/lib/libc/time/Makefile:1.32
--- src/lib/libc/time/Makefile:1.31 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/Makefile Tue Mar 15 11:16:01 2016
@@ -5,7 +5,7 @@
PACKAGE= tzcode
# Version numbers of the code and data distributions.
-VERSION= 2015g
+VERSION= 2016b
# Email address for bug reports.
BUGEMAIL= [email protected]
@@ -84,14 +84,18 @@ LIBDIR= $(TOPDIR)/lib
# below. If you want both sets of data available, with leap seconds counted
# normally, use
# REDO= right_posix
-# below. If you want just POSIX-compatible time values, but with
-# out-of-scope and often-wrong data from the file 'backzone', use
-# REDO= posix_packrat
-# POSIX mandates that leap seconds not be counted; for compatibility with it,
-# use "posix_only", "posix_right", or "posix_packrat".
+# below. POSIX mandates that leap seconds not be counted; for compatibility
+# with it, use "posix_only" or "posix_right".
REDO= posix_right
+# If you want out-of-scope and often-wrong data from the file 'backzone', use
+# PACKRATDATA= backzone
+# To omit this data, use
+# PACKRATDATA=
+
+PACKRATDATA=
+
# Since "." may not be in PATH...
YEARISTYPE= ./yearistype
@@ -102,6 +106,8 @@ LDLIBS=
# Add the following to the end of the "CFLAGS=" line as needed.
# -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
+# -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
+# -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
# -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
# -DHAVE_GETTEXT=1 if 'gettext' works (GNU, Linux, Solaris); also see LDLIBS
# -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
@@ -112,6 +118,8 @@ LDLIBS=
# -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
# This defaults to 1 if a working localtime_rz seems to be available.
# localtime_rz can make zdump significantly faster, but is nonstandard.
+# -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
+# functions like 'link' or variables like 'tzname' required by POSIX
# -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
# -DHAVE_STRFTIME_L=1 if <time.h> declares locale_t and strftime_l
# This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise.
@@ -237,11 +245,22 @@ CFLAGS=
LDFLAGS= $(LFLAGS)
+# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in
+# submake command lines. The default is no leap seconds.
+
+LEAPSECONDS=
+
+# The zic command and its arguments.
+
zic= ./zic
ZIC= $(zic) $(ZFLAGS)
ZFLAGS=
+# How to use zic to install tzdata binary files.
+
+ZIC_INSTALL= $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) $(LEAPSECONDS)
+
# The name of a Posix-compliant 'awk' on your system.
AWK= awk
@@ -345,8 +364,8 @@ MANTXTS= newctime.3.txt newstrftime.3.tx
time2posix.3.txt \
tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
date.1.txt
-COMMON= CONTRIBUTING Makefile NEWS README Theory
-WEB_PAGES= tz-art.htm tz-link.htm
+COMMON= CONTRIBUTING LICENSE Makefile NEWS README Theory
+WEB_PAGES= tz-art.htm tz-how-to.html tz-link.htm
DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES)
PRIMARY_YDATA= africa antarctica asia australasia \
europe northamerica southamerica
@@ -367,7 +386,7 @@ ENCHILADA= $(COMMON) $(DOCS) $(SOURCES)
SHELL= /bin/sh
-all: tzselect zic zdump libtz.a $(TABDATA)
+all: tzselect yearistype zic zdump libtz.a $(TABDATA)
ALL: all date $(ENCHILADA)
@@ -376,8 +395,7 @@ install: all $(DATA) $(REDO) $(MANS)
$(DESTDIR)$(LIBDIR) \
$(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \
$(DESTDIR)$(MANDIR)/man8
- $(ZIC) -y $(YEARISTYPE) \
- -d $(DESTDIR)$(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
+ $(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES)
cp -f iso3166.tab $(ZONETABLES) $(DESTDIR)$(TZDIR)/.
cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/.
cp libtz.a $(DESTDIR)$(LIBDIR)/.
@@ -399,7 +417,7 @@ version.h:
zdump: $(TZDOBJS)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS)
-zic: $(TZCOBJS) yearistype
+zic: $(TZCOBJS)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS)
yearistype: yearistype.sh
@@ -409,13 +427,28 @@ yearistype: yearistype.sh
leapseconds: $(LEAP_DEPS)
$(AWK) -f leapseconds.awk leap-seconds.list >$@
-posix_only: zic $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
- -L /dev/null $(TDATA)
-
-right_only: zic leapseconds $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
- -L leapseconds $(TDATA)
+# Arguments to pass to submakes of install_data.
+# They can be overridden by later submake arguments.
+INSTALLARGS = \
+ DESTDIR=$(DESTDIR) \
+ LEAPSECONDS='$(LEAPSECONDS)' \
+ PACKRATDATA='$(PACKRATDATA)' \
+ TZDIR=$(TZDIR) \
+ YEARISTYPE=$(YEARISTYPE) \
+ ZIC='$(ZIC)'
+
+# 'make install_data' installs one set of tz binary files.
+# It can be tailored by setting LEAPSECONDS, PACKRATDATA, etc.
+install_data: zic leapseconds yearistype $(PACKRATDATA) $(TDATA)
+ $(ZIC_INSTALL) $(TDATA)
+ $(AWK) '/^Rule/' $(TDATA) | $(ZIC_INSTALL) - $(PACKRATDATA)
+
+posix_only:
+ $(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data
+
+right_only:
+ $(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \
+ install_data
# In earlier versions of this makefile, the other two directories were
# subdirectories of $(TZDIR). However, this led to configuration errors.
@@ -426,26 +459,22 @@ right_only: zic leapseconds $(TDATA)
# Therefore, the other two directories are now siblings of $(TZDIR).
# You must replace all of $(TZDIR) to switch from not using leap seconds
# to using them, or vice versa.
-right_posix: right_only leapseconds
+right_posix: right_only
rm -fr $(DESTDIR)$(TZDIR)-leaps
ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
- -L leapseconds $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
- -L /dev/null $(TDATA)
+ $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only
+ $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only
-posix_right: posix_only leapseconds
+posix_right: posix_only
rm -fr $(DESTDIR)$(TZDIR)-posix
ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
- -L /dev/null $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
- -L leapseconds $(TDATA)
-
-posix_packrat: posix_only backzone
- $(AWK) '/^Rule/' $(TDATA) | \
- $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
- -L /dev/null - backzone
+ $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only
+ $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only
+
+# This obsolescent rule is present for backwards compatibility with
+# tz releases 2014g through 2015g. It should go away eventually.
+posix_packrat:
+ $(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only
zones: $(REDO)
@@ -661,6 +690,7 @@ zic.o: private.h tzfile.h version.h
.PHONY: check check_character_set check_links
.PHONY: check_public check_sorted check_tables
.PHONY: check_time_t_alternatives check_web check_white_space clean clean_misc
-.PHONY: install maintainer-clean names posix_packrat posix_only posix_right
+.PHONY: install install_data maintainer-clean names
+.PHONY: posix_only posix_packrat posix_right
.PHONY: public right_only right_posix signatures tarballs typecheck
.PHONY: zonenames zones
Index: src/lib/libc/time/NEWS
diff -u src/lib/libc/time/NEWS:1.14 src/lib/libc/time/NEWS:1.15
--- src/lib/libc/time/NEWS:1.14 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/NEWS Tue Mar 15 11:16:01 2016
@@ -1,5 +1,119 @@
News for the tz database
+Release 2016b - 2016-03-12 17:30:14 -0800
+
+ Changes affecting future time stamps
+
+ New zones Europe/Astrakhan and Europe/Ulyanovsk for Astrakhan and
+ Ulyanovsk Oblasts, Russia, both of which will switch from +03 to +04 on
+ 2016-03-27 at 02:00 local time. They need distinct zones since their
+ post-1970 histories disagree. New zone Asia/Barnaul for Altai Krai and
+ Altai Republic, Russia, which will switch from +06 to +07 on the same date
+ and local time. The Astrakhan change is already official; the others have
+ passed the first reading in the State Duma and are extremely likely.
+ Also, Asia/Sakhalin moves from +10 to +11 on 2016-03-27 at 02:00.
+ (Thanks to Alexander Krivenyshev for the heads-up, and to Matt Johnson
+ and Stepan Golosunov for followup.)
+
+ As a trial of a new system that needs less information to be made up,
+ the new zones use numeric time zone abbreviations like "+04"
+ instead of invented abbreviations like "ASTT".
+
+ Haiti will not observe DST in 2016. (Thanks to Jean Antoine via
+ Steffen Thorsen.)
+
+ Palestine's spring-forward transition on 2016-03-26 is at 01:00, not 00:00.
+ (Thanks to Hannah Kreitem.) Guess future transitions will be March's last
+ Saturday at 01:00, not March's last Friday at 24:00.
+
+ Changes affecting past time stamps
+
+ Europe/Chisinau observed DST during 1990, and switched from +04 to
+ +03 at 1990-05-06 02:00, instead of switching from +03 to +02.
+ (Thanks to Stepan Golosunov.)
+
+ 1991 abbreviations in Europe/Samara should be SAMT/SAMST, not
+ KUYT/KUYST. (Thanks to Stepan Golosunov.)
+
+ Changes to code
+
+ tzselect's diagnostics and checking, and checktab.awk's checking,
+ have been improved. (Thanks to J William Piggott.)
+
+ tzcode now builds under MinGW. (Thanks to Ian Abbott and Esben Haabendal.)
+
+ tzselect now tests Julian-date TZ settings more accurately.
+ (Thanks to J William Piggott.)
+
+ Changes to commentary
+
+ Comments in zone tables have been improved. (Thanks to J William Piggott.)
+
+ tzselect again limits its menu comments so that menus fit on a
+ 24x80 alphanumeric display.
+
+ A new web page tz-how-to.html. (Thanks to Bill Seymour.)
+
+ In the Theory file, the description of possible time zone abbreviations in
+ tzdata has been cleaned up, as the old description was unclear and
+ inconsistent. (Thanks to Alain Mouette for reporting the problem.)
+
+
+Release 2016a - 2016-01-26 23:28:02 -0800
+
+ Changes affecting future time stamps
+
+ America/Cayman will not observe daylight saving this year after all.
+ Revert our guess that it would. (Thanks to Matt Johnson.)
+
+ Asia/Chita switches from +0800 to +0900 on 2016-03-27 at 02:00.
+ (Thanks to Alexander Krivenyshev.)
+
+ Asia/Tehran now has DST predictions for the year 2038 and later,
+ to be March 21 00:00 to September 21 00:00. This is likely better
+ than predicting no DST, albeit off by a day every now and then.
+
+ Changes affecting past and future time stamps
+
+ America/Metlakatla switched from PST all year to AKST/AKDT on
+ 2015-11-01 at 02:00. (Thanks to Steffen Thorsen.)
+
+ America/Santa_Isabel has been removed, and replaced with a
+ backward compatibility link to America/Tijuana. Its contents were
+ apparently based on a misreading of Mexican legislation.
+
+ Changes affecting past time stamps
+
+ Asia/Karachi's two transition times in 2002 were off by a minute.
+ (Thanks to Matt Johnson.)
+
+ Changes affecting build procedure
+
+ An installer can now combine leap seconds with use of the backzone file,
+ e.g., with 'make PACKRATDATA=backzone REDO=posix_right zones'.
+ The old 'make posix_packrat' rule is now marked as obsolescent.
+ (Thanks to Ian Abbott for an initial implementation.)
+
+ Changes affecting documentation and commentary
+
+ A new file LICENSE makes it easier to see that the code and data
+ are mostly public-domain. (Thanks to James Knight.) The three
+ non-public-domain files now use the current (3-clause) BSD license
+ instead of older versions of that license.
+
+ tz-link.htm mentions the BDE library (thanks to Andrew Paprocki),
+ CCTZ (thanks to Tim Parenti), TimeJones.com, and has a new section
+ on editing tz source files (with a mention of Sublime zoneinfo,
+ thanks to Gilmore Davidson).
+
+ The Theory and asia files now mention the 2015 book "The Global
+ Transformation of Time, 1870-1950", and cite a couple of reviews.
+
+ The America/Chicago entry now documents the informal use of US
+ central time in Fort Pierre, South Dakota. (Thanks to Rick
+ McDermid, Matt Johnson, and Steve Jones.)
+
+
Release 2015g - 2015-10-01 00:39:51 -0700
Changes affecting future time stamps
@@ -26,6 +140,9 @@ Release 2015g - 2015-10-01 00:39:51 -070
localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)
+ On hosts with signed 32-bit time_t, localtime no longer mishandles
+ Pacific/Fiji after 2038-01-16 14:00 UTC.
+
The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
Index: src/lib/libc/time/tzselect.ksh
diff -u src/lib/libc/time/tzselect.ksh:1.14 src/lib/libc/time/tzselect.ksh:1.15
--- src/lib/libc/time/tzselect.ksh:1.14 Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/tzselect.ksh Tue Mar 15 11:16:01 2016
@@ -1,6 +1,6 @@
#! /bin/bash
#
-# $NetBSD: tzselect.ksh,v 1.14 2015/06/21 16:06:51 christos Exp $
+# $NetBSD: tzselect.ksh,v 1.15 2016/03/15 15:16:01 christos Exp $
#
PKGVERSION='(tzcode) '
TZVERSION=see_Makefile
@@ -9,7 +9,7 @@ [email protected]
# Ask the user about the time zone, and output the resulting TZ value to stdout.
# Interact with the user via stderr and stdin.
-# Contributed by Paul Eggert.
+# Contributed by Paul Eggert. This file is in the public domain.
# Porting notes:
#
@@ -348,11 +348,14 @@ while
'that is 10 hours ahead (east) of UTC.'
read TZ
$AWK -v TZ="$TZ" 'BEGIN {
- tzname = "[^-+,0-9][^-+,0-9][^-+,0-9]+"
- time = "[0-2]?[0-9](:[0-5][0-9](:[0-5][0-9])?)?"
+ tzname = "(<[[:alnum:]+-]{3,}>|[[:alpha:]]{3,})"
+ time = "(2[0-4]|[0-1]?[0-9])" \
+ "(:[0-5][0-9](:[0-5][0-9])?)?"
offset = "[-+]?" time
- date = "(J?[0-9]+|M[0-9]+\\.[0-9]+\\.[0-9]+)"
- datetime = "," date "(/" time ")?"
+ mdate = "M([1-9]|1[0-2])\\.[1-5]\\.[0-6]"
+ jdate = "((J[1-9]|[0-9]|J?[1-9][0-9]" \
+ "|J?[1-2][0-9][0-9])|J?3[0-5][0-9]|J?36[0-5])"
+ datetime = ",(" mdate "|" jdate ")(/" time ")?"
tzpattern = "^(:.*|" tzname offset "(" tzname \
"(" offset ")?(" datetime datetime ")?)?)$"
if (TZ ~ tzpattern) exit 1
@@ -511,7 +514,7 @@ while
case $TZsec in
$UTsec)
extra_info="
-Local time is now: $TZdate.
+Selected time is now: $TZdate.
Universal Time is now: $UTdate."
break
esac
@@ -547,7 +550,7 @@ case $SHELL in
*) file=.profile line="TZ='$TZ'; export TZ"
esac
-say >&2 "
+test -t 1 && say >&2 "
You can make this change permanent for yourself by appending the line
$line
to the file '$file' in your home directory; then log out and log in again.
Index: src/lib/libc/time/README
diff -u src/lib/libc/time/README:1.9 src/lib/libc/time/README:1.10
--- src/lib/libc/time/README:1.9 Tue Oct 7 17:51:03 2014
+++ src/lib/libc/time/README Tue Mar 15 11:16:01 2016
@@ -10,10 +10,6 @@ locations around the globe. It is updat
changes made by political bodies to time zone boundaries, UTC offsets,
and daylight-saving rules.
-Unless otherwise specified, all files in the tz code and data are in
-the public domain, so clarified as of 2009-05-17 by Arthur David Olson.
-The few exceptions are code derived from BSD, which uses the BSD license.
-
Here is a recipe for acquiring, building, installing, and testing the
tz distribution on a GNU/Linux or similar host.
@@ -59,3 +55,9 @@ None of them are responsible for remaini
Look in <ftp://ftp.iana.org/tz/releases/> for updated versions of these files.
Please send comments or information to [email protected].
+
+-----
+
+This file is in the public domain, so clarified as of 2009-05-17 by
+Arthur David Olson. The other files in this distribution are either
+public domain or BSD licensed; see the file LICENSE for details.
Index: src/lib/libc/time/Theory
diff -u src/lib/libc/time/Theory:1.18 src/lib/libc/time/Theory:1.19
--- src/lib/libc/time/Theory:1.18 Thu Aug 13 07:21:18 2015
+++ src/lib/libc/time/Theory Tue Mar 15 11:16:01 2016
@@ -173,7 +173,7 @@ like 'EST' to be compatible with human t
Here are the general rules used for choosing time zone abbreviations,
in decreasing order of importance:
- Use abbreviations that consist of three or more ASCII letters.
+ Use three or more characters that are ASCII alphanumerics or '+' or '-'.
Previous editions of this database also used characters like
' ' and '?', but these characters have a special meaning to
the shell and cause commands like
@@ -181,19 +181,16 @@ in decreasing order of importance:
to have unexpected effects.
Previous editions of this rule required upper-case letters,
but the Congressman who introduced Chamorro Standard Time
- preferred "ChST", so the rule has been relaxed.
-
- This rule guarantees that all abbreviations could have
- been specified by a POSIX TZ string. POSIX
- requires at least three characters for an
- abbreviation. POSIX through 2000 says that an abbreviation
- cannot start with ':', and cannot contain ',', '-',
- '+', NUL, or a digit. POSIX from 2001 on changes this
- rule to say that an abbreviation can contain only '-', '+',
+ preferred "ChST", so lower-case letters are now allowed.
+ Also, POSIX from 2001 on relaxed the rule to allow '-', '+',
and alphanumeric characters from the portable character set
- in the current locale. To be portable to both sets of
- rules, an abbreviation must therefore use only ASCII
- letters.
+ in the current locale. In practice ASCII alphanumerics and
+ '+' and '-' are safe in all locales.
+
+ In other words, in the C locale the POSIX extended regular
+ expression [-+[:alnum:]]{3,} should match the abbreviation.
+ This guarantees that all abbreviations could have been
+ specified by a POSIX TZ string.
Use abbreviations that are in common use among English-speakers,
e.g. 'EST' for Eastern Standard Time in North America.
@@ -263,7 +260,15 @@ Errors in the tz database arise from man
be needed if the tz database's scope were extended to cover even
just the known or guessed history of standard time; for example,
the current single entry for France would need to split into dozens
- of entries, perhaps hundreds.
+ of entries, perhaps hundreds. And in most of the world even this
+ approach would be misleading due to widespread disagreement or
+ indifference about what times should be observed. In her 2015 book
+ "The Global Transformation of Time, 1870-1950", Vanessa Ogle writes
+ "Outside of Europe and North America there was no system of time
+ zones at all, often not even a stable landscape of mean times,
+ prior to the middle decades of the twentieth century". See:
+ Timothy Shenk, Booked: A Global History of Time. Dissent 2015-12-17
+ https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle
* Most of the pre-1970 data entries come from unreliable sources, often
astrology books that lack citations and whose compilers evidently
Index: src/lib/libc/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.101 src/lib/libc/time/localtime.c:1.102
--- src/lib/libc/time/localtime.c:1.101 Sat Feb 20 15:11:37 2016
+++ src/lib/libc/time/localtime.c Tue Mar 15 11:16:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.101 2016/02/20 20:11:37 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.102 2016/03/15 15:16:01 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.101 2016/02/20 20:11:37 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.102 2016/03/15 15:16:01 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -177,18 +177,6 @@ static timezone_t gmtptr;
static char lcl_TZname[TZ_STRLEN_MAX + 1];
static int lcl_is_set;
-#if !defined(__LIBC12_SOURCE__)
-
-__aconst char * tzname[2] = {
- (__aconst char *)__UNCONST(wildabbr),
- (__aconst char *)__UNCONST(wildabbr)
-};
-
-#else
-
-extern __aconst char * tzname[2];
-
-#endif
#ifdef _REENTRANT
static rwlock_t lcl_lock = RWLOCK_INITIALIZER;
@@ -204,15 +192,30 @@ static rwlock_t lcl_lock = RWLOCK_INITIA
static struct tm tm;
-#ifdef USG_COMPAT
-#if !defined(__LIBC12_SOURCE__)
+#if !HAVE_POSIX_DECLS || defined(__NetBSD__)
+# if !defined(__LIBC12_SOURCE__)
+
+__aconst char * tzname[2] = {
+ (__aconst char *)__UNCONST(wildabbr),
+ (__aconst char *)__UNCONST(wildabbr)
+};
+
+# else
+
+extern __aconst char * tzname[2];
+
+# endif /* __LIBC12_SOURCE__ */
+
+# ifdef USG_COMPAT
+# if !defined(__LIBC12_SOURCE__)
long timezone = 0;
int daylight = 0;
#else
extern int daylight;
extern long timezone __RENAME(__timezone13);
-#endif
-#endif /* defined USG_COMPAT */
+# endif /* __LIBC12_SOURCE__ */
+# endif /* defined USG_COMPAT */
+#endif /* !HAVE_POSIX_DECLS */
#ifdef ALTZONE
long altzone = 0;
Index: src/lib/libc/time/private.h
diff -u src/lib/libc/time/private.h:1.44 src/lib/libc/time/private.h:1.45
--- src/lib/libc/time/private.h:1.44 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/private.h Tue Mar 15 11:16:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: private.h,v 1.44 2015/10/09 17:21:45 christos Exp $ */
+/* $NetBSD: private.h,v 1.45 2016/03/15 15:16:01 christos Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
@@ -34,6 +34,10 @@
** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'.
*/
+#ifndef HAVE_DECL_ASCTIME_R
+#define HAVE_DECL_ASCTIME_R 1
+#endif
+
#ifndef HAVE_GETTEXT
#define HAVE_GETTEXT 0
#endif /* !defined HAVE_GETTEXT */
@@ -46,6 +50,10 @@
#define HAVE_LINK 1
#endif /* !defined HAVE_LINK */
+#ifndef HAVE_POSIX_DECLS
+#define HAVE_POSIX_DECLS 1
+#endif
+
#ifndef HAVE_STRDUP
#define HAVE_STRDUP 1
#endif
@@ -122,6 +130,9 @@
#ifndef ENAMETOOLONG
# define ENAMETOOLONG EINVAL
#endif
+#ifndef ENOTSUP
+# define ENOTSUP EINVAL
+#endif
#ifndef EOVERFLOW
# define EOVERFLOW EINVAL
#endif
@@ -395,25 +406,21 @@ time_t time(time_t *);
void tzset(void);
#endif
-/*
-** Some time.h implementations don't declare asctime_r.
-** Others might define it as a macro.
-** Fix the former without affecting the latter.
-** Similarly for timezone, daylight, and altzone.
-*/
-
-#ifndef asctime_r
-extern char * asctime_r(struct tm const *restrict, char *restrict);
+#if !HAVE_DECL_ASCTIME_R && !defined asctime_r
+extern char *asctime_r(struct tm const *restrict, char *restrict);
#endif
-#if defined(USG_COMPAT) && !defined(__NetBSD__)
-# ifndef timezone
+#if !HAVE_POSIX_DECLS
+# if defined(USG_COMPAT) && !defined(__NetBSD__)
+# ifndef timezone
extern long timezone;
-# endif
-# ifndef daylight
+# endif
+# ifndef daylight
extern int daylight;
+# endif
# endif
#endif
+
#if defined ALTZONE && !defined altzone
extern long altzone;
#endif
Index: src/lib/libc/time/strftime.c
diff -u src/lib/libc/time/strftime.c:1.35 src/lib/libc/time/strftime.c:1.36
--- src/lib/libc/time/strftime.c:1.35 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/strftime.c Tue Mar 15 11:16:01 2016
@@ -1,4 +1,33 @@
-/* $NetBSD: strftime.c,v 1.35 2015/10/09 17:21:45 christos Exp $ */
+/* $NetBSD: strftime.c,v 1.36 2016/03/15 15:16:01 christos Exp $ */
+
+/* Convert a broken-down time stamp to a string. */
+
+/* Copyright 1989 The Regents of the University of California.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE. */
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
@@ -6,7 +35,7 @@
static char elsieid[] = "@(#)strftime.c 7.64";
static char elsieid[] = "@(#)strftime.c 8.3";
#else
-__RCSID("$NetBSD: strftime.c,v 1.35 2015/10/09 17:21:45 christos Exp $");
+__RCSID("$NetBSD: strftime.c,v 1.36 2016/03/15 15:16:01 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -18,8 +47,7 @@ __RCSID("$NetBSD: strftime.c,v 1.35 2015
#include "setlocale_local.h"
/*
-** Based on the UCB version with the copyright notice and sccsid
-** appearing below.
+** Based on the UCB version with the copyright notice appearing above.
**
** This is ANSIish only when "multibyte character == plain character".
*/
@@ -37,39 +65,6 @@ __RCSID("$NetBSD: strftime.c,v 1.35 2015
#undef TM_GMTOFF
#endif
-/*
-** Copyright (c) 1989, 1993
-** The Regents of the University of California. All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-** 1. Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in the
-** documentation and/or other materials provided with the distribution.
-** 3. All advertising materials mentioning features or use of this software
-** must display the following acknowledgement:
-** This product includes software developed by the University of
-** California, Berkeley and its contributors.
-** 4. Neither the name of the University nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
-** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-** ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-** SUCH DAMAGE.
-*/
-
#include "tzfile.h"
#include "fcntl.h"
#include "locale.h"
@@ -91,7 +86,9 @@ static char * _fmt(const timezone_t, con
const char *, int *, locale_t);
static char * _yconv(int, int, bool, bool, char *, const char *);
+#if !HAVE_POSIX_DECLS
extern char * tzname[];
+#endif
#ifndef YEAR_2000_NAME
#define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS"
Index: src/lib/libc/time/tz-art.htm
diff -u src/lib/libc/time/tz-art.htm:1.11 src/lib/libc/time/tz-art.htm:1.12
--- src/lib/libc/time/tz-art.htm:1.11 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/tz-art.htm Tue Mar 15 11:16:01 2016
@@ -274,6 +274,15 @@ time I've ever been early for work. Exce
savings days. Lousy farmers."</td></tr>
<tr><td> </td></tr>
+<tr><td>TV episode title</td><td>Tracks</td></tr>
+<tr><td>TV series</td><td><em>The Good Wife</em></td></tr>
+<tr><td>TV episode number</td><td>12, season 7</td></tr>
+<tr><td>Network</td><td>CBS</td></tr>
+<tr><td>Air date</td><td>2016-01-17</td></tr>
+<tr><td>Notes</td><td>The applicability of a contract hinges on the
+time zone associated with a video time stamp.</td></tr>
+<tr><td> </td></tr>
+
<tr><td>Artist</td><td>Jules Verne</td></tr>
<tr><td>Book</td><td><em>Around the World in Eighty Days</em>
(<em>Le tour du monde en quatre-vingts jours</em>)</td></tr>
@@ -344,10 +353,19 @@ broadcast 1997-02-13, in which Kramer de
isn't coming fast enough, so he sets his watch ahead an hour.
</li>
<li>
-The syndicated comic strip <em>Dilbert</em> featured an all-too-rare example of
-time zone humor on 1998-03-14.
+The syndicated comic strip <em>Dilbert</em> featured an
+<a href='http://dilbert.com/strip/1998-03-14'>all-too-rare example of
+time zone humor</a> on 1998-03-14.
</li>
<li>
+The webcomic <em>xkcd</em> has the strip
+"<a href='https://xkcd.com/673/'>The Sun</a>" (2009-12-09) and the panels
+"<a href='https://xkcd.com/1017/'>Backward in Time</a>" (2012-02-14),
+"<a href='https://xkcd.com/1061/'>EST</a>" (2012-05-28), and
+"<a href='https://xkcd.com/1335/'>Now</a>" (2014-02-26).
+The related book <em>What If?</em> has an entry
+"<a href='https://what-if.xkcd.com/26/'>Leap Seconds</a>" (2012-12-31).
+<li>
Surrealist artist Guy Billout's work "Date Line" appeared on page 103
of the 1999-11 <em>Atlantic Monthly</em>.
</li>
@@ -432,6 +450,14 @@ hilarity ensues.
(Never mind that this should be 7:30am in Mumbai, yet for some reason the show
proceeds as though it's also mid-evening there.)
</li>
+<li>
+In the "14 Days to Go"/"T Minus..." episode of
+<em>You, Me and the Apocalypse</em>
+(first aired 2015-11-11 in the UK, 2016-03-10 in the US),
+the success of a mission to deal with a comet
+hinges on whether or not Russia observes daylight saving time.
+(In the US, the episode first aired in the week before the switch to DST.)
+</li>
</ul>
<hr>
<ul>
@@ -506,7 +532,7 @@ Peppermint Patty: "What if the world com
Marcie: "I promise there'll be a tomorrow, sir ... in fact,
it's already tomorrow in Australia!"
<br>
-(Charles M. Schulz, <em>Peanuts</em>, 1980-06-13)
+(Charles M. Schulz, <a href='http://www.gocomics.com/peanuts/1980/06/13'><em>Peanuts</em>, 1980-06-13</a>)
</li>
</ul>
</body>
Index: src/lib/libc/time/tz-link.htm
diff -u src/lib/libc/time/tz-link.htm:1.24 src/lib/libc/time/tz-link.htm:1.25
--- src/lib/libc/time/tz-link.htm:1.24 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/tz-link.htm Tue Mar 15 11:16:01 2016
@@ -2,13 +2,15 @@
PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
-<head>
-<title>Sources for Time Zone and Daylight Saving Time Data</title>
+<head profile="http://dublincore.org/documents/2008/08/04/dc-html/">
+<title>Sources for time zone and daylight saving time data</title>
<link rel="schema.DC" href="http://purl.org/DC/elements/1.1/">
<meta http-equiv="Content-type" content='text/html; charset="UTF-8"'>
+<meta name="DC.Title"
+ content="Sources for time zone and daylight saving time data">
<meta name="DC.Creator" content="Eggert, Paul">
<meta name="DC.Contributor" content="Olson, Arthur David">
-<meta name="DC.Date" content="2015-10-01">
+<meta name="DC.Date" content="2016-02-29">
<meta name="DC.Description"
content="Sources of information about time zones and daylight saving time">
<meta name="DC.Identifier"
@@ -17,7 +19,7 @@
content="database,daylight saving,DST,time zone,timezone,tz,zoneinfo">
</head>
<body>
-<h1>Sources for Time Zone and Daylight Saving Time Data</h1>
+<h1>Sources for time zone and daylight saving time data</h1>
<h2>The <code><abbr title="time zone">tz</abbr></code> database</h2>
<p>
The <a href="https://en.wikipedia.org/wiki/Public_domain">public-domain</a>
@@ -160,7 +162,7 @@ Here are some links that may be of inter
<li>The article
<a href="https://en.wikipedia.org/wiki/Tz_database">tz database</a> is
an encyclopedic summary.</li>
-<li><a href="https://web.archive.org/web/20140221080916/http://www.cstdbill.com/tzdb/tz-how-to.html">How to Read the
+<li><a href="tz-how-to.html">How to Read the
tz Database Source Files</a> explains the <code><abbr>tz</abbr></code>
database format.</li>
<li><a
@@ -168,6 +170,24 @@ href="http://blog.jonudell.net/2009/10/2
literary appreciation of the Olson/Zoneinfo/tz database</a> comments on the
database's style.</li>
</ul>
+<h2>Editing <code><abbr>tz</abbr></code> database source files</h2>
+<p>Sources for the <code><abbr>tz</abbr></code> database are
+<a href="https://en.wikipedia.org/wiki/UTF-8"><abbr
+title="Unicode Transformation Format 8-bit">UTF-8</abbr></a>
+<a href="https://en.wikipedia.org/wiki/Text_file">text files</a>
+with lines terminated by <a href="https://en.wikipedia.org/wiki/Newline"><abbr
+title="linefeed">LF</abbr></a>,
+which can be modified by common text editors such
+as <a href="https://www.gnu.org/software/emacs/">GNU Emacs</a>,
+<a href="https://wiki.gnome.org/Apps/Gedit">gedit</a>, and
+<a href="http://www.vim.org/">vim</a>. One
+editor has a package to simplify editing further:</p>
+<ul>
+<li><a href="https://packagecontrol.io/packages/zoneinfo">Sublime
+zoneinfo</a> is a <a href="http://www.sublimetext.com/">Sublime
+Text</a> package for syntax highlighting <code><abbr>tz</abbr></code>
+source files.</li>
+</ul>
<h2>Web sites using recent versions of the <code><abbr>tz</abbr></code> database</h2>
<p>
These are listed roughly in ascending order of complexity and fanciness.
@@ -175,11 +195,13 @@ These are listed roughly in ascending or
<ul>
<li><a href="http://time.is">Time.is</a> shows locations'
time and zones in a simple format.</li>
+<li><a href="https://www.timejones.com/">TimeJones.com</a> is a simple
+time zone converter.</li>
<li><a
href="http://twiki.org/cgi-bin/xtra/tzdatepick.html">Date and Time Gateway</a>
lets you see the <code><abbr>TZ</abbr></code> values directly.</li>
<li><a
-href="http://convertit.com/Go/ConvertIt/World_Time/Current_Time.ASP">Current
+href="http://www.convertit.com/Go/ConvertIt/World_Time/Current_Time.ASP">Current
Time in 1000 Places</a> uses descriptions of the values.</li>
<li><a href="http://www.timezoneconverter.com/cgi-bin/tzc.tzc">Time Zone
Converter</a>
@@ -187,7 +209,7 @@ uses a pulldown menu.</li>
<li><a href="http://home.kpn.nl/vanadovv/time/TZworld.html">Complete
timezone information for all countries</a> displays tables of DST rules.
<li><a href="http://www.timeanddate.com/worldclock/">The World Clock –
-Time Zones</a> lets you sort zone names and convert times.</li>
+Worldwide</a> lets you sort zone names and convert times.</li>
<li><a href="http://www.zeitverschiebung.net/en/">Time Difference</a>
calculates the current time difference between locations.</li>
<li><a href="http://www.wx-now.com">Weather Now</a> lists the weather too.</li>
@@ -356,6 +378,14 @@ a <code><abbr>tz</abbr></code> binary fi
creates a <code>GTimeZone</code> object representing sets
of <abbr>UT</abbr> offsets.
It is freely available under the <abbr>LGPL</abbr>.</li>
+<li>The
+<a href="https://github.com/bloomberg/bde/wiki">BDE Standard Library</a>'s
+<code>baltzo::TimeZoneUtil</code> component contains a C++
+implementation of a binary file reader. It is freely available under
+the Apache License.</li>
+<li><a href="https://github.com/google/cctz">CCTZ</a> is a simple C++
+library that translates between UTC and civil time and can read binary
+files. It is freely available under the Apache License.</li>
<li><a href="http://bmsi.com/java/#TZ">ZoneInfo.java</a>
is a <code><abbr>tz</abbr></code> binary file reader written in Java.
It is freely available under the <abbr>LGPL</abbr>.</li>
@@ -612,7 +642,7 @@ is Singapore in the "Wrong" Time Zone?</
history of legal time in Singapore and Malaysia.</dd>
<dt>United Kingdom</dt>
<dd><a
-href="http://www.polyomino.org.uk/british-time/">History of
+href="https://www.polyomino.org.uk/british-time/">History of
legal time in Britain</a> discusses in detail the country
with perhaps the best-documented history of clock adjustments.
The National Physical Laboratory also maintains an <a
@@ -620,7 +650,7 @@ href="http://www.npl.co.uk/educate-explo
of Summer time dates</a>.</dd>
<dt>United States</dt>
<dd>The Department of Transportation's <a
-href="http://www.transportation.gov/regulations/recent-time-zone-proceedings">Recent
+href="https://www.transportation.gov/regulations/recent-time-zone-proceedings">Recent
Time Zone Proceedings</a> lists changes to time zone boundaries.</dd>
</dl>
<h2>Precision timekeeping</h2>
@@ -669,7 +699,7 @@ code for converting among time scales li
<abbr title="International Atomic Time">TAI</abbr>,
<abbr>TDB</abbr>, <abbr>TDT</abbr> and
<abbr>UTC</abbr>.</li>
-<li><a href="http://www2.jpl.nasa.gov/basics/bsf2-3.php">Basics of
+<li><a href="http://solarsystem.nasa.gov/basics/bsf2-3.php">Basics of
Space Flight – Reference Systems – Time Conventions</a>
briefly explains interplanetary space flight timekeeping.</li>
<li><a
@@ -740,7 +770,7 @@ specifies an <abbr>ISO</abbr> 8601
profile for use in new Internet
protocols.</li>
<li>
-<a href="http://www.hackcraft.net/web/datetime/">Date & Time
+<a href="https://www.hackcraft.net/web/datetime/">Date & Time
Formats on the Web</a> surveys web- and Internet-oriented date and time
formats.</li>
<li>
Index: src/lib/libc/time/zdump.c
diff -u src/lib/libc/time/zdump.c:1.42 src/lib/libc/time/zdump.c:1.43
--- src/lib/libc/time/zdump.c:1.42 Thu Aug 13 07:21:18 2015
+++ src/lib/libc/time/zdump.c Tue Mar 15 11:16:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: zdump.c,v 1.42 2015/08/13 11:21:18 christos Exp $ */
+/* $NetBSD: zdump.c,v 1.43 2016/03/15 15:16:01 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2009-05-17 by Arthur David Olson.
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: zdump.c,v 1.42 2015/08/13 11:21:18 christos Exp $");
+__RCSID("$NetBSD: zdump.c,v 1.43 2016/03/15 15:16:01 christos Exp $");
#endif /* !defined lint */
/*
@@ -254,11 +254,14 @@ enum { SECSPER400YEARS_FITS = SECSPERLYE
# define timezone_t char **
#endif
+#if !HAVE_POSIX_DECLS
extern char ** environ;
extern int getopt(int argc, char * const argv[],
const char * options);
extern char * optarg;
extern int optind;
+extern char * tzname[];
+#endif
/* The minimum and maximum finite time values. */
enum { atime_shift = CHAR_BIT * sizeof (time_t) - 2 };
Index: src/lib/libc/time/zic.c
diff -u src/lib/libc/time/zic.c:1.56 src/lib/libc/time/zic.c:1.57
--- src/lib/libc/time/zic.c:1.56 Fri Oct 9 13:21:45 2015
+++ src/lib/libc/time/zic.c Tue Mar 15 11:16:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: zic.c,v 1.56 2015/10/09 17:21:45 christos Exp $ */
+/* $NetBSD: zic.c,v 1.57 2016/03/15 15:16:01 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@@ -10,7 +10,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.56 2015/10/09 17:21:45 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.57 2016/03/15 15:16:01 christos Exp $");
#endif /* !defined lint */
#include "private.h"
@@ -32,6 +32,13 @@ typedef int_fast64_t zic_t;
#define ZIC_MAX_ABBR_LEN_WO_WARN 6
#endif /* !defined ZIC_MAX_ABBR_LEN_WO_WARN */
+#ifdef HAVE_DIRECT_H
+# include <direct.h>
+# include <io.h>
+# undef mkdir
+# define mkdir(name, mode) _mkdir(name)
+#endif
+
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
@@ -97,21 +104,23 @@ struct zone {
zic_t z_untiltime;
};
+#if !HAVE_POSIX_DECLS
extern int getopt(int argc, char * const argv[],
const char * options);
extern int link(const char * fromname, const char * toname);
extern char * optarg;
extern int optind;
+#endif
#if ! HAVE_LINK
-# define link(from, to) (-1)
+# define link(from, to) (errno = ENOTSUP, -1)
#endif
#if ! HAVE_SYMLINK
-# define symlink(from, to) (-1)
+# define symlink(from, to) (errno = ENOTSUP, -1)
#endif
static void addtt(zic_t starttime, int type);
-static int addtype(zic_t, char * const, bool, bool, bool);
+static int addtype(zic_t, char const *, bool, bool, bool);
static void leapadd(zic_t, bool, int, int);
static void adjleap(void);
static void associate(void);
@@ -125,15 +134,14 @@ static void inlink(char ** fields, int n
static void inrule(char ** fields, int nfields);
static bool inzcont(char ** fields, int nfields);
static bool inzone(char ** fields, int nfields);
-static bool inzsub(char ** fields, int nfields, int iscont);
+static bool inzsub(char **, int, int);
static int itsdir(const char * name);
static bool is_alpha(char a);
static char lowerit(char);
-static bool mkdirs(char * filename);
+static bool mkdirs(char *);
static void newabbr(const char * abbr);
static zic_t oadd(zic_t t1, zic_t t2);
static void outzone(const struct zone * zp, int ntzones);
-static int rcomp(const void * leftp, const void * rightp);
static zic_t rpytime(const struct rule * rp, zic_t wantedy);
static void rulesub(struct rule * rp,
const char * loyearp, const char * hiyearp,
@@ -141,8 +149,6 @@ static void rulesub(struct rule * rp,
const char * dayp, const char * timep);
static zic_t tadd(zic_t t1, zic_t t2);
static bool yearistype(int year, const char * type);
-static int atcomp(const void *avp, const void *bvp);
-static void updateminmax(zic_t x);
/* Bound on length of what %z can expand to. */
enum { PERCENT_Z_LEN_BOUND = sizeof "+995959" - 1 };
@@ -525,31 +531,31 @@ static const char * leapsec;
static const char * yitcommand;
int
-main(int argc, char *argv[])
+main(int argc, char **argv)
{
int i;
int j;
int c;
#ifdef S_IWGRP
- (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
+ umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
#endif
-#if HAVE_GETTEXT - 0
- (void) setlocale(LC_MESSAGES, "");
+#if HAVE_GETTEXT
+ setlocale(LC_MESSAGES, "");
#ifdef TZ_DOMAINDIR
- (void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
+ bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined TEXTDOMAINDIR */
- (void) textdomain(TZ_DOMAIN);
+ textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
progname = argv[0];
if (TYPE_BIT(zic_t) < 64) {
- (void) fprintf(stderr, "%s: %s\n", progname,
+ fprintf(stderr, "%s: %s\n", progname,
_("wild compilation-time specification of zic_t"));
return EXIT_FAILURE;
}
for (i = 1; i < argc; ++i)
if (strcmp(argv[i], "--version") == 0) {
- (void) printf("zic %s%s\n", PKGVERSION, TZVERSION);
+ printf("zic %s%s\n", PKGVERSION, TZVERSION);
close_file(stdout, NULL);
return EXIT_SUCCESS;
} else if (strcmp(argv[i], "--help") == 0) {
@@ -771,41 +777,47 @@ dolink(char const *fromfield, char const
progname, fromname, e);
exit(EXIT_FAILURE);
}
- if (itsdir(toname) <= 0)
- remove(toname);
if (link(fromname, toname) != 0) {
- int result;
+ int link_errno = errno;
+ bool retry_if_link_supported = false;
- if (! mkdirs(toname))
- exit(EXIT_FAILURE);
-
- result = link(fromname, toname);
- if (result != 0) {
- const char *s = fromfield;
- const char *t;
- char *p;
- size_t dotdots = 0;
- char * symlinkcontents = NULL;
-
- do
- t = s;
- while ((s = strchr(s, '/'))
- && ! strncmp (fromfield, tofield,
- ++s - fromfield));
-
- for (s = tofield + (t - fromfield); *s; s++)
- dotdots += *s == '/';
- symlinkcontents
- = zic_malloc(3 * dotdots + strlen(t) + 1);
- for (p = symlinkcontents; dotdots-- != 0; p += 3)
- memcpy(p, "../", 3);
- strcpy(p, t);
- result = symlink(symlinkcontents, toname);
- if (result == 0)
- warning(_("hard link failed, symbolic link used"));
- free(symlinkcontents);
- }
- if (result != 0) {
+ if (link_errno == ENOENT || link_errno == ENOTSUP) {
+ if (! mkdirs(toname))
+ exit(EXIT_FAILURE);
+ retry_if_link_supported = true;
+ }
+ if ((link_errno == EEXIST || link_errno == ENOTSUP)
+ && itsdir(toname) == 0
+ && (remove(toname) == 0 || errno == ENOENT))
+ retry_if_link_supported = true;
+ if (retry_if_link_supported && link_errno != ENOTSUP)
+ link_errno = link(fromname, toname) == 0 ? 0 : errno;
+ if (link_errno != 0) {
+ const char *s = fromfield;
+ const char *t;
+ char *p;
+ size_t dotdots = 0;
+ char *symlinkcontents;
+ int symlink_result;
+
+ do
+ t = s;
+ while ((s = strchr(s, '/'))
+ && strncmp(fromfield, tofield, ++s - fromfield) == 0);
+
+ for (s = tofield + (t - fromfield); *s; s++)
+ dotdots += *s == '/';
+ symlinkcontents = zic_malloc(3 * dotdots + strlen(t) + 1);
+ for (p = symlinkcontents; dotdots-- != 0; p += 3)
+ memcpy(p, "../", 3);
+ strcpy(p, t);
+ symlink_result = symlink(symlinkcontents, toname);
+ free(symlinkcontents);
+ if (symlink_result == 0) {
+ if (link_errno != ENOTSUP)
+ warning(_("symbolic link used because hard link failed: %s"),
+ strerror (link_errno));
+ } else {
FILE *fp, *tp;
int c;
fp = fopen(fromname, "rb");
@@ -828,8 +840,11 @@ dolink(char const *fromfield, char const
putc(c, tp);
close_file(fp, fromname);
close_file(tp, toname);
- warning(_("link failed, copy used"));
- }
+ if (link_errno != ENOTSUP)
+ warning(_("copy used because hard link failed: %s"),
+ strerror (link_errno));
+ }
+ }
}
free(fromname);
free(toname);
@@ -876,18 +891,17 @@ itsdir(char const *name)
{
struct stat st;
int res = stat(name, &st);
- if (res != 0)
- return res;
#ifdef S_ISDIR
- return S_ISDIR(st.st_mode) != 0;
-#else
- {
+ if (res == 0)
+ return S_ISDIR(st.st_mode) != 0;
+#endif
+ if (res == 0 || errno == EOVERFLOW) {
char *nameslashdot = relname(name, ".");
- res = stat(nameslashdot, &st);
+ bool dir = stat(nameslashdot, &st) == 0 || errno == EOVERFLOW;
free(nameslashdot);
- return res == 0;
+ return dir;
}
-#endif
+ return -1;
}
/*
@@ -914,7 +928,7 @@ associate(void)
int i, j;
if (nrules != 0) {
- (void) qsort(rules, (size_t)nrules, sizeof *rules, rcomp);
+ qsort(rules, (size_t)nrules, sizeof *rules, rcomp);
for (i = 0; i < nrules - 1; ++i) {
if (strcmp(rules[i].r_name,
rules[i + 1].r_name) != 0)
@@ -1184,7 +1198,7 @@ inzcont(char **fields, int nfields)
}
static bool
-inzsub(char **const fields, const int nfields, const int iscont)
+inzsub(char **fields, int nfields, const int iscont)
{
char * cp;
char * cp1;
@@ -1377,7 +1391,7 @@ inleap(char **fields, int nfields)
}
static void
-inlink(char **const fields, const int nfields)
+inlink(char **fields, int nfields)
{
struct link l;
@@ -1574,7 +1588,7 @@ puttzcode(const zic_t val, FILE *const f
char buf[4];
convert(val, buf);
- (void) fwrite(buf, sizeof buf, (size_t) 1, fp);
+ fwrite(buf, sizeof buf, (size_t) 1, fp);
}
static void
@@ -1583,7 +1597,7 @@ puttzcode64(const zic_t val, FILE *const
char buf[8];
convert64(val, buf);
- (void) fwrite(buf, sizeof buf, (size_t) 1, fp);
+ fwrite(buf, sizeof buf, (size_t) 1, fp);
}
static int
@@ -1620,8 +1634,7 @@ writezone(const char *const name, const
** Sort.
*/
if (timecnt > 1)
- (void) qsort(attypes, (size_t) timecnt, sizeof *attypes,
- atcomp);
+ qsort(attypes, (size_t) timecnt, sizeof *attypes, atcomp);
/*
** Optimize.
*/
@@ -1699,10 +1712,10 @@ writezone(const char *const name, const
/*
** Remove old file, if any, to snap links.
*/
- if (itsdir(fullname) <= 0 && remove(fullname) != 0 && errno != ENOENT) {
+ if (itsdir(fullname) == 0 && remove(fullname) != 0 && errno != ENOENT) {
const char *e = strerror(errno);
- (void) fprintf(stderr, _("%s: Can't remove %s: %s\n"),
+ fprintf(stderr, _("%s: Can't remove %s: %s\n"),
progname, fullname, e);
exit(EXIT_FAILURE);
}
@@ -1712,7 +1725,7 @@ writezone(const char *const name, const
if ((fp = fopen(fullname, "wb")) == NULL) {
const char *e = strerror(errno);
- (void) fprintf(stderr, _("%s: Can't create %s: %s\n"),
+ fprintf(stderr, _("%s: Can't create %s: %s\n"),
progname, fullname, e);
exit(EXIT_FAILURE);
}
@@ -1828,16 +1841,15 @@ writezone(const char *const name, const
if (strcmp(&thischars[j], thisabbr) == 0)
break;
if (j == thischarcnt) {
- (void) strcpy(&thischars[(int) thischarcnt],
+ strcpy(&thischars[(int) thischarcnt],
thisabbr);
thischarcnt += strlen(thisabbr) + 1;
}
indmap[abbrinds[i]] = j;
}
-#define DO(field) (void) fwrite(tzh.field, \
- sizeof tzh.field, (size_t) 1, fp)
+#define DO(field) fwrite(tzh.field, sizeof tzh.field, (size_t) 1, fp)
tzh = tzh0;
- (void) strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic);
+ strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic);
tzh.tzh_version[0] = version;
convert(thistypecnt, tzh.tzh_ttisgmtcnt);
convert(thistypecnt, tzh.tzh_ttisstdcnt);
@@ -1868,16 +1880,16 @@ writezone(const char *const name, const
unsigned char uc;
uc = typemap[types[i]];
- (void) fwrite(&uc, sizeof uc, (size_t) 1, fp);
+ fwrite(&uc, sizeof uc, (size_t) 1, fp);
}
for (i = 0; i < typecnt; ++i)
if (writetype[i]) {
puttzcode(gmtoffs[i], fp);
- (void) putc(isdsts[i], fp);
- (void) putc((unsigned char) indmap[abbrinds[i]], fp);
+ putc(isdsts[i], fp);
+ putc((unsigned char) indmap[abbrinds[i]], fp);
}
if (thischarcnt != 0)
- (void) fwrite(thischars, sizeof thischars[0],
+ fwrite(thischars, sizeof thischars[0],
(size_t) thischarcnt, fp);
for (i = thisleapi; i < thisleaplim; ++i) {
zic_t todo;
@@ -1906,12 +1918,12 @@ writezone(const char *const name, const
}
for (i = 0; i < typecnt; ++i)
if (writetype[i])
- (void) putc(ttisstds[i], fp);
+ putc(ttisstds[i], fp);
for (i = 0; i < typecnt; ++i)
if (writetype[i])
- (void) putc(ttisgmts[i], fp);
+ putc(ttisgmts[i], fp);
}
- (void) fprintf(fp, "\n%s\n", string);
+ fprintf(fp, "\n%s\n", string);
close_file(fp, fullname);
free(ats);
free(fullname);
@@ -1966,14 +1978,14 @@ doabbr(char *abbr, int abbrlen, struct z
if (slashp == NULL) {
char letterbuf[PERCENT_Z_LEN_BOUND + 1];
if (zp->z_format_specifier == 'z')
- letters = abbroffset(letterbuf, -zp->z_gmtoff + stdoff);
+ letters = abbroffset(letterbuf, zp->z_gmtoff + stdoff);
else if (!letters)
letters = "%s";
- (void) snprintf(abbr, abbrlen, format, letters);
+ snprintf(abbr, abbrlen, format, letters);
} else if (stdoff != 0) {
- (void) strlcpy(abbr, slashp + 1, abbrlen);
+ strlcpy(abbr, slashp + 1, abbrlen);
} else {
- (void) memcpy(abbr, format, slashp - format);
+ memcpy(abbr, format, slashp - format);
abbr[slashp - format] = '\0';
}
len = strlen(abbr);
@@ -2502,7 +2514,7 @@ outzone(const struct zone *zpfirst, int
zp->z_format != NULL &&
strchr(zp->z_format, '%') == NULL &&
strchr(zp->z_format, '/') == NULL)
- (void)strncpy(startbuf, zp->z_format,
+ strncpy(startbuf, zp->z_format,
max_abbr_len + 1 - 1);
eat(zp->z_filename, zp->z_linenum);
if (*startbuf == '\0')
@@ -2594,7 +2606,7 @@ addtt(zic_t starttime, int type)
}
static int
-addtype(zic_t gmtoff, char *const abbr, bool isdst, bool ttisstd, bool ttisgmt)
+addtype(zic_t gmtoff, char const *abbr, bool isdst, bool ttisstd, bool ttisgmt)
{
int i, j;
@@ -2690,7 +2702,7 @@ yearistype(int year, const char *type)
if (type == NULL || *type == '\0')
return true;
buf = zic_realloc(buf, 132 + strlen(yitcommand) + strlen(type));
- (void)sprintf(buf, "%s %d %s", yitcommand, year, type); /* XXX: sprintf is safe */
+ sprintf(buf, "%s %d %s", yitcommand, year, type); /* XXX: sprintf is safe */
result = system(buf);
if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
case 0:
@@ -2699,7 +2711,7 @@ yearistype(int year, const char *type)
return false;
}
error(_("Wild result from command execution"));
- (void) fprintf(stderr, _("%s: command was '%s', result was %d\n"),
+ fprintf(stderr, _("%s: command was '%s', result was %d\n"),
progname, buf, result);
for ( ; ; )
exit(EXIT_FAILURE);
@@ -2992,7 +3004,7 @@ mp = _("time zone abbreviation differs f
error(_("too many, or too long, time zone abbreviations"));
exit(EXIT_FAILURE);
}
- (void)strncpy(&chars[charcnt], string, sizeof(chars) - charcnt - 1);
+ strncpy(&chars[charcnt], string, sizeof(chars) - charcnt - 1);
charcnt += i;
}
Added files:
Index: src/lib/libc/time/CONTRIBUTING
diff -u /dev/null src/lib/libc/time/CONTRIBUTING:1.1
--- /dev/null Tue Mar 15 11:16:01 2016
+++ src/lib/libc/time/CONTRIBUTING Tue Mar 15 11:16:01 2016
@@ -0,0 +1,69 @@
+Contributing to the tz code and data
+
+The time zone database is by no means authoritative: governments
+change timekeeping rules erratically and sometimes with little
+warning, the data entries do not cover all of civil time before
+1970, and undoubtedly errors remain in the code and data. Feel
+free to fill gaps or fix mistakes, and please email improvements
+to [email protected] for use in the future.
+
+To email small changes, please run a POSIX shell command like
+'diff -u old/europe new/europe >myfix.patch', and attach
+myfix.patch to the email.
+
+For more-elaborate changes, please read the Theory file and browse
+the mailing list archives <http://mm.icann.org/pipermail/tz/> for
+examples of patches that tend to work well. Ideally, additions to
+data should contain commentary citing reliable sources as
+justification.
+
+Please submit changes against either the latest release in
+<ftp://ftp.iana.org/tz/> or the master branch of the experimental
+Git repository. If you use Git the following workflow may be helpful:
+
+ * Copy the experimental repository.
+
+ git clone https://github.com/eggert/tz.git
+ cd tz
+
+ * Get current with the master branch.
+
+ git checkout master
+ git pull
+
+ * Switch to a new branch for the changes. Choose a different
+ branch name for each change set.
+
+ git checkout -b mybranch
+
+ * Edit source files. Include commentary that justifies the
+ changes by citing reliable sources.
+
+ * Debug the changes, e.g.:
+
+ make check
+ make install
+ ./zdump -v America/Los_Angeles
+
+ * For each separable change, commit it in the new branch, e.g.:
+
+ git add northamerica
+ git commit
+
+ See recent 'git log' output for the commit-message style.
+
+ * Create patch files 0001-*, 0002-*, ...
+
+ git format-patch master
+
+ * After reviewing the patch files, send the patches to [email protected]
+ for others to review.
+
+ git send-email master
+
+ * Start anew by getting current with the master branch again
+ (the second step above).
+
+Please do not create issues or pull requests on GitHub, as the
+proper procedure for proposing and distributing patches is via
+email as illustrated above.