aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorJim Blandy1992-11-07 07:00:04 +0000
committerJim Blandy1992-11-07 07:00:04 +0000
commit2381d133384a57886ae6509b4f2712cc706999d2 (patch)
tree44496e8515caa7bc57aed2567110f68910008d9e /src/buffer.c
parentd0f7e1511e23359d58184e59dccffa61f03ee0b8 (diff)
downloademacs-2381d133384a57886ae6509b4f2712cc706999d2.tar.gz
emacs-2381d133384a57886ae6509b4f2712cc706999d2.zip
* buffer.c (init_buffer): If PWD is accurate, use it instead of
calling getwd. #include <sys/types.h> and <sys/stat.h>, for the call to stat.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 83f7826b5f3..74a9ad78dd6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -18,6 +18,8 @@ along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 19
20 20
21#include <sys/types.h>
22#include <sys/stat.h>
21#include <sys/param.h> 23#include <sys/param.h>
22 24
23#ifndef MAXPATHLEN 25#ifndef MAXPATHLEN
@@ -1359,9 +1361,21 @@ init_buffer_once ()
1359init_buffer () 1361init_buffer ()
1360{ 1362{
1361 char buf[MAXPATHLEN+1]; 1363 char buf[MAXPATHLEN+1];
1364 char *pwd;
1365 struct stat dotstat, pwdstat;
1362 1366
1363 Fset_buffer (Fget_buffer_create (build_string ("*scratch*"))); 1367 Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));
1364 if (getwd (buf) == 0) 1368
1369 /* If PWD is accurate, use it instead of calling getwd. This is faster
1370 when PWD is right, and may avoid a fatal error. */
1371 if ((pwd = getenv ("PWD")) != 0 && *pwd == '/'
1372 && stat (pwd, &pwdstat) == 0
1373 && stat (".", &dotstat) == 0
1374 && dotstat.st_ino == pwdstat.st_ino
1375 && dotstat.st_dev == pwdstat.st_dev
1376 && strlen (pwd) < MAXPATHLEN)
1377 strcpy (buf, pwd);
1378 else if (getwd (buf) == 0)
1365 fatal ("`getwd' failed: %s.\n", buf); 1379 fatal ("`getwd' failed: %s.\n", buf);
1366 1380
1367#ifndef VMS 1381#ifndef VMS