Skip to content

Commit

Permalink
parse-options: add parse_options_concat() to concat options
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Mar 7, 2010
1 parent be2fb16 commit 8b74d75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions parse-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b74d75

Please sign in to comment.