From 58dbc68628fd3a4e3f044d5717a00fac62f05c4d Mon Sep 17 00:00:00 2001 From: hmurata Date: Sat, 30 Jul 2005 08:36:14 +0000 Subject: [PATCH] (elmo-safe-filename): Rewrite to replace `"' (double quote) into "_Q_". --- elmo/ChangeLog | 5 +++++ elmo/elmo-util.el | 25 +++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 9c1d4d9..a6f9a81 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,8 @@ +2005-07-30 Hiroya Murata + + * elmo-util.el (elmo-safe-filename): Rewrite to replace + `"' (double quote) into "_Q_". + 2005-07-18 Hiroya Murata * elmo-net.el (elmo-net-quote-chars): Abolish. diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index 8953d0f..877fe51 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -1041,12 +1041,25 @@ Emacs 19.28 or earlier does not have `unintern'." (setq dest (cons (cons name body) dest)))) dest))) -(defun elmo-safe-filename (folder) - (elmo-replace-in-string - (elmo-replace-in-string - (elmo-replace-in-string folder "/" " ") - ":" "__") - "|" "_or_")) +(defun elmo-safe-filename (filename) + (let* ((replace-alist '(("/" . " ") + (":" . "__") + ("|" . "_or_") + ("\"" . "_Q_"))) + (regexp (concat "[" + (regexp-quote (mapconcat 'car replace-alist "")) + "]")) + (rest filename) + converted) + (while (string-match regexp rest) + (setq converted (concat converted + (substring rest 0 (match-beginning 0)) + (cdr (assoc (substring rest + (match-beginning 0) + (match-end 0)) + replace-alist))) + rest (substring rest (match-end 0)))) + (concat converted rest))) (defvar elmo-filename-replace-chars nil) -- 1.7.10.4