[xemacs-base] Fix infloop in comint-quote-filename

Stephen J. Turnbull stephen at xemacs.org
Wed Feb 28 02:00:38 EST 2007


xemacs-base

"Some people, when confronted with a problem, think 'I know, I'll use
regular expressions.' Now they have two problems."

This patch eliminates one of the problems, and I hope it addresses the
second as well.  It seems to work in light standalone testing, but I
haven't used it in place much yet.

The original code often infloops if the original string contains a
backslash on Unix (since many modes bind comint-file-name-quote-list
to a list containing backslash).

The code I propose assumes that what is passed to it is a raw string,
in the sense that any backslashes are intended to be part of the name.
I think that's what is intended.  It's one-pass by definition, so
can't infloop.

ChangeLog addition:

2007-02-28  Stephen J. Turnbull  <stephen at xemacs.org>

	* comint.el (comint-quote-filename): Fix infloop.


xemacs-base source patch:
Diff command:   cvs -q diff -u
Files affected: comint.el
Index: comint.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/xemacs-base/comint.el,v
retrieving revision 1.19
diff -u -u -r1.19 comint.el
--- comint.el	31 Jul 2006 17:08:44 -0000	1.19
+++ comint.el	28 Feb 2007 04:13:44 -0000
@@ -2811,13 +2811,10 @@
 Magic characters are those in `comint-file-name-quote-list'."
   (if (null comint-file-name-quote-list)
       filename
-    (let ((regexp
-	   (format "\\(^\\|[^\\]\\)\\([%s]\\)"
-	    (mapconcat 'char-to-string comint-file-name-quote-list ""))))
-      (save-match-data
-	(while (string-match regexp filename)
-	  (setq filename (replace-match "\\1\\\\\\2" nil nil filename)))
-	filename))))
+    (mapconcat (lambda (x)
+		 (concat (if (memq x comint-file-name-quote-list) "\\" "")
+			 (char-to-string x)))
+	       filename)))
 
 (defun comint-unquote-filename (filename)
   "Return FILENAME with quoted characters unquoted."



More information about the XEmacs-Patches mailing list