diff options
| author | Lars Ingebrigtsen | 2020-09-15 17:36:36 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-09-15 17:36:36 +0200 |
| commit | 0a7152e095e51febedf3da794eacb3a6b538e64e (patch) | |
| tree | 488d6c649591aeb104a3cc80797d067ebfcbb617 | |
| parent | 3beb8bc9940b1de7ecee3d58b32c888898bb3ee0 (diff) | |
| download | emacs-0a7152e095e51febedf3da794eacb3a6b538e64e.tar.gz emacs-0a7152e095e51febedf3da794eacb3a6b538e64e.zip | |
Fix up previous replace-in-string commit
* lisp/subr.el (replace-in-string): Fix thinko in implementation.
| -rw-r--r-- | lisp/subr.el | 6 | ||||
| -rw-r--r-- | test/lisp/subr-tests.el | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index b8331760e34..f3c1e206603 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -4430,7 +4430,11 @@ This function returns a freshly created string." | |||
| 4430 | (aref fromstring if))) | 4430 | (aref fromstring if))) |
| 4431 | (setq ii (1+ ii) | 4431 | (setq ii (1+ ii) |
| 4432 | if (1+ if))) | 4432 | if (1+ if))) |
| 4433 | (when (= if (length fromstring)) | 4433 | (if (not (= if (length fromstring))) |
| 4434 | ;; We didn't have a match after all. | ||
| 4435 | (setq i (1+ i)) | ||
| 4436 | ;; We had one, so gather the previous part and the | ||
| 4437 | ;; substition. | ||
| 4434 | (when (not (= start i)) | 4438 | (when (not (= start i)) |
| 4435 | (push (substring instring start i) result)) | 4439 | (push (substring instring start i) result)) |
| 4436 | (push tostring result) | 4440 | (push tostring result) |
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 8bec097aadf..2adb4a62e86 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." | |||
| 450 | (should (equal (replace-in-string "zot" "bar" "barfoozot") | 450 | (should (equal (replace-in-string "zot" "bar" "barfoozot") |
| 451 | "barfoobar")) | 451 | "barfoobar")) |
| 452 | (should (equal (replace-in-string "z" "bar" "barfoozot") | 452 | (should (equal (replace-in-string "z" "bar" "barfoozot") |
| 453 | "barfoobarot"))) | 453 | "barfoobarot")) |
| 454 | (should (equal (replace-in-string "zot" "bar" "zat") | ||
| 455 | "zat")) | ||
| 456 | (should (equal (replace-in-string "azot" "bar" "zat") | ||
| 457 | "zat")) | ||
| 458 | (should (equal (replace-in-string "azot" "bar" "azot") | ||
| 459 | "bar"))) | ||
| 454 | 460 | ||
| 455 | (provide 'subr-tests) | 461 | (provide 'subr-tests) |
| 456 | ;;; subr-tests.el ends here | 462 | ;;; subr-tests.el ends here |