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>
Junio C Hamano committed
Mar 6, 2010 at 21:34 UTC
8b74d75cd26d28d38d2ff88267585fc308b89cef
2 files changed
+16
parse-options.c
+15
@@ -659,3 +659,18 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
659
*target = unset ? 2 : 1;
660
return 0;
661
}
662
+
663
+int parse_options_concat(struct option *dst, size_t dst_size, struct option *src)
664
+{
665
+ int i, j;
666
+
667
+ for (i = 0; i < dst_size; i++)
668
+ if (dst[i].type == OPTION_END)
669
+ break;
670
+ for (j = 0; i < dst_size; i++, j++) {
671
+ dst[i] = src[j];
672
+ if (src[j].type == OPTION_END)
673
+ return 0;
674
+ }
675
+ return -1;
676
+}
parse-options.h
+1
@@ -187,6 +187,7 @@ extern int parse_options_step(struct parse_opt_ctx_t *ctx,
187
188
extern int parse_options_end(struct parse_opt_ctx_t *ctx);
189
190
+extern int parse_options_concat(struct option *dst, size_t, struct option *src);
191
192
/*----- some often used options -----*/
193
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);