summaryrefslogtreecommitdiffstats
path: root/usr.sbin/zic
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/zic')
-rw-r--r--usr.sbin/zic/Makefile366
-rw-r--r--usr.sbin/zic/Makefile.inc3
-rw-r--r--usr.sbin/zic/ialloc.c14
-rw-r--r--usr.sbin/zic/scheck.c12
-rw-r--r--usr.sbin/zic/zdump.855
-rw-r--r--usr.sbin/zic/zdump.c81
-rw-r--r--usr.sbin/zic/zdump/Makefile13
-rw-r--r--usr.sbin/zic/zic.8316
-rw-r--r--usr.sbin/zic/zic.c289
-rw-r--r--usr.sbin/zic/zic/Makefile14
10 files changed, 359 insertions, 804 deletions
diff --git a/usr.sbin/zic/Makefile b/usr.sbin/zic/Makefile
index 0aefc95..963a0ee 100644
--- a/usr.sbin/zic/Makefile
+++ b/usr.sbin/zic/Makefile
@@ -1,365 +1,5 @@
-# @(#)Makefile 7.67
+# $Id$
+SUBDIR= zic zdump
-# Change the line below for your time zone (after finding the zone you want in
-# the time zone files, or adding it to a time zone file).
-# Alternately, if you discover you've got the wrong time zone, you can just
-# zic -l rightzone
-# to correct things.
-# Use the command
-# make zonenames
-# to get a list of the values you can use for LOCALTIME.
+.include <bsd.subdir.mk>
-LOCALTIME= Factory
-
-# If you want something other than Eastern United States time as a template
-# for handling POSIX-style time zone environment variables,
-# change the line below (after finding the zone you want in the
-# time zone files, or adding it to a time zone file).
-# (When a POSIX-style environment variable is handled, the rules in the
-# template file are used to determine "spring forward" and "fall back" days and
-# times; the environment variable itself specifies UTC offsets of standard and
-# summer time.)
-# Alternately, if you discover you've got the wrong time zone, you can just
-# zic -p rightzone
-# to correct things.
-# Use the command
-# make zonenames
-# to get a list of the values you can use for POSIXRULES.
-# If you want POSIX compatibility, use "America/New_York".
-
-POSIXRULES= America/New_York
-
-# Everything gets put in subdirectories of. . .
-
-TOPDIR= /usr/local
-
-# "Compiled" time zone information is placed in the "TZDIR" directory
-# (and subdirectories).
-# Use an absolute path name for TZDIR unless you're just testing the software.
-
-TZDIR= $(TOPDIR)/etc/zoneinfo
-
-# The "zic" and "zdump" commands get installed in. . .
-
-ETCDIR= $(TOPDIR)/etc
-
-# If you "make INSTALL", the "date" command gets installed in. . .
-
-BINDIR= $(TOPDIR)/bin
-
-# Manual pages go in subdirectories of. . .
-
-MANDIR= $(TOPDIR)/man
-
-# Library functions are put in an archive in LIBDIR.
-
-LIBDIR= $(TOPDIR)/lib
-TZLIB= $(LIBDIR)/libtz.a
-
-# If you always want time values interpreted as "seconds since the epoch
-# (not counting leap seconds)", use
-# REDO= posix_only
-# below. If you always want right time values interpreted as "seconds since
-# the epoch" (counting leap seconds)", use
-# REDO= right_only
-# below. If you want both sets of data available, with leap seconds not
-# counted normally, use
-# REDO= posix_right
-# below. If you want both sets of data available, with leap seconds counted
-# normally, use
-# REDO= right_posix
-# below.
-# POSIX mandates that leap seconds not be counted; for compatibility with it,
-# use either "posix_only" or "posix_right".
-
-REDO= posix_right
-
-# Since "." may not be in PATH...
-
-YEARISTYPE= ./yearistype
-
-# Non-default libraries needed to link.
-# Add -lintl if you want to use `gettext' on Solaris.
-LDLIBS=
-
-# Add the following to the end of the "CFLAGS=" line as needed.
-# -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?)
-# -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS
-# -DHAVE_LONG_DOUBLE=1 if your compiler supports the `long double' type
-# -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
-# -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
-# -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
-# -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD)
-# -DHAVE_STRERROR=1 if `strerror' works
-# -DHAVE_SYMLINK=0 if your system lacks the symlink function
-# -DLOCALE_HOME=\"path\" if locales are in "path", not "/usr/lib/locale"
-# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
-# -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
-# -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
-# -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
-# the default is system-supplied, typically "/usr/lib/locale"
-# $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
-# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
-# if you do not want run time warnings about formats that may cause
-# year 2000 grief
-#
-GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
- -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
- -Wnested-externs -Wpointer-arith -Wshadow \
- -Wtraditional # -Wstrict-prototypes -Wwrite-strings
-#
-# If you want to use System V compatibility code, add
-# -DUSG_COMPAT
-# to the end of the "CFLAGS=" line. This arrange for "timezone" and "daylight"
-# variables to be kept up-to-date by the time conversion functions. Neither
-# "timezone" nor "daylight" is described in X3J11's work.
-#
-# If your system has a "GMT offset" field in its "struct tm"s
-# (or if you decide to add such a field in your system's "time.h" file),
-# add the name to a define such as
-# -DTM_GMTOFF=tm_gmtoff
-# or
-# -DTM_GMTOFF=_tm_gmtoff
-# to the end of the "CFLAGS=" line.
-# Neither tm_gmtoff nor _tm_gmtoff is described in X3J11's work;
-# in its work, use of "tm_gmtoff" is described as non-conforming.
-# Both Linux and BSD have done the equivalent of defining TM_GMTOFF in
-# their recent releases.
-#
-# If your system has a "zone abbreviation" field in its "struct tm"s
-# (or if you decide to add such a field in your system's "time.h" file),
-# add the name to a define such as
-# -DTM_ZONE=tm_zone
-# or
-# -DTM_ZONE=_tm_zone
-# to the end of the "CFLAGS=" line.
-# Neither tm_zone nor _tm_zone is described in X3J11's work;
-# in its work, use of "tm_zone" is described as non-conforming.
-# Both UCB and Sun have done the equivalent of defining TM_ZONE in
-# their recent releases.
-#
-# If you want functions that were inspired by early versions of X3J11's work,
-# add
-# -DSTD_INSPIRED
-# to the end of the "CFLAGS=" line. This arranges for the functions
-# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
-# "posix2time", and "time2posix" to be added to the time conversion library.
-# "tzsetwall" is like "tzset" except that it arranges for local wall clock
-# time (rather than the time specified in the TZ environment variable)
-# to be used.
-# "offtime" is like "gmtime" except that it accepts a second (long) argument
-# that gives an offset to add to the time_t when converting it.
-# "timelocal" is equivalent to "mktime".
-# "timegm" is like "timelocal" except that it turns a struct tm into
-# a time_t using UTC (rather than local time as "timelocal" does).
-# "timeoff" is like "timegm" except that it accepts a second (long) argument
-# that gives an offset to use when converting to a time_t.
-# "posix2time" and "time2posix" are described in an included manual page.
-# None of these functions are described in X3J11's current work.
-# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
-# These functions may well disappear in future releases of the time
-# conversion package.
-#
-# If you want Source Code Control System ID's left out of object modules, add
-# -DNOID
-# to the end of the "CFLAGS=" line.
-#
-# If you'll never want to handle solar-time-based time zones, add
-# -DNOSOLAR
-# to the end of the "CFLAGS=" line
-# (and comment out the "SDATA=" line below).
-# This reduces (slightly) the run-time data-space requirements of
-# the time conversion functions; it may reduce the acceptability of your system
-# to folks in oil- and cash-rich places.
-#
-# If you want to allocate state structures in localtime, add
-# -DALL_STATE
-# to the end of the "CFLAGS=" line. Storage is obtained by calling malloc.
-#
-# If you want an "altzone" variable (a la System V Release 3.1), add
-# -DALTZONE
-# to the end of the "CFLAGS=" line.
-# This variable is not described in X3J11's work.
-#
-# If you want a "gtime" function (a la MACH), add
-# -DCMUCS
-# to the end of the "CFLAGS=" line
-# This function is not described in X3J11's work.
-#
-# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
-# out by the National Institute of Standards and Technology
-# which claims to test C and Posix conformance. If you want to pass PCTS, add
-# -DPCTS
-# to the end of the "CFLAGS=" line.
-#
-# If you want strict compliance with XPG4 as of 1994-04-09, add
-# -DXPG4_1994_04_09
-# to the end of the "CFLAGS=" line. This causes "strftime" to always return
-# 53 as a week number (rather than 52 or 53) for those days in January that
-# before the first Monday in January when a "%V" format is used and January 1
-# falls on a Friday, Saturday, or Sunday.
-
-CFLAGS=
-
-# If you want zic's -s option used when installing, uncomment the next line
-# ZFLAGS= -s
-
-zic= ./zic
-ZIC= $(zic) $(ZFLAGS)
-
-# The name of a Posix-compliant `awk' on your system.
-AWK= awk
-
-###############################################################################
-
-cc= cc
-CC= $(cc) -DTZDIR=\"$(TZDIR)\"
-
-TZCSRCS= zic.c localtime.c asctime.c scheck.c ialloc.c
-TZCOBJS= zic.o localtime.o asctime.o scheck.o ialloc.o
-TZDSRCS= zdump.c localtime.c asctime.c ialloc.c
-TZDOBJS= zdump.o localtime.o asctime.o ialloc.o
-DATESRCS= date.c localtime.c logwtmp.c strftime.c asctime.c
-DATEOBJS= date.o localtime.o logwtmp.o strftime.o asctime.o
-LIBSRCS= localtime.c asctime.c difftime.c
-LIBOBJS= localtime.o asctime.o difftime.o
-HEADERS= tzfile.h private.h
-NONLIBSRCS= zic.c zdump.c scheck.c ialloc.c
-NEWUCBSRCS= date.c logwtmp.c strftime.c
-SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
-MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
- tzfile.5 tzselect.8 zic.8 zdump.8
-DOCS= README Theory $(MANS) date.1 Makefile
-PRIMARY_YDATA= africa antarctica asia australasia \
- europe northamerica southamerica
-YDATA= $(PRIMARY_YDATA) pacificnew etcetera factory backward
-NDATA= systemv
-SDATA= solar87 solar88 solar89
-TDATA= $(YDATA) $(NDATA) $(SDATA)
-TABDATA= iso3166.tab zone.tab
-DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
-MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
- Arts.htm WWW.htm gccdiffs checktab.awk
-ENCHILADA= $(DOCS) $(SOURCES) $(DATA) $(MISC)
-
-# And for the benefit of csh users on systems that assume the user
-# shell should be used to handle commands in Makefiles. . .
-
-SHELL= /bin/sh
-
-all: zic zdump $(LIBOBJS)
-
-ALL: all date tzselect
-
-install: all $(DATA) $(REDO) $(TZLIB) $(MANS) $(TABDATA)
- $(ZIC) -y $(YEARISTYPE) \
- -d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
- -rm -f $(TZDIR)/iso3166.tab $(TZDIR)/zone.tab
- cp iso3166.tab zone.tab $(TZDIR)/.
- -mkdir $(TOPDIR) $(ETCDIR)
- cp zic zdump $(ETCDIR)/.
- -mkdir $(TOPDIR) $(MANDIR) \
- $(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
- -rm -f $(MANDIR)/man3/newctime.3 \
- $(MANDIR)/man3/newtzset.3 \
- $(MANDIR)/man5/tzfile.5 \
- $(MANDIR)/man8/tzselect.8 \
- $(MANDIR)/man8/zdump.8 \
- $(MANDIR)/man8/zic.8
- cp newctime.3 newtzset.3 $(MANDIR)/man3/.
- cp tzfile.5 $(MANDIR)/man5/.
- cp tzselect.8 zdump.8 zic.8 $(MANDIR)/man8/.
-
-INSTALL: ALL install date.1
- -mkdir $(TOPDIR) $(BINDIR)
- cp date $(BINDIR)/.
- -mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
- -rm -f $(MANDIR)/man1/date.1
- cp date.1 $(MANDIR)/man1/.
-
-zdump: $(TZDOBJS)
- $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) $(LDLIBS) -o $@
-
-zic: $(TZCOBJS) yearistype
- $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) $(LDLIBS) -o $@
-
-yearistype: yearistype.sh
- cp yearistype.sh yearistype
- chmod +x yearistype
-
-posix_only: zic $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L /dev/null $(TDATA)
-
-right_only: zic leapseconds $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L leapseconds $(TDATA)
-
-# In earlier versions of this makefile, the other two directories were
-# subdirectories of $(TZDIR). However, this led to configuration errors.
-# For example, with posix_right under the earlier scheme,
-# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
-# but gmtime without leap seconds, which led to problems with applications
-# like sendmail that subtract gmtime from localtime.
-# 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.
-other_two: zic leapseconds $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(TZDIR)-posix -L /dev/null $(TDATA)
- $(ZIC) -y $(YEARISTYPE) \
- -d $(TZDIR)-leaps -L leapseconds $(TDATA)
-
-posix_right: posix_only other_two
-
-right_posix: right_only other_two
-
-zones: $(REDO)
-
-$(TZLIB): $(LIBOBJS)
- -mkdir $(TOPDIR) $(LIBDIR)
- ar ru $@ $(LIBOBJS)
- if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
- then ranlib $@ ; fi
-
-# We use the system's logwtmp in preference to ours if available.
-
-date: $(DATEOBJS)
- ar r ,lib.a logwtmp.o
- if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
- then ranlib ,lib.a ; fi
- $(CC) $(CFLAGS) date.o localtime.o asctime.o strftime.o \
- $(LDLIBS) -lc ,lib.a -o $@
- rm -f ,lib.a
-
-tzselect: tzselect.ksh
- sed \
- -e 's|AWK=[^}]*|AWK=$(AWK)|g' \
- -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
- <$? >$@
- chmod +x $@
-
-check_tables: checktab.awk $(PRIMARY_YDATA)
- $(AWK) -f checktab.awk $(PRIMARY_YDATA)
-
-clean:
- rm -f core *.o *.out tzselect zdump zic yearistype date \
- ,* *.tar.gz
-
-names:
- @echo $(ENCHILADA)
-
-public: $(ENCHILADA)
- tar cf - $(DOCS) $(SOURCES) $(MISC) | gzip -9 > tzcode.tar.gz
- tar cf - $(DATA) | gzip -9 > tzdata.tar.gz
-
-zonenames: $(TDATA)
- @awk '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
-
-asctime.o: private.h tzfile.h
-date.o: private.h
-difftime.o: private.h
-ialloc.o: private.h
-localtime.o: private.h tzfile.h
-scheck.o: private.h
-strftime.o: tzfile.h
-zic.o: private.h tzfile.h
-
-.KEEP_STATE:
diff --git a/usr.sbin/zic/Makefile.inc b/usr.sbin/zic/Makefile.inc
new file mode 100644
index 0000000..c961f85
--- /dev/null
+++ b/usr.sbin/zic/Makefile.inc
@@ -0,0 +1,3 @@
+# $Id$
+
+.include "${.CURDIR}/../../Makefile.inc"
diff --git a/usr.sbin/zic/ialloc.c b/usr.sbin/zic/ialloc.c
index 8a0c701..2fd76c3 100644
--- a/usr.sbin/zic/ialloc.c
+++ b/usr.sbin/zic/ialloc.c
@@ -1,15 +1,27 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)ialloc.c 8.29";
+static char elsieid[] = "@(#)ialloc.c 8.28";
#endif /* !defined NOID */
#endif /* !defined lint */
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
/*LINTLIBRARY*/
#include "private.h"
#define nonzero(n) (((n) == 0) ? 1 : (n))
+char * icalloc P((int nelem, int elsize));
+char * icatalloc P((char * old, const char * new));
+char * icpyalloc P((const char * string));
+char * imalloc P((int n));
+void * irealloc P((void * pointer, int size));
+void ifree P((char * pointer));
+
char *
imalloc(n)
const int n;
diff --git a/usr.sbin/zic/scheck.c b/usr.sbin/zic/scheck.c
index 39feeba..313068d 100644
--- a/usr.sbin/zic/scheck.c
+++ b/usr.sbin/zic/scheck.c
@@ -1,17 +1,25 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)scheck.c 8.15";
+static char elsieid[] = "@(#)scheck.c 8.13";
#endif /* !defined lint */
#endif /* !defined NOID */
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
/*LINTLIBRARY*/
#include "private.h"
+extern char * imalloc P((int n));
+extern void ifree P((char * p));
+
char *
scheck(string, format)
const char * const string;
-const char * const format;
+char * const format;
{
register char * fbuf;
register const char * fp;
diff --git a/usr.sbin/zic/zdump.8 b/usr.sbin/zic/zdump.8
index 3323129..f9f4f95 100644
--- a/usr.sbin/zic/zdump.8
+++ b/usr.sbin/zic/zdump.8
@@ -1,24 +1,29 @@
-.TH ZDUMP 8
-.SH NAME
-zdump \- time zone dumper
-.SH SYNOPSIS
-.B zdump
-[
-.B \-v
-] [
-.B \-c
-cutoffyear ] [ zonename ... ]
-.SH DESCRIPTION
-.I Zdump
+.\"
+.\" @(#)zdump.8 7.3
+.\" $Id$
+.\"
+.Dd September 13, 1994
+.Dt ZDUMP 8
+.Os
+.Sh NAME
+.Nm zdump
+.Nd timezone dumper
+.Sh SYNOPSIS
+.Nm zdump
+.Op Fl v
+.Op Fl c Ar cutoffyear
+.Op Ar zonename ...
+.Sh DESCRIPTION
+.Nm Zdump
prints the current time in each
-.I zonename
+.Ar zonename
named on the command line.
-.PP
-These options are available:
-.TP
-.B \-v
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl v
For each
-.I zonename
+.Ar zonename
on the command line,
print the time at the lowest possible time value,
the time one day after the lowest possible time value,
@@ -27,13 +32,13 @@ each detected time discontinuity,
the time at one day less than the highest possible time value,
and the time at the highest possible time value,
Each line ends with
-.B isdst=1
+.Em isdst=1
if the given time is Daylight Saving Time or
-.B isdst=0
+.Em isdst=0
otherwise.
-.TP
-.BI "\-c " cutoffyear
+.It Fl c Ar cutoffyear
Cut off the verbose output near the start of the given year.
-.SH "SEE ALSO"
-newctime(3), tzfile(5), zic(8)
-.\" @(#)zdump.8 7.3
+.Sh "SEE ALSO"
+.Xr ctime 3 ,
+.Xr tzfile 5 ,
+.Xr zic 8
diff --git a/usr.sbin/zic/zdump.c b/usr.sbin/zic/zdump.c
index 094e172..096f862 100644
--- a/usr.sbin/zic/zdump.c
+++ b/usr.sbin/zic/zdump.c
@@ -1,20 +1,27 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)zdump.c 7.28";
+static char elsieid[] = "@(#)zdump.c 7.24";
#endif /* !defined NOID */
#endif /* !defined lint */
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
/*
** This code has been made independent of the rest of the time
** conversion package to increase confidence in the verification it provides.
** You can use this code to help in verifying other implementations.
*/
-#include "stdio.h" /* for stdout, stderr, perror */
-#include "string.h" /* for strcpy */
-#include "sys/types.h" /* for time_t */
-#include "time.h" /* for struct tm */
-#include "stdlib.h" /* for exit, malloc, atoi */
+#include <err.h>
+#include <stdio.h> /* for stdout, stderr */
+#include <stdlib.h> /* for exit, malloc, atoi */
+#include <string.h> /* for strcpy */
+#include <sys/types.h> /* for time_t */
+#include <time.h> /* for struct tm */
+#include <unistd.h>
#ifndef MAX_STRING_LENGTH
#define MAX_STRING_LENGTH 1024
@@ -111,28 +118,15 @@ static char elsieid[] = "@(#)zdump.c 7.28";
#define TZ_DOMAIN "tz"
#endif /* !defined TZ_DOMAIN */
-#ifndef P
-#ifdef __STDC__
-#define P(x) x
-#endif /* defined __STDC__ */
-#ifndef __STDC__
-#define P(x) ()
-#endif /* !defined __STDC__ */
-#endif /* !defined P */
-
extern char ** environ;
-extern int getopt P((int argc, char * const argv[],
- const char * options));
-extern char * optarg;
-extern int optind;
extern char * tzname[2];
-static char * abbr P((struct tm * tmp));
-static long delta P((struct tm * newp, struct tm * oldp));
-static time_t hunt P((char * name, time_t lot, time_t hit));
-static size_t longest;
-static char * progname;
-static void show P((char * zone, time_t t, int v));
+static char * abbr();
+static long delta();
+static time_t hunt();
+static int longest;
+static void show();
+static void usage __P((void));
int
main(argc, argv)
@@ -161,19 +155,15 @@ char * argv[];
#endif /* defined(TEXTDOMAINDIR) */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
- progname = argv[0];
vflag = 0;
cutoff = NULL;
while ((c = getopt(argc, argv, "c:v")) == 'c' || c == 'v')
if (c == 'v')
vflag = 1;
else cutoff = optarg;
- if ((c != EOF && c != -1) ||
+ if (c != EOF ||
(optind == argc - 1 && strcmp(argv[optind], "=") == 0)) {
- (void) fprintf(stderr,
-_("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"),
- argv[0], argv[0]);
- (void) exit(EXIT_FAILURE);
+ usage();
}
if (cutoff != NULL) {
int y;
@@ -200,10 +190,10 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"),
fakeenv = (char **) malloc((size_t) ((i + 2) *
sizeof *fakeenv));
if (fakeenv == NULL ||
- (fakeenv[0] = (char *) malloc(longest + 4)) == NULL) {
- (void) perror(progname);
- (void) exit(EXIT_FAILURE);
- }
+ (fakeenv[0] = (char *) malloc((size_t) (longest +
+ 4))) == NULL)
+ errx(EXIT_FAILURE,
+ _("malloc() failed"));
to = 0;
(void) strcpy(fakeenv[to++], "TZ=");
for (from = 0; environ[from] != NULL; ++from)
@@ -262,12 +252,8 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"),
t += SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
}
- if (fflush(stdout) || ferror(stdout)) {
- (void) fprintf(stderr, _("%s: Error writing "),
- argv[0]);
- (void) perror(_("standard output"));
- (void) exit(EXIT_FAILURE);
- }
+ if (fflush(stdout) || ferror(stdout))
+ errx(EXIT_FAILURE, _("error writing standard output"));
exit(EXIT_SUCCESS);
/* gcc -Wall pacifier */
@@ -275,6 +261,13 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"),
continue;
}
+static void
+usage()
+{
+ fprintf(stderr, _("usage: zdump [-v] [-c cutoff] zonename ...\n"));
+ exit(EXIT_FAILURE);
+}
+
static time_t
hunt(name, lot, hit)
char * name;
@@ -334,6 +327,8 @@ struct tm * oldp;
return result;
}
+extern struct tm * localtime();
+
static void
show(zone, t, v)
char * zone;
@@ -342,9 +337,9 @@ int v;
{
struct tm * tmp;
- (void) printf("%-*s ", (int) longest, zone);
+ (void) printf("%-*s ", longest, zone);
if (v)
- (void) printf("%.24s UTC = ", asctime(gmtime(&t)));
+ (void) printf("%.24s GMT = ", asctime(gmtime(&t)));
tmp = localtime(&t);
(void) printf("%.24s", asctime(tmp));
if (*abbr(tmp) != '\0')
diff --git a/usr.sbin/zic/zdump/Makefile b/usr.sbin/zic/zdump/Makefile
new file mode 100644
index 0000000..46af3ca
--- /dev/null
+++ b/usr.sbin/zic/zdump/Makefile
@@ -0,0 +1,13 @@
+# $Id$
+
+.PATH: ${.CURDIR}/..
+
+PROG= zdump
+
+SRCS= zdump.c ialloc.c scheck.c
+MAN8= ${.CURDIR}/../zdump.8
+CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../lib/libc/stdtime
+CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS
+CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/zic/zic.8 b/usr.sbin/zic/zic.8
index b99afca..5c2b5a1 100644
--- a/usr.sbin/zic/zic.8
+++ b/usr.sbin/zic/zic.8
@@ -1,93 +1,74 @@
-.TH ZIC 8
-.SH NAME
-zic \- time zone compiler
-.SH SYNOPSIS
-.B zic
-[
-.B \-v
-] [
-.B \-d
-.I directory
-] [
-.B \-l
-.I localtime
-] [
-.B \-p
-.I posixrules
-] [
-.B \-L
-.I leapsecondfilename
-] [
-.B \-s
-] [
-.B \-y
-.I command
-] [
-.I filename
-\&... ]
-.SH DESCRIPTION
-.if t .ds lq ``
-.if t .ds rq ''
-.if n .ds lq \&"\"
-.if n .ds rq \&"\"
-.de q
-\\$3\*(lq\\$1\*(rq\\$2
-..
-.I Zic
+.Dd
+.Dt ZIC 8
+.Os
+.Sh NAME
+.Nm zic
+.Nd timezone compiler
+.Sh SYNOPSIS
+.Nm zic
+.Op Fl v
+.Op Fl d Ar directory
+.Op Fl l Ar localtime
+.Op Fl p Ar posixrules
+.Op Fl L Ar leapsecondfilename
+.Op Fl s
+.Op Fl y Ar command
+.Op Ar filename ...
+.Sh DESCRIPTION
+.Nm Zic
reads text from the file(s) named on the command line
and creates the time conversion information files specified in this input.
If a
-.I filename
+.Ar filename
is
-.BR \- ,
+.Em - ,
the standard input is read.
-.PP
-These options are available:
-.TP
-.BI "\-d " directory
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl d Ar directory
Create time conversion information files in the named directory rather than
in the standard directory named below.
-.TP
-.BI "\-l " timezone
-Use the given time zone as local time.
-.I Zic
+.It Fl l Ar timezone
+Use the given
+.Ar time zone
+as local time.
+.Nm Zic
will act as if the input contained a link line of the form
.sp
.ti +.5i
Link \fItimezone\fP localtime
-.TP
-.BI "\-p " timezone
-Use the given time zone's rules when handling POSIX-format
+.It Fl p Ar timezone
+Use the given
+.Ar "time zone" Ns 's
+rules when handling POSIX-format
time zone environment variables.
-.I Zic
+.Nm Zic
will act as if the input contained a link line of the form
.sp
.ti +.5i
Link \fItimezone\fP posixrules
-.TP
-.BI "\-L " leapsecondfilename
+.It Fl L Ar leapsecondfilename
Read leap second information from the file with the given name.
If this option is not used,
no leap second information appears in output files.
-.TP
-.B \-v
+.It Fl v
Complain if a year that appears in a data file is outside the range
of years representable by
-.IR time (2)
+.Xr time 2
values.
-.TP
-.B \-s
+.It Fl s
Limit time values stored in output files to values that are the same
whether they're taken to be signed or unsigned.
You can use this option to generate SVVS-compatible files.
-.TP
-.BI "\-y " command
+.It Fl y Ar command
Use the given
-.I command
+.Ar command
rather than
-.B yearistype
+.Em yearistype
when checking year types (see below).
-.PP
+.El
+.Pp
Input lines are made up of fields.
Fields are separated from one another by any number of white space characters.
Leading and trailing white space on input lines is ignored.
@@ -98,7 +79,7 @@ White space characters and sharp characters may be enclosed in double quotes
Any line that is blank (after comment stripping) is ignored.
Non-blank lines are expected to be of one of three types:
rule lines, zone lines, and link lines.
-.PP
+.Pp
A rule line has the form
.nf
.ti +.5i
@@ -113,52 +94,49 @@ Rule US 1967 1973 \- Apr lastSun 2:00 1:00 D
.sp
.fi
The fields that make up a rule line are:
-.TP "\w'LETTER/S'u"
-.B NAME
-Gives the (arbitrary) name of the set of rules this rule is part of.
-.TP
-.B FROM
-Gives the first year in which the rule applies.
+.Bl -tag -width indent
+.It NAME
+Give the (arbitrary) name of the set of rules this rule is part of.
+.It FROM
+Give the first year in which the rule applies.
Any integer year can be supplied; the Gregorian calendar is assumed.
The word
-.B minimum
+.Em minimum
(or an abbreviation) means the minimum year representable as an integer.
The word
-.B maximum
+.Em maximum
(or an abbreviation) means the maximum year representable as an integer.
Rules can describe times that are not representable as time values,
with the unrepresentable times ignored; this allows rules to be portable
among hosts with differing time value types.
-.TP
-.B TO
-Gives the final year in which the rule applies.
+.It TO
+Give the final year in which the rule applies.
In addition to
-.B minimum
+.Em minimum
and
-.B maximum
+.Em maximum
(as above),
the word
-.B only
+.Em only
(or an abbreviation)
may be used to repeat the value of the
-.B FROM
+.Em FROM
field.
-.TP
-.B TYPE
-Gives the type of year in which the rule applies.
+.It TYPE
+Give the type of year in which the rule applies.
If
-.B TYPE
+.Em TYPE
is
-.B \-
+.Em \-
then the rule applies in all years between
-.B FROM
+.Em FROM
and
-.B TO
+.Em TO
inclusive.
If
-.B TYPE
+.Em TYPE
is something else, then
-.I zic
+.Nm
executes the command
.ti +.5i
\fByearistype\fP \fIyear\fP \fItype\fP
@@ -166,13 +144,11 @@ executes the command
to check the type of a year:
an exit status of zero is taken to mean that the year is of the given type;
an exit status of one is taken to mean that the year is not of the given type.
-.TP
-.B IN
-Names the month in which the rule takes effect.
+.It IN
+Name the month in which the rule takes effect.
Month names may be abbreviated.
-.TP
-.B ON
-Gives the day on which the rule takes effect.
+.It ON
+Give the day on which the rule takes effect.
Recognized forms include:
.nf
.in +.5i
@@ -188,11 +164,10 @@ Sun<=25 last Sunday on or before the 25th
.sp
Names of days of the week may be abbreviated or spelled out in full.
Note that there must be no spaces within the
-.B ON
+.Em ON
field.
-.TP
-.B AT
-Gives the time of day at which the rule takes effect.
+.It AT
+Give the time of day at which the rule takes effect.
Recognized forms include:
.nf
.in +.5i
@@ -205,54 +180,51 @@ Recognized forms include:
.fi
.in -.5i
.sp
-where hour 0 is midnight at the start of the day,
-and hour 24 is midnight at the end of the day.
Any of these forms may be followed by the letter
-.B w
+.Em w
if the given time is local
-.q "wall clock"
+.Dq "wall clock"
time,
-.B s
+.Em s
if the given time is local
-.q standard
+.Dq standard
time, or
-.B u
+.Em u
(or
-.B g
+.Em g
or
-.BR z )
+.Em z )
if the given time is universal time;
in the absence of an indicator,
wall clock time is assumed.
-.TP
-.B SAVE
-Gives the amount of time to be added to local standard time when the rule is in
+.It SAVE
+Give the amount of time to be added to local standard time when the rule is in
effect.
This field has the same format as the
-.B AT
+.Em AT
field
(although, of course, the
-.B w
+.Em w
and
-.B s
+.Em s
suffixes are not used).
-.TP
-.B LETTER/S
-Gives the
-.q "variable part"
+.It LETTER/S
+Give the
+.Dq "variable part"
(for example, the
-.q S
+.Dq S
or
-.q D
+.Dq D
in
-.q EST
+.Dq EST
or
-.q EDT )
+.Dq EDT )
of time zone abbreviations to be used when this rule is in effect.
If this field is
-.BR \- ,
+.Em \- ,
the variable part is null.
-.PP
+.El
+.Pp
A zone line has the form
.sp
.nf
@@ -267,63 +239,57 @@ Zone Australia/Adelaide 9:30 Aus CST 1971 Oct 31 2:00
.sp
.fi
The fields that make up a zone line are:
-.TP "\w'GMTOFF'u"
-.B NAME
+.Bl -tag -width indent
+.It NAME
The name of the time zone.
This is the name used in creating the time conversion information file for the
zone.
-.TP
-.B GMTOFF
-The amount of time to add to UTC to get standard time in this zone.
+.It GMTOFF
+The amount of time to add to GMT to get standard time in this zone.
This field has the same format as the
-.B AT
+.Em AT
and
-.B SAVE
+.Em SAVE
fields of rule lines;
-begin the field with a minus sign if time must be subtracted from UTC.
-.TP
-.B RULES/SAVE
+begin the field with a minus sign if time must be subtracted from GMT.
+.It RULES/SAVE
The name of the rule(s) that apply in the time zone or,
alternately, an amount of time to add to local standard time.
If this field is
-.B \-
+.Em \-
then standard time always applies in the time zone.
-.TP
-.B FORMAT
+.It FORMAT
The format for time zone abbreviations in this time zone.
The pair of characters
-.B %s
+.Em %s
is used to show where the
-.q "variable part"
+.Dq "variable part"
of the time zone abbreviation goes.
Alternately,
a slash (/)
separates standard and daylight abbreviations.
-.TP
-.B UNTIL
-The time at which the UTC offset or the rule(s) change for a location.
+.It UNTIL
+The time at which the GMT offset or the rule(s) change for a location.
It is specified as a year, a month, a day, and a time of day.
If this is specified,
-the time zone information is generated from the given UTC offset
+the time zone information is generated from the given GMT offset
and rule change until the time specified.
-The month, day, and time of day have the same format as the IN, ON, and AT
-columns of a rule; trailing columns can be omitted, and default to the
-earliest possible value for the missing columns.
-.IP
+.Pp
The next line must be a
-.q continuation
+.Dq continuation
line; this has the same form as a zone line except that the
string
-.q Zone
+.Dq Zone
and the name are omitted, as the continuation line will
place information starting at the time specified as the
-.B UNTIL
+.Em UNTIL
field in the previous line in the file used by the previous line.
Continuation lines may contain an
-.B UNTIL
+.Em UNTIL
field, just as zone lines do, indicating that the next line is a further
continuation.
-.PP
+.El
+.Pp
A link line has the form
.sp
.nf
@@ -338,17 +304,17 @@ Link Europe/Istanbul Asia/Istanbul
.sp
.fi
The
-.B LINK-FROM
+.Em LINK-FROM
field should appear as the
-.B NAME
+.Em NAME
field in some zone line;
the
-.B LINK-TO
+.Em LINK-TO
field is used as an alternate name for that zone.
-.PP
+.Pp
Except for continuation lines,
lines may appear in any order in the input.
-.PP
+.Pp
Lines in the file that describes leap seconds have the following form:
.nf
.ti +.5i
@@ -363,20 +329,20 @@ Leap 1974 Dec 31 23:59:60 + S
.sp
.fi
The
-.BR YEAR ,
-.BR MONTH ,
-.BR DAY ,
+.Em YEAR ,
+.Em MONTH ,
+.Em DAY ,
and
-.B HH:MM:SS
+.Em HH:MM:SS
fields tell when the leap second happened.
The
-.B CORR
+.Em CORR
field
should be
-.q +
+.Dq +
if a second was added
or
-.q -
+.Dq -
if a second was skipped.
.\" There's no need to document the following, since it's impossible for more
.\" than one leap second to be inserted or deleted at a time.
@@ -390,24 +356,28 @@ if a second was skipped.
.\" .q --
.\" if two seconds were skipped.
The
-.B R/S
+.Em R/S
field
should be (an abbreviation of)
-.q Stationary
-if the leap second time given by the other fields should be interpreted as UTC
+.Dq Stationary
+if the leap second time given by the other fields should be interpreted as GMT
or
(an abbreviation of)
-.q Rolling
+.Dq Rolling
if the leap second time given by the other fields should be interpreted as
local wall clock time.
-.SH NOTE
+.Sh NOTE
For areas with more than two types of local time,
you may need to use local standard time in the
-.B AT
+.Em AT
field of the earliest transition time's rule to ensure that
the earliest transition time recorded in the compiled file is correct.
-.SH FILE
-/usr/local/etc/zoneinfo standard directory used for created files
-.SH "SEE ALSO"
-newctime(3), tzfile(5), zdump(8)
-.\" @(#)zic.8 7.18
+.Sh FILE
+.Bl -tag -width /usr/share/zoneinfo -compact
+/usr/share/zoneinfo standard directory used for created files
+.El
+.Sh "SEE ALSO"
+.Xr ctime 3 ,
+.Xr tzfile 5 ,
+.Xr zdump 8
+.\" @(#)zic.8 7.12
diff --git a/usr.sbin/zic/zic.c b/usr.sbin/zic/zic.c
index 040a605..89866ba 100644
--- a/usr.sbin/zic/zic.c
+++ b/usr.sbin/zic/zic.c
@@ -1,15 +1,21 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)zic.c 7.96";
+static char elsieid[] = "@(#)zic.c 7.77";
#endif /* !defined NOID */
#endif /* !defined lint */
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include "private.h"
-#include "locale.h"
#include "tzfile.h"
-#ifdef unix
-#include "sys/stat.h" /* for umask manifest constants */
-#endif /* defined unix */
+#include <err.h>
+#include <locale.h>
+#include <sys/stat.h> /* for umask manifest constants */
+#include <sys/types.h>
+#include <unistd.h>
/*
** On some ancient hosts, predicates like `isspace(C)' are defined
@@ -79,9 +85,15 @@ struct zone {
extern int getopt P((int argc, char * const argv[],
const char * options));
+extern char * icatalloc P((char * old, const char * new));
+extern char * icpyalloc P((const char * string));
+extern void ifree P((char * p));
+extern char * imalloc P((int n));
+extern void * irealloc P((void * old, int n));
extern int link P((const char * fromname, const char * toname));
extern char * optarg;
extern int optind;
+extern char * scheck P((const char * string, const char * format));
static void addtt P((time_t starttime, int type));
static int addtype P((long gmtoff, const char * abbr, int isdst,
@@ -130,9 +142,9 @@ static void usage P((void));
static void writezone P((const char * name));
static int yearistype P((int year, const char * type));
-#if !(HAVE_STRERROR - 0)
+#if !HAVE_STRERROR
static char * strerror P((int));
-#endif /* !(HAVE_STRERROR - 0) */
+#endif /* !HAVE_STRERROR */
static int charcnt;
static int errors;
@@ -141,14 +153,11 @@ static int leapcnt;
static int linenum;
static time_t max_time;
static int max_year;
-static int max_year_representable;
static time_t min_time;
static int min_year;
-static int min_year_representable;
static int noise;
static const char * rfilename;
static int rlinenum;
-static const char * progname;
static int timecnt;
static int typecnt;
@@ -353,13 +362,8 @@ static char *
memcheck(ptr)
char * const ptr;
{
- if (ptr == NULL) {
- const char *e = strerror(errno);
-
- (void) fprintf(stderr, _("%s: Memory exhausted: %s\n"),
- progname, e);
- (void) exit(EXIT_FAILURE);
- }
+ if (ptr == NULL)
+ errx(EXIT_FAILURE, _("memory exhausted"));
return ptr;
}
@@ -372,18 +376,19 @@ char * const ptr;
** Error handling.
*/
-#if !(HAVE_STRERROR - 0)
+#if ! HAVE_STRERROR
static char *
strerror(errnum)
int errnum;
{
- extern char * sys_errlist[];
- extern int sys_nerr;
+ extern char *sys_errlist[];
+ extern int sys_nerr;
- return (errnum > 0 && errnum <= sys_nerr) ?
- sys_errlist[errnum] : _("Unknown system error");
+ if (errnum > 0 && errnum <= sys_nerr)
+ return sys_errlist[errnum];
+ return "Unknown system error";
}
-#endif /* !(HAVE_STRERROR - 0) */
+#endif /* ! HAVE_STRERROR */
static void
eats(name, num, rname, rnum)
@@ -430,9 +435,9 @@ const char * const string;
{
char * cp;
- cp = ecpyalloc(_("warning: "));
+ cp = ecpyalloc("warning: ");
cp = ecatalloc(cp, string);
- error(cp);
+ error(string);
ifree(cp);
--errors;
}
@@ -440,8 +445,9 @@ const char * const string;
static void
usage P((void))
{
- (void) fprintf(stderr, _("%s: usage is %s [ -s ] [ -v ] [ -l localtime ] [ -p posixrules ] [ -d directory ]\n\t[ -L leapseconds ] [ -y yearistype ] [ filename ... ]\n"),
- progname, progname);
+ (void) fprintf(stderr, "%s\n%s\n",
+_("usage: zic [-s] [-v] [-l localtime] [-p posixrules] [-d directory]"),
+_(" [-L leapseconds] [-y yearistype] [filename ... ]"));
(void) exit(EXIT_FAILURE);
}
@@ -471,60 +477,44 @@ char * argv[];
#endif /* defined TEXTDOMAINDIR */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
- progname = argv[0];
- while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF && c != -1)
+ while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != -1)
switch (c) {
default:
usage();
case 'd':
if (directory == NULL)
directory = optarg;
- else {
- (void) fprintf(stderr,
-_("%s: More than one -d option specified\n"),
- progname);
- (void) exit(EXIT_FAILURE);
- }
+ else
+ errx(EXIT_FAILURE,
+_("more than one -d option specified"));
break;
case 'l':
if (lcltime == NULL)
lcltime = optarg;
- else {
- (void) fprintf(stderr,
-_("%s: More than one -l option specified\n"),
- progname);
- (void) exit(EXIT_FAILURE);
- }
+ else
+ errx(EXIT_FAILURE,
+_("more than one -l option specified"));
break;
case 'p':
if (psxrules == NULL)
psxrules = optarg;
- else {
- (void) fprintf(stderr,
-_("%s: More than one -p option specified\n"),
- progname);
- (void) exit(EXIT_FAILURE);
- }
+ else
+ errx(EXIT_FAILURE,
+_("more than one -p option specified"));
break;
case 'y':
if (yitcommand == NULL)
yitcommand = optarg;
- else {
- (void) fprintf(stderr,
-_("%s: More than one -y option specified\n"),
- progname);
- (void) exit(EXIT_FAILURE);
- }
+ else
+ errx(EXIT_FAILURE,
+_("more than one -y option specified"));
break;
case 'L':
if (leapsec == NULL)
leapsec = optarg;
- else {
- (void) fprintf(stderr,
-_("%s: More than one -L option specified\n"),
- progname);
- (void) exit(EXIT_FAILURE);
- }
+ else
+ errx(EXIT_FAILURE,
+_("more than one -L option specified"));
break;
case 'v':
noise = TRUE;
@@ -601,26 +591,11 @@ const char * const tofile;
if (!itsdir(toname))
(void) remove(toname);
if (link(fromname, toname) != 0) {
- int result;
-
if (mkdirs(toname) != 0)
(void) exit(EXIT_FAILURE);
- result = link(fromname, toname);
-#if (HAVE_SYMLINK - 0)
- if (result != 0) {
- result = symlink(fromname, toname);
- if (result == 0)
-warning(_("hard link failed, symbolic link used"));
- }
-#endif
- if (result != 0) {
- const char *e = strerror(errno);
-
- (void) fprintf(stderr,
- _("%s: Can't link from %s to %s: %s\n"),
- progname, fromname, toname, e);
- (void) exit(EXIT_FAILURE);
- }
+ if (link(fromname, toname) != 0)
+ err(EXIT_FAILURE, _("can't link from %s to %s"),
+ fromname, toname);
}
ifree(fromname);
ifree(toname);
@@ -661,8 +636,6 @@ setboundaries P((void))
}
min_year = TM_YEAR_BASE + gmtime(&min_time)->tm_year;
max_year = TM_YEAR_BASE + gmtime(&max_time)->tm_year;
- min_year_representable = min_year;
- max_year_representable = max_year;
}
static int
@@ -788,13 +761,8 @@ const char * name;
if (strcmp(name, "-") == 0) {
name = _("standard input");
fp = stdin;
- } else if ((fp = fopen(name, "r")) == NULL) {
- const char *e = strerror(errno);
-
- (void) fprintf(stderr, _("%s: Can't open %s: %s\n"),
- progname, name, e);
- (void) exit(EXIT_FAILURE);
- }
+ } else if ((fp = fopen(name, "r")) == NULL)
+ err(EXIT_FAILURE, _("can't open %s"), name);
wantcont = FALSE;
for (num = 1; ; ++num) {
eat(name, num);
@@ -837,33 +805,22 @@ const char * name;
break;
case LC_LEAP:
if (name != leapsec)
- (void) fprintf(stderr,
-_("%s: Leap line in non leap seconds file %s\n"),
- progname, name);
+ warnx(
+_("leap line in non leap seconds file %s"), name);
else inleap(fields, nfields);
wantcont = FALSE;
break;
default: /* "cannot happen" */
- (void) fprintf(stderr,
-_("%s: panic: Invalid l_value %d\n"),
- progname, lp->l_value);
- (void) exit(EXIT_FAILURE);
+ errx(EXIT_FAILURE,
+_("panic: invalid l_value %d"), lp->l_value);
}
}
ifree((char *) fields);
}
- if (ferror(fp)) {
- (void) fprintf(stderr, _("%s: Error reading %s\n"),
- progname, filename);
- (void) exit(EXIT_FAILURE);
- }
- if (fp != stdin && fclose(fp)) {
- const char *e = strerror(errno);
-
- (void) fprintf(stderr, _("%s: Error closing %s: %s\n"),
- progname, filename, e);
- (void) exit(EXIT_FAILURE);
- }
+ if (ferror(fp))
+ errx(EXIT_FAILURE, _("error reading %s"), filename);
+ if (fp != stdin && fclose(fp))
+ err(EXIT_FAILURE, _("error closing %s"), filename);
if (wantcont)
error(_("expected continuation line not found"));
}
@@ -901,10 +858,9 @@ const int signable;
error(errstring);
return 0;
}
- if ((hh < 0 || hh >= HOURSPERDAY ||
+ if (hh < 0 || hh >= HOURSPERDAY ||
mm < 0 || mm >= MINSPERHOUR ||
- ss < 0 || ss > SECSPERMIN) &&
- !(hh == HOURSPERDAY && mm == 0 && ss == 0)) {
+ ss < 0 || ss > SECSPERMIN) {
error(errstring);
return 0;
}
@@ -1031,7 +987,7 @@ const int iscont;
}
z.z_filename = filename;
z.z_linenum = linenum;
- z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UTC offset"), TRUE);
+ z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid GMT offset"), TRUE);
if ((cp = strchr(fields[i_format], '%')) != 0) {
if (*++cp != 's' || strchr(cp, '%') != 0) {
error(_("invalid abbreviation format"));
@@ -1233,7 +1189,6 @@ const char * const timep;
rp->r_todisstd = FALSE;
rp->r_todisgmt = FALSE;
*ep = '\0';
- break;
case 'g': /* Greenwich */
case 'u': /* Universal */
case 'z': /* Zulu */
@@ -1258,18 +1213,11 @@ const char * const timep;
rp->r_loyear = INT_MAX;
break;
default: /* "cannot happen" */
- (void) fprintf(stderr,
- _("%s: panic: Invalid l_value %d\n"),
- progname, lp->l_value);
- (void) exit(EXIT_FAILURE);
+ errx(EXIT_FAILURE,
+ _("panic: invalid l_value %d"), lp->l_value);
} else if (sscanf(cp, scheck(cp, "%d"), &rp->r_loyear) != 1) {
error(_("invalid starting year"));
return;
- } else if (noise) {
- if (rp->r_loyear < min_year_representable)
- warning(_("starting year too low to be represented"));
- else if (rp->r_loyear > max_year_representable)
- warning(_("starting year too high to be represented"));
}
cp = hiyearp;
if ((lp = byword(cp, end_years)) != NULL) switch ((int) lp->l_value) {
@@ -1283,18 +1231,11 @@ const char * const timep;
rp->r_hiyear = rp->r_loyear;
break;
default: /* "cannot happen" */
- (void) fprintf(stderr,
- _("%s: panic: Invalid l_value %d\n"),
- progname, lp->l_value);
- (void) exit(EXIT_FAILURE);
+ errx(EXIT_FAILURE,
+ _("panic: invalid l_value %d"), lp->l_value);
} else if (sscanf(cp, scheck(cp, "%d"), &rp->r_hiyear) != 1) {
error(_("invalid ending year"));
return;
- } else if (noise) {
- if (rp->r_loyear < min_year_representable)
- warning(_("starting year too low to be represented"));
- else if (rp->r_loyear > max_year_representable)
- warning(_("starting year too high to be represented"));
}
if (rp->r_loyear > rp->r_hiyear) {
error(_("starting year greater than ending year"));
@@ -1309,8 +1250,6 @@ const char * const timep;
}
rp->r_yrtype = ecpyalloc(typep);
}
- if (rp->r_loyear < min_year && rp->r_loyear > 0)
- min_year = rp->r_loyear;
/*
** Day work.
** Accept things such as:
@@ -1419,10 +1358,8 @@ const char * const name;
toi = 0;
fromi = 0;
- while (fromi < timecnt && attypes[fromi].at < min_time)
- ++fromi;
if (isdsts[0] == 0)
- while (fromi < timecnt && attypes[fromi].type == 0)
+ while (attypes[fromi].type == 0)
++fromi; /* handled by default rule */
for ( ; fromi < timecnt; ++fromi) {
if (toi != 0
@@ -1450,26 +1387,18 @@ const char * const name;
fullname = erealloc(fullname,
(int) (strlen(directory) + 1 + strlen(name) + 1));
(void) sprintf(fullname, "%s/%s", directory, name);
+
/*
- ** Remove old file, if any, to snap links.
- */
- if (!itsdir(fullname) && remove(fullname) != 0 && errno != ENOENT) {
- const char *e = strerror(errno);
+ * Remove old file, if any, to snap links.
+ */
+ if (!itsdir(fullname) && remove(fullname) != 0 && errno != ENOENT)
+ err(EXIT_FAILURE, _("can't remove %s"), fullname);
- (void) fprintf(stderr, _("%s: Can't remove %s: %s\n"),
- progname, fullname, e);
- (void) exit(EXIT_FAILURE);
- }
if ((fp = fopen(fullname, "wb")) == NULL) {
if (mkdirs(fullname) != 0)
(void) exit(EXIT_FAILURE);
- if ((fp = fopen(fullname, "wb")) == NULL) {
- const char *e = strerror(errno);
-
- (void) fprintf(stderr, _("%s: Can't create %s: %s\n"),
- progname, fullname, e);
- (void) exit(EXIT_FAILURE);
- }
+ if ((fp = fopen(fullname, "wb")) == NULL)
+ err(EXIT_FAILURE, _("can't create %s"), fullname);
}
convert(eitol(typecnt), tzh.tzh_ttisgmtcnt);
convert(eitol(typecnt), tzh.tzh_ttisstdcnt);
@@ -1477,9 +1406,7 @@ const char * const name;
convert(eitol(timecnt), tzh.tzh_timecnt);
convert(eitol(typecnt), tzh.tzh_typecnt);
convert(eitol(charcnt), tzh.tzh_charcnt);
- (void) strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic);
#define DO(field) (void) fwrite((void *) tzh.field, (size_t) sizeof tzh.field, (size_t) 1, fp)
- DO(tzh_magic);
DO(tzh_reserved);
DO(tzh_ttisgmtcnt);
DO(tzh_ttisstdcnt);
@@ -1531,11 +1458,8 @@ const char * const name;
(void) putc(ttisstds[i], fp);
for (i = 0; i < typecnt; ++i)
(void) putc(ttisgmts[i], fp);
- if (ferror(fp) || fclose(fp)) {
- (void) fprintf(stderr, _("%s: Error writing %s\n"),
- progname, fullname);
- (void) exit(EXIT_FAILURE);
- }
+ if (ferror(fp) || fclose(fp))
+ errx(EXIT_FAILURE, _("error writing %s"), fullname);
}
static void
@@ -1643,7 +1567,7 @@ const int zonecount;
INITIALIZE(ktime);
if (useuntil) {
/*
- ** Turn untiltime into UTC
+ ** Turn untiltime into GMT
** assuming the current gmtoff and
** stdoff values.
*/
@@ -1723,7 +1647,7 @@ const int zonecount;
(void) strcpy(startbuf, zp->z_format);
eat(zp->z_filename, zp->z_linenum);
if (*startbuf == '\0')
-error(_("can't determine time zone abbreviation to use just after until time"));
+error(_("can't determine time zone abbrevation to use just after until time"));
else addtt(starttime,
addtype(startoff, startbuf,
startoff != zp->z_gmtoff,
@@ -1749,22 +1673,8 @@ error(_("can't determine time zone abbreviation to use just after until time"));
static void
addtt(starttime, type)
const time_t starttime;
-int type;
+const int type;
{
- if (starttime <= min_time ||
- (timecnt == 1 && attypes[0].at < min_time)) {
- gmtoffs[0] = gmtoffs[type];
- isdsts[0] = isdsts[type];
- ttisstds[0] = ttisstds[type];
- ttisgmts[0] = ttisgmts[type];
- if (abbrinds[type] != 0)
- (void) strcpy(chars, &chars[abbrinds[type]]);
- abbrinds[0] = 0;
- charcnt = strlen(chars) + 1;
- typecnt = 1;
- timecnt = 0;
- type = 0;
- }
if (timecnt >= TZ_MAX_TIMES) {
error(_("too many transitions?!"));
(void) exit(EXIT_FAILURE);
@@ -1896,9 +1806,8 @@ const char * const type;
return TRUE;
if (result == (1 << 8))
return FALSE;
- error(_("Wild result from command execution"));
- (void) fprintf(stderr, _("%s: command was '%s', result was %d\n"),
- progname, buf, result);
+ error(_("wild result from command execution"));
+ warnx(_("command was '%s', result was %d"), buf, result);
for ( ; ; )
(void) exit(EXIT_FAILURE);
}
@@ -1959,11 +1868,10 @@ register const struct lookup * const table;
*/
foundlp = NULL;
for (lp = table; lp->l_word != NULL; ++lp)
- if (itsabbr(word, lp->l_word)) {
+ if (itsabbr(word, lp->l_word))
if (foundlp == NULL)
foundlp = lp;
else return NULL; /* multiple inexact matches */
- }
return foundlp;
}
@@ -1992,7 +1900,7 @@ register char * cp;
else while ((*dp = *cp++) != '"')
if (*dp != '\0')
++dp;
- else error(_("Odd number of quotation marks"));
+ else error(_("odd number of quotation marks"));
} while (*cp != '\0' && *cp != '#' &&
(!isascii(*cp) || !isspace((unsigned char) *cp)));
if (isascii(*cp) && isspace((unsigned char) *cp))
@@ -2167,20 +2075,11 @@ char * const argname;
if (!itsdir(name)) {
/*
** It doesn't seem to exist, so we try to create it.
- ** Creation may fail because of the directory being
- ** created by some other multiprocessor, so we get
- ** to do extra checking.
*/
- if (mkdir(name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) != 0) {
- const char *e = strerror(errno);
-
- if (errno != EEXIST || !itsdir(name)) {
- (void) fprintf(stderr,
-_("%s: Can't create directory %s: %s\n"),
- progname, name, e);
- ifree(name);
- return -1;
- }
+ if (mkdir(name, 0755) != 0) {
+ warn(_("can't create directory %s"), name);
+ ifree(name);
+ return -1;
}
}
*cp = '/';
@@ -2196,12 +2095,8 @@ const int i;
long l;
l = i;
- if ((i < 0 && l >= 0) || (i == 0 && l != 0) || (i > 0 && l <= 0)) {
- (void) fprintf(stderr,
- _("%s: %d did not sign extend correctly\n"),
- progname, i);
- (void) exit(EXIT_FAILURE);
- }
+ if ((i < 0 && l >= 0) || (i == 0 && l != 0) || (i > 0 && l <= 0))
+ errx(EXIT_FAILURE, _("%d did not sign extend correctly"), i);
return l;
}
diff --git a/usr.sbin/zic/zic/Makefile b/usr.sbin/zic/zic/Makefile
new file mode 100644
index 0000000..2f6e49d
--- /dev/null
+++ b/usr.sbin/zic/zic/Makefile
@@ -0,0 +1,14 @@
+# $Id$
+
+.PATH: ${.CURDIR}/..
+
+PROG= zic
+
+SRCS= zic.c ialloc.c scheck.c
+MAN8= ${.CURDIR}/../zic.8
+CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../lib/libc/stdtime
+CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS
+CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir
+CFLAGS+= -DHAVE_STRERROR -DHAVE_UNISTD_H
+
+.include <bsd.prog.mk>
OpenPOWER on IntegriCloud