From b69e3c18052eb5003b9a4579c809d1b66abdd26b Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Tue, 19 Sep 2006 21:44:52 +0000 Subject: [PATCH] * search.c (struct regexp_cache): New entry syntax_table. (compile_pattern_1): Set it. (syms_of_search): Initialize it. (compile_pattern): Require the syntax_table entry of the cache element to match the current syntax table entry. --- src/ChangeLog | 8 ++++++++ src/search.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 6fec97d5a8b..cb2af5c8a3f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2006-09-19 Chong Yidong + + * search.c (struct regexp_cache): New entry syntax_table. + (compile_pattern_1): Set it. + (syms_of_search): Initialize it. + (compile_pattern): Require the syntax_table entry of the cache + element to match the current syntax table entry. + 2006-09-19 Stefan Monnier * window.c (Fwindow_end): Fix recent change. diff --git a/src/search.c b/src/search.c index 8b469a37b70..a74a320c356 100644 --- a/src/search.c +++ b/src/search.c @@ -42,6 +42,9 @@ struct regexp_cache { struct regexp_cache *next; Lisp_Object regexp, whitespace_regexp; + /* Syntax table for which the regexp applies. We need this because + of character classes. */ + Lisp_Object syntax_table; struct re_pattern_buffer buf; char fastmap[0400]; /* Nonzero means regexp was compiled to do full POSIX backtracking. */ @@ -167,6 +170,7 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte) cp->posix = posix; cp->buf.multibyte = multibyte; cp->whitespace_regexp = Vsearch_spaces_regexp; + cp->syntax_table = current_buffer->syntax_table; /* Doing BLOCK_INPUT here has the effect that the debugger won't run if an error occurs. Why is BLOCK_INPUT needed here? */ @@ -256,6 +260,10 @@ compile_pattern (pattern, regp, translate, posix, multibyte) && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) && cp->posix == posix && cp->buf.multibyte == multibyte + /* TODO: Strictly speaking, we only need to match syntax + tables when a character class like [[:space:]] occurs in + the pattern. -- cyd*/ + && EQ (cp->syntax_table, current_buffer->syntax_table) && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp))) break; @@ -3114,8 +3122,10 @@ syms_of_search () searchbufs[i].buf.fastmap = searchbufs[i].fastmap; searchbufs[i].regexp = Qnil; searchbufs[i].whitespace_regexp = Qnil; + searchbufs[i].syntax_table = Qnil; staticpro (&searchbufs[i].regexp); staticpro (&searchbufs[i].whitespace_regexp); + staticpro (&searchbufs[i].syntax_table); searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]); } searchbuf_head = &searchbufs[0]; -- 2.39.2