aboutsummaryrefslogtreecommitdiff
path: root/argp
diff options
context:
space:
mode:
Diffstat (limited to 'argp')
-rw-r--r--argp/argp-help.c6
-rw-r--r--argp/argp-parse.c10
-rw-r--r--argp/argp.h2
3 files changed, 13 insertions, 5 deletions
diff --git a/argp/argp-help.c b/argp/argp-help.c
index cd54efc..e18ee41 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -1136,7 +1136,7 @@ hol_help (struct hol *hol, const struct argp_state *state,
Mandatory or optional arguments to long options are also mandatory or \
optional for any corresponding short options.");
const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
- state ? state->argp : 0, state);
+ state ? state->root_argp : 0, state);
if (fstr && *fstr)
{
__argp_fmtstream_putc (stream, '\n');
@@ -1316,7 +1316,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
const struct argp_child *child = argp->children;
const char *tdoc = gettext (argp->args_doc), *nl = 0;
const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC,
- state ? state->argp : 0, state);
+ state ? state->root_argp : 0, state);
if (fdoc)
{
@@ -1601,7 +1601,7 @@ __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
if (state && (state->flags & ARGP_LONG_ONLY))
flags |= ARGP_HELP_LONG_ONLY;
- _help (state ? state->argp : 0, state, stream, flags,
+ _help (state ? state->root_argp : 0, state, stream, flags,
state ? state->name : program_invocation_short_name);
if (!state || ! (state->flags & ARGP_NO_EXIT))
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 47a16fa..edc5516 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -526,7 +526,7 @@ parser_init (struct parser *parser, const struct argp *argp,
parser_convert (parser, argp, flags);
memset (&parser->state, 0, sizeof (struct argp_state));
- parser->state.argp = parser->argp;
+ parser->state.root_argp = parser->argp;
parser->state.argc = argc;
parser->state.argv = argv;
parser->state.flags = flags;
@@ -548,6 +548,14 @@ parser_init (struct parser *parser, const struct argp *argp,
if (group->parent)
/* If a child parser, get the initial input value from the parent. */
group->input = group->parent->child_inputs[group->parent_index];
+
+ if (!group->parser
+ && group->argp->children && group->argp->children->argp)
+ /* For the special case where no parsing function is supplied for an
+ argp, propagate its input to its first child, if any (this just
+ makes very simple wrapper argps more convenient). */
+ group->child_inputs[0] = group->input;
+
err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
}
if (err == EBADKEY)
diff --git a/argp/argp.h b/argp/argp.h
index fa09e2a..886742a 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -274,7 +274,7 @@ struct argp_child
struct argp_state
{
/* The top level ARGP being parsed. */
- __const struct argp *argp;
+ __const struct argp *root_argp;
/* The argument vector being parsed. May be modified. */
int argc;