From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: init_buffer PWD fix Date: Tue, 23 Apr 2002 10:45:12 -0700 (PDT) Sender: emacs-devel-admin@gnu.org Message-ID: <200204231745.g3NHjCW00689@shade.twinsun.com> References: <200204220618.g3M6Icg23696@sic.twinsun.com> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1019584102 3548 127.0.0.1 (23 Apr 2002 17:48:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 23 Apr 2002 17:48:22 +0000 (UTC) Cc: emacs-devel@gnu.org, knagano@sodan.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 1704Os-0000v6-00 for ; Tue, 23 Apr 2002 19:48:22 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 1704QA-0001l5-00 for ; Tue, 23 Apr 2002 19:49:42 +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 1704Oj-00038C-00; Tue, 23 Apr 2002 13:48:13 -0400 Original-Received: from alcor.twinsun.com ([198.147.65.9]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 1704Lq-0002xj-00 for ; Tue, 23 Apr 2002 13:45:14 -0400 Original-Received: from shade.twinsun.com ([192.54.239.27]) by alcor.twinsun.com (8.12.1/8.12.1) with ESMTP id g3NHjCPd020663; Tue, 23 Apr 2002 10:45:12 -0700 (PDT) Original-Received: (eggert@localhost) by shade.twinsun.com (8.11.6+Sun/8.11.6) id g3NHjCW00689; Tue, 23 Apr 2002 10:45:12 -0700 (PDT) Original-To: himi@m17n.org In-Reply-To: (himi@m17n.org) 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:3120 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:3120 > From: MIYASHITA Hisashi > Date: Tue, 23 Apr 2002 15:14:31 +0900 > > But, in the first place, is this code necessary on all platform? It's not necessary everywhere, but it's necessary on many platforms (including GNU/Linux) and would be painful to figure out exactly which platforms need it and which don't. > Even now, is it really efficient on almost all of the platforms? It's pretty efficent on POSIX or near-POSIX platforms, yes. I suppose it might be slow on Windows, though I'm not a Windows expert. > FYI, I've tested the following code on Debian GNU/Linux (sid) to check > the efficiency. Efficiency is not the primary concern here. More important are: 1) Correctness. The current code works if a parent directory is searchable but not readable; on many hosts, getcwd won't work in that situation. 2) Using nice names for the working directory in the presence of symbolic links. For example, on my host: 15-shade $ cd /reb 16-shade $ echo $PWD /reb 17-shade $ /bin/pwd /net/sic/export/ford/reb When Emacs starts up, I want the working directory to be "/reb", not "/net/sic/export/ford/reb". Your benchmark indicates that Emacs needs to spend one microsecond to get the nicer name on your host; that's a win in my book. > Therefore, I'd like to propose to remove this hacked optimization > from init_buffer(). I'd rather leave it in, for the above reasons. However, the code's comment was misleading since it implies that the $PWD code is there purely for optimization purposes. It is faster on many traditional hosts (for example, it is faster on my Solaris 8 host) but you're correct that it's not faster on GNU/Linux hosts. I have checked in a fix to the comment, so that it looks like this instead: /* If PWD is accurate, use it instead of calling getwd. PWD is sometimes a nicer name, and using it may avoid a fatal error if a parent directory is searchable but not readable. */