From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: init_buffer PWD fix Date: Mon, 22 Apr 2002 14:14:48 +0300 (IDT) Sender: emacs-devel-admin@gnu.org Message-ID: References: <200204220722.g3M7M5D23857@sic.twinsun.com> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1019470730 4627 127.0.0.1 (22 Apr 2002 10:18:50 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 22 Apr 2002 10:18:50 +0000 (UTC) Cc: knagano@sodan.org, emacs-devel@gnu.org, andrewi@gnu.org, jasonr@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16zauI-0001CW-00 for ; Mon, 22 Apr 2002 12:18:50 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16zauw-00011b-00 for ; Mon, 22 Apr 2002 12:19:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16zau5-0007Nr-00; Mon, 22 Apr 2002 06:18:37 -0400 Original-Received: from is.elta.co.il ([199.203.121.2]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16zarn-0007DI-00; Mon, 22 Apr 2002 06:16:16 -0400 Original-Received: from is (is [199.203.121.2]) by is.elta.co.il (8.9.3/8.8.8) with SMTP id OAA14717; Mon, 22 Apr 2002 14:14:48 +0300 (IDT) X-Sender: eliz@is Original-To: Paul Eggert In-Reply-To: <200204220722.g3M7M5D23857@sic.twinsun.com> Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:3014 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:3014 On Mon, 22 Apr 2002, Paul Eggert wrote: > > > Fcopy_file uses the conditional > > > `#if !defined (DOS_NT) || __DJGPP__ > 1' before inspecting st_ino; > > > would that be appropriate here too? > > > > DJGPP emulates the inodes well enough for the code to work, but the > > Windows port is not compiled with DJGPP. > > Hmm, I guess nobody told the author of Fcopy_file.... Perhaps there's > an opportunity for code consolidation/cleanup there. Not sure what you mean here: the inode comparison is ifdef'ed away for the Windows port, so on Windows Emacs simply doesn't support the feature whereby it tells you that the source and destinations are the same file. But since there are no symlinks on Windows, the only way this can happen is if the user transmogrifies the file name in some way, which is something less probable than collisions involving symlinks. Or did you mean something else? > Anyway, rather than get sucked into st_ino portability hell, how about > checking st_mtime as well? That is, after doing this: > > && stat (pwd, &pwdstat) == 0 > && stat (".", &dotstat) == 0 > && dotstat.st_ino == pwdstat.st_ino > && dotstat.st_dev == pwdstat.st_dev > > init_buffer can do this: > > && dotstat.st_mtime == pwdstat.st_mtime > > This won't hurt much on non-broken systems, and it should fix the vast > majority of the problem on systems where st_ino is broken. That would be unreliable, I think: on some Windows filesystems, the time stamp of a directory is determined when the directory is created, and then never changes (and cannot be changed with any system call, only by accessing the disk at the sector level). > > Personally, I think the code in buffer.c could compare normalized file > > names as either an alternative or a complementary to the inode method. > > What's a "normalized file name"? For DOS/Windows systems, it's roughly a full absolute file name, in some standard letter-case (either all uppercase or all lowercase), and with all slashes converted to a single style (either all forward slashes or all backslashes). > Can it be computed as quickly as an inode number can? Every reliable method of inode simulation that I know of begins by computing a normalized file name (since you need to assign the same inode number when you see the same file). So it's as fast as a simulated inode or faster. Perhaps it's high time we added a file-name comparison primitive to Emacs. There are few other places where it could be useful. On Posix platforms it could compare inodes, while other platforms will do their own magic.