Subject: bug#21454: 25.0.93; `parse-colon-path' over dirs with 2 consecutive dir sep

From: Tino Calancha <[email-masked]>
Date: Mon, 25 Apr 2016 02:26:30 +0900 (JST)

There are 2 typos in previous report:

>B) path="$BAZ/bin" ; fails (FOO is not a directory file name)
Should be:
B) path="$BAZ/bin" ; fails (BAZ is not a directory file name)

>let ((foo "/foo/bar/baz/qux/:/quux/corge/:/grault/graply/waldo")) ; `ok'
>  (setenv "FOO" foo)
>  (parse-colon-path "$FOO"))
>("/foo/bar/baz/qux/:/quux/corge/:/grault/graply/waldo/")
It's _not_ ok: `parse-colon-path' returns list with 1 element (don't split on ':').

New patch applied over previous tests returns:

("/foo/bar/baz/" "/qux/quux/corge/")
("/foo/bar/baz/qux/" "/quux/corge/" "/grault/graply/waldo/")
("/foo/bar/baz/qux/" "/quux/corge/" "/grault/graply/waldo/")
("/foo/bar/baz/qux/" "/quux/corge/" "/grault/graply/waldo/")
("/foo/bar/baz/qux/" "/quux/corge/" "/grault/garply/waldo/")
("/foo/bar/baz/qux/" "/quux/corge/" "/grault/garply/waldo/")
("/foo/bar/baz/qux/" "/quux/corge/")
("/foo/bar/baz/qux/" "/quux/corge/")

In GNU Emacs 25.0.93.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
  of 2016-04-25 built on calancha-pc
Repository revision: 0cd2e923dba8d8c7128b0c084ce6af22069e8db5

diff --git a/lisp/files.el b/lisp/files.el
index 5cdd384..7d92535 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -675,10 +675,14 @@ 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 ((path (mapconcat 'identity
+                           (mapcar 'substitute-env-vars
+                                   (split-string search-path path-separator))
+                           path-separator)))
+      (mapcar (lambda (f)
+                (if (equal "" f) nil
+                  (file-name-as-directory (expand-file-name f))))
+              (split-string path path-separator)))))
 
 (defun cd-absolute (dir)
   "Change current directory to given absolute file name DIR."