Include <config.h> instead of "config.h".
[bpt/emacs.git] / src / search.c
index 40e0c16..930d1bb 100644 (file)
@@ -1,5 +1,5 @@
 /* String search routines for GNU Emacs.
-   Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
-#include "config.h"
+#include <config.h>
 #include "lisp.h"
 #include "syntax.h"
 #include "buffer.h"
@@ -99,9 +99,8 @@ compile_pattern (pattern, bufp, regp, translate)
   last_regexp = Qnil;
   bufp->translate = translate;
   BLOCK_INPUT;
-  val = re_compile_pattern ((char *) XSTRING (pattern)->data,
-                           XSTRING (pattern)->size,
-                           bufp);
+  val = (CONST char *) re_compile_pattern ((char *) XSTRING (pattern)->data,
+                                          XSTRING (pattern)->size, bufp);
   UNBLOCK_INPUT;
   if (val)
     {
@@ -172,11 +171,9 @@ data if you want to preserve them.")
       s2 = 0;
     }
   
-  BLOCK_INPUT;
   i = re_match_2 (&searchbuf, (char *) p1, s1, (char *) p2, s2,
                  point - BEGV, &search_regs,
                  ZV - BEGV);
-  UNBLOCK_INPUT;
   if (i == -2)
     matcher_overflow ();
 
@@ -224,11 +221,9 @@ matched by parenthesis constructs in the pattern.")
   compile_pattern (regexp, &searchbuf, &search_regs,
                   !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0);
   immediate_quit = 1;
-  BLOCK_INPUT;
   val = re_search (&searchbuf, (char *) XSTRING (string)->data,
                   XSTRING (string)->size, s, XSTRING (string)->size - s,
                   &search_regs);
-  UNBLOCK_INPUT;
   immediate_quit = 0;
   last_thing_searched = Qt;
   if (val == -2)
@@ -249,11 +244,9 @@ fast_string_match (regexp, string)
 
   compile_pattern (regexp, &searchbuf, 0, 0);
   immediate_quit = 1;
-  BLOCK_INPUT;
   val = re_search (&searchbuf, (char *) XSTRING (string)->data,
                   XSTRING (string)->size, 0, XSTRING (string)->size,
                   0);
-  UNBLOCK_INPUT;
   immediate_quit = 0;
   return val;
 }
@@ -616,7 +609,11 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
   int s1, s2;
 
   /* Null string is found at starting position.  */
-  if (!len)
+  if (len == 0)
+    return pos;
+
+  /* Searching 0 times means don't move.  */
+  if (n == 0)
     return pos;
 
   if (RE)
@@ -671,12 +668,10 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
       while (n < 0)
        {
          int val;
-         BLOCK_INPUT;
          val = re_search_2 (&searchbuf, (char *) p1, s1, (char *) p2, s2,
                             pos - BEGV, lim - pos, &search_regs,
                             /* Don't allow match past current point */
                             pos - BEGV);
-         UNBLOCK_INPUT;
          if (val == -2)
            matcher_overflow ();
          if (val >= 0)
@@ -702,11 +697,9 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
       while (n > 0)
        {
          int val;
-         BLOCK_INPUT;
          val = re_search_2 (&searchbuf, (char *) p1, s1, (char *) p2, s2,
                             pos - BEGV, lim - pos, &search_regs,
                             lim - BEGV);
-         UNBLOCK_INPUT;
          if (val == -2)
            matcher_overflow ();
          if (val >= 0)
@@ -943,7 +936,7 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
                  while ((limit - pos) * direction >= 0)
                    pos += BM_tab[FETCH_CHAR(pos)];
                  /* now run the same tests to distinguish going off the */
-                 /* end, a match or a phoney match. */
+                 /* end, a match or a phony match. */
                  if ((pos - limit) * direction <= len)
                    break;      /* ran off the end */
                  /* Found what might be a match.