Skip to content

Commit a78e9c6

Browse files
committed
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)
1 parent 2e6638d commit a78e9c6

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/filepath.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,18 @@ modify_fname(
448448
if (fnamencmp(p, dirname, namelen) == 0)
449449
{
450450
p += namelen;
451-
while (*p && vim_ispathsep(*p))
452-
++p;
453-
*fnamep = p;
454-
if (pbuf != NULL)
451+
if (vim_ispathsep(*p))
455452
{
456-
vim_free(*bufp); // free any allocated file name
457-
*bufp = pbuf;
458-
pbuf = NULL;
453+
while (*p && vim_ispathsep(*p))
454+
++p;
455+
*fnamep = p;
456+
if (pbuf != NULL)
457+
{
458+
// free any allocated file name
459+
vim_free(*bufp);
460+
*bufp = pbuf;
461+
pbuf = NULL;
462+
}
459463
}
460464
}
461465
}

src/testdir/test_fnamemodify.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func Test_fnamemodify()
3636
call chdir($HOME . '/XXXXXXXX/a/')
3737
call assert_equal('foo', fnamemodify($HOME . '/XXXXXXXX/a/foo', ':p:~:.'))
3838
call assert_equal('~/XXXXXXXX/b/foo', fnamemodify($HOME . '/XXXXXXXX/b/foo', ':p:~:.'))
39+
call mkdir($HOME . '/XXXXXXXX/a.ext', 'p')
40+
call assert_equal('~/XXXXXXXX/a.ext/foo', fnamemodify($HOME . '/XXXXXXXX/a.ext/foo', ':p:~:.'))
3941
call chdir(cwd)
4042
call delete($HOME . '/XXXXXXXX', 'rf')
4143

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
215,
745747
/**/
746748
214,
747749
/**/

0 commit comments

Comments
 (0)