Skip to content

Commit 8b74d75

Browse files
committed
parse-options: add parse_options_concat() to concat options
Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent be2fb16 commit 8b74d75

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

parse-options.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,18 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
659659
*target = unset ? 2 : 1;
660660
return 0;
661661
}
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ extern int parse_options_step(struct parse_opt_ctx_t *ctx,
187187

188188
extern int parse_options_end(struct parse_opt_ctx_t *ctx);
189189

190+
extern int parse_options_concat(struct option *dst, size_t, struct option *src);
190191

191192
/*----- some often used options -----*/
192193
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);

0 commit comments

Comments
 (0)