[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0a7152e: Fix up previous replace-in-string commit
From: |
Lars Ingebrigtsen |
Subject: |
master 0a7152e: Fix up previous replace-in-string commit |
Date: |
Tue, 15 Sep 2020 11:36:46 -0400 (EDT) |
branch: master
commit 0a7152e095e51febedf3da794eacb3a6b538e64e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix up previous replace-in-string commit
* lisp/subr.el (replace-in-string): Fix thinko in implementation.
---
lisp/subr.el | 6 +++++-
test/lisp/subr-tests.el | 8 +++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index b833176..f3c1e20 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4430,7 +4430,11 @@ This function returns a freshly created string."
(aref fromstring if)))
(setq ii (1+ ii)
if (1+ if)))
- (when (= if (length fromstring))
+ (if (not (= if (length fromstring)))
+ ;; We didn't have a match after all.
+ (setq i (1+ i))
+ ;; We had one, so gather the previous part and the
+ ;; substition.
(when (not (= start i))
(push (substring instring start i) result))
(push tostring result)
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 8bec097..2adb4a6 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -450,7 +450,13 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350."
(should (equal (replace-in-string "zot" "bar" "barfoozot")
"barfoobar"))
(should (equal (replace-in-string "z" "bar" "barfoozot")
- "barfoobarot")))
+ "barfoobarot"))
+ (should (equal (replace-in-string "zot" "bar" "zat")
+ "zat"))
+ (should (equal (replace-in-string "azot" "bar" "zat")
+ "zat"))
+ (should (equal (replace-in-string "azot" "bar" "azot")
+ "bar")))
(provide 'subr-tests)
;;; subr-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0a7152e: Fix up previous replace-in-string commit,
Lars Ingebrigtsen <=