mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.1.0566: Stop dir in findfile() doesn't work properly w/o trailing slash
Problem: Stop directory in findfile() doesn't work properly without a trailing slash. Solution: Always use fnamencmp(), not fnamecmp(). related: #15200 related: #15202 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
68819afb2c
commit
e6ab23bd4a
@@ -1078,11 +1078,13 @@ vim_findfile(void *search_ctx_arg)
|
|||||||
&& search_ctx->ffsc_stopdirs_v != NULL && !got_int)
|
&& search_ctx->ffsc_stopdirs_v != NULL && !got_int)
|
||||||
{
|
{
|
||||||
ff_stack_T *sptr;
|
ff_stack_T *sptr;
|
||||||
|
// path_end may point to the NUL or the previous path separator
|
||||||
|
int plen = (path_end - search_ctx->ffsc_start_dir)
|
||||||
|
+ (*path_end != NUL);
|
||||||
|
|
||||||
// is the last starting directory in the stop list?
|
// is the last starting directory in the stop list?
|
||||||
if (ff_path_in_stoplist(search_ctx->ffsc_start_dir,
|
if (ff_path_in_stoplist(search_ctx->ffsc_start_dir,
|
||||||
(int)(path_end - search_ctx->ffsc_start_dir),
|
plen, search_ctx->ffsc_stopdirs_v) == TRUE)
|
||||||
search_ctx->ffsc_stopdirs_v) == TRUE)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// cut of last dir
|
// cut of last dir
|
||||||
@@ -1521,22 +1523,14 @@ ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
for (i = 0; stopdirs_v[i] != NULL; i++)
|
for (i = 0; stopdirs_v[i] != NULL; i++)
|
||||||
{
|
// match for parent directory. So '/home' also matches
|
||||||
if ((int)STRLEN(stopdirs_v[i]) > path_len)
|
// '/home/rks'. Check for PATHSEP in stopdirs_v[i], else
|
||||||
{
|
// '/home/r' would also match '/home/rks'
|
||||||
// match for parent directory. So '/home' also matches
|
if (fnamencmp(stopdirs_v[i], path, path_len) == 0
|
||||||
// '/home/rks'. Check for PATHSEP in stopdirs_v[i], else
|
&& ((int)STRLEN(stopdirs_v[i]) <= path_len
|
||||||
// '/home/r' would also match '/home/rks'
|
|| vim_ispathsep(stopdirs_v[i][path_len])))
|
||||||
if (fnamencmp(stopdirs_v[i], path, path_len) == 0
|
return TRUE;
|
||||||
&& vim_ispathsep(stopdirs_v[i][path_len]))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fnamecmp(stopdirs_v[i], path) == 0)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,11 +101,18 @@ func Test_findfile()
|
|||||||
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/Xdir2/', -1)
|
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/Xdir2/', -1)
|
||||||
call assert_equal(1, len(l))
|
call assert_equal(1, len(l))
|
||||||
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
|
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
|
||||||
|
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/Xdir2', -1)
|
||||||
|
call assert_equal(1, len(l))
|
||||||
|
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
|
||||||
|
|
||||||
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/', -1)
|
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/', -1)
|
||||||
call assert_equal(2, len(l))
|
call assert_equal(2, len(l))
|
||||||
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
|
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
|
||||||
call assert_match('.*/Xfinddir1/bar', l[1])
|
call assert_match('.*/Xfinddir1/bar', l[1])
|
||||||
|
let l = findfile('bar', ';' . save_dir . '/Xfinddir1', -1)
|
||||||
|
call assert_equal(2, len(l))
|
||||||
|
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
|
||||||
|
call assert_match('.*/Xfinddir1/bar', l[1])
|
||||||
|
|
||||||
" Test combined downwards and upwards search from Xdir2/.
|
" Test combined downwards and upwards search from Xdir2/.
|
||||||
cd ../..
|
cd ../..
|
||||||
|
@@ -704,6 +704,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 */
|
||||||
|
/**/
|
||||||
|
566,
|
||||||
/**/
|
/**/
|
||||||
565,
|
565,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user