From b423e668e0b8fa259a42e8bb94a019b78f164bcb Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 15 Oct 1996 03:50:08 +0000 Subject: (argp_parse): Don't consume non-option arguments that aren't recognized by any parser. Allocate enough space for TOP_ARGP's parent list to include the version parser. --- libshouldbeinlibc/argp-parse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libshouldbeinlibc') diff --git a/libshouldbeinlibc/argp-parse.c b/libshouldbeinlibc/argp-parse.c index 73b28f06..ef1df8f0 100644 --- a/libshouldbeinlibc/argp-parse.c +++ b/libshouldbeinlibc/argp-parse.c @@ -325,7 +325,7 @@ argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, if (! (state.flags & ARGP_NO_HELP)) /* Add our own options. */ { - const struct argp **plist = alloca (3 * sizeof (struct argp *)); + const struct argp **plist = alloca (4 * sizeof (struct argp *)); struct argp *top_argp = alloca (sizeof (struct argp)); /* TOP_ARGP has no options, it just serves to group the user & default @@ -596,6 +596,9 @@ argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, err = process_arg (optarg, &arg_ebadkey); else err = process_opt (opt, optarg, &arg_ebadkey); + + if (err == EBADKEY && arg_ebadkey) + state.next--; /* Put back the unused argument. */ } mutex_unlock (&getopt_lock); -- cgit v1.2.3