diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/src/buffer.c b/src/buffer.c index 3450e88c72d..ae2a584e506 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -32,10 +32,6 @@ Boston, MA 02110-1301, USA. */ | |||
| 32 | extern int errno; | 32 | extern int errno; |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #ifndef MAXPATHLEN | ||
| 36 | /* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */ | ||
| 37 | #define MAXPATHLEN 1024 | ||
| 38 | #endif /* not MAXPATHLEN */ | ||
| 39 | 35 | ||
| 40 | #ifdef HAVE_UNISTD_H | 36 | #ifdef HAVE_UNISTD_H |
| 41 | #include <unistd.h> | 37 | #include <unistd.h> |
| @@ -5131,7 +5127,6 @@ init_buffer_once () | |||
| 5131 | void | 5127 | void |
| 5132 | init_buffer () | 5128 | init_buffer () |
| 5133 | { | 5129 | { |
| 5134 | char buf[MAXPATHLEN + 1]; | ||
| 5135 | char *pwd; | 5130 | char *pwd; |
| 5136 | struct stat dotstat, pwdstat; | 5131 | struct stat dotstat, pwdstat; |
| 5137 | Lisp_Object temp; | 5132 | Lisp_Object temp; |
| @@ -5154,40 +5149,28 @@ init_buffer () | |||
| 5154 | if (NILP (buffer_defaults.enable_multibyte_characters)) | 5149 | if (NILP (buffer_defaults.enable_multibyte_characters)) |
| 5155 | Fset_buffer_multibyte (Qnil); | 5150 | Fset_buffer_multibyte (Qnil); |
| 5156 | 5151 | ||
| 5157 | /* If PWD is accurate, use it instead of calling getwd. PWD is | 5152 | pwd = get_current_dir_name (); |
| 5158 | sometimes a nicer name, and using it may avoid a fatal error if a | 5153 | |
| 5159 | parent directory is searchable but not readable. */ | 5154 | if (!pwd) |
| 5160 | if ((pwd = getenv ("PWD")) != 0 | 5155 | fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); |
| 5161 | && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) | ||
| 5162 | && stat (pwd, &pwdstat) == 0 | ||
| 5163 | && stat (".", &dotstat) == 0 | ||
| 5164 | && dotstat.st_ino == pwdstat.st_ino | ||
| 5165 | && dotstat.st_dev == pwdstat.st_dev | ||
| 5166 | && strlen (pwd) < MAXPATHLEN) | ||
| 5167 | strcpy (buf, pwd); | ||
| 5168 | #ifdef HAVE_GETCWD | ||
| 5169 | else if (getcwd (buf, MAXPATHLEN+1) == 0) | ||
| 5170 | fatal ("`getcwd' failed: %s\n", strerror (errno)); | ||
| 5171 | #else | ||
| 5172 | else if (getwd (buf) == 0) | ||
| 5173 | fatal ("`getwd' failed: %s\n", buf); | ||
| 5174 | #endif | ||
| 5175 | 5156 | ||
| 5176 | #ifndef VMS | 5157 | #ifndef VMS |
| 5177 | /* Maybe this should really use some standard subroutine | 5158 | /* Maybe this should really use some standard subroutine |
| 5178 | whose definition is filename syntax dependent. */ | 5159 | whose definition is filename syntax dependent. */ |
| 5179 | rc = strlen (buf); | 5160 | rc = strlen (pwd); |
| 5180 | if (!(IS_DIRECTORY_SEP (buf[rc - 1]))) | 5161 | if (!(IS_DIRECTORY_SEP (pwd[rc - 1]))) |
| 5181 | { | 5162 | { |
| 5182 | buf[rc] = DIRECTORY_SEP; | 5163 | /* Grow buffer to add directory separator and '\0'. */ |
| 5183 | buf[rc + 1] = '\0'; | 5164 | pwd = (char *) xrealloc (pwd, rc + 2); |
| 5165 | pwd[rc] = DIRECTORY_SEP; | ||
| 5166 | pwd[rc + 1] = '\0'; | ||
| 5184 | } | 5167 | } |
| 5185 | #endif /* not VMS */ | 5168 | #endif /* not VMS */ |
| 5186 | 5169 | ||
| 5187 | current_buffer->directory = make_unibyte_string (buf, strlen (buf)); | 5170 | current_buffer->directory = make_unibyte_string (pwd, strlen (pwd)); |
| 5188 | if (! NILP (buffer_defaults.enable_multibyte_characters)) | 5171 | if (! NILP (buffer_defaults.enable_multibyte_characters)) |
| 5189 | /* At this momemnt, we still don't know how to decode the | 5172 | /* At this moment, we still don't know how to decode the |
| 5190 | direcotry name. So, we keep the bytes in multibyte form so | 5173 | directory name. So, we keep the bytes in multibyte form so |
| 5191 | that ENCODE_FILE correctly gets the original bytes. */ | 5174 | that ENCODE_FILE correctly gets the original bytes. */ |
| 5192 | current_buffer->directory | 5175 | current_buffer->directory |
| 5193 | = string_to_multibyte (current_buffer->directory); | 5176 | = string_to_multibyte (current_buffer->directory); |
| @@ -5206,6 +5189,8 @@ init_buffer () | |||
| 5206 | 5189 | ||
| 5207 | temp = get_minibuffer (0); | 5190 | temp = get_minibuffer (0); |
| 5208 | XBUFFER (temp)->directory = current_buffer->directory; | 5191 | XBUFFER (temp)->directory = current_buffer->directory; |
| 5192 | |||
| 5193 | free (pwd); | ||
| 5209 | } | 5194 | } |
| 5210 | 5195 | ||
| 5211 | /* initialize the buffer routines */ | 5196 | /* initialize the buffer routines */ |