diff lisp/subr.el @ 24089:70954a8be49b

(subst-char-in-string): New function.
author Andrew Innes <andrewi@gnu.org>
date Sun, 17 Jan 1999 18:55:53 +0000
parents f36caedebd5f
children 418feab1639c
line wrap: on
line diff
--- a/lisp/subr.el	Sun Jan 17 16:51:51 1999 +0000
+++ b/lisp/subr.el	Sun Jan 17 18:55:53 1999 +0000
@@ -1092,6 +1092,17 @@
 	      (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."