diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 16 |
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 | |||
| 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | 18 | the 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 () | |||
| 1359 | init_buffer () | 1361 | init_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 |