diff options
| author | Ken Brown | 2019-07-08 18:37:33 -0400 |
|---|---|---|
| committer | Ken Brown | 2019-07-08 18:37:33 -0400 |
| commit | 0528a7c8725c7c28a6f2815802fcc089c2fe306f (patch) | |
| tree | 7becae40b631d84dc3676ff6dd4f7dbe73bce5af /src | |
| parent | 122198d2f1aaf0b74c102874cc9b04ae4789f54f (diff) | |
| download | emacs-0528a7c8725c7c28a6f2815802fcc089c2fe306f.tar.gz emacs-0528a7c8725c7c28a6f2815802fcc089c2fe306f.zip | |
Ensure that expand-file-name returns an absolute file name
* src/fileio.c (Fexpand_file_name): Don't directly use the current
buffer's default-directory if it is relative. Instead replace it
by its expansion relative to invocation-directory. (Bug#36502)
* test/src/fileio-tests.el
(fileio-tests--relative-default-directory): New test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c index 505e4ec33bf..8f23a305a52 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -804,7 +804,22 @@ the root directory. */) | |||
| 804 | 804 | ||
| 805 | /* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted. */ | 805 | /* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted. */ |
| 806 | if (NILP (default_directory)) | 806 | if (NILP (default_directory)) |
| 807 | default_directory = BVAR (current_buffer, directory); | 807 | { |
| 808 | Lisp_Object dir = BVAR (current_buffer, directory); | ||
| 809 | /* The buffer's default-directory should be absolute. If it | ||
| 810 | isn't, try to expand it relative to invocation-directory. | ||
| 811 | But we have to be careful to avoid an infinite loop, because | ||
| 812 | the code in emacs.c that sets Vinvocation_directory might | ||
| 813 | call Fexpand_file_name. */ | ||
| 814 | if (STRINGP (dir)) | ||
| 815 | { | ||
| 816 | if (!NILP (Ffile_name_absolute_p (dir))) | ||
| 817 | default_directory = dir; | ||
| 818 | else if (STRINGP (Vinvocation_directory) | ||
| 819 | && !NILP (Ffile_name_absolute_p (Vinvocation_directory))) | ||
| 820 | default_directory = Fexpand_file_name (dir, Vinvocation_directory); | ||
| 821 | } | ||
| 822 | } | ||
| 808 | if (! STRINGP (default_directory)) | 823 | if (! STRINGP (default_directory)) |
| 809 | { | 824 | { |
| 810 | #ifdef DOS_NT | 825 | #ifdef DOS_NT |