]> code.delx.au - gnu-emacs/blobdiff - src/search.c
Fix Qnone definition in NS files.
[gnu-emacs] / src / search.c
index 8bfe61d5f6d851c1310adca5deb27f43696c8a19..2269afc6d821378d43848f03e7fbd42b073e67c9 100644 (file)
@@ -1,6 +1,6 @@
 /* String search routines for GNU Emacs.
    Copyright (C) 1985, 1986, 1987, 1993, 1994, 1997, 1998, 1999, 2001, 2002,
-                 2003, 2004, 2005, 2006, 2007, 2008, 2009
+                 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -1387,7 +1387,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
                  base_pat++;
                }
 
-             c = STRING_CHAR_AND_LENGTH (base_pat, len_byte, in_charlen);
+             c = STRING_CHAR_AND_LENGTH (base_pat, in_charlen);
 
              if (NILP (trt))
                {
@@ -1527,7 +1527,6 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
            EMACS_INT this_pos = pos;
            EMACS_INT this_pos_byte = pos_byte;
            int this_len = len;
-           int this_len_byte = len_byte;
            unsigned char *p = pat;
            if (pos + len > lim || pos_byte + len_byte > lim_byte)
              goto stop;
@@ -1537,16 +1536,14 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
                int charlen, buf_charlen;
                int pat_ch, buf_ch;
 
-               pat_ch = STRING_CHAR_AND_LENGTH (p, this_len_byte, charlen);
+               pat_ch = STRING_CHAR_AND_LENGTH (p, charlen);
                buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte),
-                                                ZV_BYTE - this_pos_byte,
                                                 buf_charlen);
                TRANSLATE (buf_ch, trt, buf_ch);
 
                if (buf_ch != pat_ch)
                  break;
 
-               this_len_byte -= charlen;
                this_len--;
                p += charlen;
 
@@ -1612,42 +1609,36 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
        while (1)
          {
            /* Try matching at position POS.  */
-           EMACS_INT this_pos = pos - len;
-           EMACS_INT this_pos_byte;
+           EMACS_INT this_pos = pos;
+           EMACS_INT this_pos_byte = pos_byte;
            int this_len = len;
-           int this_len_byte = len_byte;
-           unsigned char *p = pat;
+           const unsigned char *p = pat + len_byte;
 
-           if (this_pos < lim || (pos_byte - len_byte) < lim_byte)
+           if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
              goto stop;
-           this_pos_byte = CHAR_TO_BYTE (this_pos);
-           match_byte = pos_byte - this_pos_byte;
 
            while (this_len > 0)
              {
-               int charlen, buf_charlen;
+               int charlen;
                int pat_ch, buf_ch;
 
-               pat_ch = STRING_CHAR_AND_LENGTH (p, this_len_byte, charlen);
-               buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte),
-                                                ZV_BYTE - this_pos_byte,
-                                                buf_charlen);
+               DEC_BOTH (this_pos, this_pos_byte);
+               PREV_CHAR_BOUNDARY (p, pat);
+               pat_ch = STRING_CHAR (p);
+               buf_ch = STRING_CHAR (BYTE_POS_ADDR (this_pos_byte));
                TRANSLATE (buf_ch, trt, buf_ch);
 
                if (buf_ch != pat_ch)
                  break;
 
-               this_len_byte -= charlen;
                this_len--;
-               p += charlen;
-               this_pos_byte += buf_charlen;
-               this_pos++;
              }
 
            if (this_len == 0)
              {
-               pos -= len;
-               pos_byte -= match_byte;
+               match_byte = pos_byte - this_pos_byte;
+               pos = this_pos;
+               pos_byte = this_pos_byte;
                break;
              }
 
@@ -1841,7 +1832,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
 
              while (! (CHAR_HEAD_P (*charstart)))
                charstart--;
-             ch = STRING_CHAR (charstart, ptr - charstart + 1);
+             ch = STRING_CHAR (charstart);
              if (char_base != (ch & ~0x3F))
                ch = -1;
            }
@@ -3290,20 +3281,20 @@ syms_of_search ()
     }
   searchbuf_head = &searchbufs[0];
 
-  Qsearch_failed = intern ("search-failed");
+  Qsearch_failed = intern_c_string ("search-failed");
   staticpro (&Qsearch_failed);
-  Qinvalid_regexp = intern ("invalid-regexp");
+  Qinvalid_regexp = intern_c_string ("invalid-regexp");
   staticpro (&Qinvalid_regexp);
 
   Fput (Qsearch_failed, Qerror_conditions,
-       Fcons (Qsearch_failed, Fcons (Qerror, Qnil)));
+       pure_cons (Qsearch_failed, pure_cons (Qerror, Qnil)));
   Fput (Qsearch_failed, Qerror_message,
-       build_string ("Search failed"));
+       make_pure_c_string ("Search failed"));
 
   Fput (Qinvalid_regexp, Qerror_conditions,
-       Fcons (Qinvalid_regexp, Fcons (Qerror, Qnil)));
+       pure_cons (Qinvalid_regexp, pure_cons (Qerror, Qnil)));
   Fput (Qinvalid_regexp, Qerror_message,
-       build_string ("Invalid regexp"));
+       make_pure_c_string ("Invalid regexp"));
 
   last_thing_searched = Qnil;
   staticpro (&last_thing_searched);