summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2012-05-20 16:32:54 +0200
committerJunio C Hamano <gitster@pobox.com>2012-05-20 15:12:25 -0700
commit2b3873ff34ff937dad729407da4308be6a5bcd66 (patch)
tree951861c1b68f106e85f1337568ddca76b11c9a68 /grep.c
parentfc456751102ededf8405446e70c228836d390f81 (diff)
downloadgit-2b3873ff34ff937dad729407da4308be6a5bcd66.tar.gz
grep: factor out do_append_grep_pat()
Add do_append_grep_pat() as a shared function for adding patterns to the header pattern list and the general pattern list. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/grep.c b/grep.c
index 2b77c47764..c35a7ce57d 100644
--- a/grep.c
+++ b/grep.c
@@ -18,14 +18,19 @@ static struct grep_pat *create_grep_pat(const char *pat, size_t patlen,
return p;
}
+static void do_append_grep_pat(struct grep_pat ***tail, struct grep_pat *p)
+{
+ **tail = p;
+ *tail = &p->next;
+ p->next = NULL;
+}
+
void append_header_grep_pattern(struct grep_opt *opt,
enum grep_header_field field, const char *pat)
{
struct grep_pat *p = create_grep_pat(pat, strlen(pat), "header", 0,
GREP_PATTERN_HEAD, field);
- *opt->header_tail = p;
- opt->header_tail = &p->next;
- p->next = NULL;
+ do_append_grep_pat(&opt->header_tail, p);
}
void append_grep_pattern(struct grep_opt *opt, const char *pat,
@@ -38,9 +43,7 @@ void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen,
const char *origin, int no, enum grep_pat_token t)
{
struct grep_pat *p = create_grep_pat(pat, patlen, origin, no, t, 0);
- *opt->pattern_tail = p;
- opt->pattern_tail = &p->next;
- p->next = NULL;
+ do_append_grep_pat(&opt->pattern_tail, p);
}
struct grep_opt *grep_opt_dup(const struct grep_opt *opt)