summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc/argp-parse.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-05-01 00:53:34 +0000
committerMiles Bader <miles@gnu.org>1996-05-01 00:53:34 +0000
commit7fbe1c863adcc88d587569794a9300e24935787c (patch)
tree2e174a25b887aa5d78c3324ac7f8354f12f7d309 /libshouldbeinlibc/argp-parse.c
parent1943ccd6e5f29b04e0f7059df6f76be8f82c55d9 (diff)
(argp_parse): Work with ARGP == 0.
Diffstat (limited to 'libshouldbeinlibc/argp-parse.c')
-rw-r--r--libshouldbeinlibc/argp-parse.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libshouldbeinlibc/argp-parse.c b/libshouldbeinlibc/argp-parse.c
index a278c2e3..daae3f28 100644
--- a/libshouldbeinlibc/argp-parse.c
+++ b/libshouldbeinlibc/argp-parse.c
@@ -280,9 +280,10 @@ argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
bzero (top_argp, sizeof (*top_argp));
top_argp->children = plist;
- plist[0] = state.argp;
- plist[1] = &argp_default_argp;
- plist[2] = 0;
+ if (state.argp)
+ *plist++ = state.argp;
+ *plist++ = &argp_default_argp;
+ *plist = 0;
state.argp = top_argp;
}
@@ -422,7 +423,8 @@ argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
return group;
}
- calc_lengths (state.argp);
+ if (state.argp)
+ calc_lengths (state.argp);
short_opts = short_end = alloca (short_len + 1);
if (state.flags & ARGP_IN_ORDER)
@@ -437,12 +439,16 @@ argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
groups = alloca ((num_groups + 1) * sizeof (struct group));
child_inputs = alloca (num_child_inputs * sizeof (void *));
- egroup = convert_options (state.argp, 0, 0, groups);
+ if (state.argp)
+ egroup = convert_options (state.argp, 0, 0, groups);
+ else
+ egroup = groups; /* No parsers at all! */
}
/* Call each parser for the first time, giving it a chance to propagate
values to child parsers. */
- groups->input = input;
+ if (groups < egroup)
+ groups->input = input;
for (group = groups ; group < egroup && (!err || err == EINVAL); group++)
{
if (group->parent)