From d52116fd2cbe84bb6b5e579cc81631bb358597b1 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Fri, 26 Jan 2007 10:04:57 +0000 Subject: Sync with ospfctl/bgpctl: detect missing arguments. OK michele@ --- usr.sbin/ripctl/parser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'usr.sbin') 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 @@ -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); } -- cgit v1.2.3