aboutsummaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorStephen Boyd <bebarino@gmail.com>2009-05-23 11:53:12 -0700
committerJunio C Hamano <gitster@pobox.com>2009-05-25 01:07:25 -0700
commit377829201783b8a648e07af6ce7d747e0f45dc19 (patch)
treefe989294bc3d3c8adb2c6d6b8fb7702be7c23acf /parse-options.c
parent3d09e64ac10aab1ae6ae1ac9cce7a6ebb43f2e50 (diff)
downloadgit-377829201783b8a648e07af6ce7d747e0f45dc19.tar.gz
git-377829201783b8a648e07af6ce7d747e0f45dc19.tar.xz
parse-opts: prepare for OPT_FILENAME
To give OPT_FILENAME the prefix, we pass the prefix to parse_options() which passes the prefix to parse_options_start() which sets the prefix member of parse_opts_ctx accordingly. If there isn't a prefix in the calling context, passing NULL will suffice. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/parse-options.c b/parse-options.c
index 1d25b94c7..be1800d7b 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -285,12 +285,14 @@ static void check_typos(const char *arg, const struct option *options)
}
void parse_options_start(struct parse_opt_ctx_t *ctx,
- int argc, const char **argv, int flags)
+ int argc, const char **argv, const char *prefix,
+ int flags)
{
memset(ctx, 0, sizeof(*ctx));
ctx->argc = argc - 1;
ctx->argv = argv + 1;
ctx->out = argv;
+ ctx->prefix = prefix;
ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
ctx->flags = flags;
if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
@@ -389,12 +391,13 @@ int parse_options_end(struct parse_opt_ctx_t *ctx)
return ctx->cpidx + ctx->argc;
}
-int parse_options(int argc, const char **argv, const struct option *options,
- const char * const usagestr[], int flags)
+int parse_options(int argc, const char **argv, const char *prefix,
+ const struct option *options, const char * const usagestr[],
+ int flags)
{
struct parse_opt_ctx_t ctx;
- parse_options_start(&ctx, argc, argv, flags);
+ parse_options_start(&ctx, argc, argv, prefix, flags);
switch (parse_options_step(&ctx, options, usagestr)) {
case PARSE_OPT_HELP:
exit(129);