From 9f2bd2e7c9e990b48a07be71ef47327f6cc9ba25 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 7 Apr 2008 16:29:54 +0000 Subject: [PATCH] (combine-and-quote-strings): Also quote strings that contain the separator. --- lisp/ChangeLog | 3 +++ lisp/subr.el | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e7a74037af8..7518a3a71d3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -10,6 +10,9 @@ 2008-04-07 Stefan Monnier + * 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 diff --git a/lisp/subr.el b/lisp/subr.el index 94ee316f9f4..eee59086419 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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))) -- 2.39.5