1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

(combine-and-quote-strings): Also quote strings that contain the separator.

This commit is contained in:
Stefan Monnier 2008-04-07 16:29:54 +00:00
parent e66d87717a
commit 9f2bd2e7c9
2 changed files with 6 additions and 2 deletions

View File

@ -10,6 +10,9 @@
2008-04-07 Stefan Monnier <monnier@iro.umontreal.ca>
* subr.el (combine-and-quote-strings): Also quote strings that contain
the separator.
* pcvs-util.el (cvs-map): Avoid recursion :-(
2008-04-07 Glenn Morris <rgm@gnu.org>

View File

@ -2987,10 +2987,11 @@ Modifies the match data; use `save-match-data' if necessary."
This tries to quote the strings to avoid ambiguity such that
(split-string-and-unquote (combine-and-quote-strings strs)) == strs
Only some SEPARATORs will work properly."
(let ((sep (or separator " ")))
(let* ((sep (or separator " "))
(re (concat "[\\\"]" "\\|" (regexp-quote sep))))
(mapconcat
(lambda (str)
(if (string-match "[\\\"]" str)
(if (string-match re str)
(concat "\"" (replace-regexp-in-string "[\\\"]" "\\\\\\&" str) "\"")
str))
strings sep)))