diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-30 21:26:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-30 21:26:16 +0200 |
commit | 4eaef9979fc5032606897963f1af37674ee0d422 (patch) | |
tree | 07992e60f3c84fae3bfa15b4916de9fd3a44e53e | |
parent | de05ae71589f46c5d27642c33fe5eb21b22aaf5d (diff) | |
download | vim-git-4eaef9979fc5032606897963f1af37674ee0d422.tar.gz |
patch 8.2.3388: fnamemodify('path/..', ':p') differs from using 'path/../'v8.2.3388
Problem: fnamemodify('path/..', ':p') differs from using 'path/../'.
Solution: Include the "/.." in the directory name. (closes #8808)
-rw-r--r-- | src/os_unix.c | 8 | ||||
-rw-r--r-- | src/testdir/test_fnamemodify.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index b603927e3..a3e5430ef 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2602,6 +2602,10 @@ mch_FullName( */ if (p != NULL) { + if (STRCMP(p, "/..") == 0) + // for "/path/dir/.." include the "/.." + p += 3; + #ifdef HAVE_FCHDIR /* * Use fchdir() if possible, it's said to be faster and more @@ -2644,8 +2648,10 @@ mch_FullName( vim_strncpy(buf, fname, p - fname); if (mch_chdir((char *)buf)) retval = FAIL; - else + else if (*p == '/') fname = p + 1; + else + fname = p; *buf = NUL; } } diff --git a/src/testdir/test_fnamemodify.vim b/src/testdir/test_fnamemodify.vim index bcbdf77ae..7882f3cb0 100644 --- a/src/testdir/test_fnamemodify.vim +++ b/src/testdir/test_fnamemodify.vim @@ -12,6 +12,8 @@ func Test_fnamemodify() call assert_equal('r', fnamemodify('.', ':p:h')[-1:]) call assert_equal('t', fnamemodify('test.out', ':p')[-1:]) call assert_equal($HOME .. "/foo" , fnamemodify('~/foo', ':p')) + call assert_equal(fnamemodify('.', ':p:h:h:h') .. '/', fnamemodify($HOME .. '/../', ':p')) + call assert_equal(fnamemodify('.', ':p:h:h:h') .. '/', fnamemodify($HOME .. '/..', ':p')) call assert_equal('test.out', fnamemodify('test.out', ':.')) call assert_equal('a', fnamemodify('../testdir/a', ':.')) call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~')) diff --git a/src/version.c b/src/version.c index af45dedff..7aef272f6 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3388, +/**/ 3387, /**/ 3386, |