]> granicus.if.org Git - vim/commitdiff
patch 8.2.0215: wrong file name shortening v8.2.0215
authorBram Moolenaar <Bram@vim.org>
Wed, 5 Feb 2020 20:14:00 +0000 (21:14 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 5 Feb 2020 20:14:00 +0000 (21:14 +0100)
Problem:    Wrong file name shortening. (Ingo Karkat)
Solution:   Better check for path separator. (Yasuhiro Matsumoto,
            closes #5583, closes #5584)

src/filepath.c
src/testdir/test_fnamemodify.vim
src/version.c

index 9a5d127ece4c7770624127ae2edec93543b15289..79eb7bf988d29b3ec3c4961c0a644e5be560eeea 100644 (file)
@@ -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;
+                       }
                    }
                }
            }
index 7a21efef836e885592fe393f4c0834ebe6804a63..b35f1534028b360ac5289560681d559c37821aa0 100644 (file)
@@ -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')
 
index 97584e37e7db00af64441e9b7c9cecc4f9531626..20a6be433daf89a0ab345ae964bb978125d52f74 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    215,
 /**/
     214,
 /**/