summaryrefslogtreecommitdiff
path: root/src/regex.c
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2016-07-27 22:39:04 +0200
committerMichal Nazarewicz <mina86@mina86.com>2016-08-02 15:39:10 +0200
commit04d96eca08ff797c0cd93c33fe8589f4623fc449 (patch)
treeadc46050fff677705e5be6400502495e3943dd1f /src/regex.c
parent9a418e0f98a6ee14d9984e597038168ebe0a7a03 (diff)
downloademacs-04d96eca08ff797c0cd93c33fe8589f4623fc449.tar.gz
Get rid of re_set_syntax
Instead of using a global variable for storing regex syntax, pass it to re_compile_pattern. This is only enabled when compiling Emacs (i.e. ‘#ifdef emacs’). * src/regex.h (re_set_syntax): Declare only #ifndef emacs. (re_compile_pattern): Now takes syntax argument #ifdef emacs. * src/regex.c (re_syntax_options): Define only #ifndef emacs. (re_compile_pattern): Use the new syntax argument #ifdef emacs. * src/search.c (compile_pattern_1): Don’t use re_set_syntax and instead pass syntax to re_compile_pattern directly.
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/regex.c b/src/regex.c
index 261d2997c32..4edc064d6b8 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1149,6 +1149,8 @@ print_double_string (re_char *where, re_char *string1, ssize_t size1,
#endif /* not DEBUG */
+#ifndef emacs
+
/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
also be assigned to arbitrarily: each pattern buffer stores its own
syntax, so it can be changed between regex compilations. */
@@ -1174,6 +1176,8 @@ re_set_syntax (reg_syntax_t syntax)
}
WEAK_ALIAS (__re_set_syntax, re_set_syntax)
+#endif
+
/* Regexp to use to replace spaces, or NULL meaning don't. */
static const_re_char *whitespace_regexp;
@@ -6271,8 +6275,14 @@ bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len,
const char *
re_compile_pattern (const char *pattern, size_t length,
+#ifdef emacs
+ reg_syntax_t syntax,
+#endif
struct re_pattern_buffer *bufp)
{
+#ifndef emacs
+ const reg_syntax_t syntax = re_syntax_options;
+#endif
reg_errcode_t ret;
/* GNU code is written to assume at least RE_NREGS registers will be set
@@ -6284,7 +6294,7 @@ re_compile_pattern (const char *pattern, size_t length,
setting no_sub. */
bufp->no_sub = 0;
- ret = regex_compile ((re_char*) pattern, length, re_syntax_options, bufp);
+ ret = regex_compile ((re_char*) pattern, length, syntax, bufp);
if (!ret)
return NULL;