summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZev Weiss <zev@bewilderbeest.net>2016-12-25 08:57:08 (GMT)
committerJim Meyering <meyering@fb.com>2016-12-25 09:41:34 (GMT)
commit96848ac6c02f596aa542fca769c7b7aeea446ab4 (patch)
tree70689b11c18c8bfa7ea9860ac800e7671e624181
parent41268e548dfe04f9a019c5db099266391c3a4103 (diff)
downloadgrep-96848ac6c02f596aa542fca769c7b7aeea446ab4.zip
grep-96848ac6c02f596aa542fca769c7b7aeea446ab4.tar.gz
grep-96848ac6c02f596aa542fca769c7b7aeea446ab4.tar.bz2
kwsearch: thread safety
* src/kwsearch.c (Fcompile): Return a kwset_t instead of setting a global variable. (Fexecute): Use a passed-in kwset_t instead of a global variable. (kwset): Remove global variable.
-rw-r--r--src/kwsearch.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/kwsearch.c b/src/kwsearch.c
index 3b7474d..fedbe32 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -21,14 +21,10 @@
#include <config.h>
#include "search.h"
-/* KWset compiled pattern. For Ecompile and Gcompile, we compile
- a list of strings, at least one of which is known to occur in
- any string matching the regexp. */
-static kwset_t kwset;
-
void *
Fcompile (char const *pattern, size_t size, reg_syntax_t ignored)
{
+ kwset_t kwset;
size_t total = size;
kwset = kwsinit (true);
@@ -69,7 +65,7 @@ Fcompile (char const *pattern, size_t size, reg_syntax_t ignored)
kwsprep (kwset);
- return NULL;
+ return kwset;
}
size_t
@@ -83,6 +79,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t *match_size,
size_t ret_val;
bool mb_check;
bool longest;
+ kwset_t kwset = vcp;
if (match_lines)
mb_check = longest = false;