diff options
Diffstat (limited to 'src/nvim/bufwrite.c')
-rw-r--r-- | src/nvim/bufwrite.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 5522ab1ca3..9f6eb8c9e8 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -821,10 +821,6 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o // Isolate one directory name, using an entry in 'bdir'. size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ","); char *p = IObuff + dir_len; - bool trailing_pathseps = after_pathsep(IObuff, p) && p[-1] == p[-2]; - if (trailing_pathseps) { - IObuff[dir_len - 2] = NUL; - } if (*dirp == NUL && !os_isdir(IObuff)) { int ret; char *failed_dir; @@ -834,9 +830,9 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o xfree(failed_dir); } } - if (trailing_pathseps) { + if (after_pathsep(IObuff, p) && p[-1] == p[-2]) { // Ends with '//', Use Full path - if ((p = make_percent_swname(IObuff, fname)) + if ((p = make_percent_swname(IObuff, p, fname)) != NULL) { *backupp = modname(p, backup_ext, no_prepend_dot); xfree(p); @@ -963,10 +959,6 @@ nobackup: // Isolate one directory name and make the backup file name. size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ","); char *p = IObuff + dir_len; - bool trailing_pathseps = after_pathsep(IObuff, p) && p[-1] == p[-2]; - if (trailing_pathseps) { - IObuff[dir_len - 2] = NUL; - } if (*dirp == NUL && !os_isdir(IObuff)) { int ret; char *failed_dir; @@ -976,9 +968,9 @@ nobackup: xfree(failed_dir); } } - if (trailing_pathseps) { + if (after_pathsep(IObuff, p) && p[-1] == p[-2]) { // path ends with '//', use full path - if ((p = make_percent_swname(IObuff, fname)) + if ((p = make_percent_swname(IObuff, p, fname)) != NULL) { *backupp = modname(p, backup_ext, no_prepend_dot); xfree(p); |