summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b0b3a8b)
raw | patch | inline | side by side (parent: b0b3a8b)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Wed, 1 Dec 2010 23:32:55 +0000 (17:32 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 7 Dec 2010 22:19:32 +0000 (14:19 -0800) |
Introduce a PARSE_OPT_NON_OPTION state, so parse_option_step()
callers can easily distinguish between non-options and other
reasons for option parsing termination (like "--").
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
callers can easily distinguish between non-options and other
reasons for option parsing termination (like "--").
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c | patch | blob | history | |
parse-options.h | patch | blob | history |
diff --git a/parse-options.c b/parse-options.c
index cd926869166fe28d4c116840be6921de7aa3cbda..42b51ef14514f3c3df454e4b718718a9b58f1612 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
if (parse_nodash_opt(ctx, arg, options) == 0)
continue;
if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
- break;
+ return PARSE_OPT_NON_OPTION;
ctx->out[ctx->cpidx++] = ctx->argv[0];
continue;
}
switch (parse_options_step(&ctx, options, usagestr)) {
case PARSE_OPT_HELP:
exit(129);
+ case PARSE_OPT_NON_OPTION:
case PARSE_OPT_DONE:
break;
default: /* PARSE_OPT_UNKNOWN */
diff --git a/parse-options.h b/parse-options.h
index 470bb33298bbeba6ae650f926d390233d0ee8d9f..3c2ec1d092202ca6468938e09894447baf409808 100644 (file)
--- a/parse-options.h
+++ b/parse-options.h
enum {
PARSE_OPT_HELP = -1,
PARSE_OPT_DONE,
+ PARSE_OPT_NON_OPTION,
PARSE_OPT_UNKNOWN
};