diff options
author | Taylor Blau <me@ttaylorr.com> | 2022-01-06 20:50:15 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-01-06 23:15:33 +0100 |
commit | 0a6adc26e2efd2dcfb3e65407623287e08989a63 (patch) | |
tree | f1a87d7edb02c89b3bde5d9c88d92619f54f4413 /grep.c | |
parent | grep: extract grep_binexp() from grep_or_expr() (diff) | |
download | git-0a6adc26e2efd2dcfb3e65407623287e08989a63.tar.xz git-0a6adc26e2efd2dcfb3e65407623287e08989a63.zip |
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>
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -619,6 +619,11 @@ static struct grep_expr *grep_or_expr(struct grep_expr *left, struct grep_expr * return grep_binexp(GREP_NODE_OR, left, right); } +static struct grep_expr *grep_and_expr(struct grep_expr *left, struct grep_expr *right) +{ + return grep_binexp(GREP_NODE_AND, left, right); +} + static struct grep_expr *compile_pattern_or(struct grep_pat **); static struct grep_expr *compile_pattern_atom(struct grep_pat **list) { @@ -674,7 +679,7 @@ static struct grep_expr *compile_pattern_not(struct grep_pat **list) static struct grep_expr *compile_pattern_and(struct grep_pat **list) { struct grep_pat *p; - struct grep_expr *x, *y, *z; + struct grep_expr *x, *y; x = compile_pattern_not(list); p = *list; @@ -687,11 +692,7 @@ static struct grep_expr *compile_pattern_and(struct grep_pat **list) y = compile_pattern_and(list); if (!y) die("--and not followed by pattern expression"); - CALLOC_ARRAY(z, 1); - z->node = GREP_NODE_AND; - z->u.binary.left = x; - z->u.binary.right = y; - return z; + return grep_and_expr(x, y); } return x; } |