diff options
| author | Michal Nazarewicz | 2016-07-27 22:39:04 +0200 |
|---|---|---|
| committer | Michal Nazarewicz | 2016-08-02 15:39:10 +0200 |
| commit | 04d96eca08ff797c0cd93c33fe8589f4623fc449 (patch) | |
| tree | adc46050fff677705e5be6400502495e3943dd1f /src/search.c | |
| parent | 9a418e0f98a6ee14d9984e597038168ebe0a7a03 (diff) | |
| download | emacs-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/search.c')
| -rw-r--r-- | src/search.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c index 7cb18a2059a..f0419522df2 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -113,8 +113,8 @@ static void | |||
| 113 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, | 113 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, |
| 114 | Lisp_Object translate, bool posix) | 114 | Lisp_Object translate, bool posix) |
| 115 | { | 115 | { |
| 116 | reg_syntax_t syntax; | ||
| 116 | char *val; | 117 | char *val; |
| 117 | reg_syntax_t old; | ||
| 118 | 118 | ||
| 119 | cp->regexp = Qnil; | 119 | cp->regexp = Qnil; |
| 120 | cp->buf.translate = (! NILP (translate) ? translate : make_number (0)); | 120 | cp->buf.translate = (! NILP (translate) ? translate : make_number (0)); |
| @@ -131,16 +131,15 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, | |||
| 131 | Using BLOCK_INPUT here means the debugger won't run if an error occurs. | 131 | Using BLOCK_INPUT here means the debugger won't run if an error occurs. |
| 132 | So let's turn it off. */ | 132 | So let's turn it off. */ |
| 133 | /* BLOCK_INPUT; */ | 133 | /* BLOCK_INPUT; */ |
| 134 | old = re_set_syntax (RE_SYNTAX_EMACS | ||
| 135 | | (posix ? 0 : RE_NO_POSIX_BACKTRACKING)); | ||
| 136 | 134 | ||
| 137 | if (STRINGP (Vsearch_spaces_regexp)) | 135 | if (STRINGP (Vsearch_spaces_regexp)) |
| 138 | re_set_whitespace_regexp (SSDATA (Vsearch_spaces_regexp)); | 136 | re_set_whitespace_regexp (SSDATA (Vsearch_spaces_regexp)); |
| 139 | else | 137 | else |
| 140 | re_set_whitespace_regexp (NULL); | 138 | re_set_whitespace_regexp (NULL); |
| 141 | 139 | ||
| 142 | val = (char *) re_compile_pattern (SSDATA (pattern), | 140 | syntax = RE_SYNTAX_EMACS | (posix ? 0 : RE_NO_POSIX_BACKTRACKING); |
| 143 | SBYTES (pattern), &cp->buf); | 141 | val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), |
| 142 | syntax, &cp->buf); | ||
| 144 | 143 | ||
| 145 | /* If the compiled pattern hard codes some of the contents of the | 144 | /* If the compiled pattern hard codes some of the contents of the |
| 146 | syntax-table, it can only be reused with *this* syntax table. */ | 145 | syntax-table, it can only be reused with *this* syntax table. */ |
| @@ -148,7 +147,6 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, | |||
| 148 | 147 | ||
| 149 | re_set_whitespace_regexp (NULL); | 148 | re_set_whitespace_regexp (NULL); |
| 150 | 149 | ||
| 151 | re_set_syntax (old); | ||
| 152 | /* unblock_input (); */ | 150 | /* unblock_input (); */ |
| 153 | if (val) | 151 | if (val) |
| 154 | xsignal1 (Qinvalid_regexp, build_string (val)); | 152 | xsignal1 (Qinvalid_regexp, build_string (val)); |