diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-12 06:45:39 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-07-12 06:49:43 +0800 |
commit | 80818641f3504eb57a4fae5003f234f5f5f19ba1 (patch) | |
tree | b56e10b64b915ce45c665a682667daba447ab1b7 /src | |
parent | 091a130804282c9d40e639d68659d2ea2941259d (diff) | |
download | rneovim-80818641f3504eb57a4fae5003f234f5f5f19ba1.tar.gz rneovim-80818641f3504eb57a4fae5003f234f5f5f19ba1.tar.bz2 rneovim-80818641f3504eb57a4fae5003f234f5f5f19ba1.zip |
vim-patch:9.1.0567: Cannot use relative paths as findfile() stop directories
Problem: Cannot use relative paths as findfile() stop directories.
Solution: Change a relative path to an absolute path.
(zeertzjq)
related: vim/vim#15200
closes: vim/vim#15202
https://github.com/vim/vim/commit/764526e2799fbed040fc867858ee2eb0677afe98
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/file_search.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 9bc0095515..5760fc864a 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -349,23 +349,24 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char *)); do { - char *helper; - void *ptr; - - helper = walker; - ptr = xrealloc(search_ctx->ffsc_stopdirs_v, - (dircount + 1) * sizeof(char *)); + char *helper = walker; + void *ptr = xrealloc(search_ctx->ffsc_stopdirs_v, + (dircount + 1) * sizeof(char *)); search_ctx->ffsc_stopdirs_v = ptr; walker = vim_strchr(walker, ';'); + assert(!walker || walker - helper >= 0); + size_t len = walker ? (size_t)(walker - helper) : strlen(helper); + // "" means ascent till top of directory tree. + if (*helper != NUL && !vim_isAbsName(helper) && len + 1 < MAXPATHL) { + // Make the stop dir an absolute path name. + xmemcpyz(ff_expand_buffer, helper, len); + search_ctx->ffsc_stopdirs_v[dircount - 1] = FullName_save(helper, len); + } else { + search_ctx->ffsc_stopdirs_v[dircount - 1] = xmemdupz(helper, len); + } if (walker) { - assert(walker - helper >= 0); - search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrnsave(helper, (size_t)(walker - helper)); walker++; - } else { - // this might be "", which means ascent till top of directory tree. - search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrdup(helper); } - dircount++; } while (walker != NULL); search_ctx->ffsc_stopdirs_v[dircount - 1] = NULL; |