summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-02-19 23:55:15 +0000
committerMiles Bader <miles@gnu.org>1997-02-19 23:55:15 +0000
commitb1f639637563c4c5f3bac70e77fbd223e2d37792 (patch)
tree9421f5ec6e1e4abbba00f47599d1db87fa9461fe /libshouldbeinlibc
parent319a5344567c48784ca5f95c9c9ab51446329ccf (diff)
(parser_convert):
Remove FLAGS argument & use PARSER->state.flags. (parser_init): Set PARSER->state.flags. Don't pass FLAGS argument to parser_convert. Make check whether PARSER has the prog name in argv[0] at the proper place.
Diffstat (limited to 'libshouldbeinlibc')
-rw-r--r--libshouldbeinlibc/argp-parse.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/libshouldbeinlibc/argp-parse.c b/libshouldbeinlibc/argp-parse.c
index 64df2388..721ed327 100644
--- a/libshouldbeinlibc/argp-parse.c
+++ b/libshouldbeinlibc/argp-parse.c
@@ -420,7 +420,7 @@ convert_options (const struct argp *argp,
/* Find the merged set of getopt options, with keys appropiately prefixed. */
static void
-parser_convert (struct parser *parser, const struct argp *argp, int flags)
+parser_convert (struct parser *parser, const struct argp *argp)
{
struct parser_convert_state cvt;
@@ -429,9 +429,9 @@ parser_convert (struct parser *parser, const struct argp *argp, int flags)
cvt.long_end = parser->long_opts;
cvt.child_inputs_end = parser->child_inputs;
- if (flags & ARGP_IN_ORDER)
+ if (parser->state.flags & ARGP_IN_ORDER)
*cvt.short_end++ = '-';
- else if (flags & ARGP_NO_ARGS)
+ else if (parser->state.flags & ARGP_NO_ARGS)
*cvt.short_end++ = '+';
*cvt.short_end = '\0';
@@ -512,25 +512,26 @@ parser_init (struct parser *parser, const struct argp *argp,
if (! parser->storage)
return ENOMEM;
- parser->groups = parser->storage;
- parser->child_inputs = parser->storage + GLEN;
- parser->long_opts = parser->storage + GLEN + CLEN;
- parser->short_opts = parser->storage + GLEN + CLEN + LLEN;
-
- memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *));
- parser_convert (parser, argp, flags);
-
- parser->try_getopt = 1;
-
memset (&parser->state, 0, sizeof (struct argp_state));
parser->state.argp = parser->argp;
parser->state.argc = argc;
parser->state.argv = argv;
+ parser->state.flags = flags;
parser->state.err_stream = stderr;
parser->state.out_stream = stdout;
parser->state.next = 0; /* Tell getopt to initialize. */
parser->state.pstate = parser;
+ parser->groups = parser->storage;
+ parser->child_inputs = parser->storage + GLEN;
+ parser->long_opts = parser->storage + GLEN + CLEN;
+ parser->short_opts = parser->storage + GLEN + CLEN + LLEN;
+
+ memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *));
+ parser_convert (parser, argp);
+
+ parser->try_getopt = 1;
+
/* Call each parser for the first time, giving it a chance to propagate
values to child parsers. */
if (parser->groups < parser->egroup)
@@ -550,12 +551,6 @@ parser_init (struct parser *parser, const struct argp *argp,
if (err)
return err;
- if (parser->state.argv == argv && argv[0])
- /* There's an argv[0]; use it for messages. */
- parser->state.name = argv[0];
- else
- parser->state.name = program_invocation_name;
-
/* Getopt is (currently) non-reentrant. */
LOCK_GETOPT;
@@ -570,6 +565,12 @@ parser_init (struct parser *parser, const struct argp *argp,
else
opterr = 1; /* Print error messages. */
+ if (parser->state.argv == argv && argv[0])
+ /* There's an argv[0]; use it for messages. */
+ parser->state.name = argv[0];
+ else
+ parser->state.name = program_invocation_name;
+
return 0;
}