* lisp/subr.el (replace-in-string): Fix thinko in implementation.
(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)
(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