]> code.delx.au - gnu-emacs/blobdiff - src/search.c
(Flistp): Doc fix.
[gnu-emacs] / src / search.c
index aa7f6fda699a482b5be7a0ba94be2baa036c8799..e12bf69d2a177f7bb8833fba5af4dc62319c8398 100644 (file)
@@ -429,7 +429,7 @@ string_match_1 (regexp, string, start, posix)
 
 DEFUN ("string-match", Fstring_match, Sstring_match, 2, 3, 0,
        doc: /* Return index of start of first match for REGEXP in STRING, or nil.
-Case is ignored if `case-fold-search' is non-nil in the current buffer.
+Matching ignores case if `case-fold-search' is non-nil.
 If third arg START is non-nil, start search at that index in STRING.
 For index of first char beyond the match, do (match-end 0).
 `match-end' and `match-beginning' also give indices of substrings
@@ -1174,10 +1174,10 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
       int raw_pattern_size_byte;
       unsigned char *patbuf;
       int multibyte = !NILP (current_buffer->enable_multibyte_characters);
-      unsigned char *base_pat = SDATA (string);
-      /* Set to nozero if we find a non-ASCII char that need
-        translation.  */
-      int charset_base = 0;
+      unsigned char *base_pat;
+      /* Set to positive if we find a non-ASCII char that need
+        translation.  Otherwise set to zero later.  */
+      int charset_base = -1;
       int boyer_moore_ok = 1;
 
       /* MULTIBYTE says whether the text to be searched is multibyte.
@@ -1275,24 +1275,30 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
                         always handle their translation.  */
                      while (1)
                        {
-                         if (ASCII_BYTE_P (inverse))
+                         if (ASCII_BYTE_P (inverse))
                            {
-                             if (SINGLE_BYTE_CHAR_P (inverse))
-                               {
-                                 /* Boyer-moore search can't handle a
-                                    translation of an eight-bit
-                                    character.  */
-                                 boyer_moore_ok = 0;
-                                 break;
-                               }
-                             else if (charset_base == 0)
-                               charset_base = inverse & ~CHAR_FIELD3_MASK;
-                             else if ((inverse & ~CHAR_FIELD3_MASK)
-                                      != charset_base)
+                             if (charset_base > 0)
                                {
                                  boyer_moore_ok = 0;
                                  break;
                                }
+                             charset_base = 0;
+                           }
+                         else if (SINGLE_BYTE_CHAR_P (inverse))
+                           {
+                             /* Boyer-moore search can't handle a
+                                translation of an eight-bit
+                                character.  */
+                             boyer_moore_ok = 0;
+                             break;
+                           }
+                         else if (charset_base < 0)
+                           charset_base = inverse & ~CHAR_FIELD3_MASK;
+                         else if ((inverse & ~CHAR_FIELD3_MASK)
+                                  != charset_base)
+                           {
+                             boyer_moore_ok = 0;
+                             break;
                            }
                          if (c == inverse)
                            break;
@@ -1300,6 +1306,8 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
                        }
                    }
                }
+             if (charset_base < 0)
+               charset_base = 0;
 
              /* Store this character into the translated pattern.  */
              bcopy (str, pat, charlen);
@@ -1701,7 +1709,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
          if (ASCII_BYTE_P (*ptr) || ! multibyte)
            ch = *ptr;
          else if (charset_base
-                  && (pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1]))
+                  && ((pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1])))
            {
              unsigned char *charstart = ptr - 1;
 
@@ -2368,7 +2376,7 @@ since only regular expressions have distinguished subexpressions.  */)
              else
                some_multiletter_word = 1;
            }
-         else if (!NOCASEP (c))
+         else if (UPPERCASEP (c))
            {
              some_uppercase = 1;
              if (SYNTAX (prevc) != Sword)