From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#7617: 24.0.50; `expand-file-name': removal of slashes Date: Sun, 12 Dec 2010 10:58:26 -0500 Message-ID: References: <7F477A16FFA145E5AB532A96F55D5CDC@us.oracle.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1292170960 6098 80.91.229.12 (12 Dec 2010 16:22:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 12 Dec 2010 16:22:40 +0000 (UTC) Cc: 7617@debbugs.gnu.org To: "Drew Adams" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 12 17:22:36 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PRoh2-000257-34 for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Dec 2010 17:22:36 +0100 Original-Received: from localhost ([127.0.0.1]:51369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PRoh1-0008Pl-JC for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Dec 2010 11:22:35 -0500 Original-Received: from [140.186.70.92] (port=45732 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PRogr-0008K6-Nz for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2010 11:22:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PRogq-0005m1-6Y for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2010 11:22:25 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PRogq-0005lw-4v for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2010 11:22:24 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PRoEP-00040d-N4; Sun, 12 Dec 2010 10:53:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Dec 2010 15:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7617 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7617-submit@debbugs.gnu.org id=B7617.129216914415366 (code B ref 7617); Sun, 12 Dec 2010 15:53:01 +0000 Original-Received: (at 7617) by debbugs.gnu.org; 12 Dec 2010 15:52:24 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PRoDn-0003zn-5S for submit@debbugs.gnu.org; Sun, 12 Dec 2010 10:52:23 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PRoDl-0003za-EK for 7617@debbugs.gnu.org; Sun, 12 Dec 2010 10:52:22 -0500 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1PRoJe-00024G-P9; Sun, 12 Dec 2010 10:58:26 -0500 In-reply-to: <7F477A16FFA145E5AB532A96F55D5CDC@us.oracle.com> (drew.adams@oracle.com) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 12 Dec 2010 10:53:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:42439 Archived-At: > From: "Drew Adams" > Date: Sat, 11 Dec 2010 13:53:38 -0800 > Cc: > > emacs -Q > > (expand-file-name "share/" "~/today//usr/") -> > c:/today/usr/share/. > > (On my Windows laptop, `~' is just `c:/'.) > > IOW, multiple consecutive slashes are collapsed to one. Correct. > This is not the behavior I want. This behavior started in Emacs 21; > in Emacs 20 no such removal of slashes occurs. Indeed, this change was made in preparation for release of Emacs 21.1: 2001-03-02 Gerd Moellmann * fileio.c (Fexpand_file_name): Collapse sequences of slashes to a single slash in the middle of file names. > I would consider this loss of slashes a bug. Please explain why you consider this a bug. foo//bar is at best equivalent to foo/bar, and at worst simply fails various system calls and naive Lisp code that doesn't expect more than one slash in a row. > But I see that comments in > the current C code indicate that it is intentional (but not _why_). I didn't find any related discussions that would explain the immediate reasons for the above change. So I don't know (and certainly don't remember ;-) why it was made. But I do think it's the right behavior for expand-file-name, because other primitives and Lisp code normally expects a canonicalized file name, so it would make sense to have a single primitive that produces such canonicalized file names. > I don't have C source for Emacs 21, but the behavior of 21 indicates that > that is when the change was made, presumably intentionally. I searched > the change logs but found no mention of this change or why it was made. See above, for the change log, but it is not really helpful in saying why (nor should it be). I haven't found anything in NEWS, either. > Given that the change was presumably intentional (but why?), you might > not be disposed to consider this a bug. I imagine you might argue that > the second arg to `expand-file-name' in this case is not a valid > directory name, so all bets are off wrt the behavior - or something like > that. Or perhaps you will argue that `expand*' is supposed to give you > a canonicalized file name, and a name such as "c:/today//usr/share/" > cannot be said to be canonicalized. Right, on both counts. > But shouldn't `expand-file-name' do the right thing if the second arg is > in fact `file-directory-p'? > > For a user on GNU/Linux with $HOME = /home/toto": > (file-directory-p "~/today//usr") -> nil, but > (file-directory-p "~//usr/") --> t, and we have the same problem: > (expand-file-name "foo" "~//usr/") -> "/home/toto/usr/foo" > > Surely the behavior here is buggy, no? Sorry, I don't see a bug here. Please explain more. > The result should be "/home/toto//usr/foo", I would think. Not clear why. As I said, "/home/toto//usr/foo" is at best equivalent to "/home/toto/usr/foo", and at worst will simply fail in another place. So what does the former give you that the latter doesn't? > _Why should_ `expand-file-name' collapse multiple consecutive > slashes into a single slash? In order to produce a _canonicalized_ file name. > Finally, I need the Emacs 20 behavior for this for some of my code. Can you describe the use-case where the old behavior is needed? > Oh, and another thing. This behavior of `expand-file-name' is not documented. Well, one could argue that "canonicalized" does mean removing consecutive slashes, but I guess it's easy enough to say that explicitly in the doc string.