aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/lam/lam.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2002-06-27 21:01:32 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2002-06-27 21:01:32 +0000
commitf63eec78e4c6def9db4bfabbca645118cbb147f9 (patch)
treebcabeb7e1970cf67e2364956a45636ff74a8fe1b /usr.bin/lam/lam.c
parentb3ab54e105daaee03fbeb71f310d655de242fcfe (diff)
downloadsrc-f63eec78e4c6def9db4bfabbca645118cbb147f9.tar.gz
src-f63eec78e4c6def9db4bfabbca645118cbb147f9.zip
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.
Notes
Notes: svn path=/head/; revision=98933
Diffstat (limited to 'usr.bin/lam/lam.c')
-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 ddccc7c0ccc2..8a65a8da43b2 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) {