emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 18e163f 2/2: Fix error message in replace-match for


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 18e163f 2/2: Fix error message in replace-match for subexpressions
Date: Sat, 3 Aug 2019 10:00:34 -0400 (EDT)

branch: master
commit 18e163fd3455deaa30b1effd19f51a5094bc0885
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Fix error message in replace-match for subexpressions
    
    * src/search.c (Freplace_match): Output a more understandable
    error message when replacing a subexpression (bug#19208).
---
 src/search.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/search.c b/src/search.c
index 2fa8b27..0e2ae05 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2404,6 +2404,12 @@ since only regular expressions have distinguished 
subexpressions.  */)
        args_out_of_range (subexp, make_fixnum (search_regs.num_regs));
     }
 
+  /* Check whether the subexpression to replace is greater than the
+     number of subexpressions in the regexp. */
+  if (sub > 0 && search_regs.start[sub] == -1)
+    args_out_of_range (build_string ("Attempt to replace regexp subexpression 
that doesn't exist"),
+                      subexp);
+
   /* Sanity check to see whether the text to replace is present in the
      buffer/string. */
   if (NILP (string))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]