bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21454: 25.1.50; `parse-colon-path' fails with file names containing


From: Tino Calancha
Subject: bug#21454: 25.1.50; `parse-colon-path' fails with file names containing multiple consecutive "/"
Date: Tue, 13 Sep 2016 18:40:12 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)



On Tue, 13 Sep 2016, Andreas Schwab wrote:

On Sep 13 2016, Tino Calancha <tino.calancha@gmail.com> wrote:

+                    ;; backward compatibility.
+                    (while (and (char-equal ?/ (aref dir 0))
+                                (char-equal ?/ (aref dir 1)))
+                      (setq dir (substring dir 1))) dir)))
aref signals an error if dir is too short.  You can also avoid the loop
if you write it as (if (string-match "\\`/+" dir) (substring
dir (1- (match-end 0))) dir).

Indeed.  Thank you very much!
Here is the new patch:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 9adbc52a3b7a744fddc6f6692d53bc6617d5892c Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Tue, 13 Sep 2016 18:34:29 +0900
Subject: [PATCH] parse-colon-path:  Handle a dir with 2 consecutive dir
 separator

Do not truncate /foo//bar to /bar/
* lisp/files.el (parse-colon-path): Use substitute-env-vars and
expand-file-name instead of substitute-in-file-name (Bug#21454).
---
 lisp/files.el | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 4bd708d..7b84ae5 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -672,10 +672,16 @@ parse-colon-path
 a leading or trailing separator, or two adjacent separators), return
 nil (meaning `default-directory') as the associated list element."
   (when (stringp search-path)
-    (mapcar (lambda (f)
-             (if (equal "" f) nil
-               (substitute-in-file-name (file-name-as-directory f))))
-           (split-string search-path path-separator))))
+    (let ((spath (substitute-env-vars search-path)))
+      (mapcar (lambda (f)
+                (if (equal "" f) nil
+ (let ((dir (expand-file-name (file-name-as-directory f)))) + ;; Previous implementation used `substitute-in-file-name' + ;; which collapse multiple "/" in front. Do the same for
+                    ;; backward compatibility.
+                    (if (string-match "\\`/+" dir)
+                        (substring dir (1- (match-end 0))) dir))))
+              (split-string spath path-separator)))))

 (defun cd-absolute (dir)
   "Change current directory to given absolute file name DIR."
--
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.21.5)
 of 2016-09-13
Repository revision: ead76c4603f2c4a1761ab8a7dd5cf6f56e782fb2






reply via email to

[Prev in Thread] Current Thread [Next in Thread]