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

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)
This commit is contained in:
Bram Moolenaar 2020-02-05 21:14:00 +01:00
parent 2e6638d5f0
commit a78e9c61a0
3 changed files with 15 additions and 7 deletions

View File

@ -448,17 +448,21 @@ repeat:
if (fnamencmp(p, dirname, namelen) == 0) if (fnamencmp(p, dirname, namelen) == 0)
{ {
p += namelen; p += namelen;
if (vim_ispathsep(*p))
{
while (*p && vim_ispathsep(*p)) while (*p && vim_ispathsep(*p))
++p; ++p;
*fnamep = p; *fnamep = p;
if (pbuf != NULL) if (pbuf != NULL)
{ {
vim_free(*bufp); // free any allocated file name // free any allocated file name
vim_free(*bufp);
*bufp = pbuf; *bufp = pbuf;
pbuf = NULL; pbuf = NULL;
} }
} }
} }
}
else else
{ {
home_replace(NULL, p, dirname, MAXPATHL, TRUE); home_replace(NULL, p, dirname, MAXPATHL, TRUE);

View File

@ -36,6 +36,8 @@ func Test_fnamemodify()
call chdir($HOME . '/XXXXXXXX/a/') call chdir($HOME . '/XXXXXXXX/a/')
call assert_equal('foo', fnamemodify($HOME . '/XXXXXXXX/a/foo', ':p:~:.')) call assert_equal('foo', fnamemodify($HOME . '/XXXXXXXX/a/foo', ':p:~:.'))
call assert_equal('~/XXXXXXXX/b/foo', fnamemodify($HOME . '/XXXXXXXX/b/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 chdir(cwd)
call delete($HOME . '/XXXXXXXX', 'rf') call delete($HOME . '/XXXXXXXX', 'rf')

View File

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