diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/buffer.c b/src/buffer.c index ac2de7d19f2..90ef886b229 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -5268,9 +5268,7 @@ init_buffer_once (void) | |||
| 5268 | void | 5268 | void |
| 5269 | init_buffer (int initialized) | 5269 | init_buffer (int initialized) |
| 5270 | { | 5270 | { |
| 5271 | char *pwd; | ||
| 5272 | Lisp_Object temp; | 5271 | Lisp_Object temp; |
| 5273 | ptrdiff_t len; | ||
| 5274 | 5272 | ||
| 5275 | #ifdef USE_MMAP_FOR_BUFFERS | 5273 | #ifdef USE_MMAP_FOR_BUFFERS |
| 5276 | if (initialized) | 5274 | if (initialized) |
| @@ -5324,7 +5322,7 @@ init_buffer (int initialized) | |||
| 5324 | if (NILP (BVAR (&buffer_defaults, enable_multibyte_characters))) | 5322 | if (NILP (BVAR (&buffer_defaults, enable_multibyte_characters))) |
| 5325 | Fset_buffer_multibyte (Qnil); | 5323 | Fset_buffer_multibyte (Qnil); |
| 5326 | 5324 | ||
| 5327 | pwd = emacs_get_current_dir_name (); | 5325 | char const *pwd = emacs_wd; |
| 5328 | 5326 | ||
| 5329 | if (!pwd) | 5327 | if (!pwd) |
| 5330 | { | 5328 | { |
| @@ -5336,22 +5334,16 @@ init_buffer (int initialized) | |||
| 5336 | { | 5334 | { |
| 5337 | /* Maybe this should really use some standard subroutine | 5335 | /* Maybe this should really use some standard subroutine |
| 5338 | whose definition is filename syntax dependent. */ | 5336 | whose definition is filename syntax dependent. */ |
| 5339 | len = strlen (pwd); | 5337 | ptrdiff_t len = strlen (pwd); |
| 5340 | if (!(IS_DIRECTORY_SEP (pwd[len - 1]))) | 5338 | bool add_slash = ! IS_DIRECTORY_SEP (pwd[len - 1]); |
| 5341 | { | ||
| 5342 | /* Grow buffer to add directory separator and '\0'. */ | ||
| 5343 | pwd = realloc (pwd, len + 2); | ||
| 5344 | if (!pwd) | ||
| 5345 | fatal ("get_current_dir_name: %s\n", strerror (errno)); | ||
| 5346 | pwd[len] = DIRECTORY_SEP; | ||
| 5347 | pwd[len + 1] = '\0'; | ||
| 5348 | len++; | ||
| 5349 | } | ||
| 5350 | 5339 | ||
| 5351 | /* At this moment, we still don't know how to decode the directory | 5340 | /* At this moment, we still don't know how to decode the directory |
| 5352 | name. So, we keep the bytes in unibyte form so that file I/O | 5341 | name. So, we keep the bytes in unibyte form so that file I/O |
| 5353 | routines correctly get the original bytes. */ | 5342 | routines correctly get the original bytes. */ |
| 5354 | bset_directory (current_buffer, make_unibyte_string (pwd, len)); | 5343 | Lisp_Object dirname = make_unibyte_string (pwd, len + add_slash); |
| 5344 | if (add_slash) | ||
| 5345 | SSET (dirname, len, DIRECTORY_SEP); | ||
| 5346 | bset_directory (current_buffer, dirname); | ||
| 5355 | 5347 | ||
| 5356 | /* Add /: to the front of the name | 5348 | /* Add /: to the front of the name |
| 5357 | if it would otherwise be treated as magic. */ | 5349 | if it would otherwise be treated as magic. */ |
| @@ -5372,8 +5364,6 @@ init_buffer (int initialized) | |||
| 5372 | 5364 | ||
| 5373 | temp = get_minibuffer (0); | 5365 | temp = get_minibuffer (0); |
| 5374 | bset_directory (XBUFFER (temp), BVAR (current_buffer, directory)); | 5366 | bset_directory (XBUFFER (temp), BVAR (current_buffer, directory)); |
| 5375 | |||
| 5376 | free (pwd); | ||
| 5377 | } | 5367 | } |
| 5378 | 5368 | ||
| 5379 | /* Similar to defvar_lisp but define a variable whose value is the | 5369 | /* Similar to defvar_lisp but define a variable whose value is the |
| @@ -5706,8 +5696,8 @@ visual lines rather than logical lines. See the documentation of | |||
| 5706 | DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory), | 5696 | DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory), |
| 5707 | Qstringp, | 5697 | Qstringp, |
| 5708 | doc: /* Name of default directory of current buffer. | 5698 | doc: /* Name of default directory of current buffer. |
| 5709 | It should be a directory name (as opposed to a directory file-name). | 5699 | It should be an absolute directory name; on GNU and Unix systems, |
| 5710 | On GNU and Unix systems, directory names end in a slash `/'. | 5700 | these names start with `/' or `~' and end with `/'. |
| 5711 | To interactively change the default directory, use command `cd'. */); | 5701 | To interactively change the default directory, use command `cd'. */); |
| 5712 | 5702 | ||
| 5713 | DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function), | 5703 | DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function), |