vim-patch:9.1.0569: fnamemodify() treats ".." and "../" differently (#29673)

Problem:  fnamemodify() treats ".." and "../" differently.
Solution: Expand ".." properly like how "/.." is treated in 8.2.3388.
          (zeertzjq)

closes: vim/vim#15218

1ee7420460
This commit is contained in:
zeertzjq
2024-07-12 14:30:49 +08:00
committed by GitHub
parent bcb17689da
commit 028dd3c5c4
5 changed files with 47 additions and 22 deletions

View File

@@ -2393,9 +2393,13 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
p = strrchr(fname, '\\');
}
#endif
if (p == NULL && strcmp(fname, "..") == 0) {
// Handle ".." without path separators.
p = fname + 2;
}
if (p != NULL) {
if (strcmp(p + 1, "..") == 0) {
// for "/path/dir/.." include the "/.."
if (vim_ispathsep_nocolon(*p) && strcmp(p + 1, "..") == 0) {
// For "/path/dir/.." include the "/..".
p += 3;
}
assert(p >= fname);