[hackers] [sbase] uniq: fix argv check || Hiltjo Posthuma
commit 2df86d754fe4b7114e4fa7e2ccb02b16eff1f586
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat Mar 7 13:29:12 2015 +0100
uniq: fix argv check
uniq inputfile failed with "extra argument"
diff --git a/uniq.c b/uniq.c
index 8d145a4..c63b54d 100644
--- a/uniq.c
+++ b/uniq.c
_AT_@ -52,6 +52,9 @@ main(int argc, char *argv[])
usage();
} ARGEND;
+ if (argc > 2)
+ usage();
+
if (argc == 0) {
uniq(stdin, stdout);
} else if (argc >= 1) {
_AT_@ -61,8 +64,7 @@ main(int argc, char *argv[])
if (strcmp(argv[1], "-") &&
!(ofp = fopen(argv[1], "w")))
eprintf("fopen %s:", argv[1]);
- } else
- eprintf("extra argument: %s\n", argv[2]);
+ }
uniq(fp, ofp);
if (fp != stdin)
fclose(fp);
Received on Sun Mar 08 2015 - 12:50:38 CET
This archive was generated by hypermail 2.3.0
: Sun Mar 08 2015 - 13:00:11 CET