projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
/etc/securetty is checked, even when root logins across the net.
[unix-history]
/
usr
/
src
/
usr.bin
/
wc
/
wc.c
diff --git
a/usr/src/usr.bin/wc/wc.c
b/usr/src/usr.bin/wc/wc.c
index
30d6b81
..
227aa95
100644
(file)
--- a/
usr/src/usr.bin/wc/wc.c
+++ b/
usr/src/usr.bin/wc/wc.c
@@
-1,4
+1,4
@@
-static char *sccsid = "@(#)wc.c 4.
1
(Berkeley) %G%";
+static char *sccsid = "@(#)wc.c 4.
5
(Berkeley) %G%";
/* wc line and word count */
#include <stdio.h>
/* wc line and word count */
#include <stdio.h>
@@
-26,6
+26,8
@@
char **argv;
break;
case 's':
lpp = atoi(argv[1]+2);
break;
case 's':
lpp = atoi(argv[1]+2);
+ if (lpp <= 0)
+ goto usage;
break;
case 'v':
verbose++;
break;
case 'v':
verbose++;
@@
-40,7
+42,13
@@
char **argv;
cps = 10;
else
cps = baud / 10;
cps = 10;
else
cps = baud / 10;
+ if (cps <= 0)
+ goto usage;
break;
break;
+ default:
+ usage:
+ fprintf(stderr, "Usage: wc [-lwcpt] [-v] [-u] [-spagesize] [-bbaudrate]\n");
+ exit(1);
}
argc--;
argv++;
}
argc--;
argv++;
@@
-75,7
+83,7
@@
char **argv;
fp = stdin;
do {
if(argc>1 && (fp=fopen(argv[i], "r")) == NULL) {
fp = stdin;
do {
if(argc>1 && (fp=fopen(argv[i], "r")) == NULL) {
-
fprintf(stderr, "wc: can't open %s\n",
argv[i]);
+
perror(
argv[i]);
continue;
}
linect = 0;
continue;
}
linect = 0;
@@
-156,7
+164,7
@@
long num;
if (verbose)
printf("%ld\t", num);
else
if (verbose)
printf("%ld\t", num);
else
- printf("%7ld", num);
+ printf("
%7ld", num);
}
prttime(secs)
}
prttime(secs)
@@
-183,5
+191,8
@@
long secs;
} else {
units = "se";
}
} else {
units = "se";
}
- printf("%4.1f %2s\t", t, units);
+ if (verbose)
+ printf("%4.1f %2s\t", t, units);
+ else
+ printf(" %4.1f %2s", t, units);
}
}