From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#57353: [PATCH] Fix parse-colon-path with UNC directory names Date: Wed, 24 Aug 2022 17:15:53 +0300 Message-ID: <83fshl682u.fsf@gnu.org> References: <83bksb859u.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11770"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57353@debbugs.gnu.org To: rcopley@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 24 16:16:28 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQrBD-0002s4-AW for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Aug 2022 16:16:27 +0200 Original-Received: from localhost ([::1]:43984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQrBB-0004Ky-3j for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Aug 2022 10:16:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQrAp-0004KE-Ce for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2022 10:16:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQrAp-0002j0-3j for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2022 10:16:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQrAo-0006r8-Vx for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2022 10:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Aug 2022 14:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57353 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 57353-submit@debbugs.gnu.org id=B57353.166135055726325 (code B ref 57353); Wed, 24 Aug 2022 14:16:02 +0000 Original-Received: (at 57353) by debbugs.gnu.org; 24 Aug 2022 14:15:57 +0000 Original-Received: from localhost ([127.0.0.1]:47589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQrAi-0006qR-Sc for submit@debbugs.gnu.org; Wed, 24 Aug 2022 10:15:57 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQrAd-0006q2-CV for 57353@debbugs.gnu.org; Wed, 24 Aug 2022 10:15:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:37264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQrAY-0002fu-0n; Wed, 24 Aug 2022 10:15:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=9qcd6V7OqsPsvV45EhHj4ZHZDFV6PP8xLweA6S9RAO4=; b=h2RdZEfihl2a 7eCKox9vgEy+RG9uwYp/bRQYn5xWzihYtL3rSkhAFmWNcAVLSg42ZCj86Kepp4jmKoDg4R/Woln38 x0z3phXSLOtKmckR/1w2b/YXMXZFQSy6x+9nbo4H9eWPKAyGEYDTAXUKNEcrpIMQPpNJFHz6Ua966 a7HYQWQlj0If1aHQsvmyhA7rfwbXMI0vffMyZssXETK8JDDPwHvaEJp0nyOeaRzG4BcWFoCkNwvGJ Uoo5kunBOtM5HecRUjpTVzFLQtyqzjkkf8I4H8bQfKyxiunKUc5mtfHpM9/BqvqPdQ0ueqYCo4k4Z fnhYYF8u9zm2rV8gBK/I/Q==; Original-Received: from [87.69.77.57] (port=3473 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQrAX-0002g6-C5; Wed, 24 Aug 2022 10:15:45 -0400 In-Reply-To: <83bksb859u.fsf@gnu.org> (message from Eli Zaretskii on Tue, 23 Aug 2022 16:21:17 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:240627 Archived-At: > Cc: 57353@debbugs.gnu.org > Date: Tue, 23 Aug 2022 16:21:17 +0300 > From: Eli Zaretskii > > > From: Richard Copley > > Date: Tue, 23 Aug 2022 12:34:02 +0100 > > > > 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" > > That is true, but: > > (substitute-in-file-name "///foo/a/b") => "//foo/a/b" > > So it does collapse multiple "/", at least sometimes. Moreover, the > above is on MS-Windows, but on GNU/Linux: > > (substitute-in-file-name "///foo/a/b") => "/foo/a/b" > > So (a) this is system-dependent, and (b) substitute-in-file-name does > collapse multiple slashes, but preserves UNCs on MS-Windows. > > Therefore, your patch needs some (minor) amendments. 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)