grep: use grep_and_expr() in compile_pattern_and()
In a similar spirit as a previous commit, use the new `grep_and_expr()` to construct the AND node in `compile_pattern_and()`. Unlike the aforementioned previous commit, this is not about code duplication, since this is the only spot in grep.c where an AND node is constructed. Rather, this is about visual consistency with the other `compile_pattern_xyz()` functions. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Jan 6, 2022 at 14:50 UTC
0a6adc26e2efd2dcfb3e65407623287e08989a63
1 file changed
+7
-6
grep.c
+7
-6
@@ -619,6 +619,11 @@ static struct grep_expr *grep_or_expr(struct grep_expr *left, struct grep_expr *
619
return grep_binexp(GREP_NODE_OR, left, right);
620
}
621
622
+static struct grep_expr *grep_and_expr(struct grep_expr *left, struct grep_expr *right)
623
+{
624
+ return grep_binexp(GREP_NODE_AND, left, right);
625
+}
626
+
627
static struct grep_expr *compile_pattern_or(struct grep_pat **);
628
static struct grep_expr *compile_pattern_atom(struct grep_pat **list)
629
{
@@ -674,7 +679,7 @@ static struct grep_expr *compile_pattern_not(struct grep_pat **list)
679
static struct grep_expr *compile_pattern_and(struct grep_pat **list)
680
{
681
struct grep_pat *p;
677
- struct grep_expr *x, *y, *z;
682
+ struct grep_expr *x, *y;
683
684
x = compile_pattern_not(list);
685
p = *list;
@@ -687,11 +692,7 @@ static struct grep_expr *compile_pattern_and(struct grep_pat **list)
692
y = compile_pattern_and(list);
693
if (!y)
694
die("--and not followed by pattern expression");
690
- CALLOC_ARRAY(z, 1);
691
- z->node = GREP_NODE_AND;
692
- z->u.binary.left = x;
693
- z->u.binary.right = y;
694
- return z;
695
+ return grep_and_expr(x, y);
696
}
697
return x;
698
}