From 028dd3c5c4d1828eec64c099d3372ffb90572dc0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Jul 2024 14:30:49 +0800 Subject: 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 https://github.com/vim/vim/commit/1ee7420460768df67ea4bc73467f2d4f8b1555bd --- src/nvim/path.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/path.c b/src/nvim/path.c index e33e34fff3..adea7ff0f7 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -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); -- cgit