summaryrefslogtreecommitdiffstats
path: root/usr.sbin/zic
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/zic')
-rw-r--r--usr.sbin/zic/Arts.htm3
-rw-r--r--usr.sbin/zic/Makefile367
-rw-r--r--usr.sbin/zic/Makefile.inc3
-rw-r--r--usr.sbin/zic/Music81
-rw-r--r--usr.sbin/zic/WWW71
-rw-r--r--usr.sbin/zic/ialloc.c7
-rw-r--r--usr.sbin/zic/private.h137
-rw-r--r--usr.sbin/zic/scheck.c7
-rw-r--r--usr.sbin/zic/zdump.865
-rw-r--r--usr.sbin/zic/zdump.c62
-rw-r--r--usr.sbin/zic/zdump/Makefile13
-rw-r--r--usr.sbin/zic/zic.8478
-rw-r--r--usr.sbin/zic/zic.c390
-rw-r--r--usr.sbin/zic/zic/Makefile14
14 files changed, 541 insertions, 1157 deletions
diff --git a/usr.sbin/zic/Arts.htm b/usr.sbin/zic/Arts.htm
index 39dcab7..baa84ed 100644
--- a/usr.sbin/zic/Arts.htm
+++ b/usr.sbin/zic/Arts.htm
@@ -1,4 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<!-- $FreeBSD$ -->
<HTML>
<HEAD>
<TITLE>Time and the Arts</TITLE>
@@ -143,7 +144,7 @@ Copyright Date: 1996
Label: Black Lion
ID: BLCD 760221
Total Time: 72:58
-Personnel: Anthony Braxton, sporanino and alto saxophones,
+Personnel: Anthony Braxton, sopranino and alto saxophones,
contrebasse clarinet, miscellaneous instruments
Leo Smith, trumpet and miscellaneous instruments
Leroy Jenkins, violin and miscellaneous instruments
diff --git a/usr.sbin/zic/Makefile b/usr.sbin/zic/Makefile
index 0aefc95..2496e82 100644
--- a/usr.sbin/zic/Makefile
+++ b/usr.sbin/zic/Makefile
@@ -1,365 +1,8 @@
-# @(#)Makefile 7.67
+# $FreeBSD$
-# 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.
+# Vendor contact: tz@elsie.nci.nih.gov
+MAINTAINER= wollman@FreeBSD.org
-LOCALTIME= Factory
+SUBDIR= zic zdump
-# 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:
+.include <bsd.subdir.mk>
diff --git a/usr.sbin/zic/Makefile.inc b/usr.sbin/zic/Makefile.inc
new file mode 100644
index 0000000..b915adf
--- /dev/null
+++ b/usr.sbin/zic/Makefile.inc
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+.include "${.CURDIR}/../../Makefile.inc"
diff --git a/usr.sbin/zic/Music b/usr.sbin/zic/Music
deleted file mode 100644
index 9fb0cec..0000000
--- a/usr.sbin/zic/Music
+++ /dev/null
@@ -1,81 +0,0 @@
-@(#)Music 7.4
-
-Data on recordings of "Save That Time," Russ Long, Serrob Publishing, BMI:
---------------------------------------------------------------------------
-Artist: Karrin Allyson
-CD: I Didn't Know About You
-Copyright Date: 1993
-Label: Concord Jazz, Inc.
-ID: CCD-4543
-Track Time: 3:44
-Personnel: Karrin Allyson, vocal
- Russ Long, piano
- Gerald Spaits, bass
- Todd Strait, drums
-Notes: CD notes "additional lyric by Karrin Allyson;
- arranged by Russ Long and Karrin Allyson"
-Rating: 1 star
---------------------------------------------------------------------------
-Artist: Kevin Mahogany
-CD: Double Rainbow
-Copyright Date: 1993
-Label: Enja Records
-ID: ENJ-7097 2
-Track Time: 6:27
-Personnel: Kevin Mahogany, vocal
- Kenny Barron, piano
- Ray Drummond, bss
- Ralph Moore, tenor saxophone
- Lewis Nash, drums
-Rating: 1.5 stars
---------------------------------------------------------------------------
-Artist: Joe Williams
-CD: Here's to Life
-Copyright Date: 1994
-Label: Telarc International Corporation
-ID: CD-83357
-Track Time: 3:58
-Personnel: Joe Williams, vocal
- The Robert Farnon [39 piece] Orchestra
-Rating: black dot
---------------------------------------------------------------------------
-Artist: Charles Fambrough
-CD: Keeper of the Spirit
-Copyright Date: 1995
-Label: AudioQuest Music
-ID: AQ-CD1033
-Track Time: 7:07
-Personnel: Charles Fambrough, bass
- Joel Levine, tenor recorder
- Edward Simon, piano
- Lenny White, drums
- Marion Simon, percussion
-Rating: 2 stars
-==========================================================================
-Also of note:
-Artist: Milt Hinton
-CD: Old Man Time
-Date: 1993
-Label: Chiaroscuro
-ID: CR(D) 310
-Total Time: 149:38 (two CDs)
-Personnel: Milt Hinton, bass
- Doc Cheatham, Dizzy Gillespie, Clark Terry, trumpet
- Al Grey, trombone
- Eddier Barefield, Joe Camel (Flip Phillips), Buddy Tate,
- clarinet and saxophone
- John Bunch, Red Richards, Norman Simmons, Derek Smith,
- Ralph Sutton, piano
- Danny Barker, Al Casey, guitar
- Gus Johnson, Gerryck King, Bob Rosengarden, Jackie Williams,
- drums
- Lionel Hampton, vibraphone
- Cab Calloway, Joe Williams, vocal
- Buck Clayton, arrangements
-Notes: tunes include Old Man Time, Time After Time,
- Sometimes I'm Happy,
- A Hot Time in the Old Town Tonight,
- Four or Five Times, Now's the Time,
- Time on My Hands, This Time It's Us,
- and Good Time Charlie
-Rating: 3 stars
diff --git a/usr.sbin/zic/WWW b/usr.sbin/zic/WWW
deleted file mode 100644
index d2fd684..0000000
--- a/usr.sbin/zic/WWW
+++ /dev/null
@@ -1,71 +0,0 @@
-# '@(#)WWW 7.3'
-
-# From Paul Eggert <eggert@twinsun.com> (1995-11-03)
-#
-# The Web has several other sources for time zone and daylight savings data.
-# Here are some recent links that may be of interest.
-#
-# Date and Time Gateway
-# http://www.bsdi.com/date
-# A text-based source for tables of current time throughout the world.
-# Its point-and-click interface accesses a recent version of the tz data.
-#
-# Local Times Around the World
-# http://www.hilink.com.au/times/
-# This text-based system contains links to local time servers
-# throughout the world, and though the coverage is limited,
-# the live data provide a nice way to check one's tables.
-#
-# World Time Zones
-# http://tycho.usno.navy.mil/tzones.html
-# US Naval Observatory data, used as the source for `usno1995'.
-#
-# Standard Time Zones of the World
-# http://www.odci.gov/cia/publications/95fact/802389.gif [54 kB]
-# http://www.odci.gov/cia/publications/95fact/802389h.gif [1317 kB]
-# A static time zone map, available in both low-resolution and
-# high-resolution versions. The quality is good, but the map does not
-# indicate summer time, and parts of the data are a few years out of date.
-#
-# VIBE's World Map
-# http://pathfinder.com/vibe/vibeworld
-# An active time zone map. You can point to the map and find out what
-# time it is at that location. The map and data are not as good as
-# other sources.
-
-###############################################################################
-
-# From Manavendra Thakur <Manavendra_Thakur@NeXT.COM> (1995-11-06)
-#
-# To Paul's list of time zone information on the web, I would add the
-# following URL:
-# http://www.dhl.com/dhl/dhlinfo/1bb.html
-# or more simply:
-# http://www.dhl.com/
-#
-# This is run by DHL (the courier company), and it presents a list of the
-# countries served by that company. If you then click on a particular
-# country, here's an example of what you'll see (graphics stripped out):
-#
-# United Kingdom
-#
-# HOLIDAYS: Jan 1, 2, Apr 14, 17, May 1, 29, Aug 28, Dec 25, 26
-#
-# INTERNATIONAL DIALING CODE: +44
-#
-# CURRENT LOCAL TIME: 09:41 Monday 6 November 1995
-#
-# I find this rather handy, and given that DHL covers 217 countries and
-# territories, it's pretty comprehensive coverage.
-#
-# (I have no idea what system DHL is using to calculate the local time, but
-# it's been accurate so far.)
-
-###############################################################################
-
-
-# From Arthur David Olson <arthur_david_olson@nih.gov> (1996-01-04)
-#
-# A good source of information about ISO 8601 seems to be
-# http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html
-# maintained by Markus Kuhn.
diff --git a/usr.sbin/zic/ialloc.c b/usr.sbin/zic/ialloc.c
index 8a0c701..a069032 100644
--- a/usr.sbin/zic/ialloc.c
+++ b/usr.sbin/zic/ialloc.c
@@ -1,9 +1,14 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)ialloc.c 8.29";
+static const char elsieid[] = "@(#)ialloc.c 8.29";
#endif /* !defined NOID */
#endif /* !defined lint */
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
/*LINTLIBRARY*/
#include "private.h"
diff --git a/usr.sbin/zic/private.h b/usr.sbin/zic/private.h
index c8f4548..585d6e6 100644
--- a/usr.sbin/zic/private.h
+++ b/usr.sbin/zic/private.h
@@ -8,6 +8,15 @@
*/
/*
+ * FreeBSD modifications: separate libc's privates from zic's.
+ * This makes it easier when we need to update one but not the other.
+ * I have removed all of the ifdef spaghetti which is not relevant to
+ * zic from this file.
+ *
+ * $FreeBSD$
+ */
+
+/*
** This header is for use ONLY with the time conversion code.
** There is no guarantee that it will remain unchanged,
** or that it will remain at all.
@@ -21,7 +30,7 @@
#ifndef lint
#ifndef NOID
-static char privatehid[] = "@(#)private.h 7.53";
+static const char privatehid[] = "@(#)private.h 7.48";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -30,22 +39,10 @@ static char privatehid[] = "@(#)private.h 7.53";
** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
*/
-#ifndef HAVE_ADJTIME
-#define HAVE_ADJTIME 1
-#endif /* !defined HAVE_ADJTIME */
-
#ifndef HAVE_GETTEXT
#define HAVE_GETTEXT 0
#endif /* !defined HAVE_GETTEXT */
-#ifndef HAVE_INCOMPATIBLE_CTIME_R
-#define HAVE_INCOMPATIBLE_CTIME_R 0
-#endif /* !defined INCOMPATIBLE_CTIME_R */
-
-#ifndef HAVE_SETTIMEOFDAY
-#define HAVE_SETTIMEOFDAY 3
-#endif /* !defined HAVE_SETTIMEOFDAY */
-
#ifndef HAVE_STRERROR
#define HAVE_STRERROR 1
#endif /* !defined HAVE_STRERROR */
@@ -54,31 +51,10 @@ static char privatehid[] = "@(#)private.h 7.53";
#define HAVE_SYMLINK 1
#endif /* !defined HAVE_SYMLINK */
-#ifndef HAVE_SYS_STAT_H
-#define HAVE_SYS_STAT_H 1
-#endif /* !defined HAVE_SYS_STAT_H */
-
-#ifndef HAVE_SYS_WAIT_H
-#define HAVE_SYS_WAIT_H 1
-#endif /* !defined HAVE_SYS_WAIT_H */
-
#ifndef HAVE_UNISTD_H
#define HAVE_UNISTD_H 1
#endif /* !defined HAVE_UNISTD_H */
-#ifndef HAVE_UTMPX_H
-#define HAVE_UTMPX_H 0
-#endif /* !defined HAVE_UTMPX_H */
-
-#ifndef LOCALE_HOME
-#define LOCALE_HOME "/usr/lib/locale"
-#endif /* !defined LOCALE_HOME */
-
-#if HAVE_INCOMPATIBLE_CTIME_R
-#define asctime_r _incompatible_asctime_r
-#define ctime_r _incompatible_ctime_r
-#endif /* HAVE_INCOMPATIBLE_CTIME_R */
-
/*
** Nested includes
*/
@@ -95,17 +71,6 @@ static char privatehid[] = "@(#)private.h 7.53";
#include "libintl.h"
#endif /* HAVE_GETTEXT - 0 */
-#if HAVE_SYS_WAIT_H - 0
-#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
-#endif /* HAVE_SYS_WAIT_H - 0 */
-
-#ifndef WIFEXITED
-#define WIFEXITED(status) (((status) & 0xff) == 0)
-#endif /* !defined WIFEXITED */
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
-#endif /* !defined WEXITSTATUS */
-
#if HAVE_UNISTD_H - 0
#include "unistd.h" /* for F_OK and R_OK */
#endif /* HAVE_UNISTD_H - 0 */
@@ -122,77 +87,7 @@ static char privatehid[] = "@(#)private.h 7.53";
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
-/*
-** Workarounds for compilers/systems.
-*/
-
-/*
-** SunOS 4.1.1 cc lacks prototypes.
-*/
-
-#ifndef P
-#ifdef __STDC__
-#define P(x) x
-#endif /* defined __STDC__ */
-#ifndef __STDC__
-#define P(x) ()
-#endif /* !defined __STDC__ */
-#endif /* !defined P */
-
-/*
-** SunOS 4.1.1 headers lack EXIT_SUCCESS.
-*/
-
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif /* !defined EXIT_SUCCESS */
-
-/*
-** SunOS 4.1.1 headers lack EXIT_FAILURE.
-*/
-
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif /* !defined EXIT_FAILURE */
-
-/*
-** SunOS 4.1.1 headers lack FILENAME_MAX.
-*/
-
-#ifndef FILENAME_MAX
-
-#ifndef MAXPATHLEN
-#ifdef unix
-#include "sys/param.h"
-#endif /* defined unix */
-#endif /* !defined MAXPATHLEN */
-
-#ifdef MAXPATHLEN
-#define FILENAME_MAX MAXPATHLEN
-#endif /* defined MAXPATHLEN */
-#ifndef MAXPATHLEN
-#define FILENAME_MAX 1024 /* Pure guesswork */
-#endif /* !defined MAXPATHLEN */
-
-#endif /* !defined FILENAME_MAX */
-
-/*
-** SunOS 4.1.1 libraries lack remove.
-*/
-
-#ifndef remove
-extern int unlink P((const char * filename));
-#define remove unlink
-#endif /* !defined remove */
-
-/*
-** Some ancient errno.h implementations don't declare errno.
-** But some newer errno.h implementations define it as a macro.
-** Fix the former without affecting the latter.
-*/
-#ifndef errno
-extern int errno;
-#endif /* !defined errno */
+#define P(x) x
/*
** Private function declarations.
@@ -206,7 +101,6 @@ void icfree P((char * pointer));
void ifree P((char * pointer));
char * scheck P((const char *string, const char *format));
-
/*
** Finally, some convenience items.
*/
@@ -280,15 +174,8 @@ char * scheck P((const char *string, const char *format));
#define TZ_DOMAIN "tz"
#endif /* !defined TZ_DOMAIN */
-#if HAVE_INCOMPATIBLE_CTIME_R
-#undef asctime_r
-#undef ctime_r
-char *asctime_r P((struct tm const *, char *));
-char *ctime_r P((time_t const *, char *));
-#endif /* HAVE_INCOMPATIBLE_CTIME_R */
-
/*
-** UNIX was a registered trademark of The Open Group in 2003.
+** UNIX was a registered trademark of UNIX System Laboratories in 1993.
*/
#endif /* !defined PRIVATE_H */
diff --git a/usr.sbin/zic/scheck.c b/usr.sbin/zic/scheck.c
index 39feeba..692bf1a 100644
--- a/usr.sbin/zic/scheck.c
+++ b/usr.sbin/zic/scheck.c
@@ -1,9 +1,14 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)scheck.c 8.15";
+static const char elsieid[] = "@(#)scheck.c 8.15";
#endif /* !defined lint */
#endif /* !defined NOID */
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
/*LINTLIBRARY*/
#include "private.h"
diff --git a/usr.sbin/zic/zdump.8 b/usr.sbin/zic/zdump.8
index dff68c2..6961595 100644
--- a/usr.sbin/zic/zdump.8
+++ b/usr.sbin/zic/zdump.8
@@ -1,30 +1,30 @@
-.TH ZDUMP 8
-.SH NAME
-zdump \- time zone dumper
-.SH SYNOPSIS
-.B zdump
-[
-.B \-\-version
-]
-[
-.B \-v
-] [
-.B \-c
-cutoffyear ] [ zonename ... ]
-.SH DESCRIPTION
-.I Zdump
-prints the current time in each
-.I zonename
+.\"
+.\" @(#)zdump.8 7.3
+.\" $FreeBSD$
+.\"
+.Dd September 13, 1994
+.Dt ZDUMP 8
+.Os
+.Sh NAME
+.Nm zdump
+.Nd timezone dumper
+.Sh SYNOPSIS
+.Nm
+.Op Fl v
+.Op Fl c Ar cutoffyear
+.Op Ar zonename ...
+.Sh DESCRIPTION
+The
+.Nm
+utility prints the current time in each
+.Ar zonename
named on the command line.
-.PP
-These options are available:
-.TP
-.BI "\-\-version"
-Output version information and exit.
-.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,
@@ -33,13 +33,14 @@ 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.4
+.El
+.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 a34cadd..cfd94ea 100644
--- a/usr.sbin/zic/zdump.c
+++ b/usr.sbin/zic/zdump.c
@@ -1,4 +1,13 @@
-static char elsieid[] = "@(#)zdump.c 7.31";
+#ifndef lint
+#ifndef NOID
+static const char elsieid[] = "@(#)zdump.c 7.28";
+#endif /* !defined NOID */
+#endif /* !defined lint */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
/*
** This code has been made independent of the rest of the time
@@ -6,11 +15,13 @@ static char elsieid[] = "@(#)zdump.c 7.31";
** 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
@@ -117,18 +128,14 @@ static char elsieid[] = "@(#)zdump.c 7.31";
#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 void usage(void);
int
main(argc, argv)
@@ -157,12 +164,6 @@ char * argv[];
#endif /* defined(TEXTDOMAINDIR) */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
- progname = argv[0];
- for (i = 1; i < argc; ++i)
- if (strcmp(argv[i], "--version") == 0) {
- (void) printf("%s\n", elsieid);
- (void) exit(EXIT_SUCCESS);
- }
vflag = 0;
cutoff = NULL;
while ((c = getopt(argc, argv, "c:v")) == 'c' || c == 'v')
@@ -171,10 +172,7 @@ char * argv[];
else cutoff = optarg;
if ((c != EOF && c != -1) ||
(optind == argc - 1 && strcmp(argv[optind], "=") == 0)) {
- (void) fprintf(stderr,
-_("%s: usage is %s [ --version ] [ -v ] [ -c cutoff ] zonename ...\n"),
- argv[0], argv[0]);
- (void) exit(EXIT_FAILURE);
+ usage();
}
if (cutoff != NULL) {
int y;
@@ -201,10 +199,10 @@ _("%s: usage is %s [ --version ] [ -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)
@@ -263,11 +261,8 @@ _("%s: usage is %s [ --version ] [ -v ] [ -c cutoff ] zonename ...\n"),
t += SECSPERHOUR * HOURSPERDAY;
show(argv[i], t, TRUE);
}
- if (fflush(stdout) || ferror(stdout)) {
- (void) fprintf(stderr, "%s: ", argv[0]);
- (void) perror(_("Error writing 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 +270,13 @@ _("%s: usage is %s [ --version ] [ -v ] [ -c cutoff ] zonename ...\n"),
continue;
}
+static void
+usage(void)
+{
+ fprintf(stderr, _("usage: zdump [-v] [-c cutoff] zonename ...\n"));
+ exit(EXIT_FAILURE);
+}
+
static time_t
hunt(name, lot, hit)
char * name;
diff --git a/usr.sbin/zic/zdump/Makefile b/usr.sbin/zic/zdump/Makefile
new file mode 100644
index 0000000..127946f
--- /dev/null
+++ b/usr.sbin/zic/zdump/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/..
+
+PROG= zdump
+MAN= ${.CURDIR}/../zdump.8
+SRCS= zdump.c ialloc.c scheck.c
+
+CFLAGS+= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DSTD_INSPIRED -DPCTS
+CFLAGS+= -DHAVE_LONG_DOUBLE -DTZDIR=\"/usr/share/zoneinfo\" -Demkdir=mkdir
+CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../lib/libc/stdtime
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/zic/zic.8 b/usr.sbin/zic/zic.8
index 86b1354..5355c80 100644
--- a/usr.sbin/zic/zic.8
+++ b/usr.sbin/zic/zic.8
@@ -1,103 +1,109 @@
-.TH ZIC 8
-.SH NAME
-zic \- time zone compiler
-.SH SYNOPSIS
-.B zic
-[
-.B \-\-version
-]
-[
-.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
-reads text from the file(s) named on the command line
+.\" $FreeBSD$
+.Dd October 29, 1997
+.Dt ZIC 8
+.Os
+.Sh NAME
+.Nm zic
+.Nd timezone compiler
+.Sh SYNOPSIS
+.Nm
+.Op Fl Dsv
+.Op Fl d Ar directory
+.Op Fl g Ar group
+.Op Fl L Ar leapsecondfilename
+.Op Fl l Ar localtime
+.Op Fl m Ar mode
+.Op Fl p Ar posixrules
+.Op Fl u Ar user
+.Op Fl y Ar command
+.Op Ar filename ...
+.Sh DESCRIPTION
+The
+.Nm
+utility 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 "\-\-version"
-Output version information and exit.
-.TP
-.BI "\-d " directory
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl D
+Do not automatically create directories. If the input file(s) specify
+an output file in a directory which does not already exist, the
+default behavior is to attempt to create the directory. If
+.Fl D
+is specified,
+.Nm
+will instead error out immediately.
+.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
-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
-time zone environment variables.
-.I 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 g Ar group
+After creating each output file, change its group ownership to the
+specified
+.Ar group
+(which can be either a name or a numeric group ID).
+.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 l Ar timezone
+Use the given
+.Ar time zone
+as local time.
+The
+.Nm
+utility will act as if the input contained a link line of the form
+.Bd -literal -offset indent
+.No "Link timezone localtime
+.Ed
+(Note that this action has no effect on
+.Fx ,
+since the local time zone is specified in
+.Pa /etc/localtime
+and not
+.Pa /usr/share/zoneinfo/localtime . )
+.It Fl m Ar mode
+After creating each output file, change its access mode to
+.Ar mode .
+Both numeric and alphabetic modes are accepted
+(see
+.Xr chmod 1 ) .
+.It Fl p Ar timezone
+Use the given
+.Ar "time zone" Ns 's
+rules when handling POSIX-format
+time zone environment variables.
+The
+.Nm
+utility will act as if the input contained a link line of the form
+.Bd -literal -offset indent
+.No "Link timezone posixrules
+.Ed
+.It Fl u Ar user
+After creating each output file, change its owner to
+.Ar user
+(which can be either a name or a numeric user ID).
+.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 3
values.
-Also complain if a time of 24:00
-(which cannot be handled by pre-1998 versions of
-.IR zic )
-appears in the input.
-.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.
@@ -108,210 +114,182 @@ 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
-A rule line has the form
-.nf
-.ti +.5i
-.ta \w'Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'TYPE\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u
-.sp
-Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-.sp
+.Pp
+A rule line has the form:
+.Dl "Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
For example:
-.ti +.5i
-.sp
-Rule US 1967 1973 \- Apr lastSun 2:00 1:00 D
-.sp
-.fi
+.Dl "Rule US 1967 1973 \- Apr lastSun 2:00 1:00 D
+.Pp
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 "LETTER/S" -offset 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
-.br
+.Li yearistype Ar year Ar type
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
-.sp
-.ta \w'Sun<=25\0\0'u
-5 the fifth of the month
-lastSun the last Sunday in the month
-lastMon the last Monday in the month
-Sun>=8 first Sunday on or after the eighth
-Sun<=25 last Sunday on or before the 25th
-.fi
-.in -.5i
-.sp
+.Pp
+.Bl -tag -width lastSun -compact -offset indent
+.It \&5
+the fifth of the month
+.It lastSun
+the last Sunday in the month
+.It lastMon
+the last Monday in the month
+.It Sun>=8
+first Sunday on or after the eighth
+.It Sun<=25
+last Sunday on or before the 25th
+.El
+.Pp
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
-.sp
-.ta \w'1:28:13\0\0'u
-2 time in hours
-2:00 time in hours and minutes
-15:00 24-hour format time (for times after noon)
-1:28:14 time in hours, minutes, and seconds
-\- equivalent to 0
-.fi
-.in -.5i
-.sp
+.Pp
+.Bl -tag -width "\&1:28:14" -offset indent -compact
+.It 2
+time in hours
+.It 2:00
+time in hours and minutes
+.It 15:00
+24-hour format time (for times after noon)
+.It 1:28:14
+time in hours, minutes, and seconds
+.El
+.Pp
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
+.Sq Li w
if the given time is local
-.q "wall clock"
+.Dq "wall clock"
time,
-.B s
+.Sq Li s
if the given time is local
-.q standard
+.Dq standard
time, or
-.B u
+.Sq Li u
(or
-.B g
+.Sq Li g
or
-.BR z )
+.Sq Li 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
+.Sq Li w
and
-.B s
+.Sq Li 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
-A zone line has the form
-.sp
-.nf
-.ti +.5i
-.ta \w'Zone\0\0'u +\w'Australia/Adelaide\0\0'u +\w'GMTOFF\0\0'u +\w'RULES/SAVE\0\0'u +\w'FORMAT\0\0'u
-Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
-.sp
+.El
+.Pp
+A zone line has the form:
+.Dl "Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
For example:
-.sp
-.ti +.5i
-Zone Australia/Adelaide 9:30 Aus CST 1971 Oct 31 2:00
-.sp
-.fi
+.Dl "Zone Australia/Adelaide 9:30 Aus CST 1971 Oct 31 2:00
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
+.It GMTOFF
The amount of time to add to UTC 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
+.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
+.It UNTIL
The time at which the UTC 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,
@@ -320,74 +298,57 @@ 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
-.ti +.5i
-.ta \w'Link\0\0'u +\w'Europe/Istanbul\0\0'u
-Link LINK-FROM LINK-TO
-.sp
+.Dl "Link LINK-FROM LINK-TO
For example:
-.sp
-.ti +.5i
-Link Europe/Istanbul Asia/Istanbul
-.sp
-.fi
+.Dl "Link Europe/Istanbul Asia/Istanbul
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
-.ta \w'Leap\0\0'u +\w'YEAR\0\0'u +\w'MONTH\0\0'u +\w'DAY\0\0'u +\w'HH:MM:SS\0\0'u +\w'CORR\0\0'u
-.sp
-Leap YEAR MONTH DAY HH:MM:SS CORR R/S
-.sp
+.Dl "Leap YEAR MONTH DAY HH:MM:SS CORR R/S
For example:
-.ti +.5i
-.sp
-Leap 1974 Dec 31 23:59:60 + S
-.sp
-.fi
+.Dl "Leap 1974 Dec 31 23:59:60 + S
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.
@@ -401,24 +362,29 @@ 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
+.Dq Stationary
if the leap second time given by the other fields should be interpreted as UTC
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.22
+.Sh FILES
+.Bl -tag -width /usr/share/zoneinfo -compact
+.It /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.18
diff --git a/usr.sbin/zic/zic.c b/usr.sbin/zic/zic.c
index 1a046ff..5492648 100644
--- a/usr.sbin/zic/zic.c
+++ b/usr.sbin/zic/zic.c
@@ -1,23 +1,27 @@
-static char elsieid[] = "@(#)zic.c 7.116";
+#ifndef lint
+#ifndef NOID
+static const char elsieid[] = "@(#)zic.c 7.96";
+#endif /* !defined NOID */
+#endif /* !defined lint */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
#include "private.h"
-#include "locale.h"
#include "tzfile.h"
-
-#if HAVE_SYS_STAT_H
-#include "sys/stat.h"
-#endif
-#ifdef S_IRUSR
-#define MKDIR_UMASK (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
-#else
-#define MKDIR_UMASK 0755
-#endif
+#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
** only if isascii(C) || C == EOF. Modern hosts obey the C Standard,
** which says they are defined only if C == ((unsigned char) C) || C == EOF.
-** Neither the C Standard nor Posix require that `isascii' exist.
+** Neither the C Standard nor POSIX require that `isascii' exist.
** For portability, we check both ancient and modern requirements.
** If isascii is not defined, the isascii check succeeds trivially.
*/
@@ -79,12 +83,6 @@ struct zone {
time_t z_untiltime;
};
-extern int getopt P((int argc, char * const argv[],
- const char * options));
-extern int link P((const char * fromname, const char * toname));
-extern char * optarg;
-extern int optind;
-
static void addtt P((time_t starttime, int type));
static int addtype P((long gmtoff, const char * abbr, int isdst,
int ttisstd, int ttisgmt));
@@ -127,6 +125,8 @@ static void rulesub P((struct rule * rp,
const char * typep, const char * monthp,
const char * dayp, const char * timep));
static void setboundaries P((void));
+static void setgroup P((gid_t *flag, const char *name));
+static void setuser P((uid_t *flag, const char *name));
static time_t tadd P((time_t t1, long t2));
static void usage P((void));
static void writezone P((const char * name));
@@ -150,7 +150,6 @@ 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;
@@ -355,13 +354,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;
}
@@ -442,8 +436,9 @@ const char * const string;
static void
usage P((void))
{
- (void) fprintf(stderr, _("%s: usage is %s [ --version ] [ -s ] [ -v ] [ -l localtime ] [ -p posixrules ] \\\n\t[ -d directory ] [ -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);
}
@@ -453,6 +448,11 @@ static const char * directory;
static const char * leapsec;
static const char * yitcommand;
static int sflag = FALSE;
+static int Dflag;
+static uid_t uflag = (uid_t)-1;
+static gid_t gflag = (gid_t)-1;
+static mode_t mflag = (S_IRUSR | S_IRGRP | S_IROTH
+ | S_IWUSR);
int
main(argc, argv)
@@ -473,65 +473,63 @@ char * argv[];
#endif /* defined TEXTDOMAINDIR */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
- progname = argv[0];
- for (i = 1; i < argc; ++i)
- if (strcmp(argv[i], "--version") == 0) {
- (void) printf("%s\n", elsieid);
- (void) exit(EXIT_SUCCESS);
- }
- while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF && c != -1)
+ while ((c = getopt(argc, argv, "Dd:g:l:m:p:L:u:vsy:")) != -1)
switch (c) {
default:
usage();
+ case 'D':
+ Dflag = 1;
+ break;
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 'g':
+ setgroup(&gflag, optarg);
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 'm':
+ {
+ void *set = setmode(optarg);
+ if (set == NULL)
+ errx(EXIT_FAILURE,
+_("invalid file mode"));
+ getmode(set, mflag);
+ free(set);
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 'u':
+ setuser(&uflag, optarg);
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;
@@ -570,18 +568,12 @@ _("%s: More than one -L option specified\n"),
/*
** Make links.
*/
- for (i = 0; i < nlinks; ++i) {
- eat(links[i].l_filename, links[i].l_linenum);
+ for (i = 0; i < nlinks; ++i)
dolink(links[i].l_from, links[i].l_to);
- }
- if (lcltime != NULL) {
- eat("command line", 1);
+ if (lcltime != NULL)
dolink(lcltime, TZDEFAULT);
- }
- if (psxrules != NULL) {
- eat("command line", 1);
+ if (psxrules != NULL)
dolink(psxrules, TZDEFRULES);
- }
return (errors == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
@@ -618,31 +610,17 @@ const char * const tofile;
if (mkdirs(toname) != 0)
(void) exit(EXIT_FAILURE);
-
result = link(fromname, toname);
-#if (HAVE_SYMLINK - 0)
- if (result != 0 &&
- access(fromname, F_OK) == 0 &&
- !itsdir(fromname)) {
- const char *s = tofile;
- register char * symlinkcontents = NULL;
- while ((s = strchr(s+1, '/')) != NULL)
- symlinkcontents = ecatalloc(symlinkcontents, "../");
- symlinkcontents = ecatalloc(symlinkcontents, fromfile);
-
- result = symlink(symlinkcontents, toname);
+#if (HAVE_SYMLINK - 0)
+ if (result != 0) {
+ result = symlink(fromname, toname);
if (result == 0)
warning(_("hard link failed, symbolic link used"));
- ifree(symlinkcontents);
}
#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);
+ err(EXIT_FAILURE, _("can't link from %s to %s"),
+ fromname, toname);
}
}
ifree(fromname);
@@ -811,13 +789,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);
@@ -860,33 +833,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"));
}
@@ -931,8 +893,6 @@ const int signable;
error(errstring);
return 0;
}
- if (noise && hh == HOURSPERDAY)
- warning(_("24:00 not handled by pre-1998 versions of zic"));
return eitol(sign) *
(eitol(hh * MINSPERHOUR + mm) *
eitol(SECSPERMIN) + eitol(ss));
@@ -1157,15 +1117,14 @@ const int nfields;
error(_("time before zero"));
return;
}
- if (dayoff < min_time / SECSPERDAY) {
- error(_("time too small"));
- return;
- }
- if (dayoff > max_time / SECSPERDAY) {
- error(_("time too large"));
+ t = (time_t) dayoff * SECSPERDAY;
+ /*
+ ** Cheap overflow check.
+ */
+ if (t / SECSPERDAY != dayoff) {
+ error(_("time overflow"));
return;
}
- t = (time_t) dayoff * SECSPERDAY;
tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
cp = fields[LP_CORR];
{
@@ -1284,10 +1243,8 @@ 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;
@@ -1309,18 +1266,16 @@ 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(_("ending year too low to be represented"));
+ warning(_("starting year too low to be represented"));
else if (rp->r_loyear > max_year_representable)
- warning(_("ending year too high to be represented"));
+ warning(_("starting year too high to be represented"));
}
if (rp->r_loyear > rp->r_hiyear) {
error(_("starting year greater than ending year"));
@@ -1476,26 +1431,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);
@@ -1557,11 +1504,15 @@ 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);
+ if (chmod(fullname, mflag) < 0)
+ err(EXIT_FAILURE, _("cannot change mode of %s to %03o"),
+ fullname, (unsigned)mflag);
+ if ((uflag != (uid_t)-1 || gflag != (gid_t)-1)
+ && chown(fullname, uflag, gflag) < 0)
+ err(EXIT_FAILURE, _("cannot change ownership of %s"),
+ fullname);
}
static void
@@ -1611,16 +1562,16 @@ const int zonecount;
typecnt = 0;
charcnt = 0;
/*
+ ** A guess that may well be corrected later.
+ */
+ stdoff = 0;
+ /*
** Thanks to Earl Chew (earl@dnd.icp.nec.com.au)
** for noting the need to unconditionally initialize startttisstd.
*/
startttisstd = FALSE;
startttisgmt = FALSE;
for (i = 0; i < zonecount; ++i) {
- /*
- ** A guess that may well be corrected later.
- */
- stdoff = 0;
zp = &zpfirst[i];
usestart = i > 0 && (zp - 1)->z_untiltime > min_time;
useuntil = i < (zonecount - 1);
@@ -1640,7 +1591,8 @@ const int zonecount;
if (usestart) {
addtt(starttime, type);
usestart = FALSE;
- } else if (stdoff != 0)
+ }
+ else if (stdoff != 0)
addtt(min_time, type);
} else for (year = min_year; year <= max_year; ++year) {
if (useuntil && year > zp->z_untilrule.r_hiyear)
@@ -1917,15 +1869,12 @@ const char * const type;
buf = erealloc(buf, (int) (132 + strlen(yitcommand) + strlen(type)));
(void) sprintf(buf, "%s %d %s", yitcommand, year, type);
result = system(buf);
- if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
- case 0:
- return TRUE;
- case 1:
- return FALSE;
- }
- error(_("Wild result from command execution"));
- (void) fprintf(stderr, _("%s: command was '%s', result was %d\n"),
- progname, buf, result);
+ if (result == 0)
+ return TRUE;
+ if (result == (1 << 8))
+ return FALSE;
+ error(_("wild result from command execution"));
+ warnx(_("command was '%s', result was %d"), buf, result);
for ( ; ; )
(void) exit(EXIT_FAILURE);
}
@@ -2019,7 +1968,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))
@@ -2139,17 +2088,18 @@ register const int wantedy;
--i;
}
if (i < 0 || i >= len_months[isleap(y)][m]) {
- if (noise)
- warning(_("rule goes past start/end of month--will not work with pre-2004 versions of zic"));
+ error(_("no day in month matches rule"));
+ (void) exit(EXIT_FAILURE);
}
}
if (dayoff < 0 && !TYPE_SIGNED(time_t))
return min_time;
- if (dayoff < min_time / SECSPERDAY)
- return min_time;
- if (dayoff > max_time / SECSPERDAY)
- return max_time;
t = (time_t) dayoff * SECSPERDAY;
+ /*
+ ** Cheap overflow check.
+ */
+ if (t / SECSPERDAY != dayoff)
+ return (dayoff > 0) ? max_time : min_time;
return tadd(t, rp->r_tod);
}
@@ -2175,7 +2125,7 @@ char * const argname;
register char * name;
register char * cp;
- if (argname == NULL || *argname == '\0')
+ if (argname == NULL || *argname == '\0' || Dflag)
return 0;
cp = name = ecpyalloc(argname);
while ((cp = strchr(cp + 1, '/')) != 0) {
@@ -2197,16 +2147,13 @@ char * const argname;
** created by some other multiprocessor, so we get
** to do extra checking.
*/
- if (mkdir(name, MKDIR_UMASK) != 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, (S_IRUSR | S_IWUSR | S_IXUSR
+ | S_IRGRP | S_IXGRP | S_IROTH
+ | S_IXOTH)) != 0
+ && (errno != EEXIST || !itsdir(name))) {
+ warn(_("can't create directory %s"), name);
+ ifree(name);
+ return -1;
}
}
*cp = '/';
@@ -2222,15 +2169,64 @@ 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;
}
+#include <grp.h>
+#include <pwd.h>
+
+static void
+setgroup(flag, name)
+ gid_t *flag;
+ const char *name;
+{
+ struct group *gr;
+
+ if (*flag != (gid_t)-1)
+ errx(EXIT_FAILURE, _("multiple -g flags specified"));
+
+ gr = getgrnam(name);
+ if (gr == 0) {
+ char *ep;
+ unsigned long ul;
+
+ ul = strtoul(name, &ep, 10);
+ if (ul == (unsigned long)(gid_t)ul && *ep == '\0') {
+ *flag = ul;
+ return;
+ }
+ errx(EXIT_FAILURE, _("group `%s' not found"), name);
+ }
+ *flag = gr->gr_gid;
+}
+
+static void
+setuser(flag, name)
+ uid_t *flag;
+ const char *name;
+{
+ struct passwd *pw;
+
+ if (*flag != (gid_t)-1)
+ errx(EXIT_FAILURE, _("multiple -u flags specified"));
+
+ pw = getpwnam(name);
+ if (pw == 0) {
+ char *ep;
+ unsigned long ul;
+
+ ul = strtoul(name, &ep, 10);
+ if (ul == (unsigned long)(gid_t)ul && *ep == '\0') {
+ *flag = ul;
+ return;
+ }
+ errx(EXIT_FAILURE, _("user `%s' not found"), name);
+ }
+ *flag = pw->pw_uid;
+}
+
/*
-** UNIX was a registered trademark of The Open Group in 2003.
+** UNIX was a registered trademark of UNIX System Laboratories in 1993.
*/
diff --git a/usr.sbin/zic/zic/Makefile b/usr.sbin/zic/zic/Makefile
new file mode 100644
index 0000000..c98799cf
--- /dev/null
+++ b/usr.sbin/zic/zic/Makefile
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/..
+
+PROG= zic
+MAN= ${.CURDIR}/../zic.8
+SRCS= zic.c ialloc.c scheck.c
+
+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
+CFLAGS+= -I${.CURDIR}/.. -I${.CURDIR}/../../../lib/libc/stdtime
+
+.include <bsd.prog.mk>
OpenPOWER on IntegriCloud