diff options
Diffstat (limited to 'src/nvim/runtime.c')
-rw-r--r-- | src/nvim/runtime.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index c47bffd426..67df0c9258 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -47,13 +47,13 @@ void ex_runtime(exarg_T *eap) arg = skipwhite(arg + len); } - source_runtime(arg, flags); + source_runtime((char *)arg, flags); } static void source_callback(char_u *fname, void *cookie) { - (void)do_source(fname, false, DOSO_NONE); + (void)do_source((char *)fname, false, DOSO_NONE); } /// Find the file "name" in all directories in "path" and invoke @@ -64,7 +64,7 @@ static void source_callback(char_u *fname, void *cookie) /// When "flags" has DIP_ERR: give an error message if there is no match. /// /// return FAIL when no file could be sourced, OK otherwise. -int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) +int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie) { char_u *tail; int num_files; @@ -79,8 +79,7 @@ int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback { if (p_verbose > 10 && name != NULL) { verbose_enter(); - smsg(_("Searching for \"%s\" in \"%s\""), - (char *)name, (char *)path); + smsg(_("Searching for \"%s\" in \"%s\""), name, (char *)path); verbose_leave(); } @@ -109,7 +108,7 @@ int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback tail = buf + STRLEN(buf); // Loop over all patterns in "name" - char_u *np = name; + char_u *np = (char_u *)name; while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { // Append the pattern from "name" to buf[]. assert(MAXPATHL >= (tail - buf)); @@ -281,16 +280,16 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c int done = FAIL; if ((flags & DIP_NORTP) == 0) { - done |= do_in_path(path, (name && !*name) ? NULL : name, flags, callback, cookie); + done |= do_in_path(path, (char *)((name && !*name) ? NULL : name), flags, callback, cookie); } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { char *start_dir = "pack/*/start/*/%s%s"; // NOLINT size_t len = STRLEN(start_dir) + STRLEN(name) + 6; - char_u *s = xmallocz(len); // TODO(bfredl): get rid of random allocations + char *s = xmallocz(len); // TODO(bfredl): get rid of random allocations char *suffix = (flags & DIP_AFTER) ? "after/" : ""; - vim_snprintf((char *)s, len, start_dir, suffix, name); + vim_snprintf(s, len, start_dir, suffix, name); done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie); xfree(s); @@ -300,7 +299,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c len = STRLEN(start_dir) + STRLEN(name) + 6; s = xmallocz(len); - vim_snprintf((char *)s, len, start_dir, suffix, name); + vim_snprintf(s, len, start_dir, suffix, name); done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie); xfree(s); @@ -310,9 +309,9 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) { char *opt_dir = "pack/*/opt/*/%s"; // NOLINT size_t len = STRLEN(opt_dir) + STRLEN(name); - char_u *s = xmallocz(len); + char *s = xmallocz(len); - vim_snprintf((char *)s, len, opt_dir, name); + vim_snprintf(s, len, opt_dir, name); done |= do_in_path(p_pp, s, flags, callback, cookie); xfree(s); @@ -322,7 +321,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c len = STRLEN(opt_dir) + STRLEN(name); s = xmallocz(len); - vim_snprintf((char *)s, len, opt_dir, name); + vim_snprintf(s, len, opt_dir, name); done |= do_in_path(p_pp, s, flags, callback, cookie); xfree(s); @@ -374,7 +373,7 @@ static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle if (STRLEN(pack_entry) + STRLEN(start_pat[i]) + 1 > MAXPATHL) { continue; } - xstrlcpy(buf, (char *)pack_entry, MAXPATHL); + STRLCPY(buf, pack_entry, MAXPATHL); xstrlcat(buf, start_pat[i], sizeof buf); expand_rtp_entry(search_path, rtp_used, buf, false); size_t after_size = STRLEN(buf)+7; @@ -515,9 +514,9 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, void /// When "flags" has DIP_ALL: source all files, otherwise only the first one. /// /// return FAIL when no file could be sourced, OK otherwise. -int source_runtime(char_u *name, int flags) +int source_runtime(char *name, int flags) { - return do_in_runtimepath(name, flags, source_callback, NULL); + return do_in_runtimepath((char_u *)name, flags, source_callback, NULL); } /// Just like source_runtime(), but use "path" instead of 'runtimepath'. @@ -535,7 +534,7 @@ static void source_all_matches(char_u *pat) if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) == OK) { for (int i = 0; i < num_files; i++) { - (void)do_source(files[i], false, DOSO_NONE); + (void)do_source((char *)files[i], false, DOSO_NONE); } FreeWild(num_files, files); } @@ -791,7 +790,7 @@ static void add_pack_start_dir(char_u *fname, void *cookie) if (STRLEN(fname) + STRLEN(start_pat[i]) + 1 > MAXPATHL) { continue; } - xstrlcpy((char *)buf, (char *)fname, MAXPATHL); + STRLCPY(buf, fname, MAXPATHL); xstrlcat((char *)buf, start_pat[i], sizeof buf); if (pack_has_entries(buf)) { add_pack_dir_to_rtp(buf, true); @@ -804,9 +803,9 @@ static void add_pack_start_dir(char_u *fname, void *cookie) void load_start_packages(void) { did_source_packages = true; - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT + do_in_path(p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_start_pack_plugin, &APP_LOAD); - do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT + do_in_path(p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT add_start_pack_plugin, &APP_LOAD); } @@ -849,8 +848,8 @@ void load_plugins(void) } TIME_MSG("loading packages"); - source_runtime(plugin_pattern_vim, DIP_ALL | DIP_AFTER); - source_runtime(plugin_pattern_lua, DIP_ALL | DIP_AFTER); + source_runtime((char *)plugin_pattern_vim, DIP_ALL | DIP_AFTER); + source_runtime((char *)plugin_pattern_lua, DIP_ALL | DIP_AFTER); TIME_MSG("loading after plugins"); } } @@ -873,9 +872,7 @@ void ex_packadd(exarg_T *eap) vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg); // The first round don't give a "not found" error, in the second round // only when nothing was found in the first round. - res = do_in_path(p_pp, (char_u *)pat, - DIP_ALL + DIP_DIR - + (round == 2 && res == FAIL ? DIP_ERR : 0), + res = do_in_path(p_pp, pat, DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0), round == 1 ? add_start_pack_plugin : add_opt_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH); xfree(pat); |