summaryrefslogtreecommitdiffstats
path: root/usr.bin/lam
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-06-27 21:01:32 +0000
committerjmallett <jmallett@FreeBSD.org>2002-06-27 21:01:32 +0000
commit3e36f9e3d98e954aef3b51154a07c7484a5c5557 (patch)
treebcabeb7e1970cf67e2364956a45636ff74a8fe1b /usr.bin/lam
parent70c2bebb2731d25bb7b981f6274d4c0bada74f81 (diff)
downloadFreeBSD-src-3e36f9e3d98e954aef3b51154a07c7484a5c5557.zip
FreeBSD-src-3e36f9e3d98e954aef3b51154a07c7484a5c5557.tar.gz
Instead of not using argc and doing other great evil, check for no arguments
in main() and print usage, or if there are too many arguments, handle that there, too.
Diffstat (limited to 'usr.bin/lam')
-rw-r--r--usr.bin/lam/lam.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/lam/lam.c b/usr.bin/lam/lam.c
index ddccc7c..8a65a8d 100644
--- a/usr.bin/lam/lam.c
+++ b/usr.bin/lam/lam.c
@@ -79,13 +79,16 @@ static char *pad(struct openfile *);
static void usage(void);
int
-main(int argc __unused, char *argv[])
+main(int argc, char *argv[])
{
struct openfile *ip;
- getargs(argv);
- if (!morefiles)
+ if (argc > MAXOFILES)
+ errx(1, "too many input files");
+ else if (argc == 1)
usage();
+
+ getargs(argv);
for (;;) {
linep = line;
for (ip = input; ip->fp != NULL; ip++)
@@ -111,8 +114,6 @@ getargs(char *av[])
P = S = F = T = 0; /* capitalized options */
while ((p = *++av) != NULL) {
if (*p != '-' || !p[1]) {
- if (++morefiles >= MAXOFILES)
- errx(1, "too many input files");
if (*p == '-')
ip->fp = stdin;
else if ((ip->fp = fopen(p, "r")) == NULL) {
OpenPOWER on IntegriCloud