From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#26911: 25.2; eshell "cd .." doesn't work correctly with TRAMP Date: Fri, 28 Aug 2020 22:52:28 -0700 Organization: UCLA Computer Science Department Message-ID: <47047d69-91aa-fd0d-1510-64ba7c246970@cs.ucla.edu> References: <693aa189-03fa-b963-89eb-ce19c51ba325@cs.ucla.edu> <83wo1jz32t.fsf@gnu.org> <83sgc7z220.fsf@gnu.org> <83r1rryrk0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------6A5D97583D7579B50A6FFD4E" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8212"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: 26911@debbugs.gnu.org, mattiase@acm.org, michael.albinus@gmx.de, yegortimoshenko@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 29 07:53:10 2020 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 1kBtnZ-00022B-Nx for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 07:53:09 +0200 Original-Received: from localhost ([::1]:50576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBtnY-00058A-MV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Aug 2020 01:53:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBtnS-000581-EU for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 01:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBtnS-0003rh-4C for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 01:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kBtnS-0006jc-28 for bug-gnu-emacs@gnu.org; Sat, 29 Aug 2020 01:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Aug 2020 05:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26911 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 26911-submit@debbugs.gnu.org id=B26911.159868036125862 (code B ref 26911); Sat, 29 Aug 2020 05:53:02 +0000 Original-Received: (at 26911) by debbugs.gnu.org; 29 Aug 2020 05:52:41 +0000 Original-Received: from localhost ([127.0.0.1]:47822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBtn7-0006j3-9M for submit@debbugs.gnu.org; Sat, 29 Aug 2020 01:52:41 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kBtn2-0006il-5a for 26911@debbugs.gnu.org; Sat, 29 Aug 2020 01:52:40 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9622B160066; Fri, 28 Aug 2020 22:52:30 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 9BCc3W9lwBjJ; Fri, 28 Aug 2020 22:52:29 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 764AB1600DA; Fri, 28 Aug 2020 22:52:29 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YiL49kzwfMed; Fri, 28 Aug 2020 22:52:29 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-75-82-69-226.socal.res.rr.com [75.82.69.226]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 3E7A2160066; Fri, 28 Aug 2020 22:52:29 -0700 (PDT) Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkV5QWNtUUJFQURB QXlIMnhvVHU3cHBHNUQzYThGTVpFb243NGRDdmM0K3ExWEEySjJ0QnkycHdhVHFmCmhweHhk R0E5Smo1MFVKM1BENGJTVUVnTjh0TFowc2FuNDdsNVhUQUZMaTI0NTZjaVNsNW04c0thSGxH ZHQ5WG0KQUF0bVhxZVpWSVlYL1VGUzk2ZkR6ZjR4aEVtbS95N0xiWUVQUWRVZHh1NDd4QTVL aFRZcDVibHRGM1dZRHoxWQpnZDdneDA3QXV3cDdpdzdlTnZub0RUQWxLQWw4S1lEWnpiRE5D UUdFYnBZM2VmWkl2UGRlSStGV1FONFcra2doCnkrUDZhdTZQcklJaFlyYWV1YTdYRGRiMkxT MWVuM1NzbUUzUWpxZlJxSS9BMnVlOEpNd3N2WGUvV0szOEV6czYKeDc0aVRhcUkzQUZINmls QWhEcXBNbmQvbXNTRVNORnQ3NkRpTzFaS1FNcjlhbVZQa25qZlBtSklTcWRoZ0IxRApsRWR3 MzRzUk9mNlY4bVp3MHhmcVQ2UEtFNDZMY0ZlZnpzMGtiZzRHT1JmOHZqRzJTZjF0azVlVThN Qml5Ti9iClowM2JLTmpOWU1wT0REUVF3dVA4NGtZTGtYMndCeHhNQWhCeHdiRFZadWR6eERa SjFDMlZYdWpDT0pWeHEya2wKakJNOUVUWXVVR3FkNzVBVzJMWHJMdzYrTXVJc0hGQVlBZ1Jy NytLY3dEZ0JBZndoU In-Reply-To: <83r1rryrk0.fsf@gnu.org> Content-Language: en-US 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:186630 Archived-At: This is a multi-part message in MIME format. --------------6A5D97583D7579B50A6FFD4E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 8/28/20 3:48 AM, Eli Zaretskii wrote: > That period after the colon following the drive letter shouldn't be > there. As you may imagine, many Emacs commands are now broken because > of this. This must be fixed ASAP. I installed the attached patch to revert the recent expand-file-changes in the DOS_NT case, which should fix the problem you mentioned. This part of fileio.c is hard to follow because of the #ifdef DOS_NT and #ifdef WINDOWSNT and #ifdef MSDOS and whatnot. How about if we move the MS-Windows-specific code to a different source file instead of having that forest of ifdefs in fileio.c? As things stand, it's hard to maintain the mainline GNU code, because the way everything's arranged the Microsoft-specific stuff significantly obfuscates everything else. --------------6A5D97583D7579B50A6FFD4E Content-Type: text/x-patch; charset=UTF-8; name="0001-Revert-recent-expand-file-name-changes-if-DOS_NT.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Revert-recent-expand-file-name-changes-if-DOS_NT.patch" >From 7d5807277ff614a337c7e4530bb8d0e0188c189b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 28 Aug 2020 22:37:29 -0700 Subject: [PATCH] Revert recent expand-file-name changes if DOS_NT * src/fileio.c (Fexpand_file_name): Restore pre-August-26 behavior, if DOS_NT. This should fix the recently-introduced expand-file-name bugs on DOS_NT (Bug#26911). --- src/fileio.c | 66 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 66010b6878..c91af36fdf 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1372,6 +1372,14 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, length = newdirlim - newdir; +#ifdef DOS_NT + /* Ignore any slash at the end of newdir, unless newdir is + just "/" or "//". */ + while (length > 1 && IS_DIRECTORY_SEP (newdir[length - 1]) + && ! (length == 2 && IS_DIRECTORY_SEP (newdir[0]))) + length--; +#endif + /* Now concatenate the directory and name to new space in the stack frame. */ tlen = length + file_name_as_directory_slop + (nmlim - nm) + 1; eassert (tlen >= file_name_as_directory_slop + 1); @@ -1388,22 +1396,40 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, if (newdir) { - if (!collapse_newdir) +#ifndef DOS_NT + bool treat_as_absolute = !collapse_newdir; +#else + bool treat_as_absolute = !nm[0] || IS_DIRECTORY_SEP (nm[0]); +#endif + if (treat_as_absolute) { - /* With ~ or ~user, leave NEWDIR as-is to avoid transforming - it from a symlink (or a regular file!) into a directory. */ - memcpy (target, newdir, length); - nbytes = length; +#ifdef DOS_NT + /* If newdir is effectively "C:/", then the drive letter will have + been stripped and newdir will be "/". Concatenating with an + absolute directory in nm produces "//", which will then be + incorrectly treated as a network share. Ignore newdir in + this case (keeping the drive letter). */ + if (!(drive && nm[0] && IS_DIRECTORY_SEP (newdir[0]) + && newdir[1] == '\0')) +#endif + { + /* With ~ or ~user, leave NEWDIR as-is to avoid transforming + it from a symlink (or a regular file!) into a directory. */ + memcpy (target, newdir, length); + nbytes = length; + } } else nbytes = file_name_as_directory (target, newdir, length, multibyte); +#ifndef DOS_NT /* If TARGET ends in a directory separator, omit leading directory separators from NM so that concatenating a TARGET "/" to an NM "/foo" does not result in the incorrect "//foo". */ if (nbytes && IS_DIRECTORY_SEP (target[nbytes - 1])) while (IS_DIRECTORY_SEP (nm[0])) nm++; +#endif } memcpy (target + nbytes, nm, nmlim - nm + 1); @@ -1420,6 +1446,7 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, { *o++ = *p++; } +#ifndef DOS_NT else if (p[1] == '.' && IS_DIRECTORY_SEP (p[2])) { /* Replace "/./" with "/". */ @@ -1432,6 +1459,18 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, *o++ = *p; p += 2; } +#else + else if (p[1] == '.' + && (IS_DIRECTORY_SEP (p[2]) + || p[2] == 0)) + { + /* If "/." is the entire filename, keep the "/". Otherwise, + just delete the whole "/.". */ + if (o == target && p[2] == '\0') + *o++ = *p; + p += 2; + } +#endif else if (p[1] == '.' && p[2] == '.' /* `/../' is the "superroot" on certain file systems. Turned off on DOS_NT systems because they have no @@ -1445,9 +1484,7 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, #endif && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0)) { -#ifdef WINDOWSNT - char *prev_o = o; -#endif +#ifndef DOS_NT while (o != target) { o--; @@ -1459,11 +1496,22 @@ DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0, break; } } -#ifdef WINDOWSNT +#else +# ifdef WINDOWSNT + char *prev_o = o; +# endif + while (o != target && (--o, !IS_DIRECTORY_SEP (*o))) + continue; +# ifdef WINDOWSNT /* Don't go below server level in UNC filenames. */ if (o == target + 1 && IS_DIRECTORY_SEP (*o) && IS_DIRECTORY_SEP (*target)) o = prev_o; + else +# endif + /* Keep initial / only if this is the whole name. */ + if (o == target && IS_ANY_SEP (*o) && p[3] == 0) + ++o; #endif p += 3; } -- 2.17.1 --------------6A5D97583D7579B50A6FFD4E--