diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-03-06 21:34:40 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-03-06 23:58:33 -0800 |
commit | 8b74d75cd26d28d38d2ff88267585fc308b89cef (patch) | |
tree | d0b59b21dc4085b72381cb901d361546a5d99853 | |
parent | Merge branch 'maint' (diff) | |
download | tgif-8b74d75cd26d28d38d2ff88267585fc308b89cef.tar.xz |
parse-options: add parse_options_concat() to concat options
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | parse-options.c | 15 | ||||
-rw-r--r-- | parse-options.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c index c83035d013..8546d8526f 100644 --- a/parse-options.c +++ b/parse-options.c @@ -659,3 +659,18 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) *target = unset ? 2 : 1; return 0; } + +int parse_options_concat(struct option *dst, size_t dst_size, struct option *src) +{ + int i, j; + + for (i = 0; i < dst_size; i++) + if (dst[i].type == OPTION_END) + break; + for (j = 0; i < dst_size; i++, j++) { + dst[i] = src[j]; + if (src[j].type == OPTION_END) + return 0; + } + return -1; +} diff --git a/parse-options.h b/parse-options.h index 9429f7e361..7581e931da 100644 --- a/parse-options.h +++ b/parse-options.h @@ -187,6 +187,7 @@ extern int parse_options_step(struct parse_opt_ctx_t *ctx, extern int parse_options_end(struct parse_opt_ctx_t *ctx); +extern int parse_options_concat(struct option *dst, size_t, struct option *src); /*----- some often used options -----*/ extern int parse_opt_abbrev_cb(const struct option *, const char *, int); |