From: Junio C Hamano Date: Tue, 28 Apr 2009 07:46:39 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.6.3-rc4~14 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b79376cdf3bd6ee922261776613d085a7b36ffd9;p=git.git Merge branch 'maint' * maint: grep: fix segfault when "git grep '('" is given Documentation: fix a grammatical error in api-builtin.txt builtin-merge: fix a typo in an error message --- b79376cdf3bd6ee922261776613d085a7b36ffd9 diff --cc grep.c index f3a27d7d6,b0d992a6e..04c777a20 --- a/grep.c +++ b/grep.c @@@ -366,23 -380,31 +368,25 @@@ static int match_one_pattern(struct gre return hit; } -static int match_expr_eval(struct grep_opt *o, - struct grep_expr *x, - char *bol, char *eol, - enum grep_context ctx, - int collect_hits) +static int match_expr_eval(struct grep_expr *x, char *bol, char *eol, + enum grep_context ctx, int collect_hits) { int h = 0; + regmatch_t match; + if (!x) + die("Not a valid grep expression"); switch (x->node) { case GREP_NODE_ATOM: - h = match_one_pattern(o, x->u.atom, bol, eol, ctx); + h = match_one_pattern(x->u.atom, bol, eol, ctx, &match, 0); break; case GREP_NODE_NOT: - h = !match_expr_eval(o, x->u.unary, bol, eol, ctx, 0); + h = !match_expr_eval(x->u.unary, bol, eol, ctx, 0); break; case GREP_NODE_AND: - if (!collect_hits) - return (match_expr_eval(o, x->u.binary.left, - bol, eol, ctx, 0) && - match_expr_eval(o, x->u.binary.right, - bol, eol, ctx, 0)); - h = match_expr_eval(o, x->u.binary.left, bol, eol, ctx, 0); - h &= match_expr_eval(o, x->u.binary.right, bol, eol, ctx, 0); + if (!match_expr_eval(x->u.binary.left, bol, eol, ctx, 0)) + return 0; + h = match_expr_eval(x->u.binary.right, bol, eol, ctx, 0); break; case GREP_NODE_OR: if (!collect_hits)