32 |
extern int errno; |
extern int errno; |
33 |
#endif |
#endif |
34 |
|
|
|
#ifndef MAXPATHLEN |
|
|
/* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */ |
|
|
#define MAXPATHLEN 1024 |
|
|
#endif /* not MAXPATHLEN */ |
|
35 |
|
|
36 |
#ifdef HAVE_UNISTD_H |
#ifdef HAVE_UNISTD_H |
37 |
#include <unistd.h> |
#include <unistd.h> |
50 |
#include "keymap.h" |
#include "keymap.h" |
51 |
#include "frame.h" |
#include "frame.h" |
52 |
|
|
53 |
|
extern char * get_current_dir_name (); |
54 |
|
|
55 |
struct buffer *current_buffer; /* the current buffer */ |
struct buffer *current_buffer; /* the current buffer */ |
56 |
|
|
57 |
/* First buffer in chain of all buffers (in reverse order of creation). |
/* First buffer in chain of all buffers (in reverse order of creation). |
5113 |
void |
void |
5114 |
init_buffer () |
init_buffer () |
5115 |
{ |
{ |
|
char buf[MAXPATHLEN + 1]; |
|
5116 |
char *pwd; |
char *pwd; |
5117 |
struct stat dotstat, pwdstat; |
struct stat dotstat, pwdstat; |
5118 |
Lisp_Object temp; |
Lisp_Object temp; |
5135 |
if (NILP (buffer_defaults.enable_multibyte_characters)) |
if (NILP (buffer_defaults.enable_multibyte_characters)) |
5136 |
Fset_buffer_multibyte (Qnil); |
Fset_buffer_multibyte (Qnil); |
5137 |
|
|
5138 |
/* If PWD is accurate, use it instead of calling getwd. PWD is |
pwd = get_current_dir_name (); |
5139 |
sometimes a nicer name, and using it may avoid a fatal error if a |
|
5140 |
parent directory is searchable but not readable. */ |
if(!pwd) |
5141 |
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 |
|
5142 |
|
|
5143 |
#ifndef VMS |
#ifndef VMS |
5144 |
/* Maybe this should really use some standard subroutine |
/* Maybe this should really use some standard subroutine |
5145 |
whose definition is filename syntax dependent. */ |
whose definition is filename syntax dependent. */ |
5146 |
rc = strlen (buf); |
rc = strlen (pwd); |
5147 |
if (!(IS_DIRECTORY_SEP (buf[rc - 1]))) |
if (!(IS_DIRECTORY_SEP (pwd[rc - 1]))) |
5148 |
{ |
{ |
5149 |
buf[rc] = DIRECTORY_SEP; |
pwd[rc] = DIRECTORY_SEP; |
5150 |
buf[rc + 1] = '\0'; |
pwd[rc + 1] = '\0'; |
5151 |
} |
} |
5152 |
#endif /* not VMS */ |
#endif /* not VMS */ |
5153 |
|
|
5154 |
current_buffer->directory = make_unibyte_string (buf, strlen (buf)); |
current_buffer->directory = make_unibyte_string (pwd, strlen (pwd)); |
5155 |
if (! NILP (buffer_defaults.enable_multibyte_characters)) |
if (! NILP (buffer_defaults.enable_multibyte_characters)) |
5156 |
/* At this momemnt, we still don't know how to decode the |
/* At this momemnt, we still don't know how to decode the |
5157 |
direcotry name. So, we keep the bytes in multibyte form so |
direcotry name. So, we keep the bytes in multibyte form so |
5173 |
|
|
5174 |
temp = get_minibuffer (0); |
temp = get_minibuffer (0); |
5175 |
XBUFFER (temp)->directory = current_buffer->directory; |
XBUFFER (temp)->directory = current_buffer->directory; |
5176 |
|
|
5177 |
|
free (pwd); |
5178 |
} |
} |
5179 |
|
|
5180 |
/* initialize the buffer routines */ |
/* initialize the buffer routines */ |