mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #16014 from dundargoc/refactor/reduce-char-casts
refactor: reduce number of unique char casts
This commit is contained in:
commit
5fd4557573
@ -712,7 +712,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Error *err)
|
||||
}
|
||||
fn = (String) {
|
||||
.data = (char *)di->di_tv.vval.v_string,
|
||||
.size = strlen((char *)di->di_tv.vval.v_string),
|
||||
.size = STRLEN(di->di_tv.vval.v_string),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3235,7 +3235,7 @@ void maketitle(void)
|
||||
int use_sandbox = false;
|
||||
int save_called_emsg = called_emsg;
|
||||
|
||||
use_sandbox = was_set_insecurely(curwin, (char_u *)"titlestring", 0);
|
||||
use_sandbox = was_set_insecurely(curwin, "titlestring", 0);
|
||||
called_emsg = false;
|
||||
build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
|
||||
p_titlestring, use_sandbox,
|
||||
@ -3353,7 +3353,7 @@ void maketitle(void)
|
||||
int use_sandbox = false;
|
||||
int save_called_emsg = called_emsg;
|
||||
|
||||
use_sandbox = was_set_insecurely(curwin, (char_u *)"iconstring", 0);
|
||||
use_sandbox = was_set_insecurely(curwin, "iconstring", 0);
|
||||
called_emsg = false;
|
||||
build_stl_str_hl(curwin, icon_str, sizeof(buf),
|
||||
p_iconstring, use_sandbox,
|
||||
|
@ -1843,12 +1843,12 @@ char_u *keymap_init(void)
|
||||
vim_snprintf(buf, buflen, "keymap/%s_%s.vim",
|
||||
curbuf->b_p_keymap, p_enc);
|
||||
|
||||
if (source_runtime((char_u *)buf, 0) == FAIL) {
|
||||
if (source_runtime(buf, 0) == FAIL) {
|
||||
// try finding "keymap/'keymap'.vim" in 'runtimepath'
|
||||
vim_snprintf(buf, buflen, "keymap/%s.vim",
|
||||
curbuf->b_p_keymap);
|
||||
|
||||
if (source_runtime((char_u *)buf, 0) == FAIL) {
|
||||
if (source_runtime(buf, 0) == FAIL) {
|
||||
xfree(buf);
|
||||
return (char_u *)N_("E544: Keymap file not found");
|
||||
}
|
||||
|
@ -1191,7 +1191,7 @@ int eval_foldexpr(char_u *arg, int *cp)
|
||||
{
|
||||
typval_T tv;
|
||||
varnumber_T retval;
|
||||
int use_sandbox = was_set_insecurely(curwin, (char_u *)"foldexpr", OPT_LOCAL);
|
||||
int use_sandbox = was_set_insecurely(curwin, "foldexpr", OPT_LOCAL);
|
||||
|
||||
++emsg_off;
|
||||
if (use_sandbox) {
|
||||
@ -10224,7 +10224,7 @@ bool script_autoload(const char *const name, const size_t name_len, const bool r
|
||||
}
|
||||
|
||||
// Try loading the package from $VIMRUNTIME/autoload/<name>.vim
|
||||
if (source_runtime((char_u *)scriptname, 0) == OK) {
|
||||
if (source_runtime(scriptname, 0) == OK) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
@ -4362,7 +4362,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
globpath((char_u *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags);
|
||||
|
||||
if (rettv->v_type == VAR_STRING) {
|
||||
rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n");
|
||||
rettv->vval.v_string = (char_u *)ga_concat_strings_sep(&ga, "\n");
|
||||
} else {
|
||||
tv_list_alloc_ret(rettv, ga.ga_len);
|
||||
for (int i = 0; i < ga.ga_len; i++) {
|
||||
|
@ -1439,11 +1439,11 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
|
||||
|
||||
if (linecount > p_report) {
|
||||
if (do_in) {
|
||||
vim_snprintf((char *)msg_buf, sizeof(msg_buf),
|
||||
vim_snprintf(msg_buf, sizeof(msg_buf),
|
||||
_("%" PRId64 " lines filtered"), (int64_t)linecount);
|
||||
if (msg(msg_buf) && !msg_scroll) {
|
||||
if (msg((char_u *)msg_buf) && !msg_scroll) {
|
||||
// save message to display it after redraw
|
||||
set_keep_msg(msg_buf, 0);
|
||||
set_keep_msg((char_u *)msg_buf, 0);
|
||||
}
|
||||
} else {
|
||||
msgmore((long)linecount);
|
||||
@ -4451,24 +4451,24 @@ bool do_sub_msg(bool count_only)
|
||||
*msg_buf = NUL;
|
||||
}
|
||||
if (sub_nsubs == 1) {
|
||||
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
|
||||
vim_snprintf_add(msg_buf, sizeof(msg_buf),
|
||||
"%s", count_only ? _("1 match") : _("1 substitution"));
|
||||
} else {
|
||||
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
|
||||
vim_snprintf_add(msg_buf, sizeof(msg_buf),
|
||||
count_only ? _("%" PRId64 " matches")
|
||||
: _("%" PRId64 " substitutions"),
|
||||
(int64_t)sub_nsubs);
|
||||
}
|
||||
if (sub_nlines == 1) {
|
||||
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
|
||||
vim_snprintf_add(msg_buf, sizeof(msg_buf),
|
||||
"%s", _(" on 1 line"));
|
||||
} else {
|
||||
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
|
||||
vim_snprintf_add(msg_buf, sizeof(msg_buf),
|
||||
_(" on %" PRId64 " lines"), (int64_t)sub_nlines);
|
||||
}
|
||||
if (msg(msg_buf)) {
|
||||
if (msg((char_u *)msg_buf)) {
|
||||
// save message to display it after redraw
|
||||
set_keep_msg(msg_buf, 0);
|
||||
set_keep_msg((char_u *)msg_buf, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -5800,8 +5800,7 @@ void ex_helptags(exarg_T *eap)
|
||||
}
|
||||
|
||||
if (STRCMP(eap->arg, "ALL") == 0) {
|
||||
do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR,
|
||||
helptags_cb, &add_help_tags);
|
||||
do_in_path(p_rtp, "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags);
|
||||
} else {
|
||||
ExpandInit(&xpc);
|
||||
xpc.xp_context = EXPAND_DIRECTORIES;
|
||||
|
@ -1640,10 +1640,10 @@ void ex_compiler(exarg_T *eap)
|
||||
do_unlet(S_LEN("b:current_compiler"), true);
|
||||
|
||||
snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg);
|
||||
if (source_runtime(buf, DIP_ALL) == FAIL) {
|
||||
if (source_runtime((char *)buf, DIP_ALL) == FAIL) {
|
||||
// Try lua compiler
|
||||
snprintf((char *)buf, bufsize, "compiler/%s.lua", eap->arg);
|
||||
if (source_runtime(buf, DIP_ALL) == FAIL) {
|
||||
if (source_runtime((char *)buf, DIP_ALL) == FAIL) {
|
||||
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
|
||||
}
|
||||
}
|
||||
@ -1823,7 +1823,7 @@ static void cmd_source(char_u *fname, exarg_T *eap)
|
||||
|| eap->cstack->cs_idx >= 0);
|
||||
|
||||
// ":source" read ex commands
|
||||
} else if (do_source(fname, false, DOSO_NONE) == FAIL) {
|
||||
} else if (do_source((char *)fname, false, DOSO_NONE) == FAIL) {
|
||||
EMSG2(_(e_notopen), fname);
|
||||
}
|
||||
}
|
||||
@ -2027,7 +2027,7 @@ int do_source_str(const char *cmd, const char *traceback_name)
|
||||
/// @param is_vimrc DOSO_ value
|
||||
///
|
||||
/// @return FAIL if file could not be opened, OK otherwise
|
||||
int do_source(char_u *fname, int check_other, int is_vimrc)
|
||||
int do_source(char *fname, int check_other, int is_vimrc)
|
||||
{
|
||||
struct source_cookie cookie;
|
||||
char_u *save_sourcing_name;
|
||||
@ -2043,7 +2043,7 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
|
||||
proftime_T wait_start;
|
||||
bool trigger_source_post = false;
|
||||
|
||||
p = expand_env_save(fname);
|
||||
p = expand_env_save((char_u *)fname);
|
||||
if (p == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
@ -9433,14 +9433,14 @@ static void ex_filetype(exarg_T *eap)
|
||||
}
|
||||
if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) {
|
||||
if (*arg == 'o' || !filetype_detect) {
|
||||
source_runtime((char_u *)FILETYPE_FILE, DIP_ALL);
|
||||
source_runtime(FILETYPE_FILE, DIP_ALL);
|
||||
filetype_detect = kTrue;
|
||||
if (plugin) {
|
||||
source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL);
|
||||
source_runtime(FTPLUGIN_FILE, DIP_ALL);
|
||||
filetype_plugin = kTrue;
|
||||
}
|
||||
if (indent) {
|
||||
source_runtime((char_u *)INDENT_FILE, DIP_ALL);
|
||||
source_runtime(INDENT_FILE, DIP_ALL);
|
||||
filetype_indent = kTrue;
|
||||
}
|
||||
}
|
||||
@ -9451,15 +9451,15 @@ static void ex_filetype(exarg_T *eap)
|
||||
} else if (STRCMP(arg, "off") == 0) {
|
||||
if (plugin || indent) {
|
||||
if (plugin) {
|
||||
source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL);
|
||||
source_runtime(FTPLUGOF_FILE, DIP_ALL);
|
||||
filetype_plugin = kFalse;
|
||||
}
|
||||
if (indent) {
|
||||
source_runtime((char_u *)INDOFF_FILE, DIP_ALL);
|
||||
source_runtime(INDOFF_FILE, DIP_ALL);
|
||||
filetype_indent = kFalse;
|
||||
}
|
||||
} else {
|
||||
source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
|
||||
source_runtime(FTOFF_FILE, DIP_ALL);
|
||||
filetype_detect = kFalse;
|
||||
}
|
||||
} else {
|
||||
@ -9471,15 +9471,15 @@ static void ex_filetype(exarg_T *eap)
|
||||
void filetype_maybe_enable(void)
|
||||
{
|
||||
if (filetype_detect == kNone) {
|
||||
source_runtime((char_u *)FILETYPE_FILE, true);
|
||||
source_runtime(FILETYPE_FILE, true);
|
||||
filetype_detect = kTrue;
|
||||
}
|
||||
if (filetype_plugin == kNone) {
|
||||
source_runtime((char_u *)FTPLUGIN_FILE, true);
|
||||
source_runtime(FTPLUGIN_FILE, true);
|
||||
filetype_plugin = kTrue;
|
||||
}
|
||||
if (filetype_indent == kNone) {
|
||||
source_runtime((char_u *)INDENT_FILE, true);
|
||||
source_runtime(INDENT_FILE, true);
|
||||
filetype_indent = kTrue;
|
||||
}
|
||||
}
|
||||
|
@ -859,7 +859,7 @@ void ex_loadview(exarg_T *eap)
|
||||
{
|
||||
char *fname = get_view_file(*eap->arg);
|
||||
if (fname != NULL) {
|
||||
if (do_source((char_u *)fname, false, DOSO_NONE) == FAIL) {
|
||||
if (do_source(fname, false, DOSO_NONE) == FAIL) {
|
||||
EMSG2(_(e_notopen), fname);
|
||||
}
|
||||
xfree(fname);
|
||||
|
@ -1664,13 +1664,13 @@ int vim_chdirfile(char_u *fname)
|
||||
/// Change directory to "new_dir". Search 'cdpath' for relative directory names.
|
||||
int vim_chdir(char_u *new_dir)
|
||||
{
|
||||
char_u *dir_name = find_directory_in_path(new_dir, STRLEN(new_dir),
|
||||
FNAME_MESS, curbuf->b_ffname);
|
||||
char *dir_name = (char *)find_directory_in_path(new_dir, STRLEN(new_dir),
|
||||
FNAME_MESS, curbuf->b_ffname);
|
||||
if (dir_name == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = os_chdir((char *)dir_name);
|
||||
int r = os_chdir(dir_name);
|
||||
xfree(dir_name);
|
||||
return r;
|
||||
}
|
||||
|
@ -1838,8 +1838,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
|
||||
curbuf = wp->w_buffer;
|
||||
|
||||
emsg_silent++; // handle exceptions, but don't display errors
|
||||
text = eval_to_string_safe(wp->w_p_fdt, NULL,
|
||||
was_set_insecurely(wp, (char_u *)"foldtext", OPT_LOCAL));
|
||||
text = eval_to_string_safe(wp->w_p_fdt, NULL, was_set_insecurely(wp, "foldtext", OPT_LOCAL));
|
||||
emsg_silent--;
|
||||
|
||||
if (text == NULL || did_emsg) {
|
||||
|
@ -143,14 +143,14 @@ void ga_remove_duplicate_strings(garray_T *gap)
|
||||
/// @param sep
|
||||
///
|
||||
/// @returns the concatenated strings
|
||||
char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
|
||||
char *ga_concat_strings_sep(const garray_T *gap, const char *sep)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
const size_t nelem = (size_t)gap->ga_len;
|
||||
const char **strings = gap->ga_data;
|
||||
|
||||
if (nelem == 0) {
|
||||
return (char_u *)xstrdup("");
|
||||
return xstrdup("");
|
||||
}
|
||||
|
||||
size_t len = 0;
|
||||
@ -169,7 +169,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
|
||||
}
|
||||
strcpy(s, strings[nelem - 1]);
|
||||
|
||||
return (char_u *)ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// For a growing array that contains a list of strings: concatenate all the
|
||||
@ -180,7 +180,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
|
||||
/// @returns the concatenated strings
|
||||
char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
return ga_concat_strings_sep(gap, ",");
|
||||
return (char_u *)ga_concat_strings_sep(gap, ",");
|
||||
}
|
||||
|
||||
/// Concatenate a string to a growarray which contains characters.
|
||||
@ -198,7 +198,7 @@ void ga_concat(garray_T *gap, const char *restrict s)
|
||||
return;
|
||||
}
|
||||
|
||||
ga_concat_len(gap, s, strlen((char *)s));
|
||||
ga_concat_len(gap, s, STRLEN(s));
|
||||
}
|
||||
|
||||
/// Concatenate a string to a growarray which contains characters
|
||||
|
@ -2660,12 +2660,11 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const
|
||||
char_u *replaced = replace_termcodes(orig_lhs, orig_lhs_len, &lhs_buf,
|
||||
true, true, true, cpo_flags);
|
||||
mapargs->lhs_len = STRLEN(replaced);
|
||||
xstrlcpy((char *)mapargs->lhs, (char *)replaced, sizeof(mapargs->lhs));
|
||||
STRLCPY(mapargs->lhs, replaced, sizeof(mapargs->lhs));
|
||||
|
||||
mapargs->orig_rhs_len = orig_rhs_len;
|
||||
mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char_u));
|
||||
xstrlcpy((char *)mapargs->orig_rhs, (char *)orig_rhs,
|
||||
mapargs->orig_rhs_len + 1);
|
||||
STRLCPY(mapargs->orig_rhs, orig_rhs, mapargs->orig_rhs_len + 1);
|
||||
|
||||
if (STRICMP(orig_rhs, "<nop>") == 0) { // "<Nop>" means nothing
|
||||
mapargs->rhs = xcalloc(1, sizeof(char_u)); // single null-char
|
||||
@ -2677,7 +2676,7 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const
|
||||
mapargs->rhs_len = STRLEN(replaced);
|
||||
mapargs->rhs_is_noop = false;
|
||||
mapargs->rhs = xcalloc(mapargs->rhs_len + 1, sizeof(char_u));
|
||||
xstrlcpy((char *)mapargs->rhs, (char *)replaced, mapargs->rhs_len + 1);
|
||||
STRLCPY(mapargs->rhs, replaced, mapargs->rhs_len + 1);
|
||||
}
|
||||
|
||||
xfree(lhs_buf);
|
||||
@ -2785,7 +2784,7 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs)
|
||||
// (e.g. "<Space>" is longer than ' '), so first copy into a buffer.
|
||||
size_t orig_lhs_len = (size_t)(lhs_end - to_parse);
|
||||
char_u *lhs_to_replace = xcalloc(orig_lhs_len + 1, sizeof(char_u));
|
||||
xstrlcpy((char *)lhs_to_replace, (char *)to_parse, orig_lhs_len + 1);
|
||||
STRLCPY(lhs_to_replace, to_parse, orig_lhs_len + 1);
|
||||
|
||||
size_t orig_rhs_len = STRLEN(rhs_start);
|
||||
set_maparg_lhs_rhs(lhs_to_replace, orig_lhs_len,
|
||||
|
@ -669,7 +669,7 @@ EXTERN bool swap_exists_did_quit INIT(= false);
|
||||
|
||||
EXTERN char_u IObuff[IOSIZE]; ///< Buffer for sprintf, I/O, etc.
|
||||
EXTERN char_u NameBuff[MAXPATHL]; ///< Buffer for expanding file names
|
||||
EXTERN char_u msg_buf[MSG_BUF_LEN]; ///< Small buffer for messages
|
||||
EXTERN char msg_buf[MSG_BUF_LEN]; ///< Small buffer for messages
|
||||
EXTERN char os_buf[ ///< Buffer for the os/ layer
|
||||
#if MAXPATHL > IOSIZE
|
||||
MAXPATHL
|
||||
@ -982,9 +982,8 @@ EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String"));
|
||||
|
||||
EXTERN char_u e_autocmd_err[] INIT(=N_("E5500: autocmd has thrown an exception: %s"));
|
||||
EXTERN char_u e_cmdmap_err[] INIT(=N_("E5520: <Cmd> mapping must end with <CR>"));
|
||||
EXTERN char_u e_cmdmap_repeated[] INIT(=
|
||||
N_(
|
||||
"E5521: <Cmd> mapping must end with <CR> before second <Cmd>"));
|
||||
EXTERN char_u
|
||||
e_cmdmap_repeated[] INIT(=N_("E5521: <Cmd> mapping must end with <CR> before second <Cmd>"));
|
||||
EXTERN char_u e_cmdmap_key[] INIT(=N_("E5522: <Cmd> mapping must not include %s key"));
|
||||
|
||||
EXTERN char_u e_api_error[] INIT(=N_("E5555: API call: %s"));
|
||||
|
@ -551,7 +551,7 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum, const
|
||||
curwin->w_botline = lnum + 63;
|
||||
printer_page_num = pagenum;
|
||||
|
||||
use_sandbox = was_set_insecurely(curwin, (char_u *)"printheader", 0);
|
||||
use_sandbox = was_set_insecurely(curwin, "printheader", 0);
|
||||
build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE,
|
||||
p_header, use_sandbox,
|
||||
' ', width, NULL, NULL);
|
||||
|
@ -533,7 +533,7 @@ int get_expr_indent(void)
|
||||
colnr_T save_curswant;
|
||||
int save_set_curswant;
|
||||
int save_State;
|
||||
int use_sandbox = was_set_insecurely(curwin, (char_u *)"indentexpr", OPT_LOCAL);
|
||||
int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL);
|
||||
|
||||
// Save and restore cursor position and curswant, in case it was changed
|
||||
// * via :normal commands.
|
||||
|
@ -1700,7 +1700,7 @@ static void do_system_initialization(void)
|
||||
memcpy(vimrc, dir, dir_len);
|
||||
vimrc[dir_len] = PATHSEP;
|
||||
memcpy(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
|
||||
if (do_source((char_u *)vimrc, false, DOSO_NONE) != FAIL) {
|
||||
if (do_source(vimrc, false, DOSO_NONE) != FAIL) {
|
||||
xfree(vimrc);
|
||||
xfree(config_dirs);
|
||||
return;
|
||||
@ -1712,7 +1712,7 @@ static void do_system_initialization(void)
|
||||
|
||||
#ifdef SYS_VIMRC_FILE
|
||||
// Get system wide defaults, if the file name is defined.
|
||||
(void)do_source((char_u *)SYS_VIMRC_FILE, false, DOSO_NONE);
|
||||
(void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1741,7 +1741,7 @@ static bool do_user_initialization(void)
|
||||
|
||||
// init.lua
|
||||
if (os_path_exists(init_lua_path)
|
||||
&& do_source(init_lua_path, true, DOSO_VIMRC)) {
|
||||
&& do_source((char *)init_lua_path, true, DOSO_VIMRC)) {
|
||||
if (os_path_exists(user_vimrc)) {
|
||||
EMSG3(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path,
|
||||
user_vimrc);
|
||||
@ -1754,7 +1754,7 @@ static bool do_user_initialization(void)
|
||||
xfree(init_lua_path);
|
||||
|
||||
// init.vim
|
||||
if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||
if (do_source((char *)user_vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||
do_exrc = p_exrc;
|
||||
if (do_exrc) {
|
||||
do_exrc = (path_full_compare((char_u *)VIMRC_FILE, user_vimrc,
|
||||
@ -1782,7 +1782,7 @@ static bool do_user_initialization(void)
|
||||
memmove(vimrc, dir, dir_len);
|
||||
vimrc[dir_len] = PATHSEP;
|
||||
memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
|
||||
if (do_source((char_u *)vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||
if (do_source(vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||
do_exrc = p_exrc;
|
||||
if (do_exrc) {
|
||||
do_exrc = (path_full_compare((char_u *)VIMRC_FILE, (char_u *)vimrc,
|
||||
@ -1814,7 +1814,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
|
||||
|| strequal(parmp->use_vimrc, "NORC")) {
|
||||
// Do nothing.
|
||||
} else {
|
||||
if (do_source((char_u *)parmp->use_vimrc, false, DOSO_NONE) != OK) {
|
||||
if (do_source(parmp->use_vimrc, false, DOSO_NONE) != OK) {
|
||||
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
|
||||
}
|
||||
}
|
||||
@ -1835,7 +1835,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
|
||||
#endif
|
||||
secure = p_secure;
|
||||
|
||||
if (do_source((char_u *)VIMRC_FILE, true, DOSO_VIMRC) == FAIL) {
|
||||
if (do_source(VIMRC_FILE, true, DOSO_VIMRC) == FAIL) {
|
||||
#if defined(UNIX)
|
||||
// if ".exrc" is not owned by user set 'secure' mode
|
||||
if (!file_owned(EXRC_FILE)) {
|
||||
@ -1844,7 +1844,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
|
||||
secure = 0;
|
||||
}
|
||||
#endif
|
||||
(void)do_source((char_u *)EXRC_FILE, false, DOSO_NONE);
|
||||
(void)do_source(EXRC_FILE, false, DOSO_NONE);
|
||||
}
|
||||
}
|
||||
if (secure == 2) {
|
||||
|
@ -696,18 +696,18 @@ void msgmore(long n)
|
||||
}
|
||||
} else {
|
||||
if (n > 0) {
|
||||
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
|
||||
vim_snprintf(msg_buf, MSG_BUF_LEN,
|
||||
_("%" PRId64 " more lines"), (int64_t)pn);
|
||||
} else {
|
||||
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
|
||||
vim_snprintf(msg_buf, MSG_BUF_LEN,
|
||||
_("%" PRId64 " fewer lines"), (int64_t)pn);
|
||||
}
|
||||
}
|
||||
if (got_int) {
|
||||
xstrlcat((char *)msg_buf, _(" (Interrupted)"), MSG_BUF_LEN);
|
||||
xstrlcat(msg_buf, _(" (Interrupted)"), MSG_BUF_LEN);
|
||||
}
|
||||
if (msg(msg_buf)) {
|
||||
set_keep_msg(msg_buf, 0);
|
||||
if (msg((char_u *)msg_buf)) {
|
||||
set_keep_msg((char_u *)msg_buf, 0);
|
||||
keep_msg_more = true;
|
||||
}
|
||||
}
|
||||
|
@ -4253,7 +4253,7 @@ void op_formatexpr(oparg_T *oap)
|
||||
/// @param c character to be inserted
|
||||
int fex_format(linenr_T lnum, long count, int c)
|
||||
{
|
||||
int use_sandbox = was_set_insecurely(curwin, (char_u *)"formatexpr", OPT_LOCAL);
|
||||
int use_sandbox = was_set_insecurely(curwin, "formatexpr", OPT_LOCAL);
|
||||
int r;
|
||||
char_u *fex;
|
||||
|
||||
@ -4817,7 +4817,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd)
|
||||
if (change_cnt == 1) {
|
||||
MSG(_("1 line changed"));
|
||||
} else {
|
||||
smsg((char *)_("%" PRId64 " lines changed"), (int64_t)change_cnt);
|
||||
smsg(_("%" PRId64 " lines changed"), (int64_t)change_cnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6056,7 +6056,7 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines)
|
||||
|
||||
void finish_yankreg_from_object(yankreg_T *reg, bool clipboard_adjust)
|
||||
{
|
||||
if (reg->y_size > 0 && strlen((char *)reg->y_array[reg->y_size-1]) == 0) {
|
||||
if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) {
|
||||
// a known-to-be charwise yank might have a final linebreak
|
||||
// but otherwise there is no line after the final newline
|
||||
if (reg->y_type != kMTCharWise) {
|
||||
@ -6121,7 +6121,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
|
||||
goto err;
|
||||
}
|
||||
char_u *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string;
|
||||
if (regtype == NULL || strlen((char *)regtype) > 1) {
|
||||
if (regtype == NULL || STRLEN(regtype) > 1) {
|
||||
goto err;
|
||||
}
|
||||
switch (regtype[0]) {
|
||||
@ -6164,7 +6164,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
|
||||
reg->y_array[tv_idx++] = (char_u *)xstrdupnul((const char *)TV_LIST_ITEM_TV(li)->vval.v_string);
|
||||
});
|
||||
|
||||
if (reg->y_size > 0 && strlen((char *)reg->y_array[reg->y_size-1]) == 0) {
|
||||
if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) {
|
||||
// a known-to-be charwise yank might have a final linebreak
|
||||
// but otherwise there is no line after the final newline
|
||||
if (reg->y_type != kMTCharWise) {
|
||||
|
@ -2072,9 +2072,9 @@ static void check_string_option(char_u **pp)
|
||||
/// Return true when option "opt" was set from a modeline or in secure mode.
|
||||
/// Return false when it wasn't.
|
||||
/// Return -1 for an unknown option.
|
||||
int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags)
|
||||
int was_set_insecurely(win_T *const wp, char *opt, int opt_flags)
|
||||
{
|
||||
int idx = findoption((const char *)opt);
|
||||
int idx = findoption(opt);
|
||||
|
||||
if (idx >= 0) {
|
||||
uint32_t *flagp = insecure_flag(wp, idx, opt_flags);
|
||||
@ -3288,7 +3288,7 @@ ambw_end:
|
||||
if (p > q) {
|
||||
vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim",
|
||||
(int)(p - q), q);
|
||||
source_runtime(fname, DIP_ALL);
|
||||
source_runtime((char *)fname, DIP_ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1658,8 +1658,7 @@ static char *eval_includeexpr(const char *const ptr, const size_t len)
|
||||
{
|
||||
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
|
||||
char *res = (char *)eval_to_string_safe(curbuf->b_p_inex, NULL,
|
||||
was_set_insecurely(curwin, (char_u *)"includeexpr",
|
||||
OPT_LOCAL));
|
||||
was_set_insecurely(curwin, "includeexpr", OPT_LOCAL));
|
||||
set_vim_var_string(VV_FNAME, NULL, 0);
|
||||
return res;
|
||||
}
|
||||
@ -2038,7 +2037,7 @@ char_u *path_shorten_fname(char_u *full_path, char_u *dir_name)
|
||||
}
|
||||
|
||||
assert(dir_name != NULL);
|
||||
size_t len = strlen((char *)dir_name);
|
||||
size_t len = STRLEN(dir_name);
|
||||
|
||||
// If dir_name is a path head, full_path can always be made relative.
|
||||
if (len == (size_t)path_head_length() && is_path_head(dir_name)) {
|
||||
|
@ -1628,8 +1628,8 @@ static int qf_parse_multiline_pfx(int idx, qf_list_T *qfl, qffields_T *fields)
|
||||
return QF_FAIL;
|
||||
}
|
||||
if (*fields->errmsg) {
|
||||
size_t textlen = strlen((char *)qfprev->qf_text);
|
||||
size_t errlen = strlen((char *)fields->errmsg);
|
||||
size_t textlen = STRLEN(qfprev->qf_text);
|
||||
size_t errlen = STRLEN(fields->errmsg);
|
||||
qfprev->qf_text = xrealloc(qfprev->qf_text, textlen + errlen + 2);
|
||||
qfprev->qf_text[textlen] = '\n';
|
||||
STRCPY(qfprev->qf_text + textlen + 1, fields->errmsg);
|
||||
|
@ -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);
|
||||
|
@ -5465,7 +5465,7 @@ static void win_redr_custom(win_T *wp, bool draw_ruler)
|
||||
fillchar = ' ';
|
||||
attr = HL_ATTR(HLF_TPF);
|
||||
maxwidth = Columns;
|
||||
use_sandbox = was_set_insecurely(wp, (char_u *)"tabline", 0);
|
||||
use_sandbox = was_set_insecurely(wp, "tabline", 0);
|
||||
} else {
|
||||
row = W_ENDROW(wp);
|
||||
fillchar = fillchar_status(&attr, wp);
|
||||
@ -5500,15 +5500,14 @@ static void win_redr_custom(win_T *wp, bool draw_ruler)
|
||||
attr = HL_ATTR(HLF_MSG);
|
||||
}
|
||||
|
||||
use_sandbox = was_set_insecurely(wp, (char_u *)"rulerformat", 0);
|
||||
use_sandbox = was_set_insecurely(wp, "rulerformat", 0);
|
||||
} else {
|
||||
if (*wp->w_p_stl != NUL) {
|
||||
stl = wp->w_p_stl;
|
||||
} else {
|
||||
stl = p_stl;
|
||||
}
|
||||
use_sandbox = was_set_insecurely(wp, (char_u *)"statusline",
|
||||
*wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
|
||||
use_sandbox = was_set_insecurely(wp, "statusline", *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
|
||||
}
|
||||
|
||||
col += wp->w_wincol;
|
||||
|
@ -4393,8 +4393,8 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
|
||||
prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
|
||||
curwin->w_s->b_syn_topgrp = sgl_id;
|
||||
if (source
|
||||
? do_source(eap->arg, false, DOSO_NONE) == FAIL
|
||||
: source_runtime(eap->arg, DIP_ALL) == FAIL) {
|
||||
? do_source((char *)eap->arg, false, DOSO_NONE) == FAIL
|
||||
: source_runtime((char *)eap->arg, DIP_ALL) == FAIL) {
|
||||
EMSG2(_(e_notopen), eap->arg);
|
||||
}
|
||||
curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
|
||||
@ -6616,10 +6616,10 @@ int load_colors(char_u *name)
|
||||
buf = xmalloc(buflen);
|
||||
apply_autocmds(EVENT_COLORSCHEMEPRE, name, curbuf->b_fname, false, curbuf);
|
||||
snprintf((char *)buf, buflen, "colors/%s.vim", name);
|
||||
retval = source_runtime(buf, DIP_START + DIP_OPT);
|
||||
retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
|
||||
if (retval == FAIL) {
|
||||
snprintf((char *)buf, buflen, "colors/%s.lua", name);
|
||||
retval = source_runtime(buf, DIP_START + DIP_OPT);
|
||||
retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
|
||||
}
|
||||
xfree(buf);
|
||||
apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, false, curbuf);
|
||||
|
@ -906,7 +906,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches)
|
||||
if (len > 128) {
|
||||
len = 128;
|
||||
}
|
||||
xstrlcpy((char *)tag_name, (const char *)tagp.tagname, len + 1);
|
||||
STRLCPY(tag_name, tagp.tagname, len + 1);
|
||||
tag_name[len] = NUL;
|
||||
|
||||
// Save the tag file name
|
||||
@ -914,7 +914,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches)
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
xstrlcpy((char *)fname, (const char *)p, MAXPATHL);
|
||||
STRLCPY(fname, p, MAXPATHL);
|
||||
XFREE_CLEAR(p);
|
||||
|
||||
// Get the line number or the search pattern used to locate
|
||||
|
Loading…
Reference in New Issue
Block a user