Patch 8.2.3388
Problem: fnamemodify('path/..', ':p') differs from using 'path/../'.
Solution: Include the "/.." in the directory name. (closes #8808)
Files: src/os_unix.c, src/testdir/test_fnamemodify.vim
*** ../vim-8.2.3387/src/os_unix.c 2021-08-11 14:20:01.863195717 +0200
--- src/os_unix.c 2021-08-30 21:23:17.469238367 +0200
***************
*** 2602,2607 ****
--- 2602,2611 ----
*/
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,2651 ****
vim_strncpy(buf, fname, p - fname);
if (mch_chdir((char *)buf))
retval = FAIL;
! else
fname = p + 1;
*buf = NUL;
}
}
--- 2648,2657 ----
vim_strncpy(buf, fname, p - fname);
if (mch_chdir((char *)buf))
retval = FAIL;
! else if (*p == '/')
fname = p + 1;
+ else
+ fname = p;
*buf = NUL;
}
}
*** ../vim-8.2.3387/src/testdir/test_fnamemodify.vim 2020-08-21
22:46:07.583820586 +0200
--- src/testdir/test_fnamemodify.vim 2021-08-30 21:19:16.813794474 +0200
***************
*** 12,17 ****
--- 12,19 ----
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', ':~'))
*** ../vim-8.2.3387/src/version.c 2021-08-30 19:57:31.241438772 +0200
--- src/version.c 2021-08-30 21:25:28.084935248 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3388,
/**/
--
Westheimer's Discovery:
A couple of months in the laboratory can
frequently save a couple of hours in the library.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202108301927.17UJR2RJ3681283%40masaka.moolenaar.net.