summaryrefslogtreecommitdiffstats
path: root/usr.bin/uniq/uniq.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-05-30 00:07:14 +0000
committertjr <tjr@FreeBSD.org>2002-05-30 00:07:14 +0000
commit60d1ab01d7d0344f0d2313c5eb05bfa76b9c8f15 (patch)
treeeb37c045d97e5fb55348fdce816bda92e6f5d3cf /usr.bin/uniq/uniq.c
parent2d9a2285efeefa07b1e51441cecaadce92de9af1 (diff)
downloadFreeBSD-src-60d1ab01d7d0344f0d2313c5eb05bfa76b9c8f15.zip
FreeBSD-src-60d1ab01d7d0344f0d2313c5eb05bfa76b9c8f15.tar.gz
Accept an input file name of "-" to mean standard input, as required by
P1003.2.
Diffstat (limited to 'usr.bin/uniq/uniq.c')
-rw-r--r--usr.bin/uniq/uniq.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 2d2b980..98f9eda 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -122,22 +122,15 @@ main (argc, argv)
} else if (!dflag && !uflag)
dflag = uflag = 1;
- switch(argc) {
- case 0:
- ifp = stdin;
- ofp = stdout;
- break;
- case 1:
- ifp = file(argv[0], "r");
- ofp = stdout;
- break;
- case 2:
+ if (argc > 2)
+ usage();
+
+ ifp = stdin;
+ ofp = stdout;
+ if (argc > 0 && strcmp(argv[0], "-") != 0)
ifp = file(argv[0], "r");
+ if (argc > 1)
ofp = file(argv[1], "w");
- break;
- default:
- usage();
- }
prevline = malloc(MAXLINELEN);
thisline = malloc(MAXLINELEN);
OpenPOWER on IntegriCloud