diff options
author | ru <ru@FreeBSD.org> | 2005-02-23 20:59:03 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-02-23 20:59:03 +0000 |
commit | 0b408ef0dc0d84919f3fa821cf12419a8abfc769 (patch) | |
tree | 9dde2523da3762bccd3a6ca7676529f1dea88178 /games | |
parent | 327b7b9ca4f6f83d923f242e631ef2ee9eb967f3 (diff) | |
download | FreeBSD-src-0b408ef0dc0d84919f3fa821cf12419a8abfc769.zip FreeBSD-src-0b408ef0dc0d84919f3fa821cf12419a8abfc769.tar.gz |
Fixed warnings and bump WARNS to 6.
Diffstat (limited to 'games')
-rw-r--r-- | games/fortune/unstr/Makefile | 2 | ||||
-rw-r--r-- | games/fortune/unstr/unstr.c | 37 |
2 files changed, 14 insertions, 25 deletions
diff --git a/games/fortune/unstr/Makefile b/games/fortune/unstr/Makefile index 6b5b76e..0331e4b 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 <bsd.prog.mk> diff --git a/games/fortune/unstr/unstr.c b/games/fortune/unstr/unstr.c index 9246a8e..25996f4 100644 --- a/games/fortune/unstr/unstr.c +++ b/games/fortune/unstr/unstr.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); # include <sys/endian.h> # include <stdio.h> # include <ctype.h> +# include <err.h> # include <stdlib.h> # include <string.h> # 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; { |