changeset 21988:8cf3bbc89c3c

(Freplace_match): Fix the loop for copying text from a string, in handling lastpos and pos.
author Richard M. Stallman <rms@gnu.org>
date Thu, 07 May 1998 23:15:14 +0000
parents cd7ff97f3b05
children d6cca4865f58
files src/search.c
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c	Thu May 07 23:11:57 1998 +0000
+++ b/src/search.c	Thu May 07 23:15:14 1998 +0000
@@ -2300,8 +2300,8 @@
 	 if desired.  */
       if (NILP (literal))
 	{
-	  int lastpos = -1;
-	  int lastpos_byte = -1;
+	  int lastpos = 0;
+	  int lastpos_byte = 0;
 	  /* We build up the substituted string in ACCUM.  */
 	  Lisp_Object accum;
 	  Lisp_Object middle;
@@ -2340,10 +2340,10 @@
 		}
 	      if (substart >= 0)
 		{
-		  if (pos - 1 != lastpos + 1)
-		    middle = substring_both (newtext, lastpos + 1,
-					     lastpos_byte + 1,
-					     pos - 1, pos_byte - 1);
+		  if (pos - 2 != lastpos)
+		    middle = substring_both (newtext, lastpos,
+					     lastpos_byte,
+					     pos - 2, pos_byte - 2);
 		  else
 		    middle = Qnil;
 		  accum = concat3 (accum, middle,
@@ -2355,9 +2355,9 @@
 		}
 	      else if (delbackslash)
 		{
-		  middle = substring_both (newtext, lastpos + 1,
-					   lastpos_byte + 1,
-					   pos, pos_byte);
+		  middle = substring_both (newtext, lastpos,
+					   lastpos_byte,
+					   pos - 1, pos_byte - 1);
 
 		  accum = concat2 (accum, middle);
 		  lastpos = pos;
@@ -2365,9 +2365,9 @@
 		}
 	    }
 
-	  if (pos != lastpos + 1)
-	    middle = substring_both (newtext, lastpos + 1,
-				     lastpos_byte + 1,
+	  if (pos != lastpos)
+	    middle = substring_both (newtext, lastpos,
+				     lastpos_byte,
 				     pos, pos_byte);
 	  else
 	    middle = Qnil;