summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-10-10 22:42:50 +0000
committerMiles Bader <miles@gnu.org>1995-10-10 22:42:50 +0000
commit91849a9dcb8c3ccf6b721be198f693fbd18ac66c (patch)
tree09c86cf91e3b8d0dec266af15efcf9d07343a311 /libshouldbeinlibc
parent63f2cb4ee262c4c0b642684fcfac96279567700f (diff)
(argp_parse): Add support for ARGP_KEY_NO_ARGS.
Diffstat (limited to 'libshouldbeinlibc')
-rw-r--r--libshouldbeinlibc/argp-parse.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libshouldbeinlibc/argp-parse.c b/libshouldbeinlibc/argp-parse.c
index dd42b72d..e80a8f41 100644
--- a/libshouldbeinlibc/argp-parse.c
+++ b/libshouldbeinlibc/argp-parse.c
@@ -119,7 +119,7 @@ argp_parse (struct argp *argp, int argc, char **argv, unsigned flags,
all the groups of options. */
struct option *long_opts;
/* State block supplied to parsing routines. */
- struct argp_state state = { argp, argc, argv, 0, flags };
+ struct argp_state state = { argp, argc, argv, 0, flags, 0 };
error_t err = 0;
if (! (flags & ARGP_NO_HELP))
@@ -299,6 +299,11 @@ argp_parse (struct argp *argp, int argc, char **argv, unsigned flags,
err = 0;
break;
}
+ else if (state.index >= optind)
+ /* Remember that we successfully processed a non-option
+ argument -- but only if the user hasn't gotten tricky and set
+ the clock back. */
+ state.processed_arg = 1;
}
else if (group == 0)
/* A short option. */
@@ -331,9 +336,12 @@ argp_parse (struct argp *argp, int argc, char **argv, unsigned flags,
if (!err && !state.argv[state.index])
/* We successfully parsed all arguments! Call all the parsers again,
- just one last time... */
+ just a few more times... */
{
int group;
+ if (!state.processed_arg)
+ for (group = 0; group < num_groups && (!err || err == EINVAL); group++)
+ err = (*group_parsers[group])(ARGP_KEY_NO_ARGS, 0, &state);
for (group = 0; group < num_groups && (!err || err == EINVAL); group++)
err = (*group_parsers[group])(ARGP_KEY_END, 0, &state);
if (err == EINVAL)