mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-18 18:05:07 +00:00
(init_buffer): Use get_current_dir_name.
This commit is contained in:
parent
f78f1a83df
commit
01537133a0
41
src/buffer.c
41
src/buffer.c
@ -32,10 +32,6 @@ Boston, MA 02110-1301, USA. */
|
|||||||
extern int errno;
|
extern int errno;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAXPATHLEN
|
|
||||||
/* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */
|
|
||||||
#define MAXPATHLEN 1024
|
|
||||||
#endif /* not MAXPATHLEN */
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -54,6 +50,8 @@ extern int errno;
|
|||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
|
extern char * get_current_dir_name ();
|
||||||
|
|
||||||
struct buffer *current_buffer; /* the current buffer */
|
struct buffer *current_buffer; /* the current buffer */
|
||||||
|
|
||||||
/* First buffer in chain of all buffers (in reverse order of creation).
|
/* First buffer in chain of all buffers (in reverse order of creation).
|
||||||
@ -5115,7 +5113,6 @@ init_buffer_once ()
|
|||||||
void
|
void
|
||||||
init_buffer ()
|
init_buffer ()
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN + 1];
|
|
||||||
char *pwd;
|
char *pwd;
|
||||||
struct stat dotstat, pwdstat;
|
struct stat dotstat, pwdstat;
|
||||||
Lisp_Object temp;
|
Lisp_Object temp;
|
||||||
@ -5138,37 +5135,23 @@ init_buffer ()
|
|||||||
if (NILP (buffer_defaults.enable_multibyte_characters))
|
if (NILP (buffer_defaults.enable_multibyte_characters))
|
||||||
Fset_buffer_multibyte (Qnil);
|
Fset_buffer_multibyte (Qnil);
|
||||||
|
|
||||||
/* If PWD is accurate, use it instead of calling getwd. PWD is
|
pwd = get_current_dir_name ();
|
||||||
sometimes a nicer name, and using it may avoid a fatal error if a
|
|
||||||
parent directory is searchable but not readable. */
|
if(!pwd)
|
||||||
if ((pwd = getenv ("PWD")) != 0
|
fatal ("`get_cwd' failed: %s\n", strerror (errno));
|
||||||
&& (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1])))
|
|
||||||
&& stat (pwd, &pwdstat) == 0
|
|
||||||
&& stat (".", &dotstat) == 0
|
|
||||||
&& dotstat.st_ino == pwdstat.st_ino
|
|
||||||
&& dotstat.st_dev == pwdstat.st_dev
|
|
||||||
&& strlen (pwd) < MAXPATHLEN)
|
|
||||||
strcpy (buf, pwd);
|
|
||||||
#ifdef HAVE_GETCWD
|
|
||||||
else if (getcwd (buf, MAXPATHLEN+1) == 0)
|
|
||||||
fatal ("`getcwd' failed: %s\n", strerror (errno));
|
|
||||||
#else
|
|
||||||
else if (getwd (buf) == 0)
|
|
||||||
fatal ("`getwd' failed: %s\n", buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef VMS
|
#ifndef VMS
|
||||||
/* Maybe this should really use some standard subroutine
|
/* Maybe this should really use some standard subroutine
|
||||||
whose definition is filename syntax dependent. */
|
whose definition is filename syntax dependent. */
|
||||||
rc = strlen (buf);
|
rc = strlen (pwd);
|
||||||
if (!(IS_DIRECTORY_SEP (buf[rc - 1])))
|
if (!(IS_DIRECTORY_SEP (pwd[rc - 1])))
|
||||||
{
|
{
|
||||||
buf[rc] = DIRECTORY_SEP;
|
pwd[rc] = DIRECTORY_SEP;
|
||||||
buf[rc + 1] = '\0';
|
pwd[rc + 1] = '\0';
|
||||||
}
|
}
|
||||||
#endif /* not VMS */
|
#endif /* not VMS */
|
||||||
|
|
||||||
current_buffer->directory = make_unibyte_string (buf, strlen (buf));
|
current_buffer->directory = make_unibyte_string (pwd, strlen (pwd));
|
||||||
if (! NILP (buffer_defaults.enable_multibyte_characters))
|
if (! NILP (buffer_defaults.enable_multibyte_characters))
|
||||||
/* At this momemnt, we still don't know how to decode the
|
/* At this momemnt, we still don't know how to decode the
|
||||||
direcotry name. So, we keep the bytes in multibyte form so
|
direcotry name. So, we keep the bytes in multibyte form so
|
||||||
@ -5190,6 +5173,8 @@ init_buffer ()
|
|||||||
|
|
||||||
temp = get_minibuffer (0);
|
temp = get_minibuffer (0);
|
||||||
XBUFFER (temp)->directory = current_buffer->directory;
|
XBUFFER (temp)->directory = current_buffer->directory;
|
||||||
|
|
||||||
|
free (pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the buffer routines */
|
/* initialize the buffer routines */
|
||||||
|
Loading…
Reference in New Issue
Block a user