[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 09adf92: Fix previous replace-in-string rewrite
From: |
Lars Ingebrigtsen |
Subject: |
master 09adf92: Fix previous replace-in-string rewrite |
Date: |
Thu, 24 Sep 2020 20:07:14 -0400 (EDT) |
branch: master
commit 09adf92644112dbd09865b9de703868ea50c2d4f
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix previous replace-in-string rewrite
* lisp/subr.el (replace-in-string): Fix logic errors in previous
patch.
---
lisp/subr.el | 4 ++--
test/lisp/subr-tests.el | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 0f72b38..0de9ac5 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4439,8 +4439,8 @@ Unless optional argument INPLACE is non-nil, return a new
string."
(unless (= start pos)
(push (substring instring start pos) result))
(push tostring result)
- (setq start (+ start (length fromstring))))
- (unless (= start pos)
+ (setq start (+ pos (length fromstring))))
+ (unless (= start (length instring))
(push (substring instring start pos) result))
(apply #'concat (nreverse result))))
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 14870d4..fa728e4 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -462,9 +462,9 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350."
"foozotbar"))
(should (equal (replace-in-string "\377" "x" "a\377b")
- "axxb"))
+ "axb"))
(should (equal (replace-in-string "\377" "x" "a\377ø")
- "axxø")))
+ "axø")))
(provide 'subr-tests)
;;; subr-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 09adf92: Fix previous replace-in-string rewrite,
Lars Ingebrigtsen <=