diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-25 19:30:08 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-25 19:30:08 +0000 |
commit | 8fba15145e83aae3f67d3bd544aa5bfd99108970 (patch) | |
tree | 1e7007e7b2d7e8bb053e5544c403fb612421678b /usr.sbin/bgpctl/parser.c | |
parent | aabe59db15cb39a42f27d1427d74f2d201c72303 (diff) |
Correctly detect missing arguments. Same diff as in ospfctl. OK henning@
Diffstat (limited to 'usr.sbin/bgpctl/parser.c')
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 4173804beb8..f07e321f05c 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.34 2006/08/23 08:21:11 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.35 2007/01/25 19:30:07 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -295,7 +295,7 @@ parse(int argc, char *argv[]) bzero(&res, sizeof(res)); TAILQ_INIT(&res.set); - while (argc > 0) { + while (argc >= 0) { if ((match = match_token(argv[0], table)) == NULL) { fprintf(stderr, "valid commands/args:\n"); show_valid_args(table); @@ -461,9 +461,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); } |