changeset 22082:84bcdbc46d71

(search_buffer): Set search regs for all success with an empty string. (set_search_regs): Clear out all regs except 0.
author Richard M. Stallman <rms@gnu.org>
date Fri, 15 May 1998 22:23:01 +0000
parents 0f4e461dd691
children 3a0152d73914
files src/search.c
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c	Fri May 15 21:50:07 1998 +0000
+++ b/src/search.c	Fri May 15 22:23:01 1998 +0000
@@ -1005,17 +1005,14 @@
   if (running_asynch_code)
     save_search_regs ();
 
+  /* Searching 0 times means don't move.  */
   /* Null string is found at starting position.  */
-  if (len == 0)
+  if (len == 0 || n == 0)
     {
       set_search_regs (pos, 0);
       return pos;
     }
 
-  /* Searching 0 times means don't move.  */
-  if (n == 0)
-    return pos;
-
   if (RE && !trivial_regexp_p (string))
     {
       unsigned char *p1, *p2;
@@ -1896,12 +1893,15 @@
 }
 
 /* Record beginning BEG_BYTE and end BEG_BYTE + NBYTES
-   for a match just found in the current buffer.  */
+   for the overall match just found in the current buffer.
+   Also clear out the match data for registers 1 and up.  */
 
 static void
 set_search_regs (beg_byte, nbytes)
      int beg_byte, nbytes;
 {
+  int i;
+
   /* Make sure we have registers in which to store
      the match position.  */
   if (search_regs.num_regs == 0)
@@ -1911,6 +1911,13 @@
       search_regs.num_regs = 2;
     }
 
+  /* Clear out the other registers.  */
+  for (i = 1; i < search_regs.num_regs; i++)
+    {
+      search_regs.start[i] = -1;
+      search_regs.end[i] = -1;
+    }
+
   search_regs.start[0] = BYTE_TO_CHAR (beg_byte);
   search_regs.end[0] = BYTE_TO_CHAR (beg_byte + nbytes);
   XSETBUFFER (last_thing_searched, current_buffer);