diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-26 10:04:57 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-01-26 10:04:57 +0000 |
commit | d52116fd2cbe84bb6b5e579cc81631bb358597b1 (patch) | |
tree | 527cdad65dc59645fb6fcd19f9b91d5cbce60541 | |
parent | b130d4c2d7cde40e2332fd8dbb2d7112268d050d (diff) |
Sync with ospfctl/bgpctl: detect missing arguments. OK michele@
-rw-r--r-- | usr.sbin/ripctl/parser.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/ripctl/parser.c b/usr.sbin/ripctl/parser.c index f6b18ed1349..da8d5e433d0 100644 --- a/usr.sbin/ripctl/parser.c +++ b/usr.sbin/ripctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.1 2006/10/18 16:15:25 norby Exp $ */ +/* $OpenBSD: parser.c,v 1.2 2007/01/26 10:04:56 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -117,7 +117,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); @@ -209,9 +209,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); } |