summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorAndrew Innes <andrewi@gnu.org>1999-01-17 18:55:53 +0000
committerAndrew Innes <andrewi@gnu.org>1999-01-17 18:55:53 +0000
commit1ccaea525e5580acbd88624ecc9554d2a6b7d641 (patch)
tree34fde640048c0d7b1680db03c87f8b5b8babc853 /lisp
parent795537a21c2ad08be72c571a9e3756dec226e90d (diff)
downloademacs-1ccaea525e5580acbd88624ecc9554d2a6b7d641.tar.gz
(subst-char-in-string): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el11
1 files changed, 11 insertions, 0 deletions
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."