comparison src/search.c @ 58348:623ffd21f0ff

(Vsearch_spaces_regexp): Renamed from Vsearch_whitespace_regexp. All uses changed.
author Richard M. Stallman <rms@gnu.org>
date Sat, 20 Nov 2004 14:04:16 +0000
parents 5be8a633ec57
children 47729f2cb184
comparison
equal deleted inserted replaced
58347:25b8b4e18c9a 58348:623ffd21f0ff
81 81
82 /* error condition signaled when regexp compile_pattern fails */ 82 /* error condition signaled when regexp compile_pattern fails */
83 83
84 Lisp_Object Qinvalid_regexp; 84 Lisp_Object Qinvalid_regexp;
85 85
86 Lisp_Object Vsearch_whitespace_regexp; 86 Lisp_Object Vsearch_spaces_regexp;
87 87
88 static void set_search_regs (); 88 static void set_search_regs ();
89 static void save_search_regs (); 89 static void save_search_regs ();
90 static int simple_search (); 90 static int simple_search ();
91 static int boyer_moore (); 91 static int boyer_moore ();
109 for this pattern. 0 means backtrack only enough to get a valid match. 109 for this pattern. 0 means backtrack only enough to get a valid match.
110 MULTIBYTE is nonzero if we want to handle multibyte characters in 110 MULTIBYTE is nonzero if we want to handle multibyte characters in
111 PATTERN. 0 means all multibyte characters are recognized just as 111 PATTERN. 0 means all multibyte characters are recognized just as
112 sequences of binary data. 112 sequences of binary data.
113 113
114 The behavior also depends on Vsearch_whitespace_regexp. */ 114 The behavior also depends on Vsearch_spaces_regexp. */
115 115
116 static void 116 static void
117 compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte) 117 compile_pattern_1 (cp, pattern, translate, regp, posix, multibyte)
118 struct regexp_cache *cp; 118 struct regexp_cache *cp;
119 Lisp_Object pattern; 119 Lisp_Object pattern;
160 160
161 cp->regexp = Qnil; 161 cp->regexp = Qnil;
162 cp->buf.translate = (! NILP (translate) ? translate : make_number (0)); 162 cp->buf.translate = (! NILP (translate) ? translate : make_number (0));
163 cp->posix = posix; 163 cp->posix = posix;
164 cp->buf.multibyte = multibyte; 164 cp->buf.multibyte = multibyte;
165 cp->whitespace_regexp = Vsearch_whitespace_regexp; 165 cp->whitespace_regexp = Vsearch_spaces_regexp;
166 BLOCK_INPUT; 166 BLOCK_INPUT;
167 old = re_set_syntax (RE_SYNTAX_EMACS 167 old = re_set_syntax (RE_SYNTAX_EMACS
168 | (posix ? 0 : RE_NO_POSIX_BACKTRACKING)); 168 | (posix ? 0 : RE_NO_POSIX_BACKTRACKING));
169 169
170 re_set_whitespace_regexp (NILP (Vsearch_whitespace_regexp) ? NULL 170 re_set_whitespace_regexp (NILP (Vsearch_spaces_regexp) ? NULL
171 : SDATA (Vsearch_whitespace_regexp)); 171 : SDATA (Vsearch_spaces_regexp));
172 172
173 val = (char *) re_compile_pattern ((char *)raw_pattern, 173 val = (char *) re_compile_pattern ((char *)raw_pattern,
174 raw_pattern_size, &cp->buf); 174 raw_pattern_size, &cp->buf);
175 175
176 re_set_whitespace_regexp (NULL); 176 re_set_whitespace_regexp (NULL);
234 && STRING_MULTIBYTE (cp->regexp) == STRING_MULTIBYTE (pattern) 234 && STRING_MULTIBYTE (cp->regexp) == STRING_MULTIBYTE (pattern)
235 && !NILP (Fstring_equal (cp->regexp, pattern)) 235 && !NILP (Fstring_equal (cp->regexp, pattern))
236 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0))) 236 && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0)))
237 && cp->posix == posix 237 && cp->posix == posix
238 && cp->buf.multibyte == multibyte 238 && cp->buf.multibyte == multibyte
239 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_whitespace_regexp))) 239 && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp)))
240 break; 240 break;
241 241
242 /* If we're at the end of the cache, compile into the nil cell 242 /* If we're at the end of the cache, compile into the nil cell
243 we found, or the last (least recently used) cell with a 243 we found, or the last (least recently used) cell with a
244 string value. */ 244 string value. */
1062 { 1062 {
1063 set_search_regs (pos_byte, 0); 1063 set_search_regs (pos_byte, 0);
1064 return pos; 1064 return pos;
1065 } 1065 }
1066 1066
1067 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_whitespace_regexp))) 1067 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
1068 { 1068 {
1069 unsigned char *p1, *p2; 1069 unsigned char *p1, *p2;
1070 int s1, s2; 1070 int s1, s2;
1071 struct re_pattern_buffer *bufp; 1071 struct re_pattern_buffer *bufp;
1072 1072
3010 staticpro (&last_thing_searched); 3010 staticpro (&last_thing_searched);
3011 3011
3012 saved_last_thing_searched = Qnil; 3012 saved_last_thing_searched = Qnil;
3013 staticpro (&saved_last_thing_searched); 3013 staticpro (&saved_last_thing_searched);
3014 3014
3015 DEFVAR_LISP ("search-whitespace-regexp", &Vsearch_whitespace_regexp, 3015 DEFVAR_LISP ("search-spaces-regexp", &Vsearch_spaces_regexp,
3016 /* doc: Regexp to substitute for bunches of spaces in regexp search. 3016 /* doc: Regexp to substitute for bunches of spaces in regexp search.
3017 Some commands use this for user-specified regexps. 3017 Some commands use this for user-specified regexps.
3018 Spaces that occur inside character classes or repetition operators 3018 Spaces that occur inside character classes or repetition operators
3019 or other such regexp constructs are not replaced with this. 3019 or other such regexp constructs are not replaced with this.
3020 A value of nil (which is the normal value) means treat spaces literally. */); 3020 A value of nil (which is the normal value) means treat spaces literally. */);
3021 Vsearch_whitespace_regexp = Qnil; 3021 Vsearch_spaces_regexp = Qnil;
3022 3022
3023 defsubr (&Slooking_at); 3023 defsubr (&Slooking_at);
3024 defsubr (&Sposix_looking_at); 3024 defsubr (&Sposix_looking_at);
3025 defsubr (&Sstring_match); 3025 defsubr (&Sstring_match);
3026 defsubr (&Sposix_string_match); 3026 defsubr (&Sposix_string_match);