changeset 17225:739e41eed8b6

(Freplace_match): Give error if NEWTEXT uses backslash in an invalid way.
author Richard M. Stallman <rms@gnu.org>
date Sat, 22 Mar 1997 04:17:06 +0000
parents dd2545e79add
children 8a8bcf6d7a0c
files src/search.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c	Sat Mar 22 04:13:50 1997 +0000
+++ b/src/search.c	Sat Mar 22 04:17:06 1997 +0000
@@ -1821,7 +1821,8 @@
 			   make_number (search_regs.start[sub]));
       after = Fsubstring (string, make_number (search_regs.end[sub]), Qnil);
 
-      /* Do case substitution into NEWTEXT if desired.  */
+      /* Substitute parts of the match into NEWTEXT
+	 if desired.  */
       if (NILP (literal))
 	{
 	  int lastpos = -1;
@@ -1856,6 +1857,8 @@
 		    }
 		  else if (c == '\\')
 		    delbackslash = 1;
+		  else
+		    error ("Invalid use of `\\' in replacement text");
 		}
 	      if (substart >= 0)
 		{
@@ -1888,6 +1891,7 @@
 	  newtext = concat2 (accum, middle);
 	}
 
+      /* Do case substitution in NEWTEXT if desired.  */
       if (case_action == all_caps)
 	newtext = Fupcase (newtext);
       else if (case_action == cap_initial)
@@ -1929,8 +1933,10 @@
 		       make_number (search_regs.start[c - '0'] + offset),
 		       make_number (search_regs.end[c - '0'] + offset));
 		}
+	      else if (c == '\\')
+		insert_char (c);
 	      else
-		insert_char (c);
+		error ("Invalid use of `\\' in replacement text");
 	    }
 	  else
 	    insert_char (c);