refactor: replace char_u variables and functions with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
Dundar Goc 2022-05-01 11:18:17 +02:00
parent 46734cf7c1
commit b9bdd0f61e
30 changed files with 574 additions and 587 deletions

View File

@ -131,7 +131,7 @@ Object nvim_eval(String expr, Error *err)
try_start();
typval_T rettv;
int ok = eval0((char_u *)expr.data, &rettv, NULL, true);
int ok = eval0(expr.data, &rettv, NULL, true);
if (!try_end(err)) {
if (ok == FAIL) {
@ -246,7 +246,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Error *err)
switch (dict.type) {
case kObjectTypeString:
try_start();
if (eval0((char_u *)dict.data.string.data, &rettv, NULL, true) == FAIL) {
if (eval0(dict.data.string.data, &rettv, NULL, true) == FAIL) {
api_set_error(err, kErrorTypeException,
"Failed to evaluate dict expression");
}

View File

@ -1816,7 +1816,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
// set v:cmdarg (only when there is a matching pattern)
save_cmdbang = (long)get_vim_var_nr(VV_CMDBANG);
if (eap != NULL) {
save_cmdarg = set_cmdarg(eap, NULL);
save_cmdarg = (char_u *)set_cmdarg(eap, NULL);
set_vim_var_nr(VV_CMDBANG, (long)eap->forceit);
} else {
save_cmdarg = NULL; // avoid gcc warning
@ -1845,7 +1845,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
if (eap != NULL) {
(void)set_cmdarg(NULL, save_cmdarg);
(void)set_cmdarg(NULL, (char *)save_cmdarg);
set_vim_var_nr(VV_CMDBANG, save_cmdbang);
}
// delete from active_apc_list

View File

@ -3421,7 +3421,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
};
set_var(S_LEN("g:statusline_winid"), &tv, false);
usefmt = eval_to_string_safe(fmt + 2, NULL, use_sandbox);
usefmt = (char_u *)eval_to_string_safe((char *)fmt + 2, NULL, use_sandbox);
if (usefmt == NULL) {
usefmt = fmt;
}
@ -3878,9 +3878,9 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// Store the current buffer number as a string variable
vim_snprintf(buf_tmp, sizeof(buf_tmp), "%d", curbuf->b_fnum);
set_internal_string_var("g:actual_curbuf", (char_u *)buf_tmp);
set_internal_string_var("g:actual_curbuf", buf_tmp);
vim_snprintf((char *)win_tmp, sizeof(win_tmp), "%d", curwin->handle);
set_internal_string_var("g:actual_curwin", win_tmp);
set_internal_string_var("g:actual_curwin", (char *)win_tmp);
buf_T *const save_curbuf = curbuf;
win_T *const save_curwin = curwin;
@ -3893,7 +3893,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
// Note: The result stored in `t` is unused.
str = (char *)eval_to_string_safe(out_p, &t, use_sandbox);
str = eval_to_string_safe((char *)out_p, (char **)&t, use_sandbox);
curwin = save_curwin;
curbuf = save_curbuf;

View File

@ -461,7 +461,7 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp)
{
// Disable error messages, a bad expression would make Vim unusable.
emsg_off++;
typval_T *const tv = eval_expr(bp->dbg_name);
typval_T *const tv = eval_expr((char *)bp->dbg_name);
emsg_off--;
return tv;
}

View File

@ -4028,7 +4028,7 @@ static void expand_by_function(int type, char_u *base)
curbuf_save = curbuf;
// Call a function, which returns a list or dict.
if (call_vim_function(funcname, 2, args, &rettv) == OK) {
if (call_vim_function((char *)funcname, 2, args, &rettv) == OK) {
switch (rettv.v_type) {
case VAR_LIST:
matchlist = rettv.vval.v_list;
@ -5311,7 +5311,7 @@ static int ins_complete(int c, bool enable_pum)
pos = curwin->w_cursor;
curwin_save = curwin;
curbuf_save = curbuf;
int col = call_func_retnr(funcname, 2, args);
int col = call_func_retnr((char *)funcname, 2, args);
State = save_State;
if (curwin_save != curwin || curbuf_save != curbuf) {

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ typedef struct lval_S {
long ll_n2; ///< Second index for list range.
dict_T *ll_dict; ///< The Dictionary or NULL.
dictitem_T *ll_di; ///< The dictitem or NULL.
char_u *ll_newkey; ///< New key for Dict in allocated memory or NULL.
char *ll_newkey; ///< New key for Dict in allocated memory or NULL.
blob_T *ll_blob; ///< The Blob or NULL.
} lval_T;
@ -266,7 +266,7 @@ typedef enum {
kDictListItems, ///< List dictionary contents: [keys, values].
} DictListType;
typedef int (*ex_unletlock_callback)(lval_T *, char_u *, exarg_T *, int);
typedef int (*ex_unletlock_callback)(lval_T *, char *, exarg_T *, int);
// Used for checking if local variables or arguments used in a lambda.
extern bool *eval_lavars_used;

View File

@ -129,7 +129,7 @@ char_u *get_function_name(expand_T *xp, int idx)
if (name != NULL) {
if (*name != NUL && *name != '<'
&& STRNCMP("g:", xp->xp_pattern, 2) == 0) {
return cat_prefix_varname('g', name);
return (char_u *)cat_prefix_varname('g', (char *)name);
}
return name;
}
@ -772,7 +772,7 @@ static void f_call(typval_T *argvars, typval_T *rettv, FunPtr fptr)
func = argvars[0].vval.v_string;
} else if (argvars[0].v_type == VAR_PARTIAL) {
partial = argvars[0].vval.v_partial;
func = partial_name(partial);
func = (char_u *)partial_name(partial);
} else if (nlua_is_table_from_lua(&argvars[0])) {
// TODO(tjdevries): UnifiedCallback
func = nlua_register_table_as_callable(&argvars[0]);
@ -1896,7 +1896,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
const char *const expr_start = s;
if (s == NULL || eval1((char_u **)&s, rettv, true) == FAIL) {
if (s == NULL || eval1((char **)&s, rettv, true) == FAIL) {
if (expr_start != NULL && !aborting()) {
semsg(_(e_invexpr2), expr_start);
}
@ -2489,8 +2489,8 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, FunPtr fptr)
len = strlen(fname);
if (*mods != NUL) {
size_t usedlen = 0;
(void)modify_fname((char_u *)mods, false, &usedlen,
(char_u **)&fname, &fbuf, &len);
(void)modify_fname((char *)mods, false, &usedlen,
(char **)&fname, (char **)&fbuf, &len);
}
}
@ -4886,11 +4886,11 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
dictitem_T *di;
rettv->vval.v_number = -1;
const char_u *const end = get_lval((char_u *)tv_get_string(&argvars[0]),
NULL,
&lv, false, false,
GLV_NO_AUTOLOAD|GLV_READ_ONLY,
FNE_CHECK_START);
const char_u *const end = (char_u *)get_lval((char *)tv_get_string(&argvars[0]),
NULL,
&lv, false, false,
GLV_NO_AUTOLOAD|GLV_READ_ONLY,
FNE_CHECK_START);
if (end != NULL && lv.ll_name != NULL) {
if (*end != NUL) {
emsg(_(e_trailing));
@ -7506,7 +7506,7 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr)
func_name = argvars[1].vval.v_string;
} else if (argvars[1].v_type == VAR_PARTIAL) {
partial = argvars[1].vval.v_partial;
func_name = partial_name(partial);
func_name = (char_u *)partial_name(partial);
} else {
func_name = (const char_u *)tv_get_string(&argvars[1]);
}
@ -10303,8 +10303,8 @@ static void f_substitute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|| flg == NULL) {
rettv->vval.v_string = NULL;
} else {
rettv->vval.v_string = do_string_sub((char_u *)str, (char_u *)pat,
(char_u *)sub, expr, (char_u *)flg);
rettv->vval.v_string = (char_u *)do_string_sub((char *)str, (char *)pat,
(char *)sub, expr, (char *)flg);
}
}

View File

@ -343,8 +343,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
case VAR_PARTIAL: {
partial_T *const pt = tv->vval.v_partial;
(void)pt;
TYPVAL_ENCODE_CONV_FUNC_START( // -V547
tv, (pt == NULL ? NULL : partial_name(pt)));
TYPVAL_ENCODE_CONV_FUNC_START(tv, (pt == NULL ? NULL : (char_u *)partial_name(pt))); // -V547
_mp_push(*mpstack, ((MPConvStackVal) { // -V779
.type = kMPConvPartial,
.tv = tv,

View File

@ -132,7 +132,7 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i
p = skipwhite(p) + 1;
p = skipwhite(p);
char_u *expr = p;
if (eval1(&p, &rettv, false) != FAIL) {
if (eval1((char **)&p, &rettv, false) != FAIL) {
ga_grow(default_args, 1);
// trim trailing whitespace
@ -253,7 +253,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
// Get the start and the end of the expression.
*arg = skipwhite(*arg + 1);
s = *arg;
ret = skip_expr(arg);
ret = skip_expr((char **)arg);
if (ret == FAIL) {
goto errret;
}
@ -372,7 +372,7 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp,
if (partialp != NULL) {
*partialp = pt;
}
char_u *s = partial_name(pt);
char_u *s = (char_u *)partial_name(pt);
*lenp = (int)STRLEN(s);
return s;
}
@ -426,7 +426,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char_u **arg, func
if (*argp == ')' || *argp == ',' || *argp == NUL) {
break;
}
if (eval1(&argp, &argvars[argcount], funcexe->evaluate) == FAIL) {
if (eval1((char **)&argp, &argvars[argcount], funcexe->evaluate) == FAIL) {
ret = FAIL;
break;
}
@ -941,7 +941,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
default_expr = ((char_u **)(fp->uf_def_args.ga_data))
[ai + fp->uf_def_args.ga_len];
if (eval1(&default_expr, &def_rettv, true) == FAIL) {
if (eval1((char **)&default_expr, &def_rettv, true) == FAIL) {
default_arg_err = true;
break;
}
@ -1103,7 +1103,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
// A Lambda always has the command "return {expr}". It is much faster
// to evaluate {expr} directly.
ex_nesting_level++;
(void)eval1(&p, rettv, true);
(void)eval1((char **)&p, rettv, true);
ex_nesting_level--;
} else {
// call do_cmdline() to execute the lines
@ -1150,18 +1150,18 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
smsg(_("%s returning #%" PRId64 ""),
sourcing_name, (int64_t)fc->rettv->vval.v_number);
} else {
char_u buf[MSG_BUF_LEN];
char buf[MSG_BUF_LEN];
// The value may be very long. Skip the middle part, so that we
// have some idea how it starts and ends. smsg() would always
// truncate it at the end. Don't want errors such as E724 here.
emsg_off++;
char_u *s = (char_u *)encode_tv2string(fc->rettv, NULL);
char_u *tofree = s;
char *s = encode_tv2string(fc->rettv, NULL);
char *tofree = s;
emsg_off--;
if (s != NULL) {
if (vim_strsize(s) > MSG_BUF_CLEN) {
trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
if (vim_strsize((char_u *)s) > MSG_BUF_CLEN) {
trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, MSG_BUF_LEN);
s = buf;
}
smsg(_("%s returning %s"), sourcing_name, s);
@ -1724,8 +1724,8 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
}
// Note that TFN_ flags use the same values as GLV_ flags.
end = get_lval((char_u *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY,
lead > 2 ? 0 : FNE_CHECK_START);
end = (char_u *)get_lval((char *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY,
lead > 2 ? 0 : FNE_CHECK_START);
if (end == start) {
if (!skip) {
emsg(_("E129: Function name required"));
@ -1743,7 +1743,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
semsg(_(e_invarg2), start);
}
} else {
*pp = (char_u *)find_name_end(start, NULL, NULL, FNE_INCL_BR);
*pp = (char_u *)find_name_end((char *)start, NULL, NULL, FNE_INCL_BR);
}
goto theend;
}
@ -1751,7 +1751,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
if (lv.ll_tv != NULL) {
if (fdp != NULL) {
fdp->fd_dict = lv.ll_dict;
fdp->fd_newkey = lv.ll_newkey;
fdp->fd_newkey = (char_u *)lv.ll_newkey;
lv.ll_newkey = NULL;
fdp->fd_di = lv.ll_di;
}
@ -1770,7 +1770,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
memcpy(name, end + 1, (size_t)len);
*pp = (char_u *)end + 1 + len;
} else {
name = vim_strsave(partial_name(lv.ll_tv->vval.v_partial));
name = vim_strsave((char_u *)partial_name(lv.ll_tv->vval.v_partial));
*pp = (char_u *)end;
}
if (partial != NULL) {
@ -2873,7 +2873,7 @@ void ex_return(exarg_T *eap)
eap->nextcmd = NULL;
if ((*arg != NUL && *arg != '|' && *arg != '\n')
&& eval0(arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) {
&& eval0((char *)arg, &rettv, (char **)&eap->nextcmd, !eap->skip) != FAIL) {
if (!eap->skip) {
returning = do_return(eap, false, true, &rettv);
} else {
@ -2926,7 +2926,7 @@ void ex_call(exarg_T *eap)
// instead to skip to any following command, e.g. for:
// :if 0 | call dict.foo().bar() | endif.
emsg_skip++;
if (eval0(eap->arg, &rettv, &eap->nextcmd, false) != FAIL) {
if (eval0((char *)eap->arg, &rettv, (char **)&eap->nextcmd, false) != FAIL) {
tv_clear(&rettv);
}
emsg_skip--;
@ -2995,7 +2995,7 @@ void ex_call(exarg_T *eap)
// Handle a function returning a Funcref, Dictionary or List.
if (handle_subscript((const char **)&arg, &rettv, true, true,
(const char_u *)name, (const char_u **)&name)
(const char *)name, (const char **)&name)
== FAIL) {
failed = true;
break;

View File

@ -1627,14 +1627,14 @@ void ex_compiler(exarg_T *eap)
// Set "b:current_compiler" from "current_compiler".
p = get_var_value("g:current_compiler");
if (p != NULL) {
set_internal_string_var("b:current_compiler", p);
set_internal_string_var("b:current_compiler", (char *)p);
}
// Restore "current_compiler" for ":compiler {name}".
if (!eap->forceit) {
if (old_cur_comp != NULL) {
set_internal_string_var("g:current_compiler",
old_cur_comp);
(char *)old_cur_comp);
xfree(old_cur_comp);
} else {
do_unlet(S_LEN("g:current_compiler"), true);

View File

@ -152,8 +152,8 @@ static void save_dbg_stuff(struct dbg_stuff *dsp)
dsp->trylevel = trylevel; trylevel = 0;
dsp->force_abort = force_abort; force_abort = FALSE;
dsp->caught_stack = caught_stack; caught_stack = NULL;
dsp->vv_exception = (char *)v_exception(NULL);
dsp->vv_throwpoint = (char *)v_throwpoint(NULL);
dsp->vv_exception = v_exception(NULL);
dsp->vv_throwpoint = v_throwpoint(NULL);
// Necessary for debugging an inactive ":catch", ":finally", ":endtry".
dsp->did_emsg = did_emsg; did_emsg = false;
@ -169,8 +169,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp)
trylevel = dsp->trylevel;
force_abort = dsp->force_abort;
caught_stack = dsp->caught_stack;
(void)v_exception((char_u *)dsp->vv_exception);
(void)v_throwpoint((char_u *)dsp->vv_throwpoint);
(void)v_exception(dsp->vv_exception);
(void)v_throwpoint(dsp->vv_throwpoint);
did_emsg = dsp->did_emsg;
got_int = dsp->got_int;
need_rethrow = dsp->need_rethrow;
@ -3701,7 +3701,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_lexpr:
case CMD_laddexpr:
case CMD_lgetexpr:
set_context_for_expression(xp, (char_u *)arg, ea.cmdidx);
set_context_for_expression(xp, (char *)arg, ea.cmdidx);
break;
case CMD_unlet:
@ -4591,7 +4591,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
// Skip over `=expr`, wildcards in it are not expanded.
if (p[0] == '`' && p[1] == '=') {
p += 2;
(void)skip_expr((char_u **)&p);
(void)skip_expr(&p);
if (*p == '`') {
++p;
}
@ -4806,7 +4806,7 @@ void separate_nextcmd(exarg_T *eap)
} else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) {
// Skip over `=expr` when wildcards are expanded.
p += 2;
(void)skip_expr((char_u **)&p);
(void)skip_expr(&p);
if (*p == NUL) { // stop at NUL after CTRL-V
break;
}
@ -6669,7 +6669,7 @@ static void ex_colorscheme(exarg_T *eap)
char *p = NULL;
emsg_off++;
p = (char *)eval_to_string((char_u *)expr, NULL, false);
p = eval_to_string(expr, NULL, false);
emsg_off--;
xfree(expr);
@ -8527,7 +8527,7 @@ static void ex_redir(exarg_T *eap)
append = FALSE;
}
if (var_redir_start(skipwhite((char_u *)arg), append) == OK) {
if (var_redir_start((char *)skipwhite((char_u *)arg), append) == OK) {
redir_vname = 1;
}
} else { // TODO(vim): redirect to a buffer
@ -9383,8 +9383,8 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
resultlen = (size_t)(s - result);
}
} else if (!skip_mod) {
valid |= modify_fname(src, tilde_file, usedlen, (char_u **)&result,
(char_u **)&resultbuf, &resultlen);
valid |= modify_fname((char *)src, tilde_file, usedlen, &result,
&resultbuf, &resultlen);
if (result == NULL) {
*errormsg = "";
return NULL;

View File

@ -801,7 +801,7 @@ void ex_eval(exarg_T *eap)
{
typval_T tv;
if (eval0(eap->arg, &tv, &eap->nextcmd, !eap->skip) == OK) {
if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, !eap->skip) == OK) {
tv_clear(&tv);
}
}
@ -822,7 +822,7 @@ void ex_if(exarg_T *eap)
skip = CHECK_SKIP;
bool error;
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
if (!skip && !error) {
if (result) {
@ -911,7 +911,7 @@ void ex_else(exarg_T *eap)
if (eap->cmdidx == CMD_elseif) {
bool error;
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
// When throwing error exceptions, we want to throw always the first
// of several errors in a row. This is what actually happens when
// a conditional error was detected above and there is another failure
@ -962,7 +962,7 @@ void ex_while(exarg_T *eap)
/*
* ":while bool-expr"
*/
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
} else {
void *fi;
@ -976,13 +976,13 @@ void ex_while(exarg_T *eap)
error = FALSE;
} else {
// Evaluate the argument and get the info in a structure.
fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip);
fi = eval_for_line((char *)eap->arg, &error, (char **)&eap->nextcmd, skip);
cstack->cs_forinfo[cstack->cs_idx] = fi;
}
// use the element at the start of the list and advance
if (!error && fi != NULL && !skip) {
result = next_for_item(fi, eap->arg);
result = next_for_item(fi, (char *)eap->arg);
} else {
result = FALSE;
}

View File

@ -335,10 +335,10 @@ static void get_healthcheck_cb(char_u *path, void *cookie)
pattern = ".*[\\/]\\([^\\/]*\\)\\.vim$";
}
res = do_string_sub(path, (char_u *)pattern, (char_u *)sub, NULL, (char_u *)"g");
res = (char_u *)do_string_sub((char *)path, pattern, sub, NULL, "g");
if (hcookie->is_lua && res != NULL) {
// Replace slashes with dots as represented by the healthcheck plugin.
char_u *ares = do_string_sub(res, (char_u *)"[\\/]", (char_u *)".", NULL, (char_u *)"g");
char_u *ares = (char_u *)do_string_sub((char *)res, "[\\/]", ".", NULL, "g");
xfree(res);
res = ares;
}
@ -4715,7 +4715,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
if (use_ccline && ccline.cmdfirstc == '=') {
// pass CMD_SIZE because there is no real command
set_context_for_expression(xp, str, CMD_SIZE);
set_context_for_expression(xp, (char *)str, CMD_SIZE);
} else if (use_ccline && ccline.input_fn) {
xp->xp_context = ccline.xp_context;
xp->xp_pattern = ccline.cmdbuff;

View File

@ -1774,7 +1774,9 @@ 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, "foldtext", OPT_LOCAL));
text =
(char_u *)eval_to_string_safe((char *)wp->w_p_fdt, NULL,
was_set_insecurely(wp, "foldtext", OPT_LOCAL));
emsg_silent--;
if (text == NULL || did_emsg) {
@ -2962,7 +2964,7 @@ static void foldlevelExpr(fline_T *flp)
// KeyTyped may be reset to 0 when calling a function which invokes
// do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
const bool save_keytyped = KeyTyped;
const int n = eval_foldexpr(flp->wp->w_p_fde, &c);
const int n = eval_foldexpr((char *)flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped;
switch (c) {

View File

@ -4275,7 +4275,7 @@ static char_u *eval_map_expr(mapblock_T *mp, int c)
api_clear_error(&err);
}
} else {
p = eval_to_string(expr, NULL, false);
p = (char_u *)eval_to_string((char *)expr, NULL, false);
xfree(expr);
}
textlock--;

View File

@ -429,8 +429,8 @@ static int cs_add_common(char *arg1, char *arg2, char *flags)
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
size_t len = STRLEN(fname);
fbuf = (char_u *)fname;
(void)modify_fname((char_u *)":p", false, &usedlen,
(char_u **)&fname, &fbuf, &len);
(void)modify_fname(":p", false, &usedlen,
&fname, (char **)&fbuf, &len);
if (fname == NULL) {
goto add_err;
}

View File

@ -548,7 +548,7 @@ int get_expr_indent(void)
// Need to make a copy, the 'indentexpr' option could be changed while
// evaluating it.
char_u *inde_copy = vim_strsave(curbuf->b_p_inde);
indent = (int)eval_to_number(inde_copy);
indent = (int)eval_to_number((char *)inde_copy);
xfree(inde_copy);
if (use_sandbox) {

View File

@ -3195,7 +3195,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen)
if (redir_reg) {
write_reg_contents(redir_reg, (char_u *)" ", 1, true);
} else if (redir_vname) {
var_redir_str((char_u *)" ", -1);
var_redir_str(" ", -1);
} else if (redir_fd != NULL) {
fputs(" ", redir_fd);
}
@ -3214,7 +3214,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen)
write_reg_contents(redir_reg, s, len, true);
}
if (redir_vname) {
var_redir_str((char_u *)s, maxlen);
var_redir_str((char *)s, maxlen);
}
// Write and adjust the current column.

View File

@ -774,7 +774,7 @@ char_u *get_expr_line(void)
}
nested++;
rv = eval_to_string(expr_copy, NULL, true);
rv = (char_u *)eval_to_string((char *)expr_copy, NULL, true);
nested--;
xfree(expr_copy);
return rv;
@ -4441,7 +4441,7 @@ int fex_format(linenr_T lnum, long count, int c)
if (use_sandbox) {
sandbox++;
}
r = (int)eval_to_number(fex);
r = (int)eval_to_number((char *)fex);
if (use_sandbox) {
sandbox--;
}
@ -6192,7 +6192,7 @@ static void op_function(const oparg_T *oap)
// Reset finish_op so that mode() returns the right value.
finish_op = false;
(void)call_func_retnr(p_opfunc, 1, argv);
(void)call_func_retnr((char *)p_opfunc, 1, argv);
virtual_op = save_virtual_op;
finish_op = save_finish_op;

View File

@ -587,7 +587,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo
if (src[0] == '`' && src[1] == '=') {
var = src;
src += 2;
(void)skip_expr(&src);
(void)skip_expr((char **)&src);
if (*src == '`') {
src++;
}
@ -1072,8 +1072,8 @@ size_t home_replace(const buf_T *const buf, const char_u *src, char_u *const dst
size_t usedlen = 0;
size_t flen = strlen(homedir_env_mod);
char_u *fbuf = NULL;
(void)modify_fname((char_u *)":p", false, &usedlen,
(char_u **)&homedir_env_mod, &fbuf, &flen);
(void)modify_fname(":p", false, &usedlen,
&homedir_env_mod, (char **)&fbuf, &flen);
flen = strlen(homedir_env_mod);
assert(homedir_env_mod != homedir_env);
if (vim_ispathsep(homedir_env_mod[flen - 1])) {

View File

@ -1383,7 +1383,7 @@ static int expand_backtick(garray_T *gap, char_u *pat, int flags)
char_u *cmd = vim_strnsave(pat + 1, STRLEN(pat) - 2);
if (*cmd == '=') { // `={expr}`: Expand expression
buffer = eval_to_string(cmd + 1, &p, true);
buffer = (char_u *)eval_to_string((char *)cmd + 1, (char **)&p, true);
} else {
buffer = get_cmd_output(cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0, NULL);
}
@ -1678,8 +1678,8 @@ void simplify_filename(char_u *filename)
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, "includeexpr", OPT_LOCAL));
char *res = eval_to_string_safe((char *)curbuf->b_p_inex, NULL,
was_set_insecurely(curwin, "includeexpr", OPT_LOCAL));
set_vim_var_string(VV_FNAME, NULL, 0);
return res;
}

View File

@ -3726,7 +3726,7 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height)
static void qf_set_title_var(qf_list_T *qfl)
{
if (qfl->qf_title != NULL) {
set_internal_string_var("w:quickfix_title", (char_u *)qfl->qf_title);
set_internal_string_var("w:quickfix_title", qfl->qf_title);
}
}
@ -3929,7 +3929,7 @@ bool qf_process_qftf_option(void)
if (*p_qftf == '{') {
// Lambda expression
tv = eval_expr(p_qftf);
tv = eval_expr((char *)p_qftf);
if (tv == NULL) {
return false;
}
@ -7035,7 +7035,7 @@ void ex_cexpr(exarg_T *eap)
// Evaluate the expression. When the result is a string or a list we can
// use it to fill the errorlist.
typval_T tv;
if (eval0(eap->arg, &tv, &eap->nextcmd, true) != FAIL) {
if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, true) != FAIL) {
if ((tv.v_type == VAR_STRING && tv.vval.v_string != NULL)
|| tv.v_type == VAR_LIST) {
incr_quickfix_busy();

View File

@ -1790,7 +1790,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
} else if (expr->v_type == VAR_PARTIAL) {
partial_T *partial = expr->vval.v_partial;
s = partial_name(partial);
s = (char_u *)partial_name(partial);
funcexe.partial = partial;
call_func(s, -1, &rettv, 1, argv, &funcexe);
}
@ -1810,7 +1810,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
}
tv_clear(&rettv);
} else {
eval_result = eval_to_string(source + 2, NULL, true);
eval_result = (char_u *)eval_to_string((char *)source + 2, NULL, true);
}
if (eval_result != NULL) {

View File

@ -826,7 +826,7 @@ static int load_pack_plugin(bool opt, char_u *fname)
// If runtime/filetype.vim wasn't loaded yet, the scripts will be
// found when it loads.
if (opt && eval_to_number(cmd) > 0) {
if (opt && eval_to_number((char *)cmd) > 0) {
do_cmdline_cmd("augroup filetypedetect");
vim_snprintf((char *)pat, len, ftpat, ffname);
source_all_matches(pat);

View File

@ -5392,7 +5392,7 @@ bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len)
curwin = wp;
STRCPY(buf, "b:keymap_name"); // must be writable
emsg_skip++;
s = p = eval_to_string(buf, NULL, false);
s = p = (char_u *)eval_to_string((char *)buf, NULL, false);
emsg_skip--;
curbuf = old_curbuf;
curwin = old_curwin;

View File

@ -3372,7 +3372,7 @@ static void spell_suggest_expr(suginfo_T *su, char_u *expr)
// The work is split up in a few parts to avoid having to export
// suginfo_T.
// First evaluate the expression and get the resulting list.
list_T *const list = eval_spell_expr(su->su_badword, expr);
list_T *const list = eval_spell_expr((char *)su->su_badword, (char *)expr);
if (list != NULL) {
// Loop over the items in the list.
TV_LIST_ITER(list, li, {

View File

@ -5674,14 +5674,14 @@ void ex_ownsyntax(exarg_T *eap)
// Move value of b:current_syntax to w:current_syntax.
new_value = get_var_value("b:current_syntax");
if (new_value != NULL) {
set_internal_string_var("w:current_syntax", new_value);
set_internal_string_var("w:current_syntax", (char *)new_value);
}
// Restore value of b:current_syntax.
if (old_value == NULL) {
do_unlet(S_LEN("b:current_syntax"), true);
} else {
set_internal_string_var("b:current_syntax", old_value);
set_internal_string_var("b:current_syntax", (char *)old_value);
xfree(old_value);
}
}

View File

@ -1182,7 +1182,7 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
flags & TAG_REGEXP ? "r": "");
save_pos = curwin->w_cursor;
result = call_vim_function(curbuf->b_p_tfu, 3, args, &rettv);
result = call_vim_function((char *)curbuf->b_p_tfu, 3, args, &rettv);
curwin->w_cursor = save_pos; // restore the cursor position
d->dv_refcount--;

View File

@ -178,7 +178,7 @@ static int assert_match_common(typval_T *argvars, assert_type_T atype)
if (pat == NULL || text == NULL) {
emsg(_(e_invarg));
} else if (pattern_match((char_u *)pat, (char_u *)text, false)
} else if (pattern_match((char *)pat, (char *)text, false)
!= (atype == ASSERT_MATCH)) {
garray_T ga;
prepare_assert_error(&ga);