diff options
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/search.c b/src/search.c index 9f55d728362..e499109555c 100644 --- a/src/search.c +++ b/src/search.c @@ -30,7 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "blockinput.h" #include "intervals.h" -#include <sys/types.h> #include "regex.h" #define REGEXP_CACHE_SIZE 20 @@ -40,7 +39,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ struct regexp_cache { struct regexp_cache *next; - Lisp_Object regexp, whitespace_regexp; + Lisp_Object regexp, f_whitespace_regexp; /* Syntax table for which the regexp applies. We need this because of character classes. If this is t, then the compiled pattern is valid for any syntax-table. */ @@ -75,12 +74,12 @@ static struct regexp_cache *searchbuf_head; to call re_set_registers after compiling a new pattern or after setting the match registers, so that the regex functions will be able to free or re-allocate it properly. */ -static struct re_registers search_regs; +/* static struct re_registers search_regs; */ /* The buffer in which the last search was performed, or Qt if the last search was done in a string; Qnil if no searching has been done yet. */ -static Lisp_Object last_thing_searched; +/* static Lisp_Object last_thing_searched; */ static void set_search_regs (ptrdiff_t, ptrdiff_t); static void save_search_regs (void); @@ -113,8 +112,8 @@ static void compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, bool posix) { + const char *whitespace_regexp; char *val; - reg_syntax_t old; cp->regexp = Qnil; cp->buf.translate = (! NILP (translate) ? translate : make_number (0)); @@ -122,33 +121,26 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, cp->buf.multibyte = STRING_MULTIBYTE (pattern); cp->buf.charset_unibyte = charset_unibyte; if (STRINGP (Vsearch_spaces_regexp)) - cp->whitespace_regexp = Vsearch_spaces_regexp; + cp->f_whitespace_regexp = Vsearch_spaces_regexp; else - cp->whitespace_regexp = Qnil; + cp->f_whitespace_regexp = Qnil; /* rms: I think BLOCK_INPUT is not needed here any more, because regex.c defines malloc to call xmalloc. Using BLOCK_INPUT here means the debugger won't run if an error occurs. So let's turn it off. */ /* BLOCK_INPUT; */ - old = re_set_syntax (RE_SYNTAX_EMACS - | (posix ? 0 : RE_NO_POSIX_BACKTRACKING)); - if (STRINGP (Vsearch_spaces_regexp)) - re_set_whitespace_regexp (SSDATA (Vsearch_spaces_regexp)); - else - re_set_whitespace_regexp (NULL); + whitespace_regexp = STRINGP (Vsearch_spaces_regexp) ? + SSDATA (Vsearch_spaces_regexp) : NULL; - val = (char *) re_compile_pattern (SSDATA (pattern), - SBYTES (pattern), &cp->buf); + val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), + posix, whitespace_regexp, &cp->buf); /* If the compiled pattern hard codes some of the contents of the syntax-table, it can only be reused with *this* syntax table. */ cp->syntax_table = cp->buf.used_syntax ? BVAR (current_buffer, syntax_table) : Qt; - re_set_whitespace_regexp (NULL); - - re_set_syntax (old); /* unblock_input (); */ if (val) xsignal1 (Qinvalid_regexp, build_string (val)); @@ -224,7 +216,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp, && cp->posix == posix && (EQ (cp->syntax_table, Qt) || EQ (cp->syntax_table, BVAR (current_buffer, syntax_table))) - && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp)) + && !NILP (Fequal (cp->f_whitespace_regexp, Vsearch_spaces_regexp)) && cp->buf.charset_unibyte == charset_unibyte) break; @@ -2789,7 +2781,8 @@ since only regular expressions have distinguished subexpressions. */) if (case_action == all_caps) Fupcase_region (make_number (search_regs.start[sub]), - make_number (newpoint)); + make_number (newpoint), + Qnil); else if (case_action == cap_initial) Fupcase_initials_region (make_number (search_regs.start[sub]), make_number (newpoint)); @@ -3095,9 +3088,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) /* If true the match data have been saved in saved_search_regs during the execution of a sentinel or filter. */ -static bool search_regs_saved; -static struct re_registers saved_search_regs; -static Lisp_Object saved_last_thing_searched; +/* static bool search_regs_saved; */ +/* static struct re_registers saved_search_regs; */ +/* static Lisp_Object saved_last_thing_searched; */ /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data if asynchronous code (filter or sentinel) is running. */ @@ -3407,10 +3400,10 @@ syms_of_search (void) searchbufs[i].buf.buffer = xmalloc (100); searchbufs[i].buf.fastmap = searchbufs[i].fastmap; searchbufs[i].regexp = Qnil; - searchbufs[i].whitespace_regexp = Qnil; + searchbufs[i].f_whitespace_regexp = Qnil; searchbufs[i].syntax_table = Qnil; staticpro (&searchbufs[i].regexp); - staticpro (&searchbufs[i].whitespace_regexp); + staticpro (&searchbufs[i].f_whitespace_regexp); staticpro (&searchbufs[i].syntax_table); searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]); } |