patch 9.1.0569: fnamemodify() treats ".." and "../" differently
Problem: fnamemodify() treats ".." and "../" differently.
Solution: Expand ".." properly like how "/.." is treated in 8.2.3388.
(zeertzjq)
closes: #15218
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/os_unix.c b/src/os_unix.c
index 474d288..76e7a8a 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2699,6 +2699,9 @@
if ((force || !mch_isFullName(fname))
&& ((p = vim_strrchr(fname, '/')) == NULL || p != fname))
{
+ if (p == NULL && STRCMP(fname, "..") == 0)
+ // Handle ".." without path separators.
+ p = fname + 2;
/*
* If the file name has a path, change to that directory for a moment,
* and then get the directory (and get back to where we were).
@@ -2707,7 +2710,7 @@
if (p != NULL)
{
if (STRCMP(p, "/..") == 0)
- // for "/path/dir/.." include the "/.."
+ // For "/path/dir/.." include the "/..".
p += 3;
#ifdef HAVE_FCHDIR