diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-26 09:55:03 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-26 09:55:03 +0000 |
commit | a01e385976f6f0702683f355e990143e755fa7be (patch) | |
tree | 1e1e757a582cb4cfade4b2269bd620ab501458ae /usr.sbin/dvmrpctl/parser.c | |
parent | 84979f88d4e0950e98cd9f0f3e8658553f0725a3 (diff) |
Sync with ospfctl/bgpctl: correctly detect missing arguments. OK norby@
Diffstat (limited to 'usr.sbin/dvmrpctl/parser.c')
-rw-r--r-- | usr.sbin/dvmrpctl/parser.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/dvmrpctl/parser.c b/usr.sbin/dvmrpctl/parser.c index 50724f0a45f..c12f9364f0d 100644 --- a/usr.sbin/dvmrpctl/parser.c +++ b/usr.sbin/dvmrpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.1 2006/06/01 14:21:28 norby Exp $ */ +/* $OpenBSD: parser.c,v 1.2 2007/01/26 09:55:02 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -108,7 +108,7 @@ parse(int argc, char *argv[]) bzero(&res, sizeof(res)); - while (argc > 0) { + while (argc >= 0) { if ((match = match_token(argv[0], table)) == NULL) { fprintf(stderr, "valid commands/args:\n"); show_valid_args(table); @@ -200,9 +200,11 @@ match_token(const char *word, const struct token table[]) } if (match != 1) { - if (match > 1) + if (word == NULL) + fprintf(stderr, "missing argument:\n"); + else if (match > 1) fprintf(stderr, "ambiguous argument: %s\n", word); - if (match < 1) + else if (match < 1) fprintf(stderr, "unknown argument: %s\n", word); return (NULL); } |