aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2006-10-03 13:25:26 +0000
committerStefan Monnier2006-10-03 13:25:26 +0000
commit58e95211ec3351c8867c5ca1cb2c59f85825e5b5 (patch)
treed81dd9f0b6f66bce172c2dfa1cfa26b9a37c4337 /src
parent6224b623fd39be87b33e0ff7dd582a3e8818e340 (diff)
downloademacs-58e95211ec3351c8867c5ca1cb2c59f85825e5b5.tar.gz
emacs-58e95211ec3351c8867c5ca1cb2c59f85825e5b5.zip
(compile_pattern): Only check `cp->syntax_table' if needed.
(compile_pattern_1): Remember `used_syntax' in `cp->syntax_table'.
Diffstat (limited to 'src')
-rw-r--r--src/search.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c
index e26b8f883e1..5f9f321067a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -43,7 +43,8 @@ struct regexp_cache
43 struct regexp_cache *next; 43 struct regexp_cache *next;
44 Lisp_Object regexp, whitespace_regexp; 44 Lisp_Object regexp, whitespace_regexp;
45 /* Syntax table for which the regexp applies. We need this because 45 /* Syntax table for which the regexp applies. We need this because
46 of character classes. */ 46 of character classes. If this is t, then the compiled pattern is valid
47 for any syntax-table. */
47 Lisp_Object syntax_table; 48 Lisp_Object syntax_table;
48 struct re_pattern_buffer buf; 49 struct re_pattern_buffer buf;
49 char fastmap[0400]; 50 char fastmap[0400];
@@ -170,7 +171,6 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
170 cp->posix = posix; 171 cp->posix = posix;
171 cp->buf.multibyte = multibyte; 172 cp->buf.multibyte = multibyte;
172 cp->whitespace_regexp = Vsearch_spaces_regexp; 173 cp->whitespace_regexp = Vsearch_spaces_regexp;
173 cp->syntax_table = current_buffer->syntax_table;
174 /* rms: I think BLOCK_INPUT is not needed here any more, 174 /* rms: I think BLOCK_INPUT is not needed here any more,
175 because regex.c defines malloc to call xmalloc. 175 because regex.c defines malloc to call xmalloc.
176 Using BLOCK_INPUT here means the debugger won't run if an error occurs. 176 Using BLOCK_INPUT here means the debugger won't run if an error occurs.
@@ -185,6 +185,10 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
185 val = (char *) re_compile_pattern ((char *)raw_pattern, 185 val = (char *) re_compile_pattern ((char *)raw_pattern,
186 raw_pattern_size, &cp->buf); 186 raw_pattern_size, &cp->buf);
187 187
188 /* If the compiled pattern hard codes some of the contents of the
189 syntax-table, it can only be reused with *this* syntax table. */
190 cp->syntax_table = cp->buf.used_syntax ? current_buffer->syntax_table : Qt;
191
188 re_set_whitespace_regexp (NULL); 192 re_set_whitespace_regexp (NULL);
189 193
190 re_set_syntax (old); 194 re_set_syntax (old);
@@ -261,10 +265,8 @@ compile_pattern (pattern, regp, translate, posix, multibyte)
261 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) 265 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0)))
262 && cp->posix == posix 266 && cp->posix == posix
263 && cp->buf.multibyte == multibyte 267 && cp->buf.multibyte == multibyte
264 /* TODO: Strictly speaking, we only need to match syntax 268 && (EQ (cp->syntax_table, Qt)
265 tables when a character class like [[:space:]] occurs in 269 || EQ (cp->syntax_table, current_buffer->syntax_table))
266 the pattern. -- cyd*/
267 && EQ (cp->syntax_table, current_buffer->syntax_table)
268 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp))) 270 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp)))
269 break; 271 break;
270 272