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-03 11:06:27 +02:00
parent 3ec93ca92c
commit 5576d30e89
42 changed files with 555 additions and 562 deletions

View File

@ -1819,7 +1819,7 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
• lockmarks: (boolean) |:lockmarks|. • lockmarks: (boolean) |:lockmarks|.
• noswapfile: (boolean) |:noswapfile|. • noswapfile: (boolean) |:noswapfile|.
• tab: (integer) |:tab|. • tab: (integer) |:tab|.
• verbose: (integer) |:verbose|. • verbose: (integer) |:verbose|. -1 when omitted.
• vertical: (boolean) |:vertical|. • vertical: (boolean) |:vertical|.
• split: (string) Split modifier string, is an empty • split: (string) Split modifier string, is an empty
string when there's no split modifier. If there is a string when there's no split modifier. If there is a

View File

@ -474,7 +474,7 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
Object *command = &opts->command; Object *command = &opts->command;
if (command->type == kObjectTypeString) { if (command->type == kObjectTypeString) {
aucmd.type = CALLABLE_EX; aucmd.type = CALLABLE_EX;
aucmd.callable.cmd = (char_u *)string_to_cstr(command->data.string); aucmd.callable.cmd = string_to_cstr(command->data.string);
} else { } else {
api_set_error(err, api_set_error(err,
kErrorTypeValidation, kErrorTypeValidation,
@ -657,8 +657,6 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Error *err)
cleanup: cleanup:
api_free_array(event_array); api_free_array(event_array);
api_free_array(patterns); api_free_array(patterns);
return;
} }
/// Create or get an autocommand group |autocmd-groups|. /// Create or get an autocommand group |autocmd-groups|.

View File

@ -2210,7 +2210,7 @@ Array nvim_get_mark(String name, Dictionary opts, Error *err)
allocated = true; allocated = true;
// Marks comes from shada // Marks comes from shada
} else { } else {
filename = (char *)mark.fname; filename = mark.fname;
bufnr = 0; bufnr = 0;
} }

View File

@ -827,7 +827,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
bool done = false; bool done = false;
while (!done) { while (!done) {
done = uc_split_args_iter(ea.arg, length, &end, buf, &len); done = uc_split_args_iter((char_u *)ea.arg, length, &end, buf, &len);
if (len > 0) { if (len > 0) {
ADD(args, STRING_OBJ(cstrn_to_string(buf, len))); ADD(args, STRING_OBJ(cstrn_to_string(buf, len)));
} }

View File

@ -972,7 +972,7 @@ int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *
if (is_adding_cmd) { if (is_adding_cmd) {
AucmdExecutable exec = AUCMD_EXECUTABLE_INIT; AucmdExecutable exec = AUCMD_EXECUTABLE_INIT;
exec.type = CALLABLE_EX; exec.type = CALLABLE_EX;
exec.callable.cmd = cmd; exec.callable.cmd = (char *)cmd;
autocmd_register(0, event, pat, patlen, group, once, nested, NULL, exec); autocmd_register(0, event, pat, patlen, group, once, nested, NULL, exec);
} }
@ -1240,7 +1240,7 @@ void ex_doautoall(exarg_T *eap)
{ {
int retval = OK; int retval = OK;
aco_save_T aco; aco_save_T aco;
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
int call_do_modelines = check_nomodeline(&arg); int call_do_modelines = check_nomodeline(&arg);
bufref_T bufref; bufref_T bufref;
bool did_aucmd; bool did_aucmd;
@ -2142,7 +2142,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat)
// However, my expectation would be that could be expensive. // However, my expectation would be that could be expensive.
retval = vim_strsave((char_u *)""); retval = vim_strsave((char_u *)"");
} else { } else {
retval = vim_strsave(ac->exec.callable.cmd); retval = vim_strsave((char_u *)ac->exec.callable.cmd);
} }
// Remove one-shot ("once") autocmd in anticipation of its execution. // Remove one-shot ("once") autocmd in anticipation of its execution.
@ -2241,7 +2241,7 @@ char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd)
autocmd_include_groups = true; autocmd_include_groups = true;
} }
xp->xp_context = EXPAND_EVENTS; // expand event name xp->xp_context = EXPAND_EVENTS; // expand event name
xp->xp_pattern = arg; xp->xp_pattern = (char *)arg;
return NULL; return NULL;
} }
@ -2501,7 +2501,7 @@ char *aucmd_exec_to_string(AutoCmd *ac, AucmdExecutable acc)
{ {
switch (acc.type) { switch (acc.type) {
case CALLABLE_EX: case CALLABLE_EX:
return (char *)acc.callable.cmd; return acc.callable.cmd;
case CALLABLE_CB: case CALLABLE_CB:
return ac->desc; return ac->desc;
case CALLABLE_NONE: case CALLABLE_NONE:
@ -2534,7 +2534,7 @@ AucmdExecutable aucmd_exec_copy(AucmdExecutable src)
switch (src.type) { switch (src.type) {
case CALLABLE_EX: case CALLABLE_EX:
dest.type = CALLABLE_EX; dest.type = CALLABLE_EX;
dest.callable.cmd = vim_strsave(src.callable.cmd); dest.callable.cmd = xstrdup(src.callable.cmd);
return dest; return dest;
case CALLABLE_CB: case CALLABLE_CB:
dest.type = CALLABLE_CB; dest.type = CALLABLE_CB;

View File

@ -2622,7 +2622,7 @@ void buflist_list(exarg_T *eap)
garray_T buflist; garray_T buflist;
buf_T **buflist_data = NULL; buf_T **buflist_data = NULL;
if (vim_strchr(eap->arg, 't')) { if (vim_strchr((char_u *)eap->arg, 't')) {
ga_init(&buflist, sizeof(buf_T *), 50); ga_init(&buflist, sizeof(buf_T *), 50);
for (buf = firstbuf; buf != NULL; buf = buf->b_next) { for (buf = firstbuf; buf != NULL; buf = buf->b_next) {
ga_grow(&buflist, 1); ga_grow(&buflist, 1);
@ -2645,21 +2645,21 @@ void buflist_list(exarg_T *eap)
const bool job_running = buf->terminal && terminal_running(buf->terminal); const bool job_running = buf->terminal && terminal_running(buf->terminal);
// skip unspecified buffers // skip unspecified buffers
if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u')) if ((!buf->b_p_bl && !eap->forceit && !vim_strchr((char_u *)eap->arg, 'u'))
|| (vim_strchr(eap->arg, 'u') && buf->b_p_bl) || (vim_strchr((char_u *)eap->arg, 'u') && buf->b_p_bl)
|| (vim_strchr(eap->arg, '+') || (vim_strchr((char_u *)eap->arg, '+')
&& ((buf->b_flags & BF_READERR) || !bufIsChanged(buf))) && ((buf->b_flags & BF_READERR) || !bufIsChanged(buf)))
|| (vim_strchr(eap->arg, 'a') || (vim_strchr((char_u *)eap->arg, 'a')
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0)) && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0))
|| (vim_strchr(eap->arg, 'h') || (vim_strchr((char_u *)eap->arg, 'h')
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0)) && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0))
|| (vim_strchr(eap->arg, 'R') && (!is_terminal || !job_running)) || (vim_strchr((char_u *)eap->arg, 'R') && (!is_terminal || !job_running))
|| (vim_strchr(eap->arg, 'F') && (!is_terminal || job_running)) || (vim_strchr((char_u *)eap->arg, 'F') && (!is_terminal || job_running))
|| (vim_strchr(eap->arg, '-') && buf->b_p_ma) || (vim_strchr((char_u *)eap->arg, '-') && buf->b_p_ma)
|| (vim_strchr(eap->arg, '=') && !buf->b_p_ro) || (vim_strchr((char_u *)eap->arg, '=') && !buf->b_p_ro)
|| (vim_strchr(eap->arg, 'x') && !(buf->b_flags & BF_READERR)) || (vim_strchr((char_u *)eap->arg, 'x') && !(buf->b_flags & BF_READERR))
|| (vim_strchr(eap->arg, '%') && buf != curbuf) || (vim_strchr((char_u *)eap->arg, '%') && buf != curbuf)
|| (vim_strchr(eap->arg, '#') || (vim_strchr((char_u *)eap->arg, '#')
&& (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) { && (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) {
continue; continue;
} }
@ -2700,7 +2700,7 @@ void buflist_list(exarg_T *eap)
do { do {
IObuff[len++] = ' '; IObuff[len++] = ' ';
} while (--i > 0 && len < IOSIZE - 18); } while (--i > 0 && len < IOSIZE - 18);
if (vim_strchr(eap->arg, 't') && buf->b_last_used) { if (vim_strchr((char_u *)eap->arg, 't') && buf->b_last_used) {
undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used); undo_fmt_time(IObuff + len, (size_t)(IOSIZE - len), buf->b_last_used);
} else { } else {
vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64), vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), _("line %" PRId64),

View File

@ -94,11 +94,11 @@ Array mode_style_array(void)
/// @returns error message for an illegal option, NULL otherwise. /// @returns error message for an illegal option, NULL otherwise.
char *parse_shape_opt(int what) char *parse_shape_opt(int what)
{ {
char_u *colonp; char *colonp;
char_u *commap; char *commap;
char_u *slashp; char *slashp;
char_u *p = NULL; char *p = NULL;
char_u *endp; char *endp;
int idx = 0; // init for GCC int idx = 0; // init for GCC
int all_idx; int all_idx;
int len; int len;
@ -118,10 +118,10 @@ char *parse_shape_opt(int what)
} }
} }
// Repeat for all comma separated parts. // Repeat for all comma separated parts.
char_u *modep = p_guicursor; char *modep = (char *)p_guicursor;
while (modep != NULL && *modep != NUL) { while (modep != NULL && *modep != NUL) {
colonp = vim_strchr(modep, ':'); colonp = (char *)vim_strchr((char_u *)modep, ':');
commap = vim_strchr(modep, ','); commap = (char *)vim_strchr((char_u *)modep, ',');
if (colonp == NULL || (commap != NULL && commap < colonp)) { if (colonp == NULL || (commap != NULL && commap < colonp)) {
return N_("E545: Missing colon"); return N_("E545: Missing colon");
@ -169,7 +169,7 @@ char *parse_shape_opt(int what)
for (p = colonp + 1; *p && *p != ',';) { for (p = colonp + 1; *p && *p != ',';) {
{ {
// First handle the ones with a number argument. // First handle the ones with a number argument.
i = *p; i = (uint8_t)(*p);
len = 0; len = 0;
if (STRNICMP(p, "ver", 3) == 0) { if (STRNICMP(p, "ver", 3) == 0) {
len = 3; len = 3;
@ -187,7 +187,7 @@ char *parse_shape_opt(int what)
if (!ascii_isdigit(*p)) { if (!ascii_isdigit(*p)) {
return N_("E548: digit expected"); return N_("E548: digit expected");
} }
int n = getdigits_int(&p, false, 0); int n = getdigits_int((char_u **)&p, false, 0);
if (len == 3) { // "ver" or "hor" if (len == 3) { // "ver" or "hor"
if (n == 0) { if (n == 0) {
return N_("E549: Illegal percentage"); return N_("E549: Illegal percentage");
@ -215,7 +215,7 @@ char *parse_shape_opt(int what)
} }
p += 5; p += 5;
} else { // must be a highlight group name then } else { // must be a highlight group name then
endp = vim_strchr(p, '-'); endp = (char *)vim_strchr((char_u *)p, '-');
if (commap == NULL) { // last part if (commap == NULL) { // last part
if (endp == NULL) { if (endp == NULL) {
endp = p + STRLEN(p); // find end of part endp = p + STRLEN(p); // find end of part
@ -223,14 +223,14 @@ char *parse_shape_opt(int what)
} else if (endp > commap || endp == NULL) { } else if (endp > commap || endp == NULL) {
endp = commap; endp = commap;
} }
slashp = vim_strchr(p, '/'); slashp = (char *)vim_strchr((char_u *)p, '/');
if (slashp != NULL && slashp < endp) { if (slashp != NULL && slashp < endp) {
// "group/langmap_group" // "group/langmap_group"
i = syn_check_group((char *)p, (size_t)(slashp - p)); i = syn_check_group(p, (size_t)(slashp - p));
p = slashp + 1; p = slashp + 1;
} }
if (round == 2) { if (round == 2) {
shape_table[idx].id = syn_check_group((char *)p, (size_t)(endp - p)); shape_table[idx].id = syn_check_group(p, (size_t)(endp - p));
shape_table[idx].id_lm = shape_table[idx].id; shape_table[idx].id_lm = shape_table[idx].id;
if (slashp != NULL && slashp < endp) { if (slashp != NULL && slashp < endp) {
shape_table[idx].id = i; shape_table[idx].id = i;

View File

@ -366,7 +366,7 @@ void ex_debug(exarg_T *eap)
int debug_break_level_save = debug_break_level; int debug_break_level_save = debug_break_level;
debug_break_level = 9999; debug_break_level = 9999;
do_cmdline_cmd((char *)eap->arg); do_cmdline_cmd(eap->arg);
debug_break_level = debug_break_level_save; debug_break_level = debug_break_level_save;
} }
@ -563,7 +563,7 @@ void ex_breakadd(exarg_T *eap)
gap = &prof_ga; gap = &prof_ga;
} }
if (dbg_parsearg(eap->arg, gap) == OK) { if (dbg_parsearg((char_u *)eap->arg, gap) == OK) {
struct debuggy *bp = &DEBUGGY(gap, gap->ga_len); struct debuggy *bp = &DEBUGGY(gap, gap->ga_len);
bp->dbg_forceit = eap->forceit; bp->dbg_forceit = eap->forceit;
@ -618,7 +618,7 @@ void ex_breakdel(exarg_T *eap)
if (ascii_isdigit(*eap->arg)) { if (ascii_isdigit(*eap->arg)) {
// ":breakdel {nr}" // ":breakdel {nr}"
int nr = atoi((char *)eap->arg); int nr = atoi(eap->arg);
for (int i = 0; i < gap->ga_len; i++) { for (int i = 0; i < gap->ga_len; i++) {
if (DEBUGGY(gap, i).dbg_nr == nr) { if (DEBUGGY(gap, i).dbg_nr == nr) {
todel = i; todel = i;
@ -630,7 +630,7 @@ void ex_breakdel(exarg_T *eap)
del_all = true; del_all = true;
} else { } else {
// ":breakdel {func|file|expr} [lnum] {name}" // ":breakdel {func|file|expr} [lnum] {name}"
if (dbg_parsearg(eap->arg, gap) == FAIL) { if (dbg_parsearg((char_u *)eap->arg, gap) == FAIL) {
return; return;
} }
bp = &DEBUGGY(gap, gap->ga_len); bp = &DEBUGGY(gap, gap->ga_len);

View File

@ -1186,9 +1186,9 @@ void ex_diffpatch(exarg_T *eap)
#ifdef UNIX #ifdef UNIX
// Get the absolute path of the patchfile, changing directory below. // Get the absolute path of the patchfile, changing directory below.
fullname = FullName_save((char *)eap->arg, false); fullname = FullName_save(eap->arg, false);
esc_name = esc_name =
vim_strsave_shellescape((fullname != NULL ? (char_u *)fullname : eap->arg), true, true); vim_strsave_shellescape((char_u *)(fullname != NULL ? fullname : eap->arg), true, true);
#else #else
esc_name = vim_strsave_shellescape(eap->arg, true, true); esc_name = vim_strsave_shellescape(eap->arg, true, true);
#endif #endif
@ -1219,7 +1219,7 @@ void ex_diffpatch(exarg_T *eap)
// Use 'patchexpr' to generate the new file. // Use 'patchexpr' to generate the new file.
#ifdef UNIX #ifdef UNIX
eval_patch((char *)tmp_orig, eval_patch((char *)tmp_orig,
(fullname != NULL ? fullname : (char *)eap->arg), (fullname != NULL ? fullname : eap->arg),
(char *)tmp_new); (char *)tmp_new);
#else #else
eval_patch((char *)tmp_orig, (char *)eap->arg, (char *)tmp_new); eval_patch((char *)tmp_orig, (char *)eap->arg, (char *)tmp_new);
@ -1268,7 +1268,7 @@ void ex_diffpatch(exarg_T *eap)
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
// Pretend it was a ":split fname" command // Pretend it was a ":split fname" command
eap->cmdidx = CMD_split; eap->cmdidx = CMD_split;
eap->arg = tmp_new; eap->arg = (char *)tmp_new;
do_exedit(eap, old_curwin); do_exedit(eap, old_curwin);
// check that split worked and editing tmp_new // check that split worked and editing tmp_new
@ -1279,7 +1279,7 @@ void ex_diffpatch(exarg_T *eap)
if (newname != NULL) { if (newname != NULL) {
// do a ":file filename.new" on the patched buffer // do a ":file filename.new" on the patched buffer
eap->arg = newname; eap->arg = (char *)newname;
ex_file(eap); ex_file(eap);
// Do filetype detection with the new name. // Do filetype detection with the new name.
@ -2469,10 +2469,10 @@ void nv_diffgetput(bool put, size_t count)
return; return;
} }
if (count == 0) { if (count == 0) {
ea.arg = (char_u *)""; ea.arg = "";
} else { } else {
vim_snprintf(buf, sizeof(buf), "%zu", count); vim_snprintf(buf, sizeof(buf), "%zu", count);
ea.arg = (char_u *)buf; ea.arg = buf;
} }
if (put) { if (put) {
@ -2553,18 +2553,18 @@ void ex_diffgetput(exarg_T *eap)
} }
} else { } else {
// Buffer number or pattern given. Ignore trailing white space. // Buffer number or pattern given. Ignore trailing white space.
p = eap->arg + STRLEN(eap->arg); p = (char_u *)eap->arg + STRLEN(eap->arg);
while (p > eap->arg && ascii_iswhite(p[-1])) { while (p > (char_u *)eap->arg && ascii_iswhite(p[-1])) {
p--; p--;
} }
for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) {} for (i = 0; ascii_isdigit(eap->arg[i]) && (char_u *)eap->arg + i < p; i++) {}
if (eap->arg + i == p) { if ((char_u *)eap->arg + i == p) {
// digits only // digits only
i = (int)atol((char *)eap->arg); i = (int)atol(eap->arg);
} else { } else {
i = buflist_findpat(eap->arg, p, false, true, false); i = buflist_findpat((char_u *)eap->arg, p, false, true, false);
if (i < 0) { if (i < 0) {
// error message already given // error message already given

View File

@ -5278,7 +5278,7 @@ static int ins_complete(int c, bool enable_pum)
// "pattern not found" message. // "pattern not found" message.
compl_col = curs_col; compl_col = curs_col;
} else { } else {
compl_col = (int)(compl_xp.xp_pattern - compl_pattern); compl_col = (int)((char_u *)compl_xp.xp_pattern - compl_pattern);
} }
compl_length = curs_col - compl_col; compl_length = curs_col - compl_col;
} else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI } else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI

View File

@ -1296,7 +1296,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd)
// The amount of indentation trimmed is the same as the indentation of // The amount of indentation trimmed is the same as the indentation of
// the first line after the :let command line. To find the end marker // the first line after the :let command line. To find the end marker
// the indent of the :let command line is trimmed. // the indent of the :let command line is trimmed.
p = (char *)(*eap->cmdlinep); p = *eap->cmdlinep;
while (ascii_iswhite(*p)) { while (ascii_iswhite(*p)) {
p++; p++;
marker_indent_len++; marker_indent_len++;
@ -1389,7 +1389,7 @@ void ex_let(exarg_T *eap)
static void ex_let_const(exarg_T *eap, const bool is_const) static void ex_let_const(exarg_T *eap, const bool is_const)
{ {
char *arg = (char *)eap->arg; char *arg = eap->arg;
char *expr = NULL; char *expr = NULL;
typval_T rettv; typval_T rettv;
int i; int i;
@ -1425,7 +1425,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
list_func_vars(&first); list_func_vars(&first);
list_vim_vars(&first); list_vim_vars(&first);
} }
eap->nextcmd = check_nextcmd((char_u *)arg); eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
} else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') { } else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') {
// HERE document // HERE document
list_T *l = heredoc_get(eap, expr + 3); list_T *l = heredoc_get(eap, expr + 3);
@ -1434,7 +1434,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
if (!eap->skip) { if (!eap->skip) {
op[0] = '='; op[0] = '=';
op[1] = NUL; op[1] = NUL;
(void)ex_let_vars((char *)eap->arg, &rettv, false, semicolon, var_count, (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
is_const, (char *)op); is_const, (char *)op);
} }
tv_clear(&rettv); tv_clear(&rettv);
@ -1457,14 +1457,14 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
if (eap->skip) { if (eap->skip) {
++emsg_skip; ++emsg_skip;
} }
i = eval0(expr, &rettv, (char **)&eap->nextcmd, !eap->skip); i = eval0(expr, &rettv, &eap->nextcmd, !eap->skip);
if (eap->skip) { if (eap->skip) {
if (i != FAIL) { if (i != FAIL) {
tv_clear(&rettv); tv_clear(&rettv);
} }
emsg_skip--; emsg_skip--;
} else if (i != FAIL) { } else if (i != FAIL) {
(void)ex_let_vars((char *)eap->arg, &rettv, false, semicolon, var_count, (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
is_const, (char *)op); is_const, (char *)op);
tv_clear(&rettv); tv_clear(&rettv);
} }
@ -2715,7 +2715,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
if (strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#") == NULL) { if (strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#") == NULL) {
// ":let var1 var2 ...": find last space. // ":let var1 var2 ...": find last space.
for (p = arg + STRLEN(arg); p >= arg;) { for (p = arg + STRLEN(arg); p >= arg;) {
xp->xp_pattern = (char_u *)p; xp->xp_pattern = p;
MB_PTR_BACK(arg, p); MB_PTR_BACK(arg, p);
if (ascii_iswhite(*p)) { if (ascii_iswhite(*p)) {
break; break;
@ -2727,10 +2727,10 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
xp->xp_context = cmdidx == CMD_call ? EXPAND_FUNCTIONS xp->xp_context = cmdidx == CMD_call ? EXPAND_FUNCTIONS
: EXPAND_EXPRESSION; : EXPAND_EXPRESSION;
} }
while ((xp->xp_pattern = (char_u *)strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#")) != NULL) { while ((xp->xp_pattern = strpbrk(arg, "\"'+-*/%.=!?~|&$([<>,#")) != NULL) {
c = *xp->xp_pattern; c = (uint8_t)(*xp->xp_pattern);
if (c == '&') { if (c == '&') {
c = xp->xp_pattern[1]; c = (uint8_t)xp->xp_pattern[1];
if (c == '&') { if (c == '&') {
++xp->xp_pattern; ++xp->xp_pattern;
xp->xp_context = cmdidx != CMD_let || got_eq xp->xp_context = cmdidx != CMD_let || got_eq
@ -2753,12 +2753,12 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
break; break;
} else if ((c == '<' || c == '#') } else if ((c == '<' || c == '#')
&& xp->xp_context == EXPAND_FUNCTIONS && xp->xp_context == EXPAND_FUNCTIONS
&& vim_strchr(xp->xp_pattern, '(') == NULL) { && vim_strchr((char_u *)xp->xp_pattern, '(') == NULL) {
// Function name can start with "<SNR>" and contain '#'. // Function name can start with "<SNR>" and contain '#'.
break; break;
} else if (cmdidx != CMD_let || got_eq) { } else if (cmdidx != CMD_let || got_eq) {
if (c == '"') { // string if (c == '"') { // string
while ((c = *++xp->xp_pattern) != NUL && c != '"') { while ((c = (uint8_t)(*++xp->xp_pattern)) != NUL && c != '"') {
if (c == '\\' && xp->xp_pattern[1] != NUL) { if (c == '\\' && xp->xp_pattern[1] != NUL) {
xp->xp_pattern++; xp->xp_pattern++;
} }
@ -2766,7 +2766,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} else if (c == '\'') { // literal string } else if (c == '\'') { // literal string
// Trick: '' is like stopping and starting a literal string. // Trick: '' is like stopping and starting a literal string.
while ((c = *++xp->xp_pattern) != NUL && c != '\'') {} while ((c = (uint8_t)(*++xp->xp_pattern)) != NUL && c != '\'') {}
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} else if (c == '|') { } else if (c == '|') {
if (xp->xp_pattern[1] == '|') { if (xp->xp_pattern[1] == '|') {
@ -2783,7 +2783,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
// anyway. // anyway.
xp->xp_context = EXPAND_EXPRESSION; xp->xp_context = EXPAND_EXPRESSION;
} }
arg = (char *)xp->xp_pattern; arg = xp->xp_pattern;
if (*arg != NUL) { if (*arg != NUL) {
while ((c = (char_u)(*++arg)) != NUL && (c == ' ' || c == '\t')) {} while ((c = (char_u)(*++arg)) != NUL && (c == ' ' || c == '\t')) {}
} }
@ -2805,13 +2805,13 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
} }
} }
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = arg;
} }
/// ":unlet[!] var1 ... " command. /// ":unlet[!] var1 ... " command.
void ex_unlet(exarg_T *eap) void ex_unlet(exarg_T *eap)
{ {
ex_unletlock(eap, (char *)eap->arg, 0, do_unlet_var); ex_unletlock(eap, eap->arg, 0, do_unlet_var);
} }
// TODO(ZyX-I): move to eval/ex_cmds // TODO(ZyX-I): move to eval/ex_cmds
@ -2819,7 +2819,7 @@ void ex_unlet(exarg_T *eap)
/// ":lockvar" and ":unlockvar" commands /// ":lockvar" and ":unlockvar" commands
void ex_lockvar(exarg_T *eap) void ex_lockvar(exarg_T *eap)
{ {
char *arg = (char *)eap->arg; char *arg = eap->arg;
int deep = 2; int deep = 2;
if (eap->forceit) { if (eap->forceit) {
@ -2894,7 +2894,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca
arg = (char *)skipwhite((char_u *)name_end); arg = (char *)skipwhite((char_u *)name_end);
} while (!ends_excmd(*arg)); } while (!ends_excmd(*arg));
eap->nextcmd = check_nextcmd((char_u *)arg); eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
} }
// TODO(ZyX-I): move to eval/ex_cmds // TODO(ZyX-I): move to eval/ex_cmds
@ -9422,7 +9422,7 @@ int var_item_copy(const vimconv_T *const conv, typval_T *const from, typval_T *c
/// ":echon expr1 ..." print each argument plain. /// ":echon expr1 ..." print each argument plain.
void ex_echo(exarg_T *eap) void ex_echo(exarg_T *eap)
{ {
char *arg = (char *)eap->arg; char *arg = eap->arg;
typval_T rettv; typval_T rettv;
bool atstart = true; bool atstart = true;
bool need_clear = true; bool need_clear = true;
@ -9478,7 +9478,7 @@ void ex_echo(exarg_T *eap)
tv_clear(&rettv); tv_clear(&rettv);
arg = (char *)skipwhite((char_u *)arg); arg = (char *)skipwhite((char_u *)arg);
} }
eap->nextcmd = check_nextcmd((char_u *)arg); eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
if (eap->skip) { if (eap->skip) {
emsg_skip--; emsg_skip--;
@ -9496,7 +9496,7 @@ void ex_echo(exarg_T *eap)
/// ":echohl {name}". /// ":echohl {name}".
void ex_echohl(exarg_T *eap) void ex_echohl(exarg_T *eap)
{ {
echo_attr = syn_name2attr(eap->arg); echo_attr = syn_name2attr((char_u *)eap->arg);
} }
/// ":execute expr1 ..." execute the result of an expression. /// ":execute expr1 ..." execute the result of an expression.
@ -9506,7 +9506,7 @@ void ex_echohl(exarg_T *eap)
/// echo commands /// echo commands
void ex_execute(exarg_T *eap) void ex_execute(exarg_T *eap)
{ {
char *arg = (char *)eap->arg; char *arg = eap->arg;
typval_T rettv; typval_T rettv;
int ret = OK; int ret = OK;
garray_T ga; garray_T ga;
@ -9576,7 +9576,7 @@ void ex_execute(exarg_T *eap)
--emsg_skip; --emsg_skip;
} }
eap->nextcmd = check_nextcmd((char_u *)arg); eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
} }
/// Skip over the name of an option: "&option", "&g:option" or "&l:option". /// Skip over the name of an option: "&option", "&g:option" or "&l:option".

View File

@ -2194,7 +2194,7 @@ static void f_expandcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
exarg_T eap = { exarg_T eap = {
.cmd = (char *)cmdstr, .cmd = (char *)cmdstr,
.arg = cmdstr, .arg = (char *)cmdstr,
.usefilter = false, .usefilter = false,
.nextcmd = NULL, .nextcmd = NULL,
.cmdidx = CMD_USER, .cmdidx = CMD_USER,
@ -3246,7 +3246,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
ExpandInit(&xpc); ExpandInit(&xpc);
xpc.xp_pattern = (char_u *)pattern; xpc.xp_pattern = (char *)pattern;
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
xpc.xp_context = cmdcomplete_str_to_type(type); xpc.xp_context = cmdcomplete_str_to_type(type);
if (xpc.xp_context == EXPAND_NOTHING) { if (xpc.xp_context == EXPAND_NOTHING) {
@ -3255,7 +3255,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
if (xpc.xp_context == EXPAND_MENUS) { if (xpc.xp_context == EXPAND_MENUS) {
set_context_in_menu_cmd(&xpc, "menu", (char *)xpc.xp_pattern, false); set_context_in_menu_cmd(&xpc, "menu", xpc.xp_pattern, false);
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
} }
@ -3265,12 +3265,12 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
if (xpc.xp_context == EXPAND_SIGN) { if (xpc.xp_context == EXPAND_SIGN) {
set_context_in_sign_cmd(&xpc, xpc.xp_pattern); set_context_in_sign_cmd(&xpc, (char_u *)xpc.xp_pattern);
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
} }
theend: theend:
pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); pat = addstar((char_u *)xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP);
tv_list_alloc_ret(rettv, xpc.xp_numfiles); tv_list_alloc_ret(rettv, xpc.xp_numfiles);
@ -3528,7 +3528,7 @@ static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
tv_dict_add_nr(d, S_LEN("coladd"), wp->w_jumplist[i].fmark.mark.coladd); tv_dict_add_nr(d, S_LEN("coladd"), wp->w_jumplist[i].fmark.mark.coladd);
tv_dict_add_nr(d, S_LEN("bufnr"), wp->w_jumplist[i].fmark.fnum); tv_dict_add_nr(d, S_LEN("bufnr"), wp->w_jumplist[i].fmark.fnum);
if (wp->w_jumplist[i].fname != NULL) { if (wp->w_jumplist[i].fname != NULL) {
tv_dict_add_str(d, S_LEN("filename"), (char *)wp->w_jumplist[i].fname); tv_dict_add_str(d, S_LEN("filename"), wp->w_jumplist[i].fname);
} }
} }
} }
@ -10994,7 +10994,6 @@ static void f_tr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
error: error:
semsg(_(e_invarg2), fromstr); semsg(_(e_invarg2), fromstr);
ga_clear(&ga); ga_clear(&ga);
return;
} }
/// "trim({expr})" function /// "trim({expr})" function

View File

@ -1953,7 +1953,7 @@ void ex_function(exarg_T *eap)
} }
} }
} }
eap->nextcmd = check_nextcmd(eap->arg); eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
return; return;
} }
@ -1961,13 +1961,13 @@ void ex_function(exarg_T *eap)
* ":function /pat": list functions matching pattern. * ":function /pat": list functions matching pattern.
*/ */
if (*eap->arg == '/') { if (*eap->arg == '/') {
p = skip_regexp(eap->arg + 1, '/', TRUE, NULL); p = skip_regexp((char_u *)eap->arg + 1, '/', true, NULL);
if (!eap->skip) { if (!eap->skip) {
regmatch_T regmatch; regmatch_T regmatch;
c = *p; c = *p;
*p = NUL; *p = NUL;
regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC); regmatch.regprog = vim_regcomp((char_u *)eap->arg + 1, RE_MAGIC);
*p = c; *p = c;
if (regmatch.regprog != NULL) { if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic; regmatch.rm_ic = p_ic;
@ -1989,7 +1989,7 @@ void ex_function(exarg_T *eap)
if (*p == '/') { if (*p == '/') {
++p; ++p;
} }
eap->nextcmd = check_nextcmd(p); eap->nextcmd = (char *)check_nextcmd(p);
return; return;
} }
@ -2007,7 +2007,7 @@ void ex_function(exarg_T *eap)
// "fudi.fd_di" set, "fudi.fd_newkey" == NULL // "fudi.fd_di" set, "fudi.fd_newkey" == NULL
// s:func script-local function name // s:func script-local function name
// g:func global function name, same as "func" // g:func global function name, same as "func"
p = eap->arg; p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL); name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
paren = (vim_strchr(p, '(') != NULL); paren = (vim_strchr(p, '(') != NULL);
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) { if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
@ -2043,7 +2043,7 @@ void ex_function(exarg_T *eap)
emsg(_(e_trailing)); emsg(_(e_trailing));
goto ret_free; goto ret_free;
} }
eap->nextcmd = check_nextcmd(p); eap->nextcmd = (char *)check_nextcmd(p);
if (eap->nextcmd != NULL) { if (eap->nextcmd != NULL) {
*p = NUL; *p = NUL;
} }
@ -2289,10 +2289,10 @@ void ex_function(exarg_T *eap)
// Another command follows. If the line came from "eap" we // Another command follows. If the line came from "eap" we
// can simply point into it, otherwise we need to change // can simply point into it, otherwise we need to change
// "eap->cmdlinep". // "eap->cmdlinep".
eap->nextcmd = nextcmd; eap->nextcmd = (char *)nextcmd;
if (line_to_free != NULL) { if (line_to_free != NULL) {
xfree(*eap->cmdlinep); xfree(*eap->cmdlinep);
*eap->cmdlinep = line_to_free; *eap->cmdlinep = (char *)line_to_free;
line_to_free = NULL; line_to_free = NULL;
} }
} }
@ -2693,7 +2693,7 @@ void ex_delfunction(exarg_T *eap)
char_u *name; char_u *name;
funcdict_T fudi; funcdict_T fudi;
p = eap->arg; p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi, NULL); name = trans_function_name(&p, eap->skip, 0, &fudi, NULL);
xfree(fudi.fd_newkey); xfree(fudi.fd_newkey);
if (name == NULL) { if (name == NULL) {
@ -2707,7 +2707,7 @@ void ex_delfunction(exarg_T *eap)
emsg(_(e_trailing)); emsg(_(e_trailing));
return; return;
} }
eap->nextcmd = check_nextcmd(p); eap->nextcmd = (char *)check_nextcmd(p);
if (eap->nextcmd != NULL) { if (eap->nextcmd != NULL) {
*p = NUL; *p = NUL;
} }
@ -2858,7 +2858,7 @@ static int can_free_funccal(funccall_T *fc, int copyID)
/// ":return [expr]" /// ":return [expr]"
void ex_return(exarg_T *eap) void ex_return(exarg_T *eap)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
typval_T rettv; typval_T rettv;
int returning = FALSE; int returning = FALSE;
@ -2873,7 +2873,7 @@ void ex_return(exarg_T *eap)
eap->nextcmd = NULL; eap->nextcmd = NULL;
if ((*arg != NUL && *arg != '|' && *arg != '\n') if ((*arg != NUL && *arg != '|' && *arg != '\n')
&& eval0((char *)arg, &rettv, (char **)&eap->nextcmd, !eap->skip) != FAIL) { && eval0((char *)arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) {
if (!eap->skip) { if (!eap->skip) {
returning = do_return(eap, false, true, &rettv); returning = do_return(eap, false, true, &rettv);
} else { } else {
@ -2896,7 +2896,7 @@ void ex_return(exarg_T *eap)
if (returning) { if (returning) {
eap->nextcmd = NULL; eap->nextcmd = NULL;
} else if (eap->nextcmd == NULL) { // no argument } else if (eap->nextcmd == NULL) { // no argument
eap->nextcmd = check_nextcmd(arg); eap->nextcmd = (char *)check_nextcmd(arg);
} }
if (eap->skip) { if (eap->skip) {
@ -2909,7 +2909,7 @@ void ex_return(exarg_T *eap)
/// ":1,25call func(arg1, arg2)" function call. /// ":1,25call func(arg1, arg2)" function call.
void ex_call(exarg_T *eap) void ex_call(exarg_T *eap)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *startarg; char_u *startarg;
char_u *name; char_u *name;
char_u *tofree; char_u *tofree;
@ -2926,7 +2926,7 @@ void ex_call(exarg_T *eap)
// instead to skip to any following command, e.g. for: // instead to skip to any following command, e.g. for:
// :if 0 | call dict.foo().bar() | endif. // :if 0 | call dict.foo().bar() | endif.
emsg_skip++; emsg_skip++;
if (eval0((char *)eap->arg, &rettv, (char **)&eap->nextcmd, false) != FAIL) { if (eval0(eap->arg, &rettv, &eap->nextcmd, false) != FAIL) {
tv_clear(&rettv); tv_clear(&rettv);
} }
emsg_skip--; emsg_skip--;
@ -3025,7 +3025,7 @@ void ex_call(exarg_T *eap)
emsg(_(e_trailing)); emsg(_(e_trailing));
} }
} else { } else {
eap->nextcmd = check_nextcmd(arg); eap->nextcmd = (char *)check_nextcmd(arg);
} }
} }

View File

@ -245,7 +245,7 @@ void ex_align(exarg_T *eap)
} }
} }
width = atoi((char *)eap->arg); width = atoi(eap->arg);
save_curpos = curwin->w_cursor; save_curpos = curwin->w_cursor;
if (eap->cmdidx == CMD_left) { // width is used for new indent if (eap->cmdidx == CMD_left) { // width is used for new indent
if (width >= 0) { if (width >= 0) {
@ -484,7 +484,7 @@ void ex_sort(exarg_T *eap)
size_t format_found = 0; size_t format_found = 0;
bool change_occurred = false; // Buffer contents changed. bool change_occurred = false; // Buffer contents changed.
for (p = (char *)eap->arg; *p != NUL; p++) { for (p = eap->arg; *p != NUL; p++) {
if (ascii_iswhite(*p)) { if (ascii_iswhite(*p)) {
// Skip // Skip
} else if (*p == 'i') { } else if (*p == 'i') {
@ -514,7 +514,7 @@ void ex_sort(exarg_T *eap)
// comment start // comment start
break; break;
} else if (check_nextcmd((char_u *)p) != NULL) { } else if (check_nextcmd((char_u *)p) != NULL) {
eap->nextcmd = check_nextcmd((char_u *)p); eap->nextcmd = (char *)check_nextcmd((char_u *)p);
break; break;
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) { } else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
s = (char *)skip_regexp((char_u *)p + 1, *p, true, NULL); s = (char *)skip_regexp((char_u *)p + 1, *p, true, NULL);
@ -746,8 +746,8 @@ void ex_retab(exarg_T *eap)
save_list = curwin->w_p_list; save_list = curwin->w_p_list;
curwin->w_p_list = 0; // don't want list mode here curwin->w_p_list = 0; // don't want list mode here
new_ts_str = (char *)eap->arg; new_ts_str = eap->arg;
if (!tabstop_set(eap->arg, &new_vts_array)) { if (!tabstop_set((char_u *)eap->arg, &new_vts_array)) {
return; return;
} }
while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') { while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') {
@ -761,7 +761,7 @@ void ex_retab(exarg_T *eap)
new_vts_array = curbuf->b_p_vts_array; new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL; new_ts_str = NULL;
} else { } else {
new_ts_str = xstrnsave(new_ts_str, eap->arg - (char_u *)new_ts_str); new_ts_str = xstrnsave(new_ts_str, eap->arg - new_ts_str);
} }
for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) { for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) {
ptr = (char *)ml_get(lnum); ptr = (char *)ml_get(lnum);
@ -1129,7 +1129,7 @@ void free_prev_shellcmd(void)
void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out) void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
char *arg = (char *)eap->arg; // command char *arg = eap->arg; // command
linenr_T line1 = eap->line1; // start of range linenr_T line1 = eap->line1; // start of range
linenr_T line2 = eap->line2; // end of range linenr_T line2 = eap->line2; // end of range
char *newcmd = NULL; // the new command char *newcmd = NULL; // the new command
@ -1755,7 +1755,7 @@ void ex_file(exarg_T *eap)
} }
if (*eap->arg != NUL || eap->addr_count == 1) { if (*eap->arg != NUL || eap->addr_count == 1) {
if (rename_buffer((char *)eap->arg) == FAIL) { if (rename_buffer(eap->arg) == FAIL) {
return; return;
} }
redraw_tabline = true; redraw_tabline = true;
@ -1811,7 +1811,7 @@ int do_write(exarg_T *eap)
return FAIL; return FAIL;
} }
ffname = (char *)eap->arg; ffname = eap->arg;
if (*ffname == NUL) { if (*ffname == NUL) {
if (eap->cmdidx == CMD_saveas) { if (eap->cmdidx == CMD_saveas) {
emsg(_(e_argreq)); emsg(_(e_argreq));
@ -2307,7 +2307,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
if (eap != NULL) { if (eap != NULL) {
command = (char *)eap->do_ecmd_cmd; command = eap->do_ecmd_cmd;
} }
set_bufref(&old_curbuf, curbuf); set_bufref(&old_curbuf, curbuf);
@ -2961,15 +2961,15 @@ void ex_append(exarg_T *eap)
if (eap->nextcmd == NULL || *eap->nextcmd == NUL) { if (eap->nextcmd == NULL || *eap->nextcmd == NUL) {
break; break;
} }
p = (char *)vim_strchr(eap->nextcmd, NL); p = (char *)vim_strchr((char_u *)eap->nextcmd, NL);
if (p == NULL) { if (p == NULL) {
p = (char *)eap->nextcmd + STRLEN(eap->nextcmd); p = eap->nextcmd + STRLEN(eap->nextcmd);
} }
theline = (char *)vim_strnsave(eap->nextcmd, (char_u *)p - eap->nextcmd); theline = xstrnsave(eap->nextcmd, p - eap->nextcmd);
if (*p != NUL) { if (*p != NUL) {
p++; p++;
} }
eap->nextcmd = (char_u *)p; eap->nextcmd = p;
} else { } else {
// Set State to avoid the cursor shape to be set to INSERT mode // Set State to avoid the cursor shape to be set to INSERT mode
// when getline() returns. // when getline() returns.
@ -3105,7 +3105,7 @@ void ex_z(exarg_T *eap)
bigness = 1; bigness = 1;
} }
x = (char *)eap->arg; x = eap->arg;
kind = x; kind = x;
if (*kind == '-' || *kind == '+' || *kind == '=' if (*kind == '-' || *kind == '+' || *kind == '='
|| *kind == '^' || *kind == '.') { || *kind == '^' || *kind == '.') {
@ -3463,7 +3463,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
bool got_quit = false; bool got_quit = false;
bool got_match = false; bool got_match = false;
int which_pat; int which_pat;
char *cmd = (char *)eap->arg; char *cmd = eap->arg;
linenr_T first_line = 0; // first changed line linenr_T first_line = 0; // first changed line
linenr_T last_line= 0; // below last changed line AFTER the change linenr_T last_line= 0; // below last changed line AFTER the change
linenr_T old_line_count = curbuf->b_ml.ml_line_count; linenr_T old_line_count = curbuf->b_ml.ml_line_count;
@ -3519,7 +3519,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
which_pat = RE_LAST; // use last used regexp which_pat = RE_LAST; // use last used regexp
delimiter = (char_u)(*cmd++); // remember delimiter character delimiter = (char_u)(*cmd++); // remember delimiter character
pat = cmd; // remember start of search pat pat = cmd; // remember start of search pat
cmd = (char *)skip_regexp((char_u *)cmd, delimiter, p_magic, &eap->arg); cmd = (char *)skip_regexp((char_u *)cmd, delimiter, p_magic, (char_u **)&eap->arg);
if (cmd[0] == delimiter) { // end delimiter found if (cmd[0] == delimiter) { // end delimiter found
*cmd++ = NUL; // replace it with a NUL *cmd++ = NUL; // replace it with a NUL
has_second_delim = true; has_second_delim = true;
@ -3592,7 +3592,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
*/ */
cmd = (char *)skipwhite((char_u *)cmd); cmd = (char *)skipwhite((char_u *)cmd);
if (*cmd && *cmd != '"') { // if not end-of-line or comment if (*cmd && *cmd != '"') { // if not end-of-line or comment
eap->nextcmd = check_nextcmd((char_u *)cmd); eap->nextcmd = (char *)check_nextcmd((char_u *)cmd);
if (eap->nextcmd == NULL) { if (eap->nextcmd == NULL) {
emsg(_(e_trailing)); emsg(_(e_trailing));
return NULL; return NULL;
@ -4570,7 +4570,7 @@ void ex_global(exarg_T *eap)
} else { } else {
type = (uint8_t)(*eap->cmd); type = (uint8_t)(*eap->cmd);
} }
cmd = (char *)eap->arg; cmd = eap->arg;
which_pat = RE_LAST; // default: use last used regexp which_pat = RE_LAST; // default: use last used regexp
/* /*
@ -4600,7 +4600,7 @@ void ex_global(exarg_T *eap)
delim = *cmd; // get the delimiter delim = *cmd; // get the delimiter
cmd++; // skip delimiter if there is one cmd++; // skip delimiter if there is one
pat = cmd; // remember start of pattern pat = cmd; // remember start of pattern
cmd = (char *)skip_regexp((char_u *)cmd, delim, p_magic, &eap->arg); cmd = (char *)skip_regexp((char_u *)cmd, delim, p_magic, (char_u **)&eap->arg);
if (cmd[0] == delim) { // end delimiter found if (cmd[0] == delim) { // end delimiter found
*cmd++ = NUL; // replace it with a NUL *cmd++ = NUL; // replace it with a NUL
} }
@ -4776,15 +4776,15 @@ void ex_help(exarg_T *eap)
* A ":help" command ends at the first LF, or at a '|' that is * A ":help" command ends at the first LF, or at a '|' that is
* followed by some text. Set nextcmd to the following command. * followed by some text. Set nextcmd to the following command.
*/ */
for (arg = (char *)eap->arg; *arg; arg++) { for (arg = eap->arg; *arg; arg++) {
if (*arg == '\n' || *arg == '\r' if (*arg == '\n' || *arg == '\r'
|| (*arg == '|' && arg[1] != NUL && arg[1] != '|')) { || (*arg == '|' && arg[1] != NUL && arg[1] != '|')) {
*arg++ = NUL; *arg++ = NUL;
eap->nextcmd = (char_u *)arg; eap->nextcmd = arg;
break; break;
} }
} }
arg = (char *)eap->arg; arg = eap->arg;
if (eap->forceit && *arg == NUL && !curbuf->b_help) { if (eap->forceit && *arg == NUL && !curbuf->b_help) {
emsg(_("E478: Don't panic!")); emsg(_("E478: Don't panic!"));
@ -5835,7 +5835,7 @@ void ex_helptags(exarg_T *eap)
// Check for ":helptags ++t {dir}". // Check for ":helptags ++t {dir}".
if (STRNCMP(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) { if (STRNCMP(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) {
add_help_tags = true; add_help_tags = true;
eap->arg = skipwhite(eap->arg + 3); eap->arg = (char *)skipwhite((char_u *)eap->arg + 3);
} }
if (STRCMP(eap->arg, "ALL") == 0) { if (STRCMP(eap->arg, "ALL") == 0) {
@ -5843,7 +5843,7 @@ void ex_helptags(exarg_T *eap)
} else { } else {
ExpandInit(&xpc); ExpandInit(&xpc);
xpc.xp_context = EXPAND_DIRECTORIES; xpc.xp_context = EXPAND_DIRECTORIES;
dirname = (char *)ExpandOne(&xpc, eap->arg, NULL, dirname = (char *)ExpandOne(&xpc, (char_u *)eap->arg, NULL,
WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
if (dirname == NULL || !os_isdir((char_u *)dirname)) { if (dirname == NULL || !os_isdir((char_u *)dirname)) {
semsg(_("E150: Not a directory: %s"), eap->arg); semsg(_("E150: Not a directory: %s"), eap->arg);
@ -6060,7 +6060,7 @@ void ex_substitute(exarg_T *eap)
block_autocmds(); // Disable events during command preview. block_autocmds(); // Disable events during command preview.
char *save_eap = (char *)eap->arg; char *save_eap = eap->arg;
garray_T save_view; garray_T save_view;
win_size_save(&save_view); // Save current window sizes. win_size_save(&save_view); // Save current window sizes.
save_search_patterns(); save_search_patterns();
@ -6101,7 +6101,7 @@ void ex_substitute(exarg_T *eap)
curbuf->b_p_ul = save_b_p_ul; curbuf->b_p_ul = save_b_p_ul;
curwin->w_p_cul = save_w_p_cul; // Restore 'cursorline' curwin->w_p_cul = save_w_p_cul; // Restore 'cursorline'
curwin->w_p_cuc = save_w_p_cuc; // Restore 'cursorcolumn' curwin->w_p_cuc = save_w_p_cuc; // Restore 'cursorcolumn'
eap->arg = (char_u *)save_eap; eap->arg = save_eap;
restore_search_patterns(); restore_search_patterns();
win_size_restore(&save_view); win_size_restore(&save_view);
ga_clear(&save_view); ga_clear(&save_view);
@ -6204,7 +6204,7 @@ void ex_oldfiles(exarg_T *eap)
return; return;
} }
char *const s = (char *)expand_env_save((char_u *)p); char *const s = (char *)expand_env_save((char_u *)p);
eap->arg = (char_u *)s; eap->arg = s;
eap->cmdidx = CMD_edit; eap->cmdidx = CMD_edit;
cmdmod.browse = false; cmdmod.browse = false;
do_exedit(eap, NULL); do_exedit(eap, NULL);

View File

@ -100,8 +100,8 @@ void ex_profile(exarg_T *eap)
char_u *e; char_u *e;
int len; int len;
e = skiptowhite(eap->arg); e = skiptowhite((char_u *)eap->arg);
len = (int)(e - eap->arg); len = (int)(e - (char_u *)eap->arg);
e = skipwhite(e); e = skipwhite(e);
if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) { if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) {
@ -218,7 +218,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
// Default: expand subcommands. // Default: expand subcommands.
xp->xp_context = EXPAND_PROFILE; xp->xp_context = EXPAND_PROFILE;
pexpand_what = PEXP_SUBCMD; pexpand_what = PEXP_SUBCMD;
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char *)arg;
char_u *const end_subcmd = skiptowhite((const char_u *)arg); char_u *const end_subcmd = skiptowhite((const char_u *)arg);
if (*end_subcmd == NUL) { if (*end_subcmd == NUL) {
@ -227,7 +227,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
if ((const char *)end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) { if ((const char *)end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) {
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;
xp->xp_pattern = skipwhite((const char_u *)end_subcmd); xp->xp_pattern = (char *)skipwhite((const char_u *)end_subcmd);
return; return;
} }
@ -1191,7 +1191,7 @@ void ex_next(exarg_T *eap)
| (eap->forceit ? CCGD_FORCEIT : 0) | (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD)) { | CCGD_EXCMD)) {
if (*eap->arg != NUL) { // redefine file list if (*eap->arg != NUL) { // redefine file list
if (do_arglist(eap->arg, AL_SET, 0, true) == FAIL) { if (do_arglist((char_u *)eap->arg, AL_SET, 0, true) == FAIL) {
return; return;
} }
i = 0; i = 0;
@ -1209,7 +1209,7 @@ void ex_argedit(exarg_T *eap)
// Whether curbuf will be reused, curbuf->b_ffname will be set. // Whether curbuf will be reused, curbuf->b_ffname will be set.
bool curbuf_is_reusable = curbuf_reusable(); bool curbuf_is_reusable = curbuf_reusable();
if (do_arglist(eap->arg, AL_ADD, i, true) == FAIL) { if (do_arglist((char_u *)eap->arg, AL_ADD, i, true) == FAIL) {
return; return;
} }
maketitle(); maketitle();
@ -1228,7 +1228,7 @@ void ex_argedit(exarg_T *eap)
/// ":argadd" /// ":argadd"
void ex_argadd(exarg_T *eap) void ex_argadd(exarg_T *eap)
{ {
do_arglist(eap->arg, AL_ADD, do_arglist((char_u *)eap->arg, AL_ADD,
eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1, eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1,
false); false);
maketitle(); maketitle();
@ -1277,7 +1277,7 @@ void ex_argdelete(exarg_T *eap)
} }
} }
} else { } else {
do_arglist(eap->arg, AL_DEL, 0, false); do_arglist((char_u *)eap->arg, AL_DEL, 0, false);
} }
maketitle(); maketitle();
} }
@ -1427,7 +1427,7 @@ void ex_listdo(exarg_T *eap)
i++; i++;
// execute the command // execute the command
if (execute) { if (execute) {
do_cmdline((char *)eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT); do_cmdline(eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT);
} }
if (eap->cmdidx == CMD_bufdo) { if (eap->cmdidx == CMD_bufdo) {
@ -1657,7 +1657,7 @@ void ex_options(exarg_T *eap)
/// ":source [{fname}]" /// ":source [{fname}]"
void ex_source(exarg_T *eap) void ex_source(exarg_T *eap)
{ {
cmd_source(eap->arg, eap); cmd_source((char_u *)eap->arg, eap);
} }
static void cmd_source(char_u *fname, exarg_T *eap) static void cmd_source(char_u *fname, exarg_T *eap)
@ -2207,7 +2207,7 @@ void ex_scriptnames(exarg_T *eap)
if (eap->line2 < 1 || eap->line2 > script_items.ga_len) { if (eap->line2 < 1 || eap->line2 > script_items.ga_len) {
emsg(_(e_invarg)); emsg(_(e_invarg));
} else { } else {
eap->arg = SCRIPT_ITEM(eap->line2).sn_name; eap->arg = (char *)SCRIPT_ITEM(eap->line2).sn_name;
do_exedit(eap, NULL); do_exedit(eap, NULL);
} }
return; return;
@ -2575,16 +2575,16 @@ void ex_scriptencoding(exarg_T *eap)
} }
if (*eap->arg != NUL) { if (*eap->arg != NUL) {
name = enc_canonize(eap->arg); name = enc_canonize((char_u *)eap->arg);
} else { } else {
name = eap->arg; name = (char_u *)eap->arg;
} }
// Setup for conversion from the specified encoding to 'encoding'. // Setup for conversion from the specified encoding to 'encoding'.
sp = (struct source_cookie *)getline_cookie(eap->getline, eap->cookie); sp = (struct source_cookie *)getline_cookie(eap->getline, eap->cookie);
convert_setup(&sp->conv, name, p_enc); convert_setup(&sp->conv, name, p_enc);
if (name != eap->arg) { if (name != (char_u *)eap->arg) {
xfree(name); xfree(name);
} }
} }
@ -2786,26 +2786,26 @@ void ex_language(exarg_T *eap)
# define VIM_LC_MESSAGES 6789 # define VIM_LC_MESSAGES 6789
# endif # endif
name = eap->arg; name = (char_u *)eap->arg;
// Check for "messages {name}", "ctype {name}" or "time {name}" argument. // Check for "messages {name}", "ctype {name}" or "time {name}" argument.
// Allow abbreviation, but require at least 3 characters to avoid // Allow abbreviation, but require at least 3 characters to avoid
// confusion with a two letter language name "me" or "ct". // confusion with a two letter language name "me" or "ct".
p = skiptowhite(eap->arg); p = skiptowhite((char_u *)eap->arg);
if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) { if ((*p == NUL || ascii_iswhite(*p)) && p - (char_u *)eap->arg >= 3) {
if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) { if (STRNICMP(eap->arg, "messages", p - (char_u *)eap->arg) == 0) {
what = VIM_LC_MESSAGES; what = VIM_LC_MESSAGES;
name = skipwhite(p); name = skipwhite(p);
whatstr = "messages "; whatstr = "messages ";
} else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0) { } else if (STRNICMP(eap->arg, "ctype", p - (char_u *)eap->arg) == 0) {
what = LC_CTYPE; what = LC_CTYPE;
name = skipwhite(p); name = skipwhite(p);
whatstr = "ctype "; whatstr = "ctype ";
} else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0) { } else if (STRNICMP(eap->arg, "time", p - (char_u *)eap->arg) == 0) {
what = LC_TIME; what = LC_TIME;
name = skipwhite(p); name = skipwhite(p);
whatstr = "time "; whatstr = "time ";
} else if (STRNICMP(eap->arg, "collate", p - eap->arg) == 0) { } else if (STRNICMP(eap->arg, "collate", p - (char_u *)eap->arg) == 0) {
what = LC_COLLATE; what = LC_COLLATE;
name = skipwhite(p); name = skipwhite(p);
whatstr = "collate "; whatstr = "collate ";
@ -2999,7 +2999,7 @@ static void script_host_execute_file(char *name, exarg_T *eap)
{ {
if (!eap->skip) { if (!eap->skip) {
uint8_t buffer[MAXPATHL]; uint8_t buffer[MAXPATHL];
vim_FullName((char *)eap->arg, (char *)buffer, sizeof(buffer), false); vim_FullName(eap->arg, (char *)buffer, sizeof(buffer), false);
list_T *args = tv_list_alloc(3); list_T *args = tv_list_alloc(3);
// filename // filename
@ -3036,7 +3036,7 @@ void ex_drop(exarg_T *eap)
// and mostly only one file is dropped. // and mostly only one file is dropped.
// This also ignores wildcards, since it is very unlikely the user is // This also ignores wildcards, since it is very unlikely the user is
// editing a file name with a wildcard character. // editing a file name with a wildcard character.
do_arglist(eap->arg, AL_SET, 0, false); do_arglist((char_u *)eap->arg, AL_SET, 0, false);
// Expanding wildcards may result in an empty argument list. E.g. when // Expanding wildcards may result in an empty argument list. E.g. when
// editing "foo.pyc" and ".pyc" is in 'wildignore'. Assume that we // editing "foo.pyc" and ".pyc" is in 'wildignore'. Assume that we

View File

@ -114,7 +114,7 @@ typedef struct aucmd_executable_t AucmdExecutable;
struct aucmd_executable_t { struct aucmd_executable_t {
AucmdExecutableType type; AucmdExecutableType type;
union { union {
char_u *cmd; char *cmd;
Callback cb; Callback cb;
} callable; } callable;
}; };
@ -174,10 +174,10 @@ enum {
/// Arguments used for Ex commands. /// Arguments used for Ex commands.
struct exarg { struct exarg {
char_u *arg; ///< argument of the command char *arg; ///< argument of the command
char_u *nextcmd; ///< next command (NULL if none) char *nextcmd; ///< next command (NULL if none)
char *cmd; ///< the name of the command (except for :make) char *cmd; ///< the name of the command (except for :make)
char_u **cmdlinep; ///< pointer to pointer of allocated cmdline char **cmdlinep; ///< pointer to pointer of allocated cmdline
cmdidx_T cmdidx; ///< the index for the command cmdidx_T cmdidx; ///< the index for the command
uint32_t argt; ///< flags for the command uint32_t argt; ///< flags for the command
int skip; ///< don't execute the command, only parse it int skip; ///< don't execute the command, only parse it
@ -187,7 +187,7 @@ struct exarg {
linenr_T line2; ///< the second line number or count linenr_T line2; ///< the second line number or count
cmd_addr_T addr_type; ///< type of the count/range cmd_addr_T addr_type; ///< type of the count/range
int flags; ///< extra flags after count: EXFLAG_ int flags; ///< extra flags after count: EXFLAG_
char_u *do_ecmd_cmd; ///< +command arg to be used in edited file char *do_ecmd_cmd; ///< +command arg to be used in edited file
linenr_T do_ecmd_lnum; ///< the line number in an edited file linenr_T do_ecmd_lnum; ///< the line number in an edited file
int append; ///< TRUE with ":w >>file" command int append; ///< TRUE with ":w >>file" command
int usefilter; ///< TRUE with ":w !command" and ":r!command" int usefilter; ///< TRUE with ":w !command" and ":r!command"
@ -201,7 +201,7 @@ struct exarg {
int useridx; ///< user command index int useridx; ///< user command index
char *errmsg; ///< returned error message char *errmsg; ///< returned error message
LineGetter getline; ///< Function used to get the next line LineGetter getline; ///< Function used to get the next line
void *cookie; ///< argument for getline() void *cookie; ///< argument for getline()
cstack_T *cstack; ///< condition stack for ":if" etc. cstack_T *cstack; ///< condition stack for ":if" etc.
long verbose_save; ///< saved value of p_verbose long verbose_save; ///< saved value of p_verbose
int save_msg_silent; ///< saved value of msg_silent int save_msg_silent; ///< saved value of msg_silent
@ -219,10 +219,10 @@ struct exarg {
// used for completion on the command line // used for completion on the command line
struct expand { struct expand {
char_u *xp_pattern; // start of item to expand char *xp_pattern; // start of item to expand
int xp_context; // type of expansion int xp_context; // type of expansion
size_t xp_pattern_len; // bytes in xp_pattern before cursor size_t xp_pattern_len; // bytes in xp_pattern before cursor
char_u *xp_arg; // completion function char *xp_arg; // completion function
LuaRef xp_luaref; // Ref to Lua completion function LuaRef xp_luaref; // Ref to Lua completion function
sctx_T xp_script_ctx; // SCTX for completion function sctx_T xp_script_ctx; // SCTX for completion function
int xp_backslash; // one of the XP_BS_ values int xp_backslash; // one of the XP_BS_ values
@ -232,8 +232,8 @@ struct expand {
#endif #endif
int xp_numfiles; // number of files found by file name completion int xp_numfiles; // number of files found by file name completion
int xp_col; // cursor position in line int xp_col; // cursor position in line
char_u **xp_files; // list of files char **xp_files; // list of files
char_u *xp_line; // text being completed char *xp_line; // text being completed
}; };
// values for xp_backslash // values for xp_backslash
@ -256,7 +256,7 @@ typedef struct {
bool keeppatterns; ///< true when ":keeppatterns" was used bool keeppatterns; ///< true when ":keeppatterns" was used
bool lockmarks; ///< true when ":lockmarks" was used bool lockmarks; ///< true when ":lockmarks" was used
bool noswapfile; ///< true when ":noswapfile" was used bool noswapfile; ///< true when ":noswapfile" was used
char_u *save_ei; ///< saved value of 'eventignore' char *save_ei; ///< saved value of 'eventignore'
regmatch_T filter_regmatch; ///< set by :filter /pat/ regmatch_T filter_regmatch; ///< set by :filter /pat/
bool filter_force; ///< set for :filter! bool filter_force; ///< set for :filter!
} cmdmod_T; } cmdmod_T;

File diff suppressed because it is too large Load Diff

View File

@ -148,7 +148,7 @@ int aborted_in_try(void)
/// When several messages appear in the same command, the first is usually the /// When several messages appear in the same command, the first is usually the
/// most specific one and used as the exception value. The "severe" flag can be /// most specific one and used as the exception value. The "severe" flag can be
/// set to true, if a later but severer message should be used instead. /// set to true, if a later but severer message should be used instead.
bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore) bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
struct msglist *elem; struct msglist *elem;
@ -197,7 +197,7 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
* interrupt exception is catchable by the innermost try conditional and * interrupt exception is catchable by the innermost try conditional and
* not replaced by an interrupt message error exception. * not replaced by an interrupt message error exception.
*/ */
if (mesg == (char_u *)_(e_interr)) { if (mesg == _(e_interr)) {
*ignore = true; *ignore = true;
return true; return true;
} }
@ -255,7 +255,7 @@ bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore)
} }
elem = xmalloc(sizeof(struct msglist)); elem = xmalloc(sizeof(struct msglist));
elem->msg = (char *)vim_strsave(mesg); elem->msg = xstrdup(mesg);
elem->next = NULL; elem->next = NULL;
elem->throw_msg = NULL; elem->throw_msg = NULL;
*plist = elem; *plist = elem;
@ -305,7 +305,7 @@ void free_global_msglist(void)
/// Throw the message specified in the call to cause_errthrow() above as an /// Throw the message specified in the call to cause_errthrow() above as an
/// error exception. If cstack is NULL, postpone the throw until do_cmdline() /// error exception. If cstack is NULL, postpone the throw until do_cmdline()
/// has returned (see do_one_cmd()). /// has returned (see do_one_cmd()).
void do_errthrow(cstack_T *cstack, char_u *cmdname) void do_errthrow(cstack_T *cstack, char *cmdname)
{ {
/* /*
* Ensure that all commands in nested function calls and sourced files * Ensure that all commands in nested function calls and sourced files
@ -382,7 +382,7 @@ int do_intthrow(cstack_T *cstack)
} }
/// Get an exception message that is to be stored in current_exception->value. /// Get an exception message that is to be stored in current_exception->value.
char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free) char *get_exception_string(void *value, except_type_T type, char *cmdname, int *should_free)
{ {
char *ret, *mesg; char *ret, *mesg;
char *p, *val; char *p, *val;
@ -446,7 +446,7 @@ char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int
/// ///
/// @return FAIL when out of memory or it was tried to throw an illegal user /// @return FAIL when out of memory or it was tried to throw an illegal user
/// exception. /// exception.
static int throw_exception(void *value, except_type_T type, char_u *cmdname) static int throw_exception(void *value, except_type_T type, char *cmdname)
{ {
except_T *excp; except_T *excp;
int should_free; int should_free;
@ -479,8 +479,7 @@ static int throw_exception(void *value, except_type_T type, char_u *cmdname)
} }
excp->type = type; excp->type = type;
excp->throw_name = vim_strsave(sourcing_name == NULL excp->throw_name = (char *)vim_strsave(sourcing_name == NULL ? (char_u *)"" : sourcing_name);
? (char_u *)"" : sourcing_name);
excp->throw_lnum = sourcing_lnum; excp->throw_lnum = sourcing_lnum;
if (p_verbose >= 13 || debug_break_level > 0) { if (p_verbose >= 13 || debug_break_level > 0) {
@ -525,7 +524,7 @@ fail:
/// caught and the catch clause has been ended normally. /// caught and the catch clause has been ended normally.
static void discard_exception(except_T *excp, bool was_finished) static void discard_exception(except_T *excp, bool was_finished)
{ {
char_u *saved_IObuff; char *saved_IObuff;
if (current_exception == excp) { if (current_exception == excp) {
current_exception = NULL; current_exception = NULL;
@ -538,7 +537,7 @@ static void discard_exception(except_T *excp, bool was_finished)
if (p_verbose >= 13 || debug_break_level > 0) { if (p_verbose >= 13 || debug_break_level > 0) {
int save_msg_silent = msg_silent; int save_msg_silent = msg_silent;
saved_IObuff = vim_strsave(IObuff); saved_IObuff = (char *)vim_strsave(IObuff);
if (debug_break_level > 0) { if (debug_break_level > 0) {
msg_silent = FALSE; // display messages msg_silent = FALSE; // display messages
} else { } else {
@ -801,7 +800,7 @@ void ex_eval(exarg_T *eap)
{ {
typval_T tv; typval_T tv;
if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, !eap->skip) == OK) { if (eval0(eap->arg, &tv, &eap->nextcmd, !eap->skip) == OK) {
tv_clear(&tv); tv_clear(&tv);
} }
} }
@ -822,7 +821,7 @@ void ex_if(exarg_T *eap)
skip = CHECK_SKIP; skip = CHECK_SKIP;
bool error; bool error;
result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
if (!skip && !error) { if (!skip && !error) {
if (result) { if (result) {
@ -911,7 +910,7 @@ void ex_else(exarg_T *eap)
if (eap->cmdidx == CMD_elseif) { if (eap->cmdidx == CMD_elseif) {
bool error; bool error;
result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
// When throwing error exceptions, we want to throw always the first // When throwing error exceptions, we want to throw always the first
// of several errors in a row. This is what actually happens when // of several errors in a row. This is what actually happens when
// a conditional error was detected above and there is another failure // a conditional error was detected above and there is another failure
@ -962,7 +961,7 @@ void ex_while(exarg_T *eap)
/* /*
* ":while bool-expr" * ":while bool-expr"
*/ */
result = eval_to_bool((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
} else { } else {
void *fi; void *fi;
@ -976,13 +975,13 @@ void ex_while(exarg_T *eap)
error = FALSE; error = FALSE;
} else { } else {
// Evaluate the argument and get the info in a structure. // Evaluate the argument and get the info in a structure.
fi = eval_for_line((char *)eap->arg, &error, (char **)&eap->nextcmd, skip); fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip);
cstack->cs_forinfo[cstack->cs_idx] = fi; cstack->cs_forinfo[cstack->cs_idx] = fi;
} }
// use the element at the start of the list and advance // use the element at the start of the list and advance
if (!error && fi != NULL && !skip) { if (!error && fi != NULL && !skip) {
result = next_for_item(fi, (char *)eap->arg); result = next_for_item(fi, eap->arg);
} else { } else {
result = FALSE; result = FALSE;
} }
@ -1283,13 +1282,13 @@ void ex_catch(exarg_T *eap)
bool give_up = false; bool give_up = false;
bool skip = false; bool skip = false;
bool caught = false; bool caught = false;
char_u *end; char *end;
char_u save_char = 0; char save_char = 0;
char_u *save_cpo; char *save_cpo;
regmatch_T regmatch; regmatch_T regmatch;
int prev_got_int; int prev_got_int;
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
char_u *pat; char *pat;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E603: :catch without :try"); eap->errmsg = N_("E603: :catch without :try");
@ -1318,12 +1317,12 @@ void ex_catch(exarg_T *eap)
} }
if (ends_excmd(*eap->arg)) { // no argument, catch all errors if (ends_excmd(*eap->arg)) { // no argument, catch all errors
pat = (char_u *)".*"; pat = ".*";
end = NULL; end = NULL;
eap->nextcmd = find_nextcmd(eap->arg); eap->nextcmd = (char *)find_nextcmd((char_u *)eap->arg);
} else { } else {
pat = eap->arg + 1; pat = eap->arg + 1;
end = skip_regexp(pat, *eap->arg, TRUE, NULL); end = (char *)skip_regexp((char_u *)pat, *eap->arg, true, NULL);
} }
if (!give_up) { if (!give_up) {
@ -1343,7 +1342,7 @@ void ex_catch(exarg_T *eap)
*/ */
if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
&& !(cstack->cs_flags[idx] & CSF_CAUGHT)) { && !(cstack->cs_flags[idx] & CSF_CAUGHT)) {
if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) { if (end != NULL && *end != NUL && !ends_excmd(*skipwhite((char_u *)end + 1))) {
emsg(_(e_trailing)); emsg(_(e_trailing));
return; return;
} }
@ -1362,18 +1361,18 @@ void ex_catch(exarg_T *eap)
save_char = *end; save_char = *end;
*end = NUL; *end = NUL;
} }
save_cpo = p_cpo; save_cpo = (char *)p_cpo;
p_cpo = (char_u *)""; p_cpo = (char_u *)"";
// Disable error messages, it will make current exception // Disable error messages, it will make current exception
// invalid // invalid
emsg_off++; emsg_off++;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING);
emsg_off--; emsg_off--;
regmatch.rm_ic = false; regmatch.rm_ic = false;
if (end != NULL) { if (end != NULL) {
*end = save_char; *end = save_char;
} }
p_cpo = save_cpo; p_cpo = (char_u *)save_cpo;
if (regmatch.regprog == NULL) { if (regmatch.regprog == NULL) {
semsg(_(e_invarg2), pat); semsg(_(e_invarg2), pat);
} else { } else {
@ -1426,7 +1425,7 @@ void ex_catch(exarg_T *eap)
} }
if (end != NULL) { if (end != NULL) {
eap->nextcmd = find_nextcmd(end); eap->nextcmd = (char *)find_nextcmd((char_u *)end);
} }
} }
@ -2036,7 +2035,7 @@ void ex_endfunction(exarg_T *eap)
} }
/// @return TRUE if the string "p" looks like a ":while" or ":for" command. /// @return TRUE if the string "p" looks like a ":while" or ":for" command.
int has_loop_cmd(char_u *p) int has_loop_cmd(char *p)
{ {
int len; int len;
@ -2045,7 +2044,7 @@ int has_loop_cmd(char_u *p)
while (*p == ' ' || *p == '\t' || *p == ':') { while (*p == ' ' || *p == '\t' || *p == ':') {
++p; ++p;
} }
len = modifier_len((char *)p); len = modifier_len(p);
if (len == 0) { if (len == 0) {
break; break;
} }

View File

@ -62,7 +62,7 @@ struct vim_exception {
except_type_T type; // exception type except_type_T type; // exception type
char *value; // exception value char *value; // exception value
struct msglist *messages; // message(s) causing error exception struct msglist *messages; // message(s) causing error exception
char_u *throw_name; // name of the throw point char *throw_name; // name of the throw point
linenr_T throw_lnum; // line number of the throw point linenr_T throw_lnum; // line number of the throw point
except_T *caught; // next exception on the caught stack except_T *caught; // next exception on the caught stack
}; };

View File

@ -833,8 +833,8 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
if (ccline.input_fn) { if (ccline.input_fn) {
s->xpc.xp_context = ccline.xp_context; s->xpc.xp_context = ccline.xp_context;
s->xpc.xp_pattern = ccline.cmdbuff; s->xpc.xp_pattern = (char *)ccline.cmdbuff;
s->xpc.xp_arg = ccline.xp_arg; s->xpc.xp_arg = (char *)ccline.xp_arg;
} }
// Avoid scrolling when called by a recursive do_cmdline(), e.g. when // Avoid scrolling when called by a recursive do_cmdline(), e.g. when
@ -1210,7 +1210,7 @@ static int command_line_execute(VimState *state, int key)
// cursor // cursor
int found = false; int found = false;
int j = (int)(s->xpc.xp_pattern - ccline.cmdbuff); int j = (int)((char_u *)s->xpc.xp_pattern - ccline.cmdbuff);
int i = 0; int i = 0;
while (--j > 0) { while (--j > 0) {
// check for start of menu name // check for start of menu name
@ -1265,7 +1265,7 @@ static int command_line_execute(VimState *state, int key)
int found = false; int found = false;
int j = ccline.cmdpos; int j = ccline.cmdpos;
int i = (int)(s->xpc.xp_pattern - ccline.cmdbuff); int i = (int)((char_u *)s->xpc.xp_pattern - ccline.cmdbuff);
while (--j > i) { while (--j > i) {
j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + j); j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + j);
if (vim_ispathsep(ccline.cmdbuff[j])) { if (vim_ispathsep(ccline.cmdbuff[j])) {
@ -1286,7 +1286,7 @@ static int command_line_execute(VimState *state, int key)
int found = false; int found = false;
int j = ccline.cmdpos - 1; int j = ccline.cmdpos - 1;
int i = (int)(s->xpc.xp_pattern - ccline.cmdbuff); int i = (int)((char_u *)s->xpc.xp_pattern - ccline.cmdbuff);
while (--j > i) { while (--j > i) {
j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + j); j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + j);
if (vim_ispathsep(ccline.cmdbuff[j]) if (vim_ispathsep(ccline.cmdbuff[j])
@ -2665,12 +2665,12 @@ static void realloc_cmdbuff(int len)
&& ccline.xpc->xp_pattern != NULL && ccline.xpc->xp_pattern != NULL
&& ccline.xpc->xp_context != EXPAND_NOTHING && ccline.xpc->xp_context != EXPAND_NOTHING
&& ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL) { && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL) {
int i = (int)(ccline.xpc->xp_pattern - p); int i = (int)((char_u *)ccline.xpc->xp_pattern - p);
// If xp_pattern points inside the old cmdbuff it needs to be adjusted // If xp_pattern points inside the old cmdbuff it needs to be adjusted
// to point into the newly allocated memory. // to point into the newly allocated memory.
if (i >= 0 && i <= ccline.cmdlen) { if (i >= 0 && i <= ccline.cmdlen) {
ccline.xpc->xp_pattern = ccline.cmdbuff + i; ccline.xpc->xp_pattern = (char *)ccline.cmdbuff + i;
} }
} }
} }
@ -3764,7 +3764,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
ui_flush(); ui_flush();
} }
i = (int)(xp->xp_pattern - ccline.cmdbuff); i = (int)((char_u *)xp->xp_pattern - ccline.cmdbuff);
assert(ccline.cmdpos >= i); assert(ccline.cmdpos >= i);
xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i; xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i;
@ -3773,7 +3773,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
p2 = ExpandOne(xp, NULL, NULL, 0, type); p2 = ExpandOne(xp, NULL, NULL, 0, type);
} else { } else {
// Translate string into pattern and expand it. // Translate string into pattern and expand it.
p1 = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); p1 = addstar((char_u *)xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
const int use_options = ( const int use_options = (
options options
| WILD_HOME_REPLACE | WILD_HOME_REPLACE
@ -3787,7 +3787,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
// xp->xp_pattern might have been modified by ExpandOne (for example, // xp->xp_pattern might have been modified by ExpandOne (for example,
// in lua completion), so recompute the pattern index and length // in lua completion), so recompute the pattern index and length
i = (int)(xp->xp_pattern - ccline.cmdbuff); i = (int)((char_u *)xp->xp_pattern - ccline.cmdbuff);
xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i; xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i;
// Longest match: make sure it is not shorter, happens with :help. // Longest match: make sure it is not shorter, happens with :help.
@ -3808,7 +3808,7 @@ static int nextwild(expand_T *xp, int type, int options, int escape)
difflen = (int)STRLEN(p2) - (int)(xp->xp_pattern_len); difflen = (int)STRLEN(p2) - (int)(xp->xp_pattern_len);
if (ccline.cmdlen + difflen + 4 > ccline.cmdbufflen) { if (ccline.cmdlen + difflen + 4 > ccline.cmdbufflen) {
realloc_cmdbuff(ccline.cmdlen + difflen + 4); realloc_cmdbuff(ccline.cmdlen + difflen + 4);
xp->xp_pattern = ccline.cmdbuff + i; xp->xp_pattern = (char *)ccline.cmdbuff + i;
} }
assert(ccline.cmdpos <= ccline.cmdlen); assert(ccline.cmdpos <= ccline.cmdlen);
memmove(&ccline.cmdbuff[ccline.cmdpos + difflen], memmove(&ccline.cmdbuff[ccline.cmdpos + difflen],
@ -3918,13 +3918,13 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
compl_selected = findex; compl_selected = findex;
cmdline_pum_display(false); cmdline_pum_display(false);
} else if (p_wmnu) { } else if (p_wmnu) {
win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, win_redr_status_matches(xp, xp->xp_numfiles, (char_u **)xp->xp_files,
findex, cmd_showtail); findex, cmd_showtail);
} }
if (findex == -1) { if (findex == -1) {
return vim_strsave(orig_save); return vim_strsave(orig_save);
} }
return vim_strsave(xp->xp_files[findex]); return vim_strsave((char_u *)xp->xp_files[findex]);
} else { } else {
return NULL; return NULL;
} }
@ -3934,12 +3934,12 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
ss = vim_strsave(orig_save ? orig_save : (char_u *)""); ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
} else if (mode == WILD_APPLY) { } else if (mode == WILD_APPLY) {
ss = vim_strsave(findex == -1 ? (orig_save ? orig_save : (char_u *)"") : ss = vim_strsave(findex == -1 ? (orig_save ? orig_save : (char_u *)"") :
xp->xp_files[findex]); (char_u *)xp->xp_files[findex]);
} }
// free old names // free old names
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) { if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) {
FreeWild(xp->xp_numfiles, xp->xp_files); FreeWild(xp->xp_numfiles, (char_u **)xp->xp_files);
xp->xp_numfiles = -1; xp->xp_numfiles = -1;
XFREE_CLEAR(orig_save); XFREE_CLEAR(orig_save);
} }
@ -3957,7 +3957,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
/* /*
* Do the expansion. * Do the expansion.
*/ */
if (ExpandFromContext(xp, str, &xp->xp_numfiles, &xp->xp_files, if (ExpandFromContext(xp, str, &xp->xp_numfiles, (char_u ***)&xp->xp_files,
options) == FAIL) { options) == FAIL) {
#ifdef FNAME_ILLEGAL #ifdef FNAME_ILLEGAL
/* Illegal file name has been silently skipped. But when there /* Illegal file name has been silently skipped. But when there
@ -3974,7 +3974,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
} }
} else { } else {
// Escape the matches for use on the command line. // Escape the matches for use on the command line.
ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options); ExpandEscape(xp, str, xp->xp_numfiles, (char_u **)xp->xp_files, options);
/* /*
* Check for matching suffixes in file names. * Check for matching suffixes in file names.
@ -3995,9 +3995,9 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
* expand_wildcards, only need to check the first two. * expand_wildcards, only need to check the first two.
*/ */
non_suf_match = 0; non_suf_match = 0;
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; i++) {
if (match_suffix(xp->xp_files[i])) { if (match_suffix((char_u *)xp->xp_files[i])) {
++non_suf_match; non_suf_match++;
} }
} }
} }
@ -4014,7 +4014,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
} }
} }
if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) { if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) {
ss = vim_strsave(xp->xp_files[0]); ss = vim_strsave((char_u *)xp->xp_files[0]);
} }
} }
} }
@ -4025,10 +4025,10 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
size_t len = 0; size_t len = 0;
for (size_t mb_len; xp->xp_files[0][len]; len += mb_len) { for (size_t mb_len; xp->xp_files[0][len]; len += mb_len) {
mb_len = (size_t)utfc_ptr2len(&xp->xp_files[0][len]); mb_len = (size_t)utfc_ptr2len((char_u *)&xp->xp_files[0][len]);
int c0 = utf_ptr2char(&xp->xp_files[0][len]); int c0 = utf_ptr2char((char_u *)&xp->xp_files[0][len]);
for (i = 1; i < xp->xp_numfiles; i++) { for (i = 1; i < xp->xp_numfiles; i++) {
int ci = utf_ptr2char(&xp->xp_files[i][len]); int ci = utf_ptr2char((char_u *)&xp->xp_files[i][len]);
if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_FILES
@ -4049,7 +4049,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
} }
} }
ss = (char_u *)xstrndup((char *)xp->xp_files[0], len); ss = (char_u *)xstrndup(xp->xp_files[0], len);
findex = -1; // next p_wc gets first one findex = -1; // next p_wc gets first one
} }
@ -4099,7 +4099,7 @@ void ExpandInit(expand_T *xp)
void ExpandCleanup(expand_T *xp) void ExpandCleanup(expand_T *xp)
{ {
if (xp->xp_numfiles >= 0) { if (xp->xp_numfiles >= 0) {
FreeWild(xp->xp_numfiles, xp->xp_files); FreeWild(xp->xp_numfiles, (char_u **)xp->xp_files);
xp->xp_numfiles = -1; xp->xp_numfiles = -1;
} }
} }
@ -4288,7 +4288,7 @@ static int showmatches(expand_T *xp, int wildmenu)
} }
} else { } else {
num_files = xp->xp_numfiles; num_files = xp->xp_numfiles;
files_found = xp->xp_files; files_found = (char_u **)xp->xp_files;
showtail = cmd_showtail; showtail = cmd_showtail;
} }
@ -4306,7 +4306,7 @@ static int showmatches(expand_T *xp, int wildmenu)
compl_match_array[i].pum_text = L_SHOWFILE(i); compl_match_array[i].pum_text = L_SHOWFILE(i);
} }
char_u *endpos = (showtail char_u *endpos = (showtail
? sm_gettail(xp->xp_pattern, true) : xp->xp_pattern); ? sm_gettail((char_u *)xp->xp_pattern, true) : (char_u *)xp->xp_pattern);
if (ui_has(kUICmdline)) { if (ui_has(kUICmdline)) {
compl_startcol = (int)(endpos - ccline.cmdbuff); compl_startcol = (int)(endpos - ccline.cmdbuff);
} else { } else {
@ -4490,14 +4490,14 @@ static int expand_showtail(expand_T *xp)
return FALSE; return FALSE;
} }
end = path_tail(xp->xp_pattern); end = path_tail((char_u *)xp->xp_pattern);
if (end == xp->xp_pattern) { // there is no path separator if (end == (char_u *)xp->xp_pattern) { // there is no path separator
return FALSE; return false;
} }
for (s = xp->xp_pattern; s < end; s++) { for (s = (char_u *)xp->xp_pattern; s < end; s++) {
/* Skip escaped wildcards. Only when the backslash is not a path // Skip escaped wildcards. Only when the backslash is not a path
* separator, on DOS the '*' "path\*\file" must not be skipped. */ // separator, on DOS the '*' "path\*\file" must not be skipped.
if (rem_backslash(s)) { if (rem_backslash(s)) {
++s; ++s;
} else if (vim_strchr((char_u *)"*?[", *s) != NULL) { } else if (vim_strchr((char_u *)"*?[", *s) != NULL) {
@ -4718,8 +4718,8 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
set_context_for_expression(xp, (char *)str, CMD_SIZE); set_context_for_expression(xp, (char *)str, CMD_SIZE);
} else if (use_ccline && ccline.input_fn) { } else if (use_ccline && ccline.input_fn) {
xp->xp_context = ccline.xp_context; xp->xp_context = ccline.xp_context;
xp->xp_pattern = ccline.cmdbuff; xp->xp_pattern = (char *)ccline.cmdbuff;
xp->xp_arg = ccline.xp_arg; xp->xp_arg = (char *)ccline.xp_arg;
} else { } else {
while (nextcomm != NULL) { while (nextcomm != NULL) {
nextcomm = set_one_cmd_context(xp, nextcomm); nextcomm = set_one_cmd_context(xp, nextcomm);
@ -4728,7 +4728,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
/* Store the string here so that call_user_expand_func() can get to them /* Store the string here so that call_user_expand_func() can get to them
* easily. */ * easily. */
xp->xp_line = str; xp->xp_line = (char *)str;
xp->xp_col = col; xp->xp_col = col;
str[col] = old_char; str[col] = old_char;
@ -4763,9 +4763,9 @@ int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char_u *
} }
// add star to file name, or convert to regexp if not exp. files. // add star to file name, or convert to regexp if not exp. files.
assert((str + col) - xp->xp_pattern >= 0); assert((str + col) - (char_u *)xp->xp_pattern >= 0);
xp->xp_pattern_len = (size_t)((str + col) - xp->xp_pattern); xp->xp_pattern_len = (size_t)((str + col) - (char_u *)xp->xp_pattern);
file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); file_str = addstar((char_u *)xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
if (p_wic) { if (p_wic) {
options += WILD_ICASE; options += WILD_ICASE;
@ -5312,18 +5312,18 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
ccline.cmdbuff[ccline.cmdlen] = 0; ccline.cmdbuff[ccline.cmdlen] = 0;
} }
pat = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len); pat = vim_strnsave((char_u *)xp->xp_pattern, xp->xp_pattern_len);
args[0].v_type = VAR_STRING; args[0].v_type = VAR_STRING;
args[1].v_type = VAR_STRING; args[1].v_type = VAR_STRING;
args[2].v_type = VAR_NUMBER; args[2].v_type = VAR_NUMBER;
args[3].v_type = VAR_UNKNOWN; args[3].v_type = VAR_UNKNOWN;
args[0].vval.v_string = pat; args[0].vval.v_string = pat;
args[1].vval.v_string = xp->xp_line; args[1].vval.v_string = (char_u *)xp->xp_line;
args[2].vval.v_number = xp->xp_col; args[2].vval.v_number = xp->xp_col;
current_sctx = xp->xp_script_ctx; current_sctx = xp->xp_script_ctx;
void *const ret = user_expand_func(xp->xp_arg, 3, args); void *const ret = user_expand_func((char_u *)xp->xp_arg, 3, args);
current_sctx = save_current_sctx; current_sctx = save_current_sctx;
if (ccline.cmdbuff != NULL) { if (ccline.cmdbuff != NULL) {
@ -6239,7 +6239,7 @@ void ex_history(exarg_T *eap)
int idx; int idx;
int i, j, k; int i, j, k;
char_u *end; char_u *end;
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
if (hislen == 0) { if (hislen == 0) {
msg(_("'history' option is zero")); msg(_("'history' option is zero"));

View File

@ -3938,7 +3938,7 @@ char_u *set_context_in_map_cmd(expand_T *xp, char_u *cmd, char_u *arg, bool forc
} }
break; break;
} }
xp->xp_pattern = arg; xp->xp_pattern = (char *)arg;
} }
return NULL; return NULL;

View File

@ -641,15 +641,15 @@ void ex_hardcopy(exarg_T *eap)
char *errormsg = NULL; char *errormsg = NULL;
// Expand things like "%.ps". // Expand things like "%.ps".
if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL) { if (expand_filename(eap, (char_u **)eap->cmdlinep, &errormsg) == FAIL) {
if (errormsg != NULL) { if (errormsg != NULL) {
emsg(errormsg); emsg(errormsg);
} }
return; return;
} }
settings.outfile = skipwhite(eap->arg + 1); settings.outfile = skipwhite((char_u *)eap->arg + 1);
} else if (*eap->arg != NUL) { } else if (*eap->arg != NUL) {
settings.arguments = eap->arg; settings.arguments = (char_u *)eap->arg;
} }
/* /*

View File

@ -1453,8 +1453,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
} }
} }
(void)syn_list_header(didh, (int)(vim_strsize((char_u *)ts) + (int)STRLEN(name) (void)syn_list_header(didh, vim_strsize((char_u *)ts) + (int)STRLEN(name) + 1, id, false);
+ 1), id, false);
didh = true; didh = true;
if (!got_int) { if (!got_int) {
if (*name != NUL) { if (*name != NUL) {
@ -1973,7 +1972,7 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
{ {
// Default: expand group names. // Default: expand group names.
xp->xp_context = EXPAND_HIGHLIGHT; xp->xp_context = EXPAND_HIGHLIGHT;
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char *)arg;
include_link = 2; include_link = 2;
include_default = 1; include_default = 1;
@ -1984,7 +1983,7 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
include_default = 0; include_default = 0;
if (strncmp("default", arg, (unsigned)(p - arg)) == 0) { if (strncmp("default", arg, (unsigned)(p - arg)) == 0) {
arg = (const char *)skipwhite((const char_u *)p); arg = (const char *)skipwhite((const char_u *)p);
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char *)arg;
p = (const char *)skiptowhite((const char_u *)arg); p = (const char *)skiptowhite((const char_u *)arg);
} }
if (*p != NUL) { // past group name if (*p != NUL) { // past group name
@ -1994,11 +1993,11 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
} }
if (strncmp("link", arg, (unsigned)(p - arg)) == 0 if (strncmp("link", arg, (unsigned)(p - arg)) == 0
|| strncmp("clear", arg, (unsigned)(p - arg)) == 0) { || strncmp("clear", arg, (unsigned)(p - arg)) == 0) {
xp->xp_pattern = skipwhite((const char_u *)p); xp->xp_pattern = (char *)skipwhite((const char_u *)p);
p = (const char *)skiptowhite(xp->xp_pattern); p = (const char *)skiptowhite((char_u *)xp->xp_pattern);
if (*p != NUL) { // Past first group name. if (*p != NUL) { // Past first group name.
xp->xp_pattern = skipwhite((const char_u *)p); xp->xp_pattern = (char *)skipwhite((const char_u *)p);
p = (const char *)skiptowhite(xp->xp_pattern); p = (const char *)skiptowhite((char_u *)xp->xp_pattern);
} }
} }
if (*p != NUL) { // Past group name(s). if (*p != NUL) { // Past group name(s).

View File

@ -145,7 +145,7 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
{ {
// Default: expand subcommands. // Default: expand subcommands.
xp->xp_context = EXPAND_CSCOPE; xp->xp_context = EXPAND_CSCOPE;
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char *)arg;
expand_what = ((cmdidx == CMD_scscope) expand_what = ((cmdidx == CMD_scscope)
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD); ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD);
@ -153,8 +153,8 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
if (*arg != NUL) { if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg); const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { // Past first word. if (*p != NUL) { // Past first word.
xp->xp_pattern = skipwhite((const char_u *)p); xp->xp_pattern = (char *)skipwhite((const char_u *)p);
if (*skiptowhite(xp->xp_pattern) != NUL) { if (*skiptowhite((char_u *)xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} else if (STRNICMP(arg, "add", p - arg) == 0) { } else if (STRNICMP(arg, "add", p - arg) == 0) {
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;
@ -224,8 +224,8 @@ void ex_cstag(exarg_T *eap)
switch (p_csto) { switch (p_csto) {
case 0: case 0:
if (cs_check_for_connections()) { if (cs_check_for_connections()) {
ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, false, ret = cs_find_common("g", eap->arg, eap->forceit, false,
false, *eap->cmdlinep); false, (char_u *)(*eap->cmdlinep));
if (ret == false) { if (ret == false) {
cs_free_tags(); cs_free_tags();
if (msg_col) { if (msg_col) {
@ -233,32 +233,32 @@ void ex_cstag(exarg_T *eap)
} }
if (cs_check_for_tags()) { if (cs_check_for_tags()) {
ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); ret = do_tag((char_u *)eap->arg, DT_JUMP, 0, eap->forceit, false);
} }
} }
} else if (cs_check_for_tags()) { } else if (cs_check_for_tags()) {
ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); ret = do_tag((char_u *)eap->arg, DT_JUMP, 0, eap->forceit, false);
} }
break; break;
case 1: case 1:
if (cs_check_for_tags()) { if (cs_check_for_tags()) {
ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); ret = do_tag((char_u *)eap->arg, DT_JUMP, 0, eap->forceit, false);
if (ret == FALSE) { if (ret == false) {
if (msg_col) { if (msg_col) {
msg_putchar('\n'); msg_putchar('\n');
} }
if (cs_check_for_connections()) { if (cs_check_for_connections()) {
ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, ret = cs_find_common("g", eap->arg, eap->forceit,
false, false, *eap->cmdlinep); false, false, (char_u *)(*eap->cmdlinep));
if (ret == false) { if (ret == false) {
cs_free_tags(); cs_free_tags();
} }
} }
} }
} else if (cs_check_for_connections()) { } else if (cs_check_for_connections()) {
ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, false, ret = cs_find_common("g", eap->arg, eap->forceit, false,
false, *eap->cmdlinep); false, (char_u *)(*eap->cmdlinep));
if (ret == false) { if (ret == false) {
cs_free_tags(); cs_free_tags();
} }
@ -899,7 +899,7 @@ static int cs_find(exarg_T *eap)
} }
pat = opt + strlen(opt) + 1; pat = opt + strlen(opt) + 1;
if (pat >= (char *)eap->arg + eap_arg_len) { if (pat >= eap->arg + eap_arg_len) {
cs_usage_msg(Find); cs_usage_msg(Find);
return false; return false;
} }
@ -915,7 +915,7 @@ static int cs_find(exarg_T *eap)
} }
return cs_find_common(opt, pat, eap->forceit, true, return cs_find_common(opt, pat, eap->forceit, true,
eap->cmdidx == CMD_lcscope, *eap->cmdlinep); eap->cmdidx == CMD_lcscope, (char_u *)(*eap->cmdlinep));
} }
@ -1210,7 +1210,7 @@ static cscmd_T *cs_lookup_cmd(exarg_T *eap)
// Store length of eap->arg before it gets modified by strtok(). // Store length of eap->arg before it gets modified by strtok().
eap_arg_len = (int)STRLEN(eap->arg); eap_arg_len = (int)STRLEN(eap->arg);
if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL) { if ((stok = strtok(eap->arg, (const char *)" ")) == NULL) { // NOLINT(runtime/threadsafe_fn)
return NULL; return NULL;
} }

View File

@ -1873,7 +1873,7 @@ void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap)
char *buf = xcalloc(length, sizeof(char)); char *buf = xcalloc(length, sizeof(char));
bool done = false; bool done = false;
while (!done) { while (!done) {
done = uc_split_args_iter(eap->arg, length, &end, buf, &len); done = uc_split_args_iter((char_u *)eap->arg, length, &end, buf, &len);
if (len > 0) { if (len > 0) {
lua_pushlstring(lstate, buf, len); lua_pushlstring(lstate, buf, len);
lua_rawseti(lstate, -2, i); lua_rawseti(lstate, -2, i);

View File

@ -513,7 +513,7 @@ int main(int argc, char **argv)
// Need to jump to the tag before executing the '-c command'. // Need to jump to the tag before executing the '-c command'.
// Makes "vim -c '/return' -t main" work. // Makes "vim -c '/return' -t main" work.
handle_tag(params.tagname); handle_tag((char_u *)params.tagname);
// Execute any "+", "-c" and "-S" arguments. // Execute any "+", "-c" and "-S" arguments.
if (params.n_commands > 0) { if (params.n_commands > 0) {
@ -1131,7 +1131,7 @@ static void command_line_scan(mparm_T *parmp)
} }
parmp->edit_type = EDIT_QF; parmp->edit_type = EDIT_QF;
if (argv[0][argv_idx]) { // "-q{errorfile}" if (argv[0][argv_idx]) { // "-q{errorfile}"
parmp->use_ef = (char_u *)argv[0] + argv_idx; parmp->use_ef = argv[0] + argv_idx;
argv_idx = -1; argv_idx = -1;
} else if (argc > 1) { // "-q {errorfile}" } else if (argc > 1) { // "-q {errorfile}"
want_argument = true; want_argument = true;
@ -1160,7 +1160,7 @@ static void command_line_scan(mparm_T *parmp)
} }
parmp->edit_type = EDIT_TAG; parmp->edit_type = EDIT_TAG;
if (argv[0][argv_idx]) { // "-t{tag}" if (argv[0][argv_idx]) { // "-t{tag}"
parmp->tagname = (char_u *)argv[0] + argv_idx; parmp->tagname = argv[0] + argv_idx;
argv_idx = -1; argv_idx = -1;
} else { // "-t {tag}" } else { // "-t {tag}"
want_argument = true; want_argument = true;
@ -1272,7 +1272,7 @@ static void command_line_scan(mparm_T *parmp)
break; break;
case 'q': // "-q {errorfile}" QuickFix mode case 'q': // "-q {errorfile}" QuickFix mode
parmp->use_ef = (char_u *)argv[0]; parmp->use_ef = argv[0];
break; break;
case 'i': // "-i {shada}" use for shada case 'i': // "-i {shada}" use for shada
@ -1313,7 +1313,7 @@ scripterror:
} }
case 't': // "-t {tag}" case 't': // "-t {tag}"
parmp->tagname = (char_u *)argv[0]; parmp->tagname = argv[0];
break; break;
case 'u': // "-u {vimrc}" vim inits file case 'u': // "-u {vimrc}" vim inits file
parmp->use_vimrc = argv[0]; parmp->use_vimrc = argv[0];
@ -1507,7 +1507,7 @@ static void handle_quickfix(mparm_T *paramp)
{ {
if (paramp->edit_type == EDIT_QF) { if (paramp->edit_type == EDIT_QF) {
if (paramp->use_ef != NULL) { if (paramp->use_ef != NULL) {
set_string_option_direct("ef", -1, paramp->use_ef, OPT_FREE, SID_CARG); set_string_option_direct("ef", -1, (char_u *)paramp->use_ef, OPT_FREE, SID_CARG);
} }
vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef); vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef);
if (qf_init(NULL, (char *)p_ef, p_efm, true, (char *)IObuff, (char *)p_menc) < 0) { if (qf_init(NULL, (char *)p_ef, p_efm, true, (char *)IObuff, (char *)p_menc) < 0) {

View File

@ -19,13 +19,13 @@ typedef struct {
int n_commands; // no. of commands from + or -c int n_commands; // no. of commands from + or -c
char *commands[MAX_ARG_CMDS]; // commands from + or -c arg char *commands[MAX_ARG_CMDS]; // commands from + or -c arg
char_u cmds_tofree[MAX_ARG_CMDS]; // commands that need free() char cmds_tofree[MAX_ARG_CMDS]; // commands that need free()
int n_pre_commands; // no. of commands from --cmd int n_pre_commands; // no. of commands from --cmd
char *pre_commands[MAX_ARG_CMDS]; // commands from --cmd argument char *pre_commands[MAX_ARG_CMDS]; // commands from --cmd argument
int edit_type; // type of editing to do int edit_type; // type of editing to do
char_u *tagname; // tag from -t argument char *tagname; // tag from -t argument
char_u *use_ef; // 'errorfile' from -q argument char *use_ef; // 'errorfile' from -q argument
bool input_isatty; // stdin is a terminal bool input_isatty; // stdin is a terminal
bool output_isatty; // stdout is a terminal bool output_isatty; // stdout is a terminal

View File

@ -651,7 +651,7 @@ static char_u *mark_line(pos_T *mp, int lead_len)
*/ */
void ex_marks(exarg_T *eap) void ex_marks(exarg_T *eap)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
int i; int i;
char_u *name; char_u *name;
pos_T *posp, *startp, *endp; pos_T *posp, *startp, *endp;
@ -668,7 +668,7 @@ void ex_marks(exarg_T *eap)
if (namedfm[i].fmark.fnum != 0) { if (namedfm[i].fmark.fnum != 0) {
name = fm_getname(&namedfm[i].fmark, 15); name = fm_getname(&namedfm[i].fmark, 15);
} else { } else {
name = namedfm[i].fname; name = (char_u *)namedfm[i].fname;
} }
if (name != NULL) { if (name != NULL) {
show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A', show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A',
@ -767,7 +767,7 @@ void ex_delmarks(exarg_T *eap)
emsg(_(e_argreq)); emsg(_(e_argreq));
} else { } else {
// clear specified marks only // clear specified marks only
for (p = eap->arg; *p != NUL; ++p) { for (p = (char_u *)eap->arg; *p != NUL; p++) {
lower = ASCII_ISLOWER(*p); lower = ASCII_ISLOWER(*p);
digit = ascii_isdigit(*p); digit = ascii_isdigit(*p);
if (lower || digit || ASCII_ISUPPER(*p)) { if (lower || digit || ASCII_ISUPPER(*p)) {
@ -1311,7 +1311,7 @@ void copy_jumplist(win_T *from, win_T *to)
for (i = 0; i < from->w_jumplistlen; ++i) { for (i = 0; i < from->w_jumplistlen; ++i) {
to->w_jumplist[i] = from->w_jumplist[i]; to->w_jumplist[i] = from->w_jumplist[i];
if (from->w_jumplist[i].fname != NULL) { if (from->w_jumplist[i].fname != NULL) {
to->w_jumplist[i].fname = vim_strsave(from->w_jumplist[i].fname); to->w_jumplist[i].fname = xstrdup(from->w_jumplist[i].fname);
} }
} }
to->w_jumplistlen = from->w_jumplistlen; to->w_jumplistlen = from->w_jumplistlen;
@ -1665,7 +1665,7 @@ void get_global_marks(list_T *l)
if (namedfm[i].fmark.fnum != 0) { if (namedfm[i].fmark.fnum != 0) {
name = (char *)buflist_nr2name(namedfm[i].fmark.fnum, true, true); name = (char *)buflist_nr2name(namedfm[i].fmark.fnum, true, true);
} else { } else {
name = (char *)namedfm[i].fname; name = namedfm[i].fname;
} }
if (name != NULL) { if (name != NULL) {
mname[1] = i >= NMARKS ? (char)(i - NMARKS + '0') : (char)(i + 'A'); mname[1] = i >= NMARKS ? (char)(i - NMARKS + '0') : (char)(i + 'A');

View File

@ -42,7 +42,7 @@ typedef struct filemark {
/// Structure defining extended mark (mark with file name attached) /// Structure defining extended mark (mark with file name attached)
typedef struct xfilemark { typedef struct xfilemark {
fmark_T fmark; ///< Actual mark. fmark_T fmark; ///< Actual mark.
char_u *fname; ///< File name, used when fnum == 0. char *fname; ///< File name, used when fnum == 0.
} xfmark_T; } xfmark_T;
#endif // NVIM_MARK_DEFS_H #endif // NVIM_MARK_DEFS_H

View File

@ -1176,14 +1176,14 @@ void ex_match(exarg_T *eap)
} }
if (ends_excmd(*eap->arg)) { if (ends_excmd(*eap->arg)) {
end = eap->arg; end = (char_u *)eap->arg;
} else if ((STRNICMP(eap->arg, "none", 4) == 0 } else if ((STRNICMP(eap->arg, "none", 4) == 0
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) { && (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) {
end = eap->arg + 4; end = (char_u *)eap->arg + 4;
} else { } else {
p = skiptowhite(eap->arg); p = skiptowhite((char_u *)eap->arg);
if (!eap->skip) { if (!eap->skip) {
g = vim_strnsave(eap->arg, (size_t)(p - eap->arg)); g = vim_strnsave((char_u *)eap->arg, (size_t)(p - (char_u *)eap->arg));
} }
p = skipwhite(p); p = skipwhite(p);
if (*p == NUL) { if (*p == NUL) {
@ -1213,5 +1213,5 @@ void ex_match(exarg_T *eap)
*end = (char_u)c; *end = (char_u)c;
} }
} }
eap->nextcmd = find_nextcmd(end); eap->nextcmd = (char *)find_nextcmd(end);
} }

View File

@ -76,8 +76,8 @@ void ex_menu(exarg_T *eap)
// kFalse for "menu disable // kFalse for "menu disable
vimmenu_T menuarg; vimmenu_T menuarg;
modes = get_menu_cmd_modes((char *)eap->cmd, eap->forceit, &noremap, &unmenu); modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu);
arg = (char *)eap->arg; arg = eap->arg;
for (;;) { for (;;) {
if (STRNCMP(arg, "<script>", 8) == 0) { if (STRNCMP(arg, "<script>", 8) == 0) {
@ -1022,7 +1022,7 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for
xfree(path_name); xfree(path_name);
xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS; xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS;
xp->xp_pattern = (char_u *)after_dot; xp->xp_pattern = after_dot;
expand_menu = menu; expand_menu = menu;
} else { // We're in the mapping part } else { // We're in the mapping part
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
@ -1470,7 +1470,7 @@ static void execute_menu(const exarg_T *eap, vimmenu_T *menu)
// execute it. // execute it.
void ex_emenu(exarg_T *eap) void ex_emenu(exarg_T *eap)
{ {
char *saved_name = xstrdup((char *)eap->arg); char *saved_name = xstrdup(eap->arg);
vimmenu_T *menu = *get_root_menu(saved_name); vimmenu_T *menu = *get_root_menu(saved_name);
char *name = saved_name; char *name = saved_name;
while (*name) { while (*name) {
@ -1531,7 +1531,7 @@ static garray_T menutrans_ga = GA_EMPTY_INIT_VALUE;
*/ */
void ex_menutranslate(exarg_T *eap) void ex_menutranslate(exarg_T *eap)
{ {
char *arg = (char *)eap->arg; char *arg = eap->arg;
char *from, *from_noamp, *to; char *from, *from_noamp, *to;
if (menutrans_ga.ga_itemsize == 0) { if (menutrans_ga.ga_itemsize == 0) {

View File

@ -631,7 +631,7 @@ static bool emsg_multiline(const char *s, bool multiline)
* when the message should be ignored completely (used for the * when the message should be ignored completely (used for the
* interrupt message). * interrupt message).
*/ */
if (cause_errthrow((char_u *)s, severe, &ignore)) { if (cause_errthrow(s, severe, &ignore)) {
if (!ignore) { if (!ignore) {
did_emsg++; did_emsg++;
} }

View File

@ -801,9 +801,9 @@ void curs_columns(win_T *wp, int may_scroll)
// When cursor wraps to first char of next line in Insert // When cursor wraps to first char of next line in Insert
// mode, the 'showbreak' string isn't shown, backup to first // mode, the 'showbreak' string isn't shown, backup to first
// column // column
char_u *const sbr = get_showbreak_value(wp); char *const sbr = (char *)get_showbreak_value(wp);
if (*sbr && *get_cursor_pos_ptr() == NUL if (*sbr && *get_cursor_pos_ptr() == NUL
&& wp->w_wcol == vim_strsize(sbr)) { && wp->w_wcol == vim_strsize((char_u *)sbr)) {
wp->w_wcol = 0; wp->w_wcol = 0;
} }
} }

View File

@ -3830,7 +3830,7 @@ void ex_display(exarg_T *eap)
char_u *p; char_u *p;
yankreg_T *yb; yankreg_T *yb;
int name; int name;
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
int clen; int clen;
int type; int type;

View File

@ -948,7 +948,7 @@ void ex_set(exarg_T *eap)
if (eap->forceit) { if (eap->forceit) {
flags |= OPT_ONECOLUMN; flags |= OPT_ONECOLUMN;
} }
(void)do_set(eap->arg, flags); (void)do_set((char_u *)eap->arg, flags);
} }
/// Parse 'arg' for option settings. /// Parse 'arg' for option settings.
@ -6698,12 +6698,12 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
xp->xp_context = EXPAND_SETTINGS; xp->xp_context = EXPAND_SETTINGS;
if (*arg == NUL) { if (*arg == NUL) {
xp->xp_pattern = arg; xp->xp_pattern = (char *)arg;
return; return;
} }
p = arg + STRLEN(arg) - 1; p = arg + STRLEN(arg) - 1;
if (*p == ' ' && *(p - 1) != '\\') { if (*p == ' ' && *(p - 1) != '\\') {
xp->xp_pattern = p + 1; xp->xp_pattern = (char *)p + 1;
return; return;
} }
while (p > arg) { while (p > arg) {
@ -6729,7 +6729,8 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
xp->xp_context = EXPAND_BOOL_SETTINGS; xp->xp_context = EXPAND_BOOL_SETTINGS;
p += 3; p += 3;
} }
xp->xp_pattern = arg = p; xp->xp_pattern = (char *)p;
arg = p;
if (*arg == '<') { if (*arg == '<') {
while (*p != '>') { while (*p != '>') {
if (*p++ == NUL) { // expand terminal option name if (*p++ == NUL) { // expand terminal option name
@ -6796,7 +6797,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
} else { } else {
expand_option_idx = opt_idx; expand_option_idx = opt_idx;
} }
xp->xp_pattern = p + 1; xp->xp_pattern = (char *)p + 1;
return; return;
} }
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
@ -6804,7 +6805,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
return; return;
} }
xp->xp_pattern = p + 1; xp->xp_pattern = (char *)p + 1;
if (flags & P_EXPAND) { if (flags & P_EXPAND) {
p = options[opt_idx].var; p = options[opt_idx].var;
@ -6837,16 +6838,16 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
// For an option that is a list of file names, find the start of the // For an option that is a list of file names, find the start of the
// last file name. // last file name.
for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; p--) { for (p = arg + STRLEN(arg) - 1; p > (char_u *)xp->xp_pattern; p--) {
// count number of backslashes before ' ' or ',' // count number of backslashes before ' ' or ','
if (*p == ' ' || *p == ',') { if (*p == ' ' || *p == ',') {
s = p; s = p;
while (s > xp->xp_pattern && *(s - 1) == '\\') { while (s > (char_u *)xp->xp_pattern && *(s - 1) == '\\') {
s--; s--;
} }
if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|| (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) { || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) {
xp->xp_pattern = p + 1; xp->xp_pattern = (char *)p + 1;
break; break;
} }
} }
@ -6854,7 +6855,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
// for 'spellsuggest' start at "file:" // for 'spellsuggest' start at "file:"
if (options[opt_idx].var == (char_u *)&p_sps if (options[opt_idx].var == (char_u *)&p_sps
&& STRNCMP(p, "file:", 5) == 0) { && STRNCMP(p, "file:", 5) == 0) {
xp->xp_pattern = p + 5; xp->xp_pattern = (char *)p + 5;
break; break;
} }
} }

View File

@ -503,7 +503,7 @@ char *save_abs_path(const char *name)
if (!path_is_absolute((char_u *)name)) { if (!path_is_absolute((char_u *)name)) {
return FullName_save(name, true); return FullName_save(name, true);
} }
return (char *)vim_strsave((char_u *)name); return xstrdup(name);
} }
/// Checks if a path has a wildcard character including '~', unless at the end. /// Checks if a path has a wildcard character including '~', unless at the end.

View File

@ -3174,7 +3174,7 @@ void qf_list(exarg_T *eap)
int i; int i;
int idx1 = 1; int idx1 = 1;
int idx2 = -1; int idx2 = -1;
char *arg = (char *)eap->arg; char *arg = eap->arg;
int all = eap->forceit; // if not :cl!, only show int all = eap->forceit; // if not :cl!, only show
// recognised errors // recognised errors
qf_info_T *qi; qf_info_T *qi;
@ -4392,7 +4392,7 @@ void ex_make(exarg_T *eap)
} }
os_remove(fname); // in case it's not unique os_remove(fname); // in case it's not unique
char *const cmd = make_get_fullcmd((char *)eap->arg, fname); char *const cmd = make_get_fullcmd(eap->arg, fname);
do_shell(cmd, 0); do_shell(cmd, 0);
@ -4401,7 +4401,7 @@ void ex_make(exarg_T *eap)
res = qf_init(wp, fname, (eap->cmdidx != CMD_make res = qf_init(wp, fname, (eap->cmdidx != CMD_make
&& eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
(eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd), (eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd),
qf_cmdtitle((char *)(*eap->cmdlinep)), enc); qf_cmdtitle(*eap->cmdlinep), enc);
if (wp != NULL) { if (wp != NULL) {
qi = GET_LOC_LIST(wp); qi = GET_LOC_LIST(wp);
if (qi == NULL) { if (qi == NULL) {
@ -5112,7 +5112,7 @@ void ex_cfile(exarg_T *eap)
} }
} }
if (*eap->arg != NUL) { if (*eap->arg != NUL) {
set_string_option_direct("ef", -1, eap->arg, OPT_FREE, 0); set_string_option_direct("ef", -1, (char_u *)eap->arg, OPT_FREE, 0);
} }
char *enc = (*curbuf->b_p_menc != NUL) ? (char *)curbuf->b_p_menc : (char *)p_menc; char *enc = (*curbuf->b_p_menc != NUL) ? (char *)curbuf->b_p_menc : (char *)p_menc;
@ -5133,7 +5133,7 @@ void ex_cfile(exarg_T *eap)
// quickfix list then a new list is created. // quickfix list then a new list is created.
int res = qf_init(wp, (char *)p_ef, p_efm, (eap->cmdidx != CMD_caddfile int res = qf_init(wp, (char *)p_ef, p_efm, (eap->cmdidx != CMD_caddfile
&& eap->cmdidx != CMD_laddfile), && eap->cmdidx != CMD_laddfile),
qf_cmdtitle((char *)(*eap->cmdlinep)), enc); qf_cmdtitle(*eap->cmdlinep), enc);
if (wp != NULL) { if (wp != NULL) {
qi = GET_LOC_LIST(wp); qi = GET_LOC_LIST(wp);
if (qi == NULL) { if (qi == NULL) {
@ -5385,7 +5385,7 @@ static void vgr_jump_to_match(qf_info_T *qi, int forceit, bool *redraw_for_dummy
// Jump to the directory used after loading the buffer. // Jump to the directory used after loading the buffer.
if (curbuf == first_match_buf && target_dir != NULL) { if (curbuf == first_match_buf && target_dir != NULL) {
exarg_T ea = { exarg_T ea = {
.arg = (char_u *)target_dir, .arg = target_dir,
.cmdidx = CMD_lcd, .cmdidx = CMD_lcd,
}; };
ex_cd(&ea); ex_cd(&ea);
@ -5414,7 +5414,7 @@ static int vgr_process_args(exarg_T *eap, vgr_args_T *args)
memset(args, 0, sizeof(*args)); memset(args, 0, sizeof(*args));
args->regmatch.regprog = NULL; args->regmatch.regprog = NULL;
args->qf_title = xstrdup(qf_cmdtitle((char *)(*eap->cmdlinep))); args->qf_title = xstrdup(qf_cmdtitle(*eap->cmdlinep));
if (eap->addr_count > 0) { if (eap->addr_count > 0) {
args->tomatch = eap->line2; args->tomatch = eap->line2;
@ -5423,7 +5423,7 @@ static int vgr_process_args(exarg_T *eap, vgr_args_T *args)
} }
// Get the search pattern: either white-separated or enclosed in // // Get the search pattern: either white-separated or enclosed in //
char *p = skip_vimgrep_pat((char *)eap->arg, &args->spat, &args->flags); char *p = skip_vimgrep_pat(eap->arg, &args->spat, &args->flags);
if (p == NULL) { if (p == NULL) {
emsg(_(e_invalpat)); emsg(_(e_invalpat));
return FAIL; return FAIL;
@ -5682,7 +5682,7 @@ static void restore_start_dir(char *dirname_start)
// If the directory has changed, change it back by building up an // If the directory has changed, change it back by building up an
// appropriate ex command and executing it. // appropriate ex command and executing it.
exarg_T ea = { exarg_T ea = {
.arg = (char_u *)dirname_start, .arg = dirname_start,
.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd, .cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd,
}; };
ex_cd(&ea); ex_cd(&ea);
@ -6887,8 +6887,8 @@ static int cbuffer_process_args(exarg_T *eap, buf_T **bufp, linenr_T *line1, lin
if (*eap->arg == NUL) { if (*eap->arg == NUL) {
buf = curbuf; buf = curbuf;
} else if (*skipwhite(skipdigits(eap->arg)) == NUL) { } else if (*skipwhite(skipdigits((char_u *)eap->arg)) == NUL) {
buf = buflist_findnr(atoi((char *)eap->arg)); buf = buflist_findnr(atoi(eap->arg));
} }
if (buf == NULL) { if (buf == NULL) {
@ -6949,7 +6949,7 @@ void ex_cbuffer(exarg_T *eap)
return; return;
} }
qf_title = qf_cmdtitle((char *)(*eap->cmdlinep)); qf_title = qf_cmdtitle(*eap->cmdlinep);
if (buf->b_sfname) { if (buf->b_sfname) {
vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)",
@ -7035,7 +7035,7 @@ void ex_cexpr(exarg_T *eap)
// Evaluate the expression. When the result is a string or a list we can // Evaluate the expression. When the result is a string or a list we can
// use it to fill the errorlist. // use it to fill the errorlist.
typval_T tv; typval_T tv;
if (eval0((char *)eap->arg, &tv, (char **)&eap->nextcmd, true) != FAIL) { if (eval0(eap->arg, &tv, &eap->nextcmd, true) != FAIL) {
if ((tv.v_type == VAR_STRING && tv.vval.v_string != NULL) if ((tv.v_type == VAR_STRING && tv.vval.v_string != NULL)
|| tv.v_type == VAR_LIST) { || tv.v_type == VAR_LIST) {
incr_quickfix_busy(); incr_quickfix_busy();
@ -7043,7 +7043,7 @@ void ex_cexpr(exarg_T *eap)
(eap->cmdidx != CMD_caddexpr (eap->cmdidx != CMD_caddexpr
&& eap->cmdidx != CMD_laddexpr), && eap->cmdidx != CMD_laddexpr),
(linenr_T)0, (linenr_T)0, (linenr_T)0, (linenr_T)0,
qf_cmdtitle((char *)(*eap->cmdlinep)), NULL); qf_cmdtitle(*eap->cmdlinep), NULL);
if (qf_stack_empty(qi)) { if (qf_stack_empty(qi)) {
decr_quickfix_busy(); decr_quickfix_busy();
goto cleanup; goto cleanup;
@ -7238,14 +7238,14 @@ void ex_helpgrep(exarg_T *eap)
incr_quickfix_busy(); incr_quickfix_busy();
// Check for a specified language // Check for a specified language
char *const lang = check_help_lang((char *)eap->arg); char *const lang = check_help_lang(eap->arg);
regmatch_T regmatch = { regmatch_T regmatch = {
.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING), .regprog = vim_regcomp((char_u *)eap->arg, RE_MAGIC + RE_STRING),
.rm_ic = false, .rm_ic = false,
}; };
if (regmatch.regprog != NULL) { if (regmatch.regprog != NULL) {
// Create a new quickfix list. // Create a new quickfix list.
qf_new_list(qi, qf_cmdtitle((char *)(*eap->cmdlinep))); qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep));
qf_list_T *const qfl = qf_get_curlist(qi); qf_list_T *const qfl = qf_get_curlist(qi);
hgr_search_in_rtp(qfl, &regmatch, lang); hgr_search_in_rtp(qfl, &regmatch, lang);

View File

@ -35,7 +35,7 @@ void runtime_init(void)
/// ":runtime [what] {name}" /// ":runtime [what] {name}"
void ex_runtime(exarg_T *eap) void ex_runtime(exarg_T *eap)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *p = skiptowhite(arg); char_u *p = skiptowhite(arg);
ptrdiff_t len = p - arg; ptrdiff_t len = p - arg;
int flags = eap->forceit ? DIP_ALL : 0; int flags = eap->forceit ? DIP_ALL : 0;

View File

@ -1289,9 +1289,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
XFREE_CLEAR(cur_entry.data.filemark.fname); XFREE_CLEAR(cur_entry.data.filemark.fname);
} }
xfmark_T fm = (xfmark_T) { xfmark_T fm = (xfmark_T) {
.fname = (char_u *)(buf == NULL .fname = buf == NULL ? cur_entry.data.filemark.fname : NULL,
? cur_entry.data.filemark.fname
: NULL),
.fmark = { .fmark = {
.mark = cur_entry.data.filemark.mark, .mark = cur_entry.data.filemark.mark,
.fnum = (buf == NULL ? 0 : buf->b_fnum), .fnum = (buf == NULL ? 0 : buf->b_fnum),
@ -4027,9 +4025,9 @@ static inline size_t shada_init_jumps(PossiblyFreedShadaEntry *jumps,
: fm.fmark.fnum != 0) { : fm.fmark.fnum != 0) {
continue; continue;
} }
const char *const fname = (char *)(fm.fmark.fnum == 0 const char *const fname =
? (fm.fname == NULL ? NULL : fm.fname) (char *)(fm.fmark.fnum ==
: buf ? buf->b_ffname : NULL); 0 ? (fm.fname == NULL ? NULL : (char_u *)fm.fname) : buf ? buf->b_ffname : NULL);
if (fname == NULL) { if (fname == NULL) {
continue; continue;
} }

View File

@ -1419,7 +1419,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
/// ":sign" command /// ":sign" command
void ex_sign(exarg_T *eap) void ex_sign(exarg_T *eap)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *p; char_u *p;
int idx; int idx;
sign_T *sp; sign_T *sp;
@ -1785,7 +1785,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// Default: expand subcommands. // Default: expand subcommands.
xp->xp_context = EXPAND_SIGN; xp->xp_context = EXPAND_SIGN;
expand_what = EXP_SUBCMD; expand_what = EXP_SUBCMD;
xp->xp_pattern = arg; xp->xp_pattern = (char *)arg;
end_subcmd = skiptowhite(arg); end_subcmd = skiptowhite(arg);
if (*end_subcmd == NUL) { if (*end_subcmd == NUL) {
@ -1822,7 +1822,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// last p // last p
if (p == NULL) { if (p == NULL) {
// Expand last argument name (before equal sign). // Expand last argument name (before equal sign).
xp->xp_pattern = last; xp->xp_pattern = (char *)last;
switch (cmd_idx) { switch (cmd_idx) {
case SIGNCMD_DEFINE: case SIGNCMD_DEFINE:
expand_what = EXP_DEFINE; expand_what = EXP_DEFINE;
@ -1852,7 +1852,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
} }
} else { } else {
// Expand last argument value (after equal sign). // Expand last argument value (after equal sign).
xp->xp_pattern = p + 1; xp->xp_pattern = (char *)p + 1;
switch (cmd_idx) { switch (cmd_idx) {
case SIGNCMD_DEFINE: case SIGNCMD_DEFINE:
if (STRNCMP(last, "texthl", 6) == 0 if (STRNCMP(last, "texthl", 6) == 0

View File

@ -4874,7 +4874,7 @@ void ex_mkspell(exarg_T *eap)
{ {
int fcount; int fcount;
char_u **fnames; char_u **fnames;
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
bool ascii = false; bool ascii = false;
if (STRNCMP(arg, "-ascii", 6) == 0) { if (STRNCMP(arg, "-ascii", 6) == 0) {
@ -5501,7 +5501,7 @@ static void spell_message(const spellinfo_T *spin, char_u *str)
// ":[count]spellrare {word}" // ":[count]spellrare {word}"
void ex_spell(exarg_T *eap) void ex_spell(exarg_T *eap)
{ {
spell_add_word(eap->arg, (int)STRLEN(eap->arg), spell_add_word((char_u *)eap->arg, (int)STRLEN(eap->arg),
eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD : eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD :
eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD, eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD,
eap->forceit ? 0 : (int)eap->line2, eap->forceit ? 0 : (int)eap->line2,

View File

@ -3032,10 +3032,10 @@ static keyentry_T *match_keyword(char_u *keyword, hashtab_T *ht, stateitem_T *cu
*/ */
static void syn_cmd_conceal(exarg_T *eap, int syncing) static void syn_cmd_conceal(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *next; char_u *next;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -3061,10 +3061,10 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing)
*/ */
static void syn_cmd_case(exarg_T *eap, int syncing) static void syn_cmd_case(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *next; char_u *next;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -3088,10 +3088,10 @@ static void syn_cmd_case(exarg_T *eap, int syncing)
/// Handle ":syntax foldlevel" command. /// Handle ":syntax foldlevel" command.
static void syn_cmd_foldlevel(exarg_T *eap, int syncing) static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *arg_end; char_u *arg_end;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -3129,10 +3129,10 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
*/ */
static void syn_cmd_spell(exarg_T *eap, int syncing) static void syn_cmd_spell(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *next; char_u *next;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -3164,7 +3164,7 @@ static void syn_cmd_spell(exarg_T *eap, int syncing)
/// Handle ":syntax iskeyword" command. /// Handle ":syntax iskeyword" command.
static void syn_cmd_iskeyword(exarg_T *eap, int syncing) static void syn_cmd_iskeyword(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u save_chartab[32]; char_u save_chartab[32];
char_u *save_isk; char_u *save_isk;
@ -3336,11 +3336,11 @@ static void syn_clear_cluster(synblock_T *block, int i)
*/ */
static void syn_cmd_clear(exarg_T *eap, int syncing) static void syn_cmd_clear(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *arg_end; char_u *arg_end;
int id; int id;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -3440,7 +3440,7 @@ static void syn_cmd_on(exarg_T *eap, int syncing)
*/ */
static void syn_cmd_reset(exarg_T *eap, int syncing) static void syn_cmd_reset(exarg_T *eap, int syncing)
{ {
eap->nextcmd = check_nextcmd(eap->arg); eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
if (!eap->skip) { if (!eap->skip) {
init_highlight(true, true); init_highlight(true, true);
} }
@ -3465,7 +3465,7 @@ static void syn_cmd_off(exarg_T *eap, int syncing)
static void syn_cmd_onoff(exarg_T *eap, char *name) static void syn_cmd_onoff(exarg_T *eap, char *name)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
eap->nextcmd = check_nextcmd(eap->arg); eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
if (!eap->skip) { if (!eap->skip) {
did_syntax_onoff = true; did_syntax_onoff = true;
char buf[100]; char buf[100];
@ -3479,7 +3479,7 @@ void syn_maybe_enable(void)
{ {
if (!did_syntax_onoff) { if (!did_syntax_onoff) {
exarg_T ea; exarg_T ea;
ea.arg = (char_u *)""; ea.arg = "";
ea.skip = false; ea.skip = false;
syn_cmd_on(&ea, false); syn_cmd_on(&ea, false);
} }
@ -3490,10 +3490,10 @@ void syn_maybe_enable(void)
/// @param syncing when TRUE: list syncing items /// @param syncing when TRUE: list syncing items
static void syn_cmd_list(exarg_T *eap, int syncing) static void syn_cmd_list(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *arg_end; char_u *arg_end;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -3569,7 +3569,7 @@ static void syn_cmd_list(exarg_T *eap, int syncing)
arg = skipwhite(arg_end); arg = skipwhite(arg_end);
} }
} }
eap->nextcmd = check_nextcmd(arg); eap->nextcmd = (char *)check_nextcmd(arg);
} }
static void syn_lines_msg(void) static void syn_lines_msg(void)
@ -4261,7 +4261,7 @@ static void syn_incl_toplevel(int id, int *flagsp)
*/ */
static void syn_cmd_include(exarg_T *eap, int syncing) static void syn_cmd_include(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
int sgl_id = 1; int sgl_id = 1;
char_u *group_name_end; char_u *group_name_end;
char_u *rest; char_u *rest;
@ -4270,7 +4270,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
int prev_syn_inc_tag; int prev_syn_inc_tag;
bool source = false; bool source = false;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -4287,7 +4287,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
return; return;
} }
// separate_nextcmd() and expand_filename() depend on this // separate_nextcmd() and expand_filename() depend on this
eap->arg = rest; eap->arg = (char *)rest;
} }
/* /*
@ -4296,7 +4296,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
*/ */
eap->argt |= (EX_XFILE | EX_NOSPC); eap->argt |= (EX_XFILE | EX_NOSPC);
separate_nextcmd(eap); separate_nextcmd(eap);
if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute(eap->arg)) { if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute((char_u *)eap->arg)) {
// For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the // For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the
// file. Need to expand the file name first. In other cases // file. Need to expand the file name first. In other cases
// ":runtime!" is used. // ":runtime!" is used.
@ -4322,8 +4322,8 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
prev_toplvl_grp = curwin->w_s->b_syn_topgrp; prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
curwin->w_s->b_syn_topgrp = sgl_id; curwin->w_s->b_syn_topgrp = sgl_id;
if (source if (source
? do_source((char *)eap->arg, false, DOSO_NONE) == FAIL ? do_source(eap->arg, false, DOSO_NONE) == FAIL
: source_runtime((char *)eap->arg, DIP_ALL) == FAIL) { : source_runtime(eap->arg, DIP_ALL) == FAIL) {
semsg(_(e_notopen), eap->arg); semsg(_(e_notopen), eap->arg);
} }
curwin->w_s->b_syn_topgrp = prev_toplvl_grp; curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
@ -4335,7 +4335,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
*/ */
static void syn_cmd_keyword(exarg_T *eap, int syncing) static void syn_cmd_keyword(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *group_name_end; char_u *group_name_end;
int syn_id; int syn_id;
char_u *rest; char_u *rest;
@ -4432,7 +4432,7 @@ error:
} }
if (rest != NULL) { if (rest != NULL) {
eap->nextcmd = check_nextcmd(rest); eap->nextcmd = (char *)check_nextcmd(rest);
} else { } else {
semsg(_(e_invarg2), arg); semsg(_(e_invarg2), arg);
} }
@ -4448,7 +4448,7 @@ error:
/// @param syncing TRUE for ":syntax sync match .. " /// @param syncing TRUE for ":syntax sync match .. "
static void syn_cmd_match(exarg_T *eap, int syncing) static void syn_cmd_match(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *group_name_end; char_u *group_name_end;
char_u *rest; char_u *rest;
synpat_T item; // the item found in the line synpat_T item; // the item found in the line
@ -4485,7 +4485,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
/* /*
* Check for trailing command and illegal trailing arguments. * Check for trailing command and illegal trailing arguments.
*/ */
eap->nextcmd = check_nextcmd(rest); eap->nextcmd = (char *)check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip) { if (!ends_excmd(*rest) || eap->skip) {
rest = NULL; rest = NULL;
} else { } else {
@ -4546,7 +4546,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
/// @param syncing TRUE for ":syntax sync region .." /// @param syncing TRUE for ":syntax sync region .."
static void syn_cmd_region(exarg_T *eap, int syncing) static void syn_cmd_region(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *group_name_end; char_u *group_name_end;
char_u *rest; // next arg, NULL on error char_u *rest; // next arg, NULL on error
char_u *key_end; char_u *key_end;
@ -4692,7 +4692,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
* Check for trailing garbage or command. * Check for trailing garbage or command.
* If OK, add the item. * If OK, add the item.
*/ */
eap->nextcmd = check_nextcmd(rest); eap->nextcmd = (char *)check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip) { if (!ends_excmd(*rest) || eap->skip) {
rest = NULL; rest = NULL;
} else { } else {
@ -4990,14 +4990,14 @@ static int syn_add_cluster(char_u *name)
*/ */
static void syn_cmd_cluster(exarg_T *eap, int syncing) static void syn_cmd_cluster(exarg_T *eap, int syncing)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *group_name_end; char_u *group_name_end;
char_u *rest; char_u *rest;
bool got_clstr = false; bool got_clstr = false;
int opt_len; int opt_len;
int list_op; int list_op;
eap->nextcmd = find_nextcmd(arg); eap->nextcmd = (char *)find_nextcmd(arg);
if (eap->skip) { if (eap->skip) {
return; return;
} }
@ -5167,7 +5167,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
*/ */
static void syn_cmd_sync(exarg_T *eap, int syncing) static void syn_cmd_sync(exarg_T *eap, int syncing)
{ {
char_u *arg_start = eap->arg; char_u *arg_start = (char_u *)eap->arg;
char_u *arg_end; char_u *arg_end;
char_u *key = NULL; char_u *key = NULL;
char_u *next_arg; char_u *next_arg;
@ -5267,7 +5267,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
} }
next_arg = skipwhite(arg_end + 1); next_arg = skipwhite(arg_end + 1);
} else { } else {
eap->arg = next_arg; eap->arg = (char *)next_arg;
if (STRCMP(key, "MATCH") == 0) { if (STRCMP(key, "MATCH") == 0) {
syn_cmd_match(eap, TRUE); syn_cmd_match(eap, TRUE);
} else if (STRCMP(key, "REGION") == 0) { } else if (STRCMP(key, "REGION") == 0) {
@ -5286,7 +5286,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
if (illegal) { if (illegal) {
semsg(_("E404: Illegal arguments: %s"), arg_start); semsg(_("E404: Illegal arguments: %s"), arg_start);
} else if (!finished) { } else if (!finished) {
eap->nextcmd = check_nextcmd(arg_start); eap->nextcmd = (char *)check_nextcmd(arg_start);
redraw_curbuf_later(SOME_VALID); redraw_curbuf_later(SOME_VALID);
syn_stack_free_all(curwin->w_s); // Need to recompute all syntax. syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
} }
@ -5614,10 +5614,10 @@ static struct subcommand subcommands[] =
*/ */
void ex_syntax(exarg_T *eap) void ex_syntax(exarg_T *eap)
{ {
char_u *arg = eap->arg; char_u *arg = (char_u *)eap->arg;
char_u *subcmd_end; char_u *subcmd_end;
syn_cmdlinep = eap->cmdlinep; syn_cmdlinep = (char_u **)eap->cmdlinep;
// isolate subcommand name // isolate subcommand name
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {} for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {}
@ -5631,8 +5631,8 @@ void ex_syntax(exarg_T *eap)
break; break;
} }
if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) { if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) {
eap->arg = skipwhite(subcmd_end); eap->arg = (char *)skipwhite(subcmd_end);
(subcommands[i].func)(eap, FALSE); (subcommands[i].func)(eap, false);
break; break;
} }
} }
@ -5669,7 +5669,7 @@ void ex_ownsyntax(exarg_T *eap)
} }
// Apply the "syntax" autocommand event, this finds and loads the syntax file. // Apply the "syntax" autocommand event, this finds and loads the syntax file.
apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, true, curbuf); apply_autocmds(EVENT_SYNTAX, (char_u *)eap->arg, curbuf->b_fname, true, curbuf);
// Move value of b:current_syntax to w:current_syntax. // Move value of b:current_syntax to w:current_syntax.
new_value = get_var_value("b:current_syntax"); new_value = get_var_value("b:current_syntax");
@ -5718,7 +5718,7 @@ void reset_expand_highlight(void)
void set_context_in_echohl_cmd(expand_T *xp, const char *arg) void set_context_in_echohl_cmd(expand_T *xp, const char *arg)
{ {
xp->xp_context = EXPAND_HIGHLIGHT; xp->xp_context = EXPAND_HIGHLIGHT;
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char *)arg;
include_none = 1; include_none = 1;
} }
@ -5730,7 +5730,7 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
// Default: expand subcommands. // Default: expand subcommands.
xp->xp_context = EXPAND_SYNTAX; xp->xp_context = EXPAND_SYNTAX;
expand_what = EXP_SUBCMD; expand_what = EXP_SUBCMD;
xp->xp_pattern = (char_u *)arg; xp->xp_pattern = (char *)arg;
include_link = 0; include_link = 0;
include_default = 0; include_default = 0;
@ -5738,8 +5738,8 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
if (*arg != NUL) { if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg); const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { // Past first word. if (*p != NUL) { // Past first word.
xp->xp_pattern = skipwhite((const char_u *)p); xp->xp_pattern = (char *)skipwhite((const char_u *)p);
if (*skiptowhite(xp->xp_pattern) != NUL) { if (*skiptowhite((char_u *)xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} else if (STRNICMP(arg, "case", p - arg) == 0) { } else if (STRNICMP(arg, "case", p - arg) == 0) {
expand_what = EXP_CASE; expand_what = EXP_CASE;