Subject: bug#57353: closed (Re: bug#57353: [PATCH] Fix parse-colon-path with UNC directory names)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 24 Aug 2022 16:22:02 +0000

Your bug report

#57353: [PATCH] Fix parse-colon-path with UNC directory names

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
57353: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57353
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#57353: [PATCH] Fix parse-colon-path with UNC directory names
From: Eli Zaretskii <[email-masked]>
To: Richard Copley <[email-masked]>
Cc: [email-masked]
Date: Wed, 24 Aug 2022 19:21:47 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Richard Copley <[email-masked]>
> Date: Wed, 24 Aug 2022 15:23:56 +0100
> Cc: [email-masked]
> 
> On Wed, 24 Aug 2022 at 15:15, Eli Zaretskii <[email-masked]> wrote:
> >
> > Does the patch below give good results in your use cases?
> >
> > diff --git a/lisp/files.el b/lisp/files.el
> > index 8596d9a..26730df 100644
> > --- a/lisp/files.el
> > +++ b/lisp/files.el
> > @@ -856,10 +856,16 @@ parse-colon-path
> >                  (if (equal "" f) nil
> >                    (let ((dir (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))))
> > +                    ;; which collapses multiple "/" in front, while
> > +                    ;; preserving double slash where it matters.  Do
> > +                    ;; the same for backward compatibility.
> > +                    (if (string-match "\\`//+" dir)
> > +                        (substring dir
> > +                                   (- (match-end 0)
> > +                                      (if (memq system-type
> > +                                                '(windows-nt 'cygwin 'ms-dos))
> > +                                          2 1)))
> > +                      dir))))
> >                (split-string spath path-separator)))))
> >
> >  (defun cd-absolute (dir)
> 
> It does.

Thanks, installed with minor changes, and closing the bug.

Subject: [PATCH] Fix parse-colon-path with UNC directory names
From: Richard Copley <[email-masked]>
To: [email-masked]
Date: Tue, 23 Aug 2022 12:34:02 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

The function `parse-colon-path' changes the leading double slash
in a UNC path component to a single slash:

(let path (mapconcat path-separator "one" "//server/share/dir")
     (parse-colon-path path))
## -> ("one" "/server/share/dir")

A comment in `parse-colon-path' says:

;; Previous implementation used `substitute-in-file-name'
;; which collapse multiple "/" in front.  Do the same for
;; backward compatibility.

However, `substitute-in-file-name' does not do that:

(substitute-in-file-name "//foo/a/b") // -> "//foo/a/b"

There's no reason to do it in `parse-colon-path' either.
From 55eb8c37eeabf11f9fc1ec1f84c64fc234ecf59f Mon Sep 17 00:00:00 2001
From: Richard Copley <[email-masked]>
Date: Tue, 23 Aug 2022 12:11:20 +0100
Subject: [PATCH] Fix parse-colon-path with UNC directory names

* lisp/files.el (parse-colon-path): don't collapse multiple / at
beginning of path component
---
 lisp/files.el | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index cf2a522193..569fd0224e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -853,13 +853,8 @@ nil (meaning `default-directory') as the associated list element."
   (when (stringp search-path)
     (let ((spath (substitute-env-vars search-path)))
       (mapcar (lambda (f)
-                (if (equal "" f) nil
-                  (let ((dir (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))))
+                (unless (equal "" f)
+                  (file-name-as-directory f)))
               (split-string spath path-separator)))))
 
 (defun cd-absolute (dir)
-- 
2.37.0.windows.1