From 1ccaea525e5580acbd88624ecc9554d2a6b7d641 Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Sun, 17 Jan 1999 18:55:53 +0000 Subject: [PATCH] (subst-char-in-string): New function. --- lisp/subr.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/subr.el b/lisp/subr.el index cdbb06b4b5d..e4c2c1e6978 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1092,6 +1092,17 @@ at the end of STRING, we don't include a null substring for that." (cons (substring string start) list))) (nreverse list))) + +(defun subst-char-in-string (fromchar tochar string &optional inplace) + "Replace FROMCHAR with TOCHAR in STRING each time it occurs. +Unless optional argument INPLACE is non-nil, return a new string." + (let ((i (length string)) + (newstr (if inplace string (copy-sequence string)))) + (while (> i 0) + (setq i (1- i)) + (if (eq (aref newstr i) fromchar) + (aset newstr i tochar))) + newstr)) (defun shell-quote-argument (argument) "Quote an argument for passing as argument to an inferior shell." -- 2.39.2