mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
fix: remove trailing slashes before making directory
Remove the trailing slashes from 'undofile' and 'backupdir' before creating directories. They cause problems on Windows which doesn't recognize these slashes as proper path separators.
This commit is contained in:
@@ -2688,7 +2688,12 @@ buf_write(
|
||||
/*
|
||||
* Isolate one directory name, using an entry in 'bdir'.
|
||||
*/
|
||||
(void)copy_option_part(&dirp, IObuff, IOSIZE, ",");
|
||||
size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ",");
|
||||
p = IObuff + dir_len;
|
||||
bool trailing_pathseps = after_pathsep((char *)IObuff, (char *)p) && p[-1] == p[-2];
|
||||
if (trailing_pathseps) {
|
||||
IObuff[dir_len - 2] = NUL;
|
||||
}
|
||||
if (*dirp == NUL && !os_isdir(IObuff)) {
|
||||
int ret;
|
||||
char *failed_dir;
|
||||
@@ -2698,8 +2703,7 @@ buf_write(
|
||||
xfree(failed_dir);
|
||||
}
|
||||
}
|
||||
p = IObuff + STRLEN(IObuff);
|
||||
if (after_pathsep((char *)IObuff, (char *)p) && p[-1] == p[-2]) {
|
||||
if (trailing_pathseps) {
|
||||
// Ends with '//', Use Full path
|
||||
if ((p = (char_u *)make_percent_swname((char *)IObuff, (char *)fname))
|
||||
!= NULL) {
|
||||
@@ -2849,7 +2853,12 @@ nobackup:
|
||||
/*
|
||||
* Isolate one directory name and make the backup file name.
|
||||
*/
|
||||
(void)copy_option_part(&dirp, IObuff, IOSIZE, ",");
|
||||
size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ",");
|
||||
p = IObuff + dir_len;
|
||||
bool trailing_pathseps = after_pathsep((char *)IObuff, (char *)p) && p[-1] == p[-2];
|
||||
if (trailing_pathseps) {
|
||||
IObuff[dir_len - 2] = NUL;
|
||||
}
|
||||
if (*dirp == NUL && !os_isdir(IObuff)) {
|
||||
int ret;
|
||||
char *failed_dir;
|
||||
@@ -2859,8 +2868,7 @@ nobackup:
|
||||
xfree(failed_dir);
|
||||
}
|
||||
}
|
||||
p = IObuff + STRLEN(IObuff);
|
||||
if (after_pathsep((char *)IObuff, (char *)p) && p[-1] == p[-2]) {
|
||||
if (trailing_pathseps) {
|
||||
// path ends with '//', use full path
|
||||
if ((p = (char_u *)make_percent_swname((char *)IObuff, (char *)fname))
|
||||
!= NULL) {
|
||||
|
Reference in New Issue
Block a user