summaryrefslogtreecommitdiff
path: root/src/pcresearch.c
diff options
context:
space:
mode:
authorZev Weiss <zev@bewilderbeest.net>2016-12-25 02:57:06 -0600
committerJim Meyering <meyering@fb.com>2016-12-25 10:41:30 +0100
commit9365ed6536d4fabf42ec17fef1bbe5d78884f950 (patch)
treebc291b229f074cddf34948c73c2d8b693c098074 /src/pcresearch.c
parent405b9042e4b67c21c448f285ff8b478846e3ee66 (diff)
downloadgrep-9365ed6536d4fabf42ec17fef1bbe5d78884f950.tar.gz
grep: prepare search backends for thread-safety
To facilitate removing mutable global state from search backends, compile() functions will return an opaque pointer to backend-specific data, which must then be passed back into the corresponding execute() function. This is merely a preparatory step changing function signatures and call sites, so the pointers passed & returned are dummies for now and not (yet) actually used. * src/grep.c (compile_fp_t): Now returns an opaque pointer (the compiled pattern). (execute_fp_t): Now passed the pointer returned by a compile_fp_t. All call sites updated accordingly. (compiled_pattern): New static variable. * src/dfasearch.c (GEAcompile): Return a void pointer (dummy NULL). (EGexecute): Receive a void pointer argument (unused). * src/kwsearch.c (Fcompile): Return a void pointer (dummy NULL). (Fexecute): Receive a void pointer argument (unused). * src/pcresearch.c (Pcompile): Return a void pointer (dummy NULL). (Pexecute): Receive a void pointer argument (unused). * src/search.h: Update compile/execute function prototypes.
Diffstat (limited to 'src/pcresearch.c')
-rw-r--r--src/pcresearch.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 245469c1..54d9430a 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -87,7 +87,7 @@ jit_exec (char const *subject, int search_bytes, int search_offset,
static int empty_match[2];
#endif
-void
+void *
Pcompile (char const *pattern, size_t size, reg_syntax_t ignored)
{
#if !HAVE_LIBPCRE
@@ -175,10 +175,12 @@ Pcompile (char const *pattern, size_t size, reg_syntax_t ignored)
PCRE_NOTBOL, sub, NSUB);
empty_match[true] = pcre_exec (cre, extra, "", 0, 0, 0, sub, NSUB);
#endif /* HAVE_LIBPCRE */
+
+ return NULL;
}
size_t
-Pexecute (char const *buf, size_t size, size_t *match_size,
+Pexecute (void *vcp, char const *buf, size_t size, size_t *match_size,
char const *start_ptr)
{
#if !HAVE_LIBPCRE