From 93ba78d6f4632ef1c5228965e3edc8c0faf88c1e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 26 May 2020 00:06:52 +0100 Subject: revert(3p/git): Revert merge of git upstream at v2.26.2 This causes cgit to serve error pages, which is undesirable. This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing changes made to f2b211131f2347342dde63975b09cf603149f1a3. --- third_party/git/parse-options-cb.c | 41 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'third_party/git/parse-options-cb.c') diff --git a/third_party/git/parse-options-cb.c b/third_party/git/parse-options-cb.c index a28b55be48dc..1240a8514e04 100644 --- a/third_party/git/parse-options-cb.c +++ b/third_party/git/parse-options-cb.c @@ -159,32 +159,39 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) return 0; } -static size_t parse_options_count(const struct option *opt) -{ - size_t n = 0; - - for (; opt && opt->type != OPTION_END; opt++) - n++; - return n; -} - struct option *parse_options_dup(const struct option *o) { - struct option no_options[] = { OPT_END() }; + struct option *opts; + int nr = 0; - return parse_options_concat(o, no_options); + while (o && o->type != OPTION_END) { + nr++; + o++; + } + + ALLOC_ARRAY(opts, nr + 1); + memcpy(opts, o - nr, sizeof(*o) * nr); + memset(opts + nr, 0, sizeof(*opts)); + opts[nr].type = OPTION_END; + return opts; } -struct option *parse_options_concat(const struct option *a, - const struct option *b) +struct option *parse_options_concat(struct option *a, struct option *b) { struct option *ret; - size_t a_len = parse_options_count(a); - size_t b_len = parse_options_count(b); + size_t i, a_len = 0, b_len = 0; + + for (i = 0; a[i].type != OPTION_END; i++) + a_len++; + for (i = 0; b[i].type != OPTION_END; i++) + b_len++; ALLOC_ARRAY(ret, st_add3(a_len, b_len, 1)); - COPY_ARRAY(ret, a, a_len); - COPY_ARRAY(ret + a_len, b, b_len + 1); /* + 1 for final OPTION_END */ + for (i = 0; i < a_len; i++) + ret[i] = a[i]; + for (i = 0; i < b_len; i++) + ret[a_len + i] = b[i]; + ret[a_len + b_len] = b[b_len]; /* final OPTION_END */ return ret; } -- cgit 1.4.1