I'd like to use the PCRE & ERE etc. code in grep.c for more things in git, starting with diffcore-pickaxe.c. The current API just exposes grep_{source,buffer}() for that purpose. I could use those, but they're very fat entry points into the entire set of bells and whistles that grep.c supports for "git grep". I just want the equivalent of a light regexec() wrapper for my compiled patterns. So let's expose patmatch() for that purpose. It's not perfect, in particular it's a bit ugly that we need to pop a pattern off the opt->pattern_list if all we've got is the "grep_opt" wrapper struct, but it'll do for now. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- grep.c | 4 ++-- grep.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/grep.c b/grep.c index 636ac48bf0..8d84313d6e 100644 --- a/grep.c +++ b/grep.c @@ -906,8 +906,8 @@ static void show_name(struct grep_opt *opt, const char *name) opt->output(opt, opt->null_following_name ? "\0" : "\n", 1); } -static int patmatch(struct grep_pat *p, char *line, char *eol, - regmatch_t *match, int eflags) +int patmatch(struct grep_pat *p, char *line, char *eol, + regmatch_t *match, int eflags) { int hit; diff --git a/grep.h b/grep.h index 72f82b1e30..66e2ee37f3 100644 --- a/grep.h +++ b/grep.h @@ -205,6 +205,8 @@ void grep_source_load_driver(struct grep_source *gs, int grep_source(struct grep_opt *opt, struct grep_source *gs); +int patmatch(struct grep_pat *p, char *line, char *eol, + regmatch_t *match, int eflags); struct grep_opt *grep_opt_dup(const struct grep_opt *opt); int grep_threads_ok(const struct grep_opt *opt); -- 2.30.0.284.gd98b1dd5eaa7