* lisp/subr.el (replace-in-string): Raise an error if FROMSTRING is
empty.
* test/lisp/subr-tests.el (replace-in-string): Add test case.
(defun replace-in-string (fromstring tostring instring)
"Replace FROMSTRING with TOSTRING in INSTRING each time it occurs."
(declare (pure t))
+ (when (equal fromstring "")
+ (signal 'wrong-length-argument fromstring))
(let ((start 0)
(result nil)
pos)
(should (equal (replace-in-string "\377" "x" "a\377b")
"axb"))
(should (equal (replace-in-string "\377" "x" "a\377ø")
- "axø")))
+ "axø"))
+
+ (should-error (replace-in-string "" "x" "abc")))
(provide 'subr-tests)
;;; subr-tests.el ends here