diff options
author | Miles Bader <miles@gnu.org> | 1996-10-15 03:50:08 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-10-15 03:50:08 +0000 |
commit | b423e668e0b8fa259a42e8bb94a019b78f164bcb (patch) | |
tree | 30fc32c59813981ea671ba5ae78660760fed27b6 | |
parent | f366c776a4d17e225782a5aa0071d917dcc360de (diff) |
(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.
-rw-r--r-- | libshouldbeinlibc/argp-parse.c | 5 |
1 files changed, 4 insertions, 1 deletions
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); |