aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.c
diff options
context:
space:
mode:
authorMichal Nazarewicz2016-07-27 22:39:04 +0200
committerMichal Nazarewicz2016-08-02 15:39:10 +0200
commit04d96eca08ff797c0cd93c33fe8589f4623fc449 (patch)
treeadc46050fff677705e5be6400502495e3943dd1f /src/regex.c
parent9a418e0f98a6ee14d9984e597038168ebe0a7a03 (diff)
downloademacs-04d96eca08ff797c0cd93c33fe8589f4623fc449.tar.gz
emacs-04d96eca08ff797c0cd93c33fe8589f4623fc449.zip
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,
1149 1149
1150#endif /* not DEBUG */ 1150#endif /* not DEBUG */
1151 1151
1152#ifndef emacs
1153
1152/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can 1154/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
1153 also be assigned to arbitrarily: each pattern buffer stores its own 1155 also be assigned to arbitrarily: each pattern buffer stores its own
1154 syntax, so it can be changed between regex compilations. */ 1156 syntax, so it can be changed between regex compilations. */
@@ -1174,6 +1176,8 @@ re_set_syntax (reg_syntax_t syntax)
1174} 1176}
1175WEAK_ALIAS (__re_set_syntax, re_set_syntax) 1177WEAK_ALIAS (__re_set_syntax, re_set_syntax)
1176 1178
1179#endif
1180
1177/* Regexp to use to replace spaces, or NULL meaning don't. */ 1181/* Regexp to use to replace spaces, or NULL meaning don't. */
1178static const_re_char *whitespace_regexp; 1182static const_re_char *whitespace_regexp;
1179 1183
@@ -6271,8 +6275,14 @@ bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len,
6271 6275
6272const char * 6276const char *
6273re_compile_pattern (const char *pattern, size_t length, 6277re_compile_pattern (const char *pattern, size_t length,
6278#ifdef emacs
6279 reg_syntax_t syntax,
6280#endif
6274 struct re_pattern_buffer *bufp) 6281 struct re_pattern_buffer *bufp)
6275{ 6282{
6283#ifndef emacs
6284 const reg_syntax_t syntax = re_syntax_options;
6285#endif
6276 reg_errcode_t ret; 6286 reg_errcode_t ret;
6277 6287
6278 /* GNU code is written to assume at least RE_NREGS registers will be set 6288 /* 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,
6284 setting no_sub. */ 6294 setting no_sub. */
6285 bufp->no_sub = 0; 6295 bufp->no_sub = 0;
6286 6296
6287 ret = regex_compile ((re_char*) pattern, length, re_syntax_options, bufp); 6297 ret = regex_compile ((re_char*) pattern, length, syntax, bufp);
6288 6298
6289 if (!ret) 6299 if (!ret)
6290 return NULL; 6300 return NULL;