From 3753bd1f69d3b17e0369390fb8960ae3b7855b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 22 Mar 2014 18:15:58 +0100 Subject: pickaxe: move pickaxe() after pickaxe_match() pickaxe() calls pickaxe_match(); moving the definition of the former after the latter allows us to do without an explicit function declaration. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- diffcore-pickaxe.c | 79 ++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 41 deletions(-) (limited to 'diffcore-pickaxe.c') diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index cfc4262e4d..827a7d7e76 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -12,47 +12,6 @@ typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two, struct diff_options *o, regex_t *regexp, kwset_t kws); -static int pickaxe_match(struct diff_filepair *p, struct diff_options *o, - regex_t *regexp, kwset_t kws, pickaxe_fn fn); - -static void pickaxe(struct diff_queue_struct *q, struct diff_options *o, - regex_t *regexp, kwset_t kws, pickaxe_fn fn) -{ - int i; - struct diff_queue_struct outq; - - DIFF_QUEUE_CLEAR(&outq); - - if (o->pickaxe_opts & DIFF_PICKAXE_ALL) { - /* Showing the whole changeset if needle exists */ - for (i = 0; i < q->nr; i++) { - struct diff_filepair *p = q->queue[i]; - if (pickaxe_match(p, o, regexp, kws, fn)) - return; /* do not munge the queue */ - } - - /* - * Otherwise we will clear the whole queue by copying - * the empty outq at the end of this function, but - * first clear the current entries in the queue. - */ - for (i = 0; i < q->nr; i++) - diff_free_filepair(q->queue[i]); - } else { - /* Showing only the filepairs that has the needle */ - for (i = 0; i < q->nr; i++) { - struct diff_filepair *p = q->queue[i]; - if (pickaxe_match(p, o, regexp, kws, fn)) - diff_q(&outq, p); - else - diff_free_filepair(p); - } - } - - free(q->queue); - *q = outq; -} - struct diffgrep_cb { regex_t *regexp; int hit; @@ -204,6 +163,44 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o, return ret; } +static void pickaxe(struct diff_queue_struct *q, struct diff_options *o, + regex_t *regexp, kwset_t kws, pickaxe_fn fn) +{ + int i; + struct diff_queue_struct outq; + + DIFF_QUEUE_CLEAR(&outq); + + if (o->pickaxe_opts & DIFF_PICKAXE_ALL) { + /* Showing the whole changeset if needle exists */ + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (pickaxe_match(p, o, regexp, kws, fn)) + return; /* do not munge the queue */ + } + + /* + * Otherwise we will clear the whole queue by copying + * the empty outq at the end of this function, but + * first clear the current entries in the queue. + */ + for (i = 0; i < q->nr; i++) + diff_free_filepair(q->queue[i]); + } else { + /* Showing only the filepairs that has the needle */ + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (pickaxe_match(p, o, regexp, kws, fn)) + diff_q(&outq, p); + else + diff_free_filepair(p); + } + } + + free(q->queue); + *q = outq; +} + void diffcore_pickaxe(struct diff_options *o) { const char *needle = o->pickaxe; -- cgit v1.2.3