changeset 19314:782f410c5df3 v8.2.0215

patch 8.2.0215: wrong file name shortening Commit: https://github.com/vim/vim/commit/a78e9c61a0ded9c5302bc77e889aa1b3d3467f61 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 5 21:14:00 2020 +0100 patch 8.2.0215: wrong file name shortening Problem: Wrong file name shortening. (Ingo Karkat) Solution: Better check for path separator. (Yasuhiro Matsumoto, closes #5583, closes #5584)
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Feb 2020 21:15:04 +0100
parents 631cb8bf6027
children 2a0fe5461ae5
files src/filepath.c src/testdir/test_fnamemodify.vim src/version.c
diffstat 3 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -448,14 +448,18 @@ repeat:
 		if (fnamencmp(p, dirname, namelen) == 0)
 		{
 		    p += namelen;
-		    while (*p && vim_ispathsep(*p))
-			++p;
-		    *fnamep = p;
-		    if (pbuf != NULL)
+		    if (vim_ispathsep(*p))
 		    {
-			vim_free(*bufp);   // free any allocated file name
-			*bufp = pbuf;
-			pbuf = NULL;
+			while (*p && vim_ispathsep(*p))
+			    ++p;
+			*fnamep = p;
+			if (pbuf != NULL)
+			{
+			    // free any allocated file name
+			    vim_free(*bufp);
+			    *bufp = pbuf;
+			    pbuf = NULL;
+			}
 		    }
 		}
 	    }
--- a/src/testdir/test_fnamemodify.vim
+++ b/src/testdir/test_fnamemodify.vim
@@ -36,6 +36,8 @@ func Test_fnamemodify()
   call chdir($HOME . '/XXXXXXXX/a/')
   call assert_equal('foo', fnamemodify($HOME . '/XXXXXXXX/a/foo', ':p:~:.'))
   call assert_equal('~/XXXXXXXX/b/foo', fnamemodify($HOME . '/XXXXXXXX/b/foo', ':p:~:.'))
+  call mkdir($HOME . '/XXXXXXXX/a.ext', 'p')
+  call assert_equal('~/XXXXXXXX/a.ext/foo', fnamemodify($HOME . '/XXXXXXXX/a.ext/foo', ':p:~:.'))
   call chdir(cwd)
   call delete($HOME . '/XXXXXXXX', 'rf')
 
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    215,
+/**/
     214,
 /**/
     213,