diff options
author | Dundar Göc <gocdundar@gmail.com> | 2022-08-26 10:36:35 +0200 |
---|---|---|
committer | Dundar Göc <gocdundar@gmail.com> | 2022-08-26 22:24:28 +0200 |
commit | 395277036014189c03b8969fc0a5cd2bdc5c8631 (patch) | |
tree | 27caaef2e0b8351eb5637d1a969229663ec2c4a8 /src/nvim/runtime.c | |
parent | 6a13b8fa5460da5aa22a1c366e5252c26ed5fe1e (diff) | |
download | rneovim-395277036014189c03b8969fc0a5cd2bdc5c8631.tar.gz rneovim-395277036014189c03b8969fc0a5cd2bdc5c8631.tar.bz2 rneovim-395277036014189c03b8969fc0a5cd2bdc5c8631.zip |
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src/nvim/runtime.c')
-rw-r--r-- | src/nvim/runtime.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index a04ae271e1..23606fdc77 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -303,7 +303,7 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, xfree(buf); xfree(rtp_copy); if (!did_one && name != NULL) { - char *basepath = path == p_rtp ? "runtimepath" : "packpath"; + char *basepath = path == (char_u *)p_rtp ? "runtimepath" : "packpath"; if (flags & DIP_ERR) { semsg(_(e_dirnotf), basepath, name); @@ -550,7 +550,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c char *suffix = (flags & DIP_AFTER) ? "after/" : ""; vim_snprintf(s, len, start_dir, suffix, name); - done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie); + done |= do_in_path((char_u *)p_pp, s, flags & ~DIP_AFTER, callback, cookie); xfree(s); @@ -560,7 +560,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c s = xmallocz(len); vim_snprintf(s, len, start_dir, suffix, name); - done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie); + done |= do_in_path((char_u *)p_pp, s, flags & ~DIP_AFTER, callback, cookie); xfree(s); } @@ -572,7 +572,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c char *s = xmallocz(len); vim_snprintf(s, len, opt_dir, name); - done |= do_in_path(p_pp, s, flags, callback, cookie); + done |= do_in_path((char_u *)p_pp, s, flags, callback, cookie); xfree(s); @@ -582,7 +582,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c s = xmallocz(len); vim_snprintf(s, len, opt_dir, name); - done |= do_in_path(p_pp, s, flags, callback, cookie); + done |= do_in_path((char_u *)p_pp, s, flags, callback, cookie); xfree(s); } @@ -665,7 +665,7 @@ RuntimeSearchPath runtime_search_path_build(void) CharVec after_path = KV_INITIAL_VALUE; static char_u buf[MAXPATHL]; - for (char *entry = (char *)p_pp; *entry != NUL;) { + for (char *entry = p_pp; *entry != NUL;) { char *cur_entry = entry; copy_option_part(&entry, (char *)buf, MAXPATHL, ","); @@ -676,7 +676,7 @@ RuntimeSearchPath runtime_search_path_build(void) } char *rtp_entry; - for (rtp_entry = (char *)p_rtp; *rtp_entry != NUL;) { + for (rtp_entry = p_rtp; *rtp_entry != NUL;) { char *cur_entry = rtp_entry; copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ","); size_t buflen = STRLEN(buf); @@ -773,7 +773,7 @@ int do_in_runtimepath(char *name, int flags, DoInRuntimepathCB callback, void *c // TODO(bfredl): we could integrate disabled OPT dirs into the cached path // which would effectivize ":packadd myoptpack" as well if ((flags & (DIP_START|DIP_OPT)) && (success == FAIL || (flags & DIP_ALL))) { - success |= do_in_path_and_pp(p_rtp, (char_u *)name, flags, callback, cookie); + success |= do_in_path_and_pp((char_u *)p_rtp, (char_u *)name, flags, callback, cookie); } return success; } @@ -1036,7 +1036,7 @@ static void add_opt_pack_plugin(char *fname, void *cookie) /// Add all packages in the "start" directory to 'runtimepath'. void add_pack_start_dirs(void) { - do_in_path(p_pp, NULL, DIP_ALL + DIP_DIR, add_pack_start_dir, NULL); + do_in_path((char_u *)p_pp, NULL, DIP_ALL + DIP_DIR, add_pack_start_dir, NULL); } static bool pack_has_entries(char_u *buf) @@ -1070,9 +1070,9 @@ static void add_pack_start_dir(char *fname, void *cookie) void load_start_packages(void) { did_source_packages = true; - do_in_path(p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT + do_in_path((char_u *)p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_start_pack_plugin, &APP_LOAD); - do_in_path(p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT + do_in_path((char_u *)p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT add_start_pack_plugin, &APP_LOAD); } @@ -1093,12 +1093,12 @@ void ex_packloadall(exarg_T *eap) void load_plugins(void) { if (p_lpl) { - char_u *rtp_copy = p_rtp; + char_u *rtp_copy = (char_u *)p_rtp; char_u *const plugin_pattern_vim = (char_u *)"plugin/**/*.vim"; // NOLINT char_u *const plugin_pattern_lua = (char_u *)"plugin/**/*.lua"; // NOLINT if (!did_source_packages) { - rtp_copy = vim_strsave(p_rtp); + rtp_copy = vim_strsave((char_u *)p_rtp); add_pack_start_dirs(); } @@ -1139,9 +1139,10 @@ 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, 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); + res = + do_in_path((char_u *)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); } } @@ -1169,10 +1170,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna size_t size = STRLEN(dirnames[i]) + pat_len + 7; char_u *s = xmalloc(size); snprintf((char *)s, size, "%s/%s*.vim", dirnames[i], pat); - globpath((char *)p_rtp, s, &ga, 0); + globpath(p_rtp, s, &ga, 0); if (flags & DIP_LUA) { snprintf((char *)s, size, "%s/%s*.lua", dirnames[i], pat); - globpath((char *)p_rtp, s, &ga, 0); + globpath(p_rtp, s, &ga, 0); } xfree(s); } @@ -1182,10 +1183,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna size_t size = STRLEN(dirnames[i]) + pat_len + 22; char_u *s = xmalloc(size); snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); if (flags & DIP_LUA) { snprintf((char *)s, size, "pack/*/start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); } xfree(s); } @@ -1194,10 +1195,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna size_t size = STRLEN(dirnames[i]) + pat_len + 22; char_u *s = xmalloc(size); snprintf((char *)s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); if (flags & DIP_LUA) { snprintf((char *)s, size, "start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); } xfree(s); } @@ -1208,10 +1209,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna size_t size = STRLEN(dirnames[i]) + pat_len + 20; char_u *s = xmalloc(size); snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); if (flags & DIP_LUA) { snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); } xfree(s); } @@ -1220,10 +1221,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna size_t size = STRLEN(dirnames[i]) + pat_len + 20; char_u *s = xmalloc(size); snprintf((char *)s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); if (flags & DIP_LUA) { snprintf((char *)s, size, "opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); } xfree(s); } @@ -1276,9 +1277,9 @@ int ExpandPackAddDir(char_u *pat, int *num_file, char ***file) size_t buflen = pat_len + 26; char_u *s = xmalloc(buflen); snprintf((char *)s, buflen, "pack/*/opt/%s*", pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); snprintf((char *)s, buflen, "opt/%s*", pat); // NOLINT - globpath((char *)p_pp, s, &ga, 0); + globpath(p_pp, s, &ga, 0); xfree(s); for (int i = 0; i < ga.ga_len; i++) { @@ -2017,7 +2018,7 @@ int do_source(char *fname, int check_other, int is_vimrc) if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef && firstline[1] == 0xbb && firstline[2] == 0xbf) { // Found BOM; setup conversion, skip over BOM and recode the line. - convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc); + convert_setup(&cookie.conv, (char_u *)"utf-8", (char_u *)p_enc); p = (char *)string_convert(&cookie.conv, (char_u *)firstline + 3, NULL); if (p == NULL) { p = xstrdup((char *)firstline + 3); @@ -2438,7 +2439,7 @@ void ex_scriptencoding(exarg_T *eap) // Setup for conversion from the specified encoding to 'encoding'. sp = (struct source_cookie *)getline_cookie(eap->getline, eap->cookie); - convert_setup(&sp->conv, (char_u *)name, p_enc); + convert_setup(&sp->conv, (char_u *)name, (char_u *)p_enc); if (name != eap->arg) { xfree(name); |