]> Kevux Git Server - rit/commitdiff
parse-options: add parse_options_concat() to concat options
authorJunio C Hamano <gitster@pobox.com>
Sat, 6 Mar 2010 20:34:40 +0000 (21:34 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Mar 2010 07:58:33 +0000 (23:58 -0800)
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
parse-options.h

index c83035d..8546d85 100644 (file)
@@ -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;
+}
index 9429f7e..7581e93 100644 (file)
@@ -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);