emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f77a395 1/2: Clarify Freplace_match logic


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master f77a395 1/2: Clarify Freplace_match logic
Date: Sat, 3 Aug 2019 10:00:34 -0400 (EDT)

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

    Clarify Freplace_match logic
    
    * src/search.c (Freplace_match): Add some doc strings to clarify
    the logic and do a minor clean up (bug#19208).
---
 src/search.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/search.c b/src/search.c
index fa57495..2fa8b27 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2397,11 +2397,15 @@ since only regular expressions have distinguished 
subexpressions.  */)
   else
     {
       CHECK_FIXNUM (subexp);
-      if (! (0 <= XFIXNUM (subexp) && XFIXNUM (subexp) < search_regs.num_regs))
-       args_out_of_range (subexp, make_fixnum (search_regs.num_regs));
       sub = XFIXNUM (subexp);
+      /* Sanity check to see whether the subexp is larger than the
+        allowed number of sub-regexps. */
+      if (sub >= 0 && sub > search_regs.num_regs)
+       args_out_of_range (subexp, make_fixnum (search_regs.num_regs));
     }
 
+  /* Sanity check to see whether the text to replace is present in the
+     buffer/string. */
   if (NILP (string))
     {
       if (search_regs.start[sub] < BEGV



reply via email to

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