aboutsummaryrefslogtreecommitdiffstats
path: root/src/search.c
diff options
context:
space:
mode:
authorMiles Bader2006-10-15 02:54:13 +0000
committerMiles Bader2006-10-15 02:54:13 +0000
commitbb9c4b4f8b3dcd1b5fc96d2d0275cc532832fbd6 (patch)
tree8c4ae9640abcb8f33326e96e661f711417e5307c /src/search.c
parent5be4d5336db8be316100a5b80ee8c5e428438b9e (diff)
parent92edaeeda5c362acf2c7e7f72b3666ab7673699a (diff)
downloademacs-bb9c4b4f8b3dcd1b5fc96d2d0275cc532832fbd6.tar.gz
emacs-bb9c4b4f8b3dcd1b5fc96d2d0275cc532832fbd6.zip
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.c23
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
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];
@@ -137,7 +138,6 @@ compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
137 cp->buf.multibyte = STRING_MULTIBYTE (pattern); 138 cp->buf.multibyte = STRING_MULTIBYTE (pattern);
138 cp->buf.target_multibyte = multibyte; 139 cp->buf.target_multibyte = multibyte;
139 cp->whitespace_regexp = Vsearch_spaces_regexp; 140 cp->whitespace_regexp = Vsearch_spaces_regexp;
140 cp->syntax_table = current_buffer->syntax_table;
141 /* rms: I think BLOCK_INPUT is not needed here any more, 141 /* rms: I think BLOCK_INPUT is not needed here any more,
142 because regex.c defines malloc to call xmalloc. 142 because regex.c defines malloc to call xmalloc.
143 Using BLOCK_INPUT here means the debugger won't run if an error occurs. 143 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)
151 val = (char *) re_compile_pattern ((char *) SDATA (pattern), 151 val = (char *) re_compile_pattern ((char *) SDATA (pattern),
152 SBYTES (pattern), &cp->buf); 152 SBYTES (pattern), &cp->buf);
153 153
154 /* If the compiled pattern hard codes some of the contents of the
155 syntax-table, it can only be reused with *this* syntax table. */
156 cp->syntax_table = cp->buf.used_syntax ? current_buffer->syntax_table : Qt;
157
154 re_set_whitespace_regexp (NULL); 158 re_set_whitespace_regexp (NULL);
155 159
156 re_set_syntax (old); 160 re_set_syntax (old);
@@ -178,7 +182,8 @@ shrink_regexp_cache ()
178 } 182 }
179} 183}
180 184
181/* Clear the regexp cache. 185/* Clear the regexp cache w.r.t. a particular syntax table,
186 because it was changed.
182 There is no danger of memory leak here because re_compile_pattern 187 There is no danger of memory leak here because re_compile_pattern
183 automagically manages the memory in each re_pattern_buffer struct, 188 automagically manages the memory in each re_pattern_buffer struct,
184 based on its `allocated' and `buffer' values. */ 189 based on its `allocated' and `buffer' values. */
@@ -188,7 +193,11 @@ clear_regexp_cache ()
188 int i; 193 int i;
189 194
190 for (i = 0; i < REGEXP_CACHE_SIZE; ++i) 195 for (i = 0; i < REGEXP_CACHE_SIZE; ++i)
191 searchbufs[i].regexp = Qnil; 196 /* It's tempting to compare with the syntax-table we've actually changd,
197 but it's not sufficient because char-table inheritance mewans that
198 modifying one syntax-table can change others at the same time. */
199 if (!EQ (searchbufs[i].syntax_table, Qt))
200 searchbufs[i].regexp = Qnil;
192} 201}
193 202
194/* Compile a regexp if necessary, but first check to see if there's one in 203/* 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)
227 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) 236 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0)))
228 && cp->posix == posix 237 && cp->posix == posix
229 && cp->buf.target_multibyte == multibyte 238 && cp->buf.target_multibyte == multibyte
230 /* TODO: Strictly speaking, we only need to match syntax 239 && (EQ (cp->syntax_table, Qt)
231 tables when a character class like [[:space:]] occurs in 240 || EQ (cp->syntax_table, current_buffer->syntax_table))
232 the pattern. -- cyd*/
233 && EQ (cp->syntax_table, current_buffer->syntax_table)
234 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp))) 241 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp)))
235 break; 242 break;
236 243