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>
This commit is contained in:
parent
be2fb164ec
commit
8b74d75cd2
@ -659,3 +659,18 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
|
|||||||
*target = unset ? 2 : 1;
|
*target = unset ? 2 : 1;
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
@ -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_end(struct parse_opt_ctx_t *ctx);
|
||||||
|
|
||||||
|
extern int parse_options_concat(struct option *dst, size_t, struct option *src);
|
||||||
|
|
||||||
/*----- some often used options -----*/
|
/*----- some often used options -----*/
|
||||||
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
|
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
|
||||||
|
Loading…
Reference in New Issue
Block a user