diff --git a/games/fortune/unstr/Makefile b/games/fortune/unstr/Makefile index 6b5b76ec754d..0331e4bfa2a8 100644 --- a/games/fortune/unstr/Makefile +++ b/games/fortune/unstr/Makefile @@ -3,7 +3,7 @@ PROG= unstr NO_MAN= -WARNS?= 3 +WARNS?= 6 CFLAGS+= -I${.CURDIR}/../strfile .include diff --git a/games/fortune/unstr/unstr.c b/games/fortune/unstr/unstr.c index 9246a8e04d52..25996f4f6b95 100644 --- a/games/fortune/unstr/unstr.c +++ b/games/fortune/unstr/unstr.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); # include # include # include +# include # include # include # include "strfile.h" @@ -75,32 +76,32 @@ char *Infile, /* name of input file */ FILE *Inf, *Dataf; -void getargs(char *[]), order_unstr(STRFILE *); +void order_unstr(STRFILE *); /* ARGSUSED */ int main(int ac, char **av) { static STRFILE tbl; /* description table */ - getargs(av); - if ((Inf = fopen(Infile, "r")) == NULL) { - perror(Infile); - exit(1); - } - if ((Dataf = fopen(Datafile, "r")) == NULL) { - perror(Datafile); + if (ac != 2) { + (void)fprintf(stderr, "usage: unstr datafile\n"); exit(1); } + Infile = av[1]; + (void) strcpy(Datafile, Infile); + (void) strcat(Datafile, ".dat"); + if ((Inf = fopen(Infile, "r")) == NULL) + err(1, "%s", Infile); + if ((Dataf = fopen(Datafile, "r")) == NULL) + err(1, "%s", Datafile); (void) fread((char *) &tbl, sizeof tbl, 1, Dataf); tbl.str_version = be32toh(tbl.str_version); tbl.str_numstr = be32toh(tbl.str_numstr); tbl.str_longlen = be32toh(tbl.str_longlen); tbl.str_shortlen = be32toh(tbl.str_shortlen); tbl.str_flags = be32toh(tbl.str_flags); - if (!(tbl.str_flags & (STR_ORDERED | STR_RANDOM))) { - fprintf(stderr, "nothing to do -- table in file order\n"); - exit(1); - } + if (!(tbl.str_flags & (STR_ORDERED | STR_RANDOM))) + errx(1, "nothing to do -- table in file order"); Delimch = tbl.str_delim; order_unstr(&tbl); (void) fclose(Inf); @@ -108,18 +109,6 @@ int main(int ac, char **av) exit(0); } -void getargs(av) -char *av[]; -{ - if (!*++av) { - (void) fprintf(stderr, "usage: unstr datafile\n"); - exit(1); - } - Infile = *av; - (void) strcpy(Datafile, Infile); - (void) strcat(Datafile, ".dat"); -} - void order_unstr(tbl) STRFILE *tbl; {