diff options
author | Miles Bader <miles@gnu.org> | 2006-10-15 02:54:13 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2006-10-15 02:54:13 +0000 |
commit | c1b35ffb04dabfdd07debcab60a7ce7a56da78e5 (patch) | |
tree | 9ef0ce59a997cb73cc1437a185fac61890bb803f /src/search.c | |
parent | eee8f5274906a0b58ce953ad92bc1753eff81e4b (diff) | |
parent | 73f055096252c1ee12beaed03afa358b9c480573 (diff) | |
download | emacs-c1b35ffb04dabfdd07debcab60a7ce7a56da78e5.tar.gz |
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 460-475)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 145-152)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-118
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/search.c b/src/search.c index 5f3f953595b..7c1090aa2bf 100644 --- a/src/search.c +++ b/src/search.c @@ -43,7 +43,8 @@ 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. */ + of character classes. If this is t, then the compiled pattern is valid + for any syntax-table. */ Lisp_Object syntax_table; struct re_pattern_buffer buf; char fastmap[0400]; @@ -137,7 +138,6 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte) cp->buf.multibyte = STRING_MULTIBYTE (pattern); cp->buf.target_multibyte = multibyte; cp->whitespace_regexp = Vsearch_spaces_regexp; - cp->syntax_table = current_buffer->syntax_table; /* 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. @@ -151,6 +151,10 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte) val = (char *) re_compile_pattern ((char *) SDATA (pattern), SBYTES (pattern), &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 ? current_buffer->syntax_table : Qt; + re_set_whitespace_regexp (NULL); re_set_syntax (old); @@ -178,7 +182,8 @@ shrink_regexp_cache () } } -/* Clear the regexp cache. +/* Clear the regexp cache w.r.t. a particular syntax table, + because it was changed. There is no danger of memory leak here because re_compile_pattern automagically manages the memory in each re_pattern_buffer struct, based on its `allocated' and `buffer' values. */ @@ -188,7 +193,11 @@ clear_regexp_cache () int i; for (i = 0; i < REGEXP_CACHE_SIZE; ++i) - searchbufs[i].regexp = Qnil; + /* It's tempting to compare with the syntax-table we've actually changd, + but it's not sufficient because char-table inheritance mewans that + modifying one syntax-table can change others at the same time. */ + if (!EQ (searchbufs[i].syntax_table, Qt)) + searchbufs[i].regexp = Qnil; } /* Compile a regexp if necessary, but first check to see if there's one in @@ -227,10 +236,8 @@ compile_pattern (pattern, regp, translate, posix, multibyte) && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) && cp->posix == posix && cp->buf.target_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) + && (EQ (cp->syntax_table, Qt) + || EQ (cp->syntax_table, current_buffer->syntax_table)) && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp))) break; |