Merge pull request #29758 from zeertzjq/vim-8.2.3543

vim-patch:{8.2.3543,9.1.0615}
This commit is contained in:
zeertzjq 2024-07-26 07:45:02 +08:00 committed by GitHub
commit cd1550818b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 22 deletions

View File

@ -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);

View File

@ -1325,11 +1325,9 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn
} else {
int len = (int)strlen(dir_name);
p = dir_name + len;
if (after_pathsep(dir_name, p)
&& len > 1
&& p[-1] == p[-2]) {
if (after_pathsep(dir_name, p) && len > 1 && p[-1] == p[-2]) {
// Ends with '//', Use Full path for swap name
tail = make_percent_swname(dir_name, fname_res);
tail = make_percent_swname(dir_name, p, fname_res);
} else {
tail = path_tail(fname_res);
tail = concat_fnames(dir_name, tail, true);
@ -1440,8 +1438,11 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn
/// Append the full path to name with path separators made into percent
/// signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"")
char *make_percent_swname(const char *dir, const char *name)
FUNC_ATTR_NONNULL_ARG(1)
/// signs, to "dir". An unnamed buffer is handled as "" (<currentdir>/"")
/// The last character in "dir" must be an extra slash or backslash, it is
/// removed.
char *make_percent_swname(char *dir, char *dir_end, const char *name)
FUNC_ATTR_NONNULL_ARG(1, 2)
{
char *d = NULL;
char *f = fix_fname(name != NULL ? name : "");
@ -1455,6 +1456,8 @@ char *make_percent_swname(const char *dir, const char *name)
*d = '%';
}
}
dir_end[-1] = NUL; // remove one trailing slash
d = concat_fnames(dir, s, true);
xfree(s);
xfree(f);
@ -3192,11 +3195,10 @@ char *makeswapname(char *fname, char *ffname, buf_T *buf, char *dir_name)
int len = (int)strlen(dir_name);
char *s = dir_name + len;
if (after_pathsep(dir_name, s)
&& len > 1
&& s[-1] == s[-2]) { // Ends with '//', Use Full path
if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2]) {
// Ends with '//', Use Full path
char *r = NULL;
s = make_percent_swname(dir_name, fname_res);
s = make_percent_swname(dir_name, s, fname_res);
if (s != NULL) {
r = modname(s, ".swp", false);
xfree(s);