From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs 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) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1473759689 5348 195.159.176.226 (13 Sep 2016 09:41:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Sep 2016 09:41:29 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 21454@debbugs.gnu.org, Tino Calancha To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 13 11:41:25 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjkDL-0008Rb-QI for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Sep 2016 11:41:16 +0200 Original-Received: from localhost ([::1]:47551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjkDJ-0006B8-UT for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Sep 2016 05:41:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjkDD-0006As-Ik for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 05:41:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjkD8-00037e-JN for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 05:41:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjkD8-00037P-FX for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 05:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bjkD8-0000gP-7i for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 05:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Sep 2016 09:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21454 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 21454-submit@debbugs.gnu.org id=B21454.14737596242571 (code B ref 21454); Tue, 13 Sep 2016 09:41:02 +0000 Original-Received: (at 21454) by debbugs.gnu.org; 13 Sep 2016 09:40:24 +0000 Original-Received: from localhost ([127.0.0.1]:58215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjkCV-0000fO-Kw for submit@debbugs.gnu.org; Tue, 13 Sep 2016 05:40:23 -0400 Original-Received: from mail-pa0-f46.google.com ([209.85.220.46]:34364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjkCT-0000f6-Va for 21454@debbugs.gnu.org; Tue, 13 Sep 2016 05:40:22 -0400 Original-Received: by mail-pa0-f46.google.com with SMTP id wk8so6296133pab.1 for <21454@debbugs.gnu.org>; Tue, 13 Sep 2016 02:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=MR8Agy0mY9Gp0pgpaaM8XB38+yUjwqrM3YhjA5LFb8Y=; b=ePg+LlAaPaFEvajh2nj6o9cZYk9Ml9u4y9YgnnXdbcmqmBbLyK0DRW2t7UFhIFFwZx 5+pI9fl+EXGWEwqCDpx/HZzEXijjyF+T5j9SSSy/fxWqcyYk6QOCfQYkDcjzwzut+QYs fUqE30rWQ6aGja17db02sA+0YkRZ4pGmLbhVrl4ESb2E30eefti0aP8YIx9H/8P48Ufu Hjo6qoTDI05VY6ZMz/ytnnibtUFPjU+aVXXNrrsvJoPjI+JJPryQ5ySxl5rtLPNTy+Ls LQyFFpWqgbqX5WguD/4xLHNYhc9AUZUM6y+EbVKokIL6hTgy/g27qi8/oBJFsHlT/G1A rAMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=MR8Agy0mY9Gp0pgpaaM8XB38+yUjwqrM3YhjA5LFb8Y=; b=Vh0imN/BT5kp/K4ntN1YBplgSQ7dmHCzET064KY84P+7aY2pY9wXckeOIBhrzaaq9x 0D8gu8ao3CJAb846xLqmM76pFKkG0Y2bBr7VjiBJk3PbR7vQXAkVnxISs1YLcHis6SJf ToxS0Gc5U5EPIAnFSNAnNiZNxJxAQIwUsoxiruWa1uv3XIgi6sEcNbf36cvMi+sBHvQK xXzdIMZ8IX6+NJOlC1BGYldS9AzTBK4mICg9GsPe+7zDJdI8MZvts6ILT9yq/YGingYr zoOv1HNNbkWifFS0htuWFpVh433XnM9SikDwvHUlX9EXcIgrz8RuFILmZ+6eR4hnaObi 9lWg== X-Gm-Message-State: AE9vXwPhmdD9c7n7hFGbo11eDpkF8TLA+2gRfuEikjAhUGyNUSVDVgysrjtVJnNEI5ZGLA== X-Received: by 10.66.249.74 with SMTP id ys10mr42483464pac.29.1473759615948; Tue, 13 Sep 2016 02:40:15 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id o5sm29882570pfb.9.2016.09.13.02.40.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2016 02:40:15 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:123248 Archived-At: On Tue, 13 Sep 2016, Andreas Schwab wrote: > On Sep 13 2016, Tino Calancha 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 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