aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-07 09:12:33 +0800
committerGitHub <noreply@github.com>2024-08-07 01:12:33 +0000
commit11a6f3c9301b3deb71f7e5886fce3718420355be (patch)
tree2291e586d0bc8de3411d0e9db402adc994582d77 /src/nvim/path.c
parent0c99ce0e89515de218f2b4e5f270885045868e93 (diff)
downloadrneovim-11a6f3c9301b3deb71f7e5886fce3718420355be.tar.gz
rneovim-11a6f3c9301b3deb71f7e5886fce3718420355be.tar.bz2
rneovim-11a6f3c9301b3deb71f7e5886fce3718420355be.zip
vim-patch:partial:8.1.0914: code related to findfile() is spread out (#30000)
Problem: Code related to findfile() is spread out. Solution: Put findfile() related code into a new source file. (Yegappan Lakshmanan, closes vim/vim#3934) https://github.com/vim/vim/commit/5fd0f5052f9a312bb4cfe7b4176b1211d45127ee Keep functions related to wildcard expansion in path.c, as in Vim they are now spread out among multiple files, which isn't really ideal.
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 67acc6e51b..c9bfd5228c 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -8,23 +8,17 @@
#include "auto/config.h"
#include "nvim/ascii_defs.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/eval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_docmd.h"
-#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
-#include "nvim/gettext_defs.h"
#include "nvim/globals.h"
#include "nvim/macros_defs.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
-#include "nvim/message.h"
#include "nvim/option.h"
-#include "nvim/option_defs.h"
#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/fs_defs.h"
@@ -37,7 +31,6 @@
#include "nvim/regexp_defs.h"
#include "nvim/strings.h"
#include "nvim/vim_defs.h"
-#include "nvim/window.h"
enum {
URL_SLASH = 1, // path_is_url() has found ":/"
@@ -1687,87 +1680,6 @@ void simplify_filename(char *filename)
} while (*p != NUL);
}
-static char *eval_includeexpr(const char *const ptr, const size_t len)
-{
- const sctx_T save_sctx = current_sctx;
- set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
- current_sctx = curbuf->b_p_script_ctx[BV_INEX].script_ctx;
-
- char *res = eval_to_string_safe(curbuf->b_p_inex,
- was_set_insecurely(curwin, kOptIncludeexpr, OPT_LOCAL),
- true);
-
- set_vim_var_string(VV_FNAME, NULL, 0);
- current_sctx = save_sctx;
- return res;
-}
-
-/// Return the name of the file ptr[len] in 'path'.
-/// Otherwise like file_name_at_cursor().
-///
-/// @param rel_fname file we are searching relative to
-char *find_file_name_in_path(char *ptr, size_t len, int options, long count, char *rel_fname)
-{
- char *file_name;
- char *tofree = NULL;
-
- if (len == 0) {
- return NULL;
- }
-
- if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
- tofree = eval_includeexpr(ptr, len);
- if (tofree != NULL) {
- ptr = tofree;
- len = strlen(ptr);
- }
- }
-
- if (options & FNAME_EXP) {
- char *file_to_find = NULL;
- char *search_ctx = NULL;
-
- file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
- true, rel_fname, &file_to_find, &search_ctx);
-
- // If the file could not be found in a normal way, try applying
- // 'includeexpr' (unless done already).
- if (file_name == NULL
- && !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
- tofree = eval_includeexpr(ptr, len);
- if (tofree != NULL) {
- ptr = tofree;
- len = strlen(ptr);
- file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
- true, rel_fname, &file_to_find, &search_ctx);
- }
- }
- if (file_name == NULL && (options & FNAME_MESS)) {
- char c = ptr[len];
- ptr[len] = NUL;
- semsg(_("E447: Can't find file \"%s\" in path"), ptr);
- ptr[len] = c;
- }
-
- // Repeat finding the file "count" times. This matters when it
- // appears several times in the path.
- while (file_name != NULL && --count > 0) {
- xfree(file_name);
- file_name = find_file_in_path(ptr, len, options, false, rel_fname,
- &file_to_find, &search_ctx);
- }
-
- xfree(file_to_find);
- vim_findfile_cleanup(search_ctx);
- } else {
- file_name = xstrnsave(ptr, len);
- }
-
- xfree(tofree);
-
- return file_name;
-}
-
/// Checks for a Windows drive letter ("C:/") at the start of the path.
///
/// @see https://url.spec.whatwg.org/#start-with-a-windows-drive-letter