summaryrefslogtreecommitdiffstats
path: root/usr.sbin/zic
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-10-29 07:27:56 +0000
committercharnier <charnier@FreeBSD.org>1997-10-29 07:27:56 +0000
commitcf8568c7a3da5d6adf1faed18886c40964858f55 (patch)
tree0e3e5cdf8720ae1a90e188a77da28c39e8db0d27 /usr.sbin/zic
parent2d829ec20ed9845c666bfe74ba4fd6f856ce682d (diff)
downloadFreeBSD-src-cf8568c7a3da5d6adf1faed18886c40964858f55.zip
FreeBSD-src-cf8568c7a3da5d6adf1faed18886c40964858f55.tar.gz
Use err(3). Rewrote man page using mdoc format.
Diffstat (limited to 'usr.sbin/zic')
-rw-r--r--usr.sbin/zic/ialloc.c5
-rw-r--r--usr.sbin/zic/scheck.c5
-rw-r--r--usr.sbin/zic/zdump.c51
-rw-r--r--usr.sbin/zic/zic.8269
-rw-r--r--usr.sbin/zic/zic.c167
5 files changed, 214 insertions, 283 deletions
diff --git a/usr.sbin/zic/ialloc.c b/usr.sbin/zic/ialloc.c
index 5631947..2fd76c3 100644
--- a/usr.sbin/zic/ialloc.c
+++ b/usr.sbin/zic/ialloc.c
@@ -4,6 +4,11 @@ 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"
diff --git a/usr.sbin/zic/scheck.c b/usr.sbin/zic/scheck.c
index 64f2507..313068d 100644
--- a/usr.sbin/zic/scheck.c
+++ b/usr.sbin/zic/scheck.c
@@ -4,6 +4,11 @@ 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"
diff --git a/usr.sbin/zic/zdump.c b/usr.sbin/zic/zdump.c
index 1058a84..096f862 100644
--- a/usr.sbin/zic/zdump.c
+++ b/usr.sbin/zic/zdump.c
@@ -4,17 +4,24 @@ 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
@@ -112,18 +119,14 @@ static char elsieid[] = "@(#)zdump.c 7.24";
#endif /* !defined TZ_DOMAIN */
extern char ** environ;
-extern int getopt();
-extern char * optarg;
-extern int optind;
-extern time_t time();
extern char * tzname[2];
static char * abbr();
static long delta();
static time_t hunt();
static int longest;
-static char * progname;
static void show();
+static void usage __P((void));
int
main(argc, argv)
@@ -152,7 +155,6 @@ 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')
@@ -161,10 +163,7 @@ char * argv[];
else cutoff = optarg;
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;
@@ -192,10 +191,9 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"),
sizeof *fakeenv));
if (fakeenv == NULL ||
(fakeenv[0] = (char *) malloc((size_t) (longest +
- 4))) == NULL) {
- (void) perror(progname);
- (void) exit(EXIT_FAILURE);
- }
+ 4))) == NULL)
+ errx(EXIT_FAILURE,
+ _("malloc() failed"));
to = 0;
(void) strcpy(fakeenv[to++], "TZ=");
for (from = 0; environ[from] != NULL; ++from)
@@ -254,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 standard output "),
- 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 */
@@ -267,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;
diff --git a/usr.sbin/zic/zic.8 b/usr.sbin/zic/zic.8
index 1cd773e..7491e7a 100644
--- a/usr.sbin/zic/zic.8
+++ b/usr.sbin/zic/zic.8
@@ -1,93 +1,74 @@
-.TH ZIC 8
-.SH NAME
-zic \- timezone 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
@@ -206,37 +181,35 @@ Recognized forms include:
.in -.5i
.sp
Any of these forms may be followed by the letter
-.B w
+.Em w
if the given time is local
.q "wall clock"
time,
-.B s
+.Em s
if the given time is local
.q 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
+.It LETTER/S
+Give the
.q "variable part"
(for example, the
.q S
@@ -248,9 +221,10 @@ or
.q 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
@@ -265,46 +239,42 @@ 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
+.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 GMT.
-.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"
of the time zone abbreviation goes.
Alternately,
a slash (/)
separates standard and daylight abbreviations.
-.TP
-.B UNTIL
+.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 GMT offset
and rule change until the time specified.
-.IP
+.Pp
The next line must be a
.q continuation
line; this has the same form as a zone line except that the
@@ -312,13 +282,14 @@ string
.q 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
@@ -333,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
@@ -358,14 +329,14 @@ 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 +
@@ -385,7 +356,7 @@ 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
@@ -395,14 +366,18 @@ or
.q 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
+.Sh FILE
+.Bl -tag -width /usr/share/zoneinfo -compact
/usr/share/zoneinfo standard directory used for created files
-.SH "SEE ALSO"
-ctime(3), tzfile(5), zdump(8)
+.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 85e4eb9..89866ba 100644
--- a/usr.sbin/zic/zic.c
+++ b/usr.sbin/zic/zic.c
@@ -4,9 +4,15 @@ 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"
+#include <err.h>
+#include <locale.h>
#include <sys/stat.h> /* for umask manifest constants */
#include <sys/types.h>
#include <unistd.h>
@@ -152,7 +158,6 @@ static int min_year;
static int noise;
static const char * rfilename;
static int rlinenum;
-static const char * progname;
static int timecnt;
static int typecnt;
@@ -357,12 +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;
}
@@ -444,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);
}
@@ -475,7 +477,6 @@ 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:")) != -1)
switch (c) {
default:
@@ -483,52 +484,37 @@ char * argv[];
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;
@@ -607,13 +593,9 @@ const char * const tofile;
if (link(fromname, toname) != 0) {
if (mkdirs(toname) != 0)
(void) exit(EXIT_FAILURE);
- if (link(fromname, toname) != 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);
@@ -779,12 +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);
@@ -827,32 +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"));
}
@@ -1245,10 +1213,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;
@@ -1265,10 +1231,8 @@ 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;
@@ -1427,22 +1391,14 @@ const char * const name;
/*
* Remove old file, if any, to snap links.
*/
- if (!itsdir(fullname) && remove(fullname) != 0 && errno != ENOENT) {
- const char *e = strerror(errno);
- (void) fprintf(stderr, _("%s: Can't remove %s: %s\n"),
- progname, fullname, e);
- (void) exit(EXIT_FAILURE);
- }
+ if (!itsdir(fullname) && remove(fullname) != 0 && errno != ENOENT)
+ err(EXIT_FAILURE, _("can't remove %s"), fullname);
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);
@@ -1502,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
@@ -1853,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);
}
@@ -1948,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))
@@ -2125,10 +2077,7 @@ char * const argname;
** It doesn't seem to exist, so we try to create it.
*/
if (mkdir(name, 0755) != 0) {
- const char *e = strerror(errno);
- (void) fprintf(stderr,
- _("%s: Can't create directory %s: %s\n"),
- progname, name, e);
+ warn(_("can't create directory %s"), name);
ifree(name);
return -1;
}
@@ -2146,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;
}
OpenPOWER on IntegriCloud