0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.3388: fnamemodify('path/..', ':p') differs from using 'path/../'

Problem:    fnamemodify('path/..', ':p') differs from using 'path/../'.
Solution:   Include the "/.." in the directory name. (closes #8808)
This commit is contained in:
Bram Moolenaar 2021-08-30 21:26:16 +02:00
parent de05ae7158
commit 4eaef9979f
3 changed files with 11 additions and 1 deletions

View File

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

View File

@ -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', ':~'))

View File

@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3388,
/**/
3387,
/**/