aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2022-04-30 16:48:00 +0200
committerGitHub <noreply@github.com>2022-04-30 16:48:00 +0200
commit3c23100130725bb79c04e933c505bbeda96fb3bb (patch)
tree6184115b0f11cec968966455ce1d3b2e81873f1b /src
parentfcdf24d8be4abada88355538a23d771e41c77dd4 (diff)
downloadrneovim-3c23100130725bb79c04e933c505bbeda96fb3bb.tar.gz
rneovim-3c23100130725bb79c04e933c505bbeda96fb3bb.tar.bz2
rneovim-3c23100130725bb79c04e933c505bbeda96fb3bb.zip
refactor: replace char_u variables and functions with char (#18288)
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/private/helpers.c11
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/autocmd.c2
-rw-r--r--src/nvim/debugger.c7
-rw-r--r--src/nvim/eval.c7
-rw-r--r--src/nvim/eval/funcs.c4
-rw-r--r--src/nvim/eval/userfunc.c6
-rw-r--r--src/nvim/ex_cmds.c24
-rw-r--r--src/nvim/ex_cmds2.c13
-rw-r--r--src/nvim/ex_cmds_defs.h2
-rw-r--r--src/nvim/ex_docmd.c902
-rw-r--r--src/nvim/ex_eval.c2
-rw-r--r--src/nvim/ex_getln.c8
-rw-r--r--src/nvim/fileio.c8
-rw-r--r--src/nvim/main.c2
15 files changed, 492 insertions, 508 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 1c43564dca..a07b5b6e3a 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -1526,7 +1526,7 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
}
if (opts->addr.type == kObjectTypeString) {
- if (parse_addr_type_arg((char_u *)opts->addr.data.string.data, (int)opts->addr.data.string.size,
+ if (parse_addr_type_arg(opts->addr.data.string.data, (int)opts->addr.data.string.size,
&addr_type_arg) != OK) {
api_set_error(err, kErrorTypeValidation, "Invalid value for 'addr'");
goto err;
@@ -1574,9 +1574,9 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
compl = EXPAND_USER_LUA;
compl_luaref = api_new_luaref(opts->complete.data.luaref);
} else if (opts->complete.type == kObjectTypeString) {
- if (parse_compl_arg((char_u *)opts->complete.data.string.data,
+ if (parse_compl_arg(opts->complete.data.string.data,
(int)opts->complete.data.string.size, &compl, &argt,
- (char_u **)&compl_arg) != OK) {
+ &compl_arg) != OK) {
api_set_error(err, kErrorTypeValidation, "Invalid value for 'complete'");
goto err;
}
@@ -1603,9 +1603,8 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
goto err;
}
- if (uc_add_command((char_u *)name.data, name.size, (char_u *)rep, argt, def, flags,
- compl, (char_u *)compl_arg, compl_luaref, addr_type_arg, luaref,
- force) != OK) {
+ if (uc_add_command(name.data, name.size, rep, argt, def, flags, compl, compl_arg, compl_luaref,
+ addr_type_arg, luaref, force) != OK) {
api_set_error(err, kErrorTypeException, "Failed to create user command");
goto err;
}
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 2174cd1620..ac2fc09056 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -568,7 +568,7 @@ void nvim_set_current_dir(String dir, Error *err)
try_start();
- if (!changedir_func(string, kCdScopeGlobal)) {
+ if (!changedir_func((char *)string, kCdScopeGlobal)) {
if (!try_end(err)) {
api_set_error(err, kErrorTypeException, "Failed to change directory");
}
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 8830be7355..bfeb70dce9 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -831,7 +831,7 @@ void do_autocmd(char_u *arg_in, int forceit)
// Find the start of the commands.
// Expand <sfile> in it.
if (*cmd != NUL) {
- cmd = expand_sfile(cmd);
+ cmd = (char_u *)expand_sfile((char *)cmd);
if (cmd == NULL) { // some error
return;
}
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index cd823546b4..c6fd8aade3 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -263,8 +263,7 @@ void do_debug(char_u *cmd)
// don't debug this command
n = debug_break_level;
debug_break_level = -1;
- (void)do_cmdline(cmdline, getexline, NULL,
- DOCMD_VERBOSE|DOCMD_EXCRESET);
+ (void)do_cmdline((char *)cmdline, getexline, NULL, DOCMD_VERBOSE|DOCMD_EXCRESET);
debug_break_level = n;
}
lines_left = Rows - 1;
@@ -406,7 +405,7 @@ void dbg_check_breakpoint(exarg_T *eap)
debug_breakpoint_name + (*p == NUL ? 0 : 3),
(int64_t)debug_breakpoint_lnum);
debug_breakpoint_name = NULL;
- do_debug(eap->cmd);
+ do_debug((char_u *)eap->cmd);
} else {
debug_skipped = true;
debug_skipped_name = debug_breakpoint_name;
@@ -414,7 +413,7 @@ void dbg_check_breakpoint(exarg_T *eap)
}
} else if (ex_nesting_level <= debug_break_level) {
if (!eap->skip) {
- do_debug(eap->cmd);
+ do_debug((char_u *)eap->cmd);
} else {
debug_skipped = true;
debug_skipped_name = NULL;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 9b03af8d32..da869df5cc 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6644,8 +6644,8 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const
const int xp_namelen = (int)strlen(xp_name);
uint32_t argt;
- if (parse_compl_arg((char_u *)xp_name, xp_namelen, &xp_type,
- &argt, (char_u **)&xp_arg) == FAIL) {
+ if (parse_compl_arg(xp_name, xp_namelen, &xp_type,
+ &argt, &xp_arg) == FAIL) {
return;
}
}
@@ -9579,8 +9579,7 @@ void ex_execute(exarg_T *eap)
did_emsg = save_did_emsg;
}
} else if (eap->cmdidx == CMD_execute) {
- do_cmdline((char_u *)ga.ga_data,
- eap->getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE);
+ do_cmdline(ga.ga_data, eap->getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE);
}
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 91a12a94fa..c6993d2ff8 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -1018,7 +1018,7 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
scope = kCdScopeTabpage;
}
- if (!changedir_func(argvars[0].vval.v_string, scope)) {
+ if (!changedir_func((char *)argvars[0].vval.v_string, scope)) {
// Directory change failed
XFREE_CLEAR(rettv->vval.v_string);
}
@@ -2193,7 +2193,7 @@ static void f_expandcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char_u *cmdstr = (char_u *)xstrdup(tv_get_string(&argvars[0]));
exarg_T eap = {
- .cmd = cmdstr,
+ .cmd = (char *)cmdstr,
.arg = cmdstr,
.usefilter = false,
.nextcmd = NULL,
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 5a63bbf631..8b47468aad 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -2272,7 +2272,7 @@ void ex_function(exarg_T *eap)
for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {}
// Check for "endfunction".
- if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) {
+ if (checkforcmd((char **)&p, "endfunction", 4) && nesting-- == 0) {
if (*p == '!') {
p++;
}
@@ -2311,7 +2311,7 @@ void ex_function(exarg_T *eap)
}
// Check for defining a function inside this function.
- if (checkforcmd(&p, "function", 2)) {
+ if (checkforcmd((char **)&p, "function", 2)) {
if (*p == '!') {
p = skipwhite(p + 1);
}
@@ -2324,7 +2324,7 @@ void ex_function(exarg_T *eap)
}
// Check for ":append", ":change", ":insert".
- p = skip_range(p, NULL);
+ p = (char_u *)skip_range((char *)p, NULL);
if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c'
&& (!ASCII_ISALPHA(p[1])
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 918510bbd0..7be8bbcaac 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1991,7 +1991,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
if (p_confirm || cmdmod.confirm) {
char_u buff[DIALOG_MSG_SIZE];
- dialog_msg(buff, _("Overwrite existing file \"%s\"?"), fname);
+ dialog_msg((char *)buff, _("Overwrite existing file \"%s\"?"), (char *)fname);
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) {
return FAIL;
}
@@ -2027,9 +2027,9 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
if (p_confirm || cmdmod.confirm) {
char_u buff[DIALOG_MSG_SIZE];
- dialog_msg(buff,
+ dialog_msg((char *)buff,
_("Swap file \"%s\" exists, overwrite anyway?"),
- swapname);
+ (char *)swapname);
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)
!= VIM_YES) {
xfree(swapname);
@@ -2150,14 +2150,14 @@ static int check_readonly(int *forceit, buf_T *buf)
char_u buff[DIALOG_MSG_SIZE];
if (buf->b_p_ro) {
- dialog_msg(buff,
+ dialog_msg((char *)buff,
_("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
- buf->b_fname);
+ (char *)buf->b_fname);
} else {
- dialog_msg(buff,
- _(
- "File permissions of \"%s\" are read-only.\nIt may still be possible to write it.\nDo you wish to try?"),
- buf->b_fname);
+ dialog_msg((char *)buff,
+ _("File permissions of \"%s\" are read-only.\nIt may still be possible to "
+ "write it.\nDo you wish to try?"),
+ (char *)buf->b_fname);
}
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES) {
@@ -2859,7 +2859,7 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
curbuf->b_last_used = time(NULL);
if (command != NULL) {
- do_cmdline(command, NULL, NULL, DOCMD_VERBOSE);
+ do_cmdline((char *)command, NULL, NULL, DOCMD_VERBOSE);
}
if (curbuf->b_kmap_state & KEYMAP_INIT) {
@@ -4527,9 +4527,9 @@ static void global_exe_one(char_u *const cmd, const linenr_T lnum)
curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0;
if (*cmd == NUL || *cmd == '\n') {
- do_cmdline((char_u *)"p", NULL, NULL, DOCMD_NOWAIT);
+ do_cmdline("p", NULL, NULL, DOCMD_NOWAIT);
} else {
- do_cmdline(cmd, NULL, NULL, DOCMD_NOWAIT);
+ do_cmdline((char *)cmd, NULL, NULL, DOCMD_NOWAIT);
}
}
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 5af202c191..38007e5ad4 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -554,7 +554,7 @@ void dialog_changed(buf_T *buf, bool checkall)
.forceit = false,
};
- dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname);
+ dialog_msg((char *)buff, _("Save changes to \"%s\"?"), (char *)buf->b_fname);
if (checkall) {
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1);
} else {
@@ -610,8 +610,8 @@ bool dialog_close_terminal(buf_T *buf)
{
char_u buff[DIALOG_MSG_SIZE];
- dialog_msg(buff, _("Close \"%s\"?"),
- (buf->b_fname != NULL) ? buf->b_fname : (char_u *)"?");
+ dialog_msg((char *)buff, _("Close \"%s\"?"),
+ (buf->b_fname != NULL) ? (char *)buf->b_fname : "?");
int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
@@ -972,7 +972,7 @@ static int do_arglist(char_u *str, int what, int after, bool will_edit)
xfree(exp_files);
} else {
assert(what == AL_SET);
- alist_set(ALIST(curwin), exp_count, exp_files, will_edit, NULL, 0);
+ alist_set(ALIST(curwin), exp_count, (char **)exp_files, will_edit, NULL, 0);
}
}
@@ -1427,8 +1427,7 @@ void ex_listdo(exarg_T *eap)
i++;
// execute the command
if (execute) {
- do_cmdline(eap->arg, eap->getline, eap->cookie,
- DOCMD_VERBOSE + DOCMD_NOWAIT);
+ do_cmdline((char *)eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT);
}
if (eap->cmdidx == CMD_bufdo) {
@@ -2086,7 +2085,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
sourcing_lnum = sourcing_lnum_backup;
} else {
// Call do_cmdline, which will call getsourceline() to get the lines.
- do_cmdline(firstline, getsourceline, (void *)&cookie,
+ do_cmdline((char *)firstline, getsourceline, (void *)&cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
}
retval = OK;
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 39dfc1b94c..d8c4544f2e 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -176,7 +176,7 @@ enum {
struct exarg {
char_u *arg; ///< argument of the command
char_u *nextcmd; ///< next command (NULL if none)
- char_u *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
cmdidx_T cmdidx; ///< the index for the command
uint32_t argt; ///< flags for the command
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index b442a651c0..74963c165e 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -95,7 +95,7 @@ garray_T ucmds = { 0, 0, sizeof(ucmd_T), 4, NULL };
// Struct for storing a line inside a while/for loop
typedef struct {
- char_u *line; // command line
+ char *line; // command line
linenr_T lnum; // sourcing_lnum of the line
} wcmd_T;
@@ -121,8 +121,8 @@ struct dbg_stuff {
int trylevel;
int force_abort;
except_T *caught_stack;
- char_u *vv_exception;
- char_u *vv_throwpoint;
+ char *vv_exception;
+ char *vv_throwpoint;
int did_emsg;
int got_int;
int need_rethrow;
@@ -145,15 +145,15 @@ struct dbg_stuff {
# include "ex_cmds_defs.generated.h"
#endif
-static char_u dollar_command[2] = { '$', 0 };
+static char dollar_command[2] = { '$', 0 };
static void save_dbg_stuff(struct dbg_stuff *dsp)
{
dsp->trylevel = trylevel; trylevel = 0;
dsp->force_abort = force_abort; force_abort = FALSE;
dsp->caught_stack = caught_stack; caught_stack = NULL;
- dsp->vv_exception = v_exception(NULL);
- dsp->vv_throwpoint = v_throwpoint(NULL);
+ dsp->vv_exception = (char *)v_exception(NULL);
+ dsp->vv_throwpoint = (char *)v_throwpoint(NULL);
// Necessary for debugging an inactive ":catch", ":finally", ":endtry".
dsp->did_emsg = did_emsg; did_emsg = false;
@@ -169,8 +169,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp)
trylevel = dsp->trylevel;
force_abort = dsp->force_abort;
caught_stack = dsp->caught_stack;
- (void)v_exception(dsp->vv_exception);
- (void)v_throwpoint(dsp->vv_throwpoint);
+ (void)v_exception((char_u *)dsp->vv_exception);
+ (void)v_throwpoint((char_u *)dsp->vv_throwpoint);
did_emsg = dsp->did_emsg;
got_int = dsp->got_int;
need_rethrow = dsp->need_rethrow;
@@ -255,7 +255,7 @@ void do_exmode(void)
/// Print the executed command for when 'verbose' is set.
///
/// @param lnum if 0, only print the command.
-static void msg_verbose_cmd(linenr_T lnum, char_u *cmd)
+static void msg_verbose_cmd(linenr_T lnum, char *cmd)
FUNC_ATTR_NONNULL_ALL
{
no_wait_return++;
@@ -277,8 +277,7 @@ static void msg_verbose_cmd(linenr_T lnum, char_u *cmd)
/// Execute a simple command line. Used for translated commands like "*".
int do_cmdline_cmd(const char *cmd)
{
- return do_cmdline((char_u *)cmd, NULL, NULL,
- DOCMD_NOWAIT|DOCMD_KEYTYPED);
+ return do_cmdline((char *)cmd, NULL, NULL, DOCMD_NOWAIT|DOCMD_KEYTYPED);
}
/// do_cmdline(): execute one Ex command line
@@ -301,10 +300,10 @@ int do_cmdline_cmd(const char *cmd)
/// @param cookie argument for fgetline()
///
/// @return FAIL if cmdline could not be executed, OK otherwise
-int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
+int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
{
- char_u *next_cmdline; // next cmd to execute
- char_u *cmdline_copy = NULL; // copy of cmd line
+ char *next_cmdline; // next cmd to execute
+ char *cmdline_copy = NULL; // copy of cmd line
bool used_getline = false; // used "fgetline" to obtain command
static int recursive = 0; // recursive depth
bool msg_didout_before_start = false;
@@ -316,7 +315,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
};
garray_T lines_ga; // keep lines for ":while"/":for"
int current_line = 0; // active line in lines_ga
- char_u *fname = NULL; // function or script name
+ char *fname = NULL; // function or script name
linenr_T *breakpoint = NULL; // ptr to breakpoint field in cookie
int *dbg_tick = NULL; // ptr to dbg_tick field in cookie
struct dbg_stuff debug_saved; // saved things for debug mode
@@ -369,11 +368,11 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// Get the function or script name and the address where the next breakpoint
// line and the debug tick for a function or script are stored.
if (getline_is_func) {
- fname = func_name(real_cookie);
+ fname = (char *)func_name(real_cookie);
breakpoint = func_breakpoint(real_cookie);
dbg_tick = func_dbg_tick(real_cookie);
} else if (getline_equal(fgetline, cookie, getsourceline)) {
- fname = sourcing_name;
+ fname = (char *)sourcing_name;
breakpoint = source_breakpoint(real_cookie);
dbg_tick = source_dbg_tick(real_cookie);
}
@@ -466,7 +465,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
if (breakpoint != NULL && dbg_tick != NULL
&& *dbg_tick != debug_tick) {
*breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline),
- fname, sourcing_lnum);
+ (char_u *)fname, sourcing_lnum);
*dbg_tick = debug_tick;
}
@@ -476,10 +475,10 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// Did we encounter a breakpoint?
if (breakpoint != NULL && *breakpoint != 0
&& *breakpoint <= sourcing_lnum) {
- dbg_breakpoint(fname, sourcing_lnum);
+ dbg_breakpoint((char_u *)fname, sourcing_lnum);
// Find next breakpoint.
*breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline),
- fname, sourcing_lnum);
+ (char_u *)fname, sourcing_lnum);
*dbg_tick = debug_tick;
}
if (do_profiling == PROF_YES) {
@@ -519,10 +518,10 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
msg_didout = true;
}
if (fgetline == NULL
- || (next_cmdline = fgetline(':', cookie,
- cstack.cs_idx <
- 0 ? 0 : (cstack.cs_idx + 1) * 2,
- true)) == NULL) {
+ || (next_cmdline = (char *)fgetline(':', cookie,
+ cstack.cs_idx <
+ 0 ? 0 : (cstack.cs_idx + 1) * 2,
+ true)) == NULL) {
// Don't call wait_return for aborted command line. The NULL
// returned for the end of a sourced file or executed function
// doesn't do this.
@@ -540,15 +539,14 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
if (flags & DOCMD_KEEPLINE) {
xfree(repeat_cmdline);
if (count == 0) {
- repeat_cmdline = vim_strsave(next_cmdline);
+ repeat_cmdline = vim_strsave((char_u *)next_cmdline);
} else {
repeat_cmdline = NULL;
}
}
- }
- // 3. Make a copy of the command so we can mess with it.
- else if (cmdline_copy == NULL) {
- next_cmdline = vim_strsave(next_cmdline);
+ } else if (cmdline_copy == NULL) {
+ // 3. Make a copy of the command so we can mess with it.
+ next_cmdline = xstrdup(next_cmdline);
}
cmdline_copy = next_cmdline;
@@ -560,7 +558,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
* :endwhile/:endfor.
*/
if (current_line == lines_ga.ga_len
- && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) {
+ && (cstack.cs_looplevel || has_loop_cmd((char_u *)next_cmdline))) {
store_loop_line(&lines_ga, next_cmdline);
}
did_endif = false;
@@ -593,9 +591,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
* "cmdline_copy" can change, e.g. for '%' and '#' expansion.
*/
recursive++;
- next_cmdline = do_one_cmd(&cmdline_copy, flags,
- &cstack,
- cmd_getline, cmd_cookie);
+ next_cmdline = do_one_cmd(&cmdline_copy, flags, &cstack, cmd_getline, cmd_cookie);
recursive--;
// Ignore trailing '|'-separated commands in preview-mode ('inccommand').
@@ -667,7 +663,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// or ":for".
if (breakpoint != NULL) {
*breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline),
- fname,
+ (char_u *)fname,
((wcmd_T *)lines_ga.ga_data)[current_line].lnum - 1);
*dbg_tick = debug_tick;
}
@@ -811,7 +807,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// commands are executed.
if (current_exception) {
char *p = NULL;
- char_u *saved_sourcing_name;
+ char *saved_sourcing_name;
linenr_T saved_sourcing_lnum;
struct msglist *messages = NULL;
struct msglist *next;
@@ -837,7 +833,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
break;
}
- saved_sourcing_name = sourcing_name;
+ saved_sourcing_name = (char *)sourcing_name;
saved_sourcing_lnum = sourcing_lnum;
sourcing_name = current_exception->throw_name;
sourcing_lnum = current_exception->throw_lnum;
@@ -861,7 +857,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
xfree(p);
}
xfree(sourcing_name);
- sourcing_name = saved_sourcing_name;
+ sourcing_name = (char_u *)saved_sourcing_name;
sourcing_lnum = saved_sourcing_lnum;
} else if (got_int || (did_emsg && force_abort)) {
// On an interrupt or an aborting error not converted to an exception,
@@ -958,7 +954,7 @@ static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat)
{
struct loop_cookie *cp = (struct loop_cookie *)cookie;
wcmd_T *wp;
- char_u *line;
+ char *line;
if (cp->current_line + 1 >= cp->lines_gap->ga_len) {
if (cp->repeating) {
@@ -966,30 +962,30 @@ static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat)
}
// First time inside the ":while"/":for": get line normally.
if (cp->getline == NULL) {
- line = getcmdline(c, 0L, indent, do_concat);
+ line = (char *)getcmdline(c, 0L, indent, do_concat);
} else {
- line = cp->getline(c, cp->cookie, indent, do_concat);
+ line = (char *)cp->getline(c, cp->cookie, indent, do_concat);
}
if (line != NULL) {
store_loop_line(cp->lines_gap, line);
++cp->current_line;
}
- return line;
+ return (char_u *)line;
}
KeyTyped = false;
cp->current_line++;
wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line;
sourcing_lnum = wp->lnum;
- return vim_strsave(wp->line);
+ return vim_strsave((char_u *)wp->line);
}
/// Store a line in "gap" so that a ":while" loop can execute it again.
-static void store_loop_line(garray_T *gap, char_u *line)
+static void store_loop_line(garray_T *gap, char *line)
{
wcmd_T *p = GA_APPEND_VIA_PTR(wcmd_T, gap);
- p->line = vim_strsave(line);
+ p->line = xstrdup(line);
p->lnum = sourcing_lnum;
}
@@ -1116,7 +1112,7 @@ static int current_tab_nr(tabpage_T *tab)
/// Figure out the address type for ":wincmd".
-static void get_wincmd_addr_type(char_u *arg, exarg_T *eap)
+static void get_wincmd_addr_type(char *arg, exarg_T *eap)
{
switch (*arg) {
case 'S':
@@ -1207,17 +1203,17 @@ static void get_wincmd_addr_type(char_u *arg, exarg_T *eap)
/// non-colon, non-whitespace character.
//
/// @param skipleadingwhite Skip leading whitespace too
-static char_u *skip_colon_white(const char_u *p, bool skipleadingwhite)
+static char *skip_colon_white(const char *p, bool skipleadingwhite)
{
if (skipleadingwhite) {
- p = skipwhite(p);
+ p = (char *)skipwhite((char_u *)p);
}
while (*p == ':') {
- p = skipwhite(p + 1);
+ p = (char *)skipwhite((char_u *)p + 1);
}
- return (char_u *)p;
+ return (char *)p;
}
/// Execute one Ex command.
@@ -1237,20 +1233,20 @@ static char_u *skip_colon_white(const char_u *p, bool skipleadingwhite)
/// This function may be called recursively!
///
/// @param cookie argument for fgetline()
-static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGetter fgetline,
- void *cookie)
+static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter fgetline,
+ void *cookie)
{
- char_u *p;
+ char *p;
linenr_T lnum;
long n;
char *errormsg = NULL; // error message
- char_u *after_modifier = NULL;
+ char *after_modifier = NULL;
exarg_T ea;
const int save_msg_scroll = msg_scroll;
cmdmod_T save_cmdmod;
const int save_reg_executing = reg_executing;
const bool save_pending_end_reg_executing = pending_end_reg_executing;
- char_u *cmd;
+ char *cmd;
memset(&ea, 0, sizeof(ea));
ea.line1 = 1;
@@ -1283,7 +1279,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
// The "ea" structure holds the arguments that can be used.
ea.cmd = *cmdlinep;
- ea.cmdlinep = cmdlinep;
+ ea.cmdlinep = (char_u **)cmdlinep;
ea.getline = fgetline;
ea.cookie = cookie;
ea.cstack = cstack;
@@ -1306,7 +1302,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
cmd = ea.cmd;
ea.cmd = skip_range(ea.cmd, NULL);
if (*ea.cmd == '*') {
- ea.cmd = skipwhite(ea.cmd + 1);
+ ea.cmd = (char *)skipwhite((char_u *)ea.cmd + 1);
}
p = find_command(&ea, NULL);
@@ -1375,7 +1371,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
}
// :wincmd range depends on the argument
if (ea.cmdidx == CMD_wincmd && p != NULL) {
- get_wincmd_addr_type(skipwhite(p), &ea);
+ get_wincmd_addr_type((char *)skipwhite((char_u *)p), &ea);
}
// :.cc in quickfix window uses line number
if ((ea.cmdidx == CMD_cc || ea.cmdidx == CMD_ll) && bt_quickfix(curbuf)) {
@@ -1402,7 +1398,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
* If we find a '|' or '\n' we set ea.nextcmd.
*/
if (*ea.cmd == NUL || *ea.cmd == '"'
- || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) {
+ || (ea.nextcmd = check_nextcmd((char_u *)ea.cmd)) != NULL) {
// strange vi behaviour:
// ":3" jumps to line 3
// ":3|..." prints line 3
@@ -1445,8 +1441,8 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
while (ASCII_ISALNUM(*p)) {
++p;
}
- p = vim_strnsave(ea.cmd, (size_t)(p - ea.cmd));
- int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, true, NULL);
+ p = xstrnsave(ea.cmd, (size_t)(p - ea.cmd));
+ int ret = apply_autocmds(EVENT_CMDUNDEFINED, (char_u *)p, (char_u *)p, true, NULL);
xfree(p);
// If the autocommands did something and didn't cause an error, try
// finding the command again.
@@ -1465,7 +1461,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
STRCPY(IObuff, _("E492: Not an editor command"));
// If the modifier was parsed OK the error must be in the following
// command
- char_u *cmdname = after_modifier ? after_modifier : *cmdlinep;
+ char *cmdname = after_modifier ? after_modifier : *cmdlinep;
if (!(flags & DOCMD_VERBOSE)) {
append_command(cmdname);
}
@@ -1598,9 +1594,9 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
* Don't do this for the ":!" command, because ":!! -l" needs the space.
*/
if (ea.cmdidx == CMD_bang) {
- ea.arg = p;
+ ea.arg = (char_u *)p;
} else {
- ea.arg = skipwhite(p);
+ ea.arg = skipwhite((char_u *)p);
}
// ":file" cannot be run with an argument when "curbuf->b_ro_locked" is set
@@ -1647,9 +1643,9 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) {
ea.amount = 1;
- while (*ea.arg == *ea.cmd) { // count number of '>' or '<'
- ++ea.arg;
- ++ea.amount;
+ while (*ea.arg == (char_u)(*ea.cmd)) { // count number of '>' or '<'
+ ea.arg++;
+ ea.amount++;
}
ea.arg = skipwhite(ea.arg);
}
@@ -1659,7 +1655,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
* Don't do this for ":read !cmd" and ":write !cmd".
*/
if ((ea.argt & EX_CMDARG) && !ea.usefilter) {
- ea.do_ecmd_cmd = getargcmd(&ea.arg);
+ ea.do_ecmd_cmd = (char_u *)getargcmd((char **)&ea.arg);
}
/*
@@ -1676,7 +1672,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
// Check for <newline> to end a shell command.
// Also do this for ":read !cmd", ":write !cmd" and ":global".
// Any others?
- for (p = ea.arg; *p; p++) {
+ for (p = (char *)ea.arg; *p; p++) {
// Remove one backslash before a newline, so that it's possible to
// pass a newline to the shell and also a newline that is preceded
// with a backslash. This makes it impossible to end a shell
@@ -1686,7 +1682,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
if (*p == '\\' && p[1] == '\n') {
STRMOVE(p, p + 1);
} else if (*p == '\n') {
- ea.nextcmd = p + 1;
+ ea.nextcmd = (char_u *)p + 1;
*p = NUL;
break;
}
@@ -1774,7 +1770,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
// count, it's a buffer name.
///
if ((ea.argt & EX_COUNT) && ascii_isdigit(*ea.arg)
- && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL
+ && (!(ea.argt & EX_BUFNAME) || *(p = (char *)skipdigits(ea.arg + 1)) == NUL
|| ascii_iswhite(*p))) {
n = getdigits_long(&ea.arg, false, -1);
ea.arg = skipwhite(ea.arg);
@@ -1915,7 +1911,7 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
}
if (ea.argt & EX_XFILE) {
- if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) {
+ if (expand_filename(&ea, (char_u **)cmdlinep, &errormsg) == FAIL) {
goto doend;
}
}
@@ -1933,20 +1929,20 @@ static char_u *do_one_cmd(char_u **cmdlinep, int flags, cstack_T *cstack, LineGe
*/
if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout
|| ea.cmdidx == CMD_bunload) {
- p = skiptowhite_esc(ea.arg);
+ p = (char *)skiptowhite_esc(ea.arg);
} else {
- p = ea.arg + STRLEN(ea.arg);
- while (p > ea.arg && ascii_iswhite(p[-1])) {
- --p;
+ p = (char *)ea.arg + STRLEN(ea.arg);
+ while ((char_u *)p > ea.arg && ascii_iswhite(p[-1])) {
+ p--;
}
}
- ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
+ ea.line2 = buflist_findpat(ea.arg, (char_u *)p, (ea.argt & EX_BUFUNL) != 0,
false, false);
if (ea.line2 < 0) { // failed
goto doend;
}
ea.addr_count = 1;
- ea.arg = skipwhite(p);
+ ea.arg = skipwhite((char_u *)p);
}
// The :try command saves the emsg_silent flag, reset it here when
@@ -2032,15 +2028,15 @@ doend:
--ex_nesting_level;
- return ea.nextcmd;
-}
+ return (char *)ea.nextcmd;
+} // NOLINT(readability/fn_size)
static char ex_error_buf[MSG_BUF_LEN];
/// @return an error message with argument included.
/// Uses a static buffer, only the last error will be kept.
/// "msg" will be translated, caller should use N_().
-char *ex_errmsg(const char *const msg, const char_u *const arg)
+char *ex_errmsg(const char *const msg, const char *const arg)
FUNC_ATTR_NONNULL_ALL
{
vim_snprintf(ex_error_buf, MSG_BUF_LEN, _(msg), arg);
@@ -2063,7 +2059,7 @@ char *ex_errmsg(const char *const msg, const char_u *const arg)
/// @return FAIL when the command is not to be executed.
int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
{
- char_u *p;
+ char *p;
memset(&cmdmod, 0, sizeof(cmdmod));
eap->verbose_save = -1;
@@ -2081,7 +2077,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
if (*eap->cmd == NUL && exmode_active
&& getline_equal(eap->getline, eap->cookie, getexline)
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
- eap->cmd = (char_u *)"+";
+ eap->cmd = "+";
if (!skip_only) {
ex_pressedreturn = true;
}
@@ -2150,29 +2146,29 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
continue;
case 'f': { // only accept ":filter {pat} cmd"
- char_u *reg_pat;
+ char *reg_pat;
if (!checkforcmd(&p, "filter", 4) || *p == NUL || ends_excmd(*p)) {
break;
}
if (*p == '!') {
cmdmod.filter_force = true;
- p = skipwhite(p + 1);
+ p = (char *)skipwhite((char_u *)p + 1);
if (*p == NUL || ends_excmd(*p)) {
break;
}
}
if (skip_only) {
- p = skip_vimgrep_pat(p, NULL, NULL);
+ p = (char *)skip_vimgrep_pat((char_u *)p, NULL, NULL);
} else {
// NOTE: This puts a NUL after the pattern.
- p = skip_vimgrep_pat(p, &reg_pat, NULL);
+ p = (char *)skip_vimgrep_pat((char_u *)p, (char_u **)&reg_pat, NULL);
}
if (p == NULL || *p == NUL) {
break;
}
if (!skip_only) {
- cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
+ cmdmod.filter_regmatch.regprog = vim_regcomp((char_u *)reg_pat, RE_MAGIC);
if (cmdmod.filter_regmatch.regprog == NULL) {
break;
}
@@ -2248,7 +2244,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
}
if (*eap->cmd == '!' && !ascii_iswhite(eap->cmd[-1])) {
// ":silent!", but not "silent !cmd"
- eap->cmd = skipwhite(eap->cmd + 1);
+ eap->cmd = (char *)skipwhite((char_u *)eap->cmd + 1);
if (!skip_only) {
emsg_silent++;
eap->did_esilent++;
@@ -2259,7 +2255,8 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
case 't':
if (checkforcmd(&p, "tab", 3)) {
if (!skip_only) {
- int tabnr = (int)get_address(eap, &eap->cmd, ADDR_TABS, eap->skip, skip_only, false, 1);
+ int tabnr = (int)get_address(eap, &eap->cmd, ADDR_TABS, eap->skip, skip_only,
+ false, 1);
if (tabnr == MAXLNUM) {
cmdmod.tab = tabpage_index(curtab) + 1;
@@ -2305,7 +2302,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
eap->verbose_save = p_verbose;
}
if (ascii_isdigit(*eap->cmd)) {
- p_verbose = atoi((char *)eap->cmd);
+ p_verbose = atoi(eap->cmd);
} else {
p_verbose = 1;
}
@@ -2412,7 +2409,7 @@ int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent)
// Will give an error later if a range is found.
break;
}
- eap->cmd = skipwhite(eap->cmd);
+ eap->cmd = (char *)skipwhite((char_u *)eap->cmd);
lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
eap->addr_count == 0, address_count++);
if (eap->cmd == NULL) { // error detected
@@ -2542,18 +2539,18 @@ int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent)
/// @param pp start of command
/// @param cmd name of command
/// @param len required length
-int checkforcmd(char_u **pp, char *cmd, int len)
+int checkforcmd(char **pp, char *cmd, int len)
{
int i;
- for (i = 0; cmd[i] != NUL; ++i) {
- if (((char_u *)cmd)[i] != (*pp)[i]) {
+ for (i = 0; cmd[i] != NUL; i++) {
+ if ((cmd)[i] != (*pp)[i]) {
break;
}
}
if (i >= len && !isalpha((*pp)[i])) {
- *pp = skipwhite(*pp + i);
- return TRUE;
+ *pp = (char *)skipwhite((char_u *)(*pp) + i);
+ return true;
}
return FALSE;
}
@@ -2561,20 +2558,20 @@ int checkforcmd(char_u **pp, char *cmd, int len)
/// Append "cmd" to the error message in IObuff.
/// Takes care of limiting the length and handling 0xa0, which would be
/// invisible otherwise.
-static void append_command(char_u *cmd)
+static void append_command(char *cmd)
{
- char_u *s = cmd;
- char_u *d;
+ char *s = cmd;
+ char *d;
STRCAT(IObuff, ": ");
- d = IObuff + STRLEN(IObuff);
- while (*s != NUL && d - IObuff < IOSIZE - 7) {
- if (s[0] == 0xc2 && s[1] == 0xa0) {
+ d = (char *)IObuff + STRLEN(IObuff);
+ while (*s != NUL && (char_u *)d - IObuff < IOSIZE - 7) {
+ if ((char_u)s[0] == 0xc2 && (char_u)s[1] == 0xa0) {
s += 2;
STRCPY(d, "<a0>");
d += 4;
} else {
- mb_copy_char((const char_u **)&s, &d);
+ mb_copy_char((const char_u **)&s, (char_u **)&d);
}
}
*d = NUL;
@@ -2586,11 +2583,11 @@ static void append_command(char_u *cmd)
/// "full" is set to TRUE if the whole command name matched.
///
/// @return NULL for an ambiguous user command.
-static char_u *find_command(exarg_T *eap, int *full)
+static char *find_command(exarg_T *eap, int *full)
FUNC_ATTR_NONNULL_ARG(1)
{
int len;
- char_u *p;
+ char *p;
int i;
/*
@@ -2631,14 +2628,14 @@ static char_u *find_command(exarg_T *eap, int *full)
// check for non-alpha command
if (p == eap->cmd && vim_strchr((char_u *)"@!=><&~#", *p) != NULL) {
- ++p;
+ p++;
}
len = (int)(p - eap->cmd);
if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) {
// Check for ":dl", ":dell", etc. to ":deletel": that's
// :delete with the 'l' flag. Same for 'p'.
for (i = 0; i < len; i++) {
- if (eap->cmd[i] != ((char_u *)"delete")[i]) {
+ if (eap->cmd[i] != ("delete")[i]) {
break;
}
}
@@ -2653,7 +2650,7 @@ static char_u *find_command(exarg_T *eap, int *full)
}
if (ASCII_ISLOWER(eap->cmd[0])) {
- const int c1 = eap->cmd[0];
+ const int c1 = (char_u)eap->cmd[0];
const int c2 = len == 1 ? NUL : eap->cmd[1];
if (command_count != CMD_SIZE) {
@@ -2709,14 +2706,14 @@ static char_u *find_command(exarg_T *eap, int *full)
/// @param full set to TRUE for a full match
/// @param xp used for completion, NULL otherwise
/// @param complp completion flags or NULL
-static char_u *find_ucmd(exarg_T *eap, char_u *p, int *full, expand_T *xp, int *complp)
+static char *find_ucmd(exarg_T *eap, char *p, int *full, expand_T *xp, int *complp)
{
int len = (int)(p - eap->cmd);
int j, k, matchlen = 0;
ucmd_T *uc;
bool found = false;
bool possible = false;
- char_u *cp, *np; // Point into typed cmd and test name
+ char *cp, *np; // Point into typed cmd and test name
garray_T *gap;
bool amb_local = false; // Found ambiguous buffer-local command,
// only full match global is accepted.
@@ -2727,7 +2724,7 @@ static char_u *find_ucmd(exarg_T *eap, char_u *p, int *full, expand_T *xp, int *
for (j = 0; j < gap->ga_len; j++) {
uc = USER_CMD_GA(gap, j);
cp = eap->cmd;
- np = uc->uc_name;
+ np = (char *)uc->uc_name;
k = 0;
while (k < len && *np != NUL && *cp++ == *np++) {
k++;
@@ -2841,17 +2838,17 @@ static struct cmdmod {
/// @return length of a command modifier (including optional count) or,
/// zero when it's not a modifier.
-int modifier_len(char_u *cmd)
+int modifier_len(char *cmd)
{
- char_u *p = cmd;
+ char *p = cmd;
if (ascii_isdigit(*cmd)) {
- p = skipwhite(skipdigits(cmd + 1));
+ p = (char *)skipwhite(skipdigits((char_u *)cmd + 1));
}
for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) {
int j;
for (j = 0; p[j] != NUL; j++) {
- if (p[j] != (char_u)cmdmods[i].name[j]) {
+ if (p[j] != cmdmods[i].name[j]) {
break;
}
}
@@ -2870,7 +2867,7 @@ int modifier_len(char_u *cmd)
int cmd_exists(const char *const name)
{
exarg_T ea;
- char_u *p;
+ char *p;
// Check command modifiers.
for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) {
@@ -2887,7 +2884,7 @@ int cmd_exists(const char *const name)
// Check built-in commands and user defined commands.
// For ":2match" and ":3match" we need to skip the number.
- ea.cmd = (char_u *)((*name == '2' || *name == '3') ? name + 1 : name);
+ ea.cmd = (char *)((*name == '2' || *name == '3') ? name + 1 : name);
ea.cmdidx = (cmdidx_T)0;
int full = false;
p = find_command(&ea, &full);
@@ -2897,7 +2894,7 @@ int cmd_exists(const char *const name)
if (ascii_isdigit(*name) && ea.cmdidx != CMD_match) {
return 0;
}
- if (*skipwhite(p) != NUL) {
+ if (*skipwhite((char_u *)p) != NUL) {
return 0; // trailing garbage
}
return ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1);
@@ -2907,7 +2904,7 @@ int cmd_exists(const char *const name)
void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
exarg_T ea;
- char_u *name = argvars[0].vval.v_string;
+ char *name = (char *)argvars[0].vval.v_string;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -2922,13 +2919,13 @@ void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
- char_u *p = find_command(&ea, NULL);
+ char *p = find_command(&ea, NULL);
if (p == NULL || ea.cmdidx == CMD_SIZE) {
return;
}
rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
- ? get_user_command_name(ea.useridx, ea.cmdidx)
+ ? (char_u *)get_user_command_name(ea.useridx, ea.cmdidx)
: cmdnames[ea.cmdidx].cmd_name);
}
@@ -2969,7 +2966,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
/*
* 3. parse a range specifier of the form: addr [,addr] [;addr] ..
*/
- cmd = (const char *)skip_range((const char_u *)cmd, &xp->xp_context);
+ cmd = (const char *)skip_range(cmd, &xp->xp_context);
/*
* 4. parse command
@@ -3052,8 +3049,8 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
ea.cmdidx = CMD_substitute;
p = cmd + 1;
} else if (cmd[0] >= 'A' && cmd[0] <= 'Z') {
- ea.cmd = (char_u *)cmd;
- p = (const char *)find_ucmd(&ea, (char_u *)p, NULL, xp, &context);
+ ea.cmd = (char *)cmd;
+ p = (const char *)find_ucmd(&ea, (char *)p, NULL, xp, &context);
if (p == NULL) {
ea.cmdidx = CMD_SIZE; // Ambiguous user command.
}
@@ -3121,7 +3118,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+') {
// Check if we're in the +command
p = arg + 1;
- arg = (const char *)skip_cmd_arg((char_u *)arg, false);
+ arg = (const char *)skip_cmd_arg((char *)arg, false);
// Still touching the command after '+'?
if (*arg == NUL) {
@@ -3820,7 +3817,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
/// @param ctx pointer to xp_context or NULL
///
/// @return the "cmd" pointer advanced to beyond the range.
-char_u *skip_range(const char_u *cmd, int *ctx)
+char *skip_range(const char *cmd, int *ctx)
{
unsigned delim;
@@ -3836,8 +3833,8 @@ char_u *skip_range(const char_u *cmd, int *ctx)
*ctx = EXPAND_NOTHING;
}
} else if (*cmd == '/' || *cmd == '?') {
- delim = *cmd++;
- while (*cmd != NUL && *cmd != delim) {
+ delim = (unsigned)(*cmd++);
+ while (*cmd != NUL && *cmd != (char)delim) {
if (*cmd++ == '\\' && *cmd != NUL) {
++cmd;
}
@@ -3852,9 +3849,9 @@ char_u *skip_range(const char_u *cmd, int *ctx)
}
// Skip ":" and white space.
- cmd = skip_colon_white(cmd, false);
+ cmd = skip_colon_white((char *)cmd, false);
- return (char_u *)cmd;
+ return (char *)cmd;
}
static void addr_error(cmd_addr_T addr_type)
@@ -3878,20 +3875,20 @@ static void addr_error(cmd_addr_T addr_type)
/// @param address_count 1 for first, >1 after comma
///
/// @return MAXLNUM when no Ex address was found.
-static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, int skip, bool silent,
+static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int skip, bool silent,
int to_other_file, int address_count)
FUNC_ATTR_NONNULL_ALL
{
int c;
int i;
long n;
- char_u *cmd;
+ char *cmd;
pos_T pos;
pos_T *fp;
linenr_T lnum;
buf_T *buf;
- cmd = skipwhite(*ptr);
+ cmd = (char *)skipwhite((char_u *)(*ptr));
lnum = MAXLNUM;
do {
switch (*cmd) {
@@ -4014,14 +4011,14 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
case '/':
case '?': // '/' or '?' - search
- c = *cmd++;
+ c = (char_u)(*cmd++);
if (addr_type != ADDR_LINES) {
addr_error(addr_type);
cmd = NULL;
goto error;
}
if (skip) { // skip "/pat/"
- cmd = skip_regexp(cmd, c, p_magic, NULL);
+ cmd = (char *)skip_regexp((char_u *)cmd, c, p_magic, NULL);
if (*cmd == c) {
++cmd;
}
@@ -4050,7 +4047,7 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
}
searchcmdlen = 0;
flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
- if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) {
+ if (!do_search(NULL, c, c, (char_u *)cmd, 1L, flags, NULL)) {
curwin->w_cursor = pos;
cmd = NULL;
goto error;
@@ -4099,12 +4096,12 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
default:
if (ascii_isdigit(*cmd)) { // absolute line number
- lnum = getdigits_long(&cmd, false, 0);
+ lnum = getdigits_long((char_u **)&cmd, false, 0);
}
}
for (;;) {
- cmd = skipwhite(cmd);
+ cmd = (char *)skipwhite((char_u *)cmd);
if (*cmd != '-' && *cmd != '+' && !ascii_isdigit(*cmd)) {
break;
}
@@ -4148,12 +4145,12 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
if (ascii_isdigit(*cmd)) {
i = '+'; // "number" is same as "+number"
} else {
- i = *cmd++;
+ i = (char_u)(*cmd++);
}
if (!ascii_isdigit(*cmd)) { // '+' is '+1', but '+0' is not '+1'
n = 1;
} else {
- n = getdigits(&cmd, false, MAXLNUM);
+ n = getdigits((char_u **)&cmd, false, MAXLNUM);
if (n == MAXLNUM) {
emsg(_(e_line_number_out_of_range));
goto error;
@@ -4330,17 +4327,17 @@ static void correct_range(exarg_T *eap)
/// For a ":vimgrep" or ":vimgrepadd" command return a pointer past the
/// pattern. Otherwise return eap->arg.
-static char_u *skip_grep_pat(exarg_T *eap)
+static char *skip_grep_pat(exarg_T *eap)
{
- char_u *p = eap->arg;
+ char *p = (char *)eap->arg;
if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep
|| eap->cmdidx == CMD_vimgrepadd
|| eap->cmdidx == CMD_lvimgrepadd
|| grep_internal(eap->cmdidx))) {
- p = skip_vimgrep_pat(p, NULL, NULL);
+ p = (char *)skip_vimgrep_pat((char_u *)p, NULL, NULL);
if (p == NULL) {
- p = eap->arg;
+ p = (char *)eap->arg;
}
}
return p;
@@ -4348,12 +4345,12 @@ static char_u *skip_grep_pat(exarg_T *eap)
/// For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option
/// in the command line, so that things like % get expanded.
-static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
+static char *replace_makeprg(exarg_T *eap, char *p, char **cmdlinep)
{
- char_u *new_cmdline;
- char_u *program;
- char_u *pos;
- char_u *ptr;
+ char *new_cmdline;
+ char *program;
+ char *pos;
+ char *ptr;
int len;
size_t i;
@@ -4368,30 +4365,30 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep
|| eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) {
if (*curbuf->b_p_gp == NUL) {
- program = p_gp;
+ program = (char *)p_gp;
} else {
- program = curbuf->b_p_gp;
+ program = (char *)curbuf->b_p_gp;
}
} else {
if (*curbuf->b_p_mp == NUL) {
- program = p_mp;
+ program = (char *)p_mp;
} else {
- program = curbuf->b_p_mp;
+ program = (char *)curbuf->b_p_mp;
}
}
- p = skipwhite(p);
+ p = (char *)skipwhite((char_u *)p);
- if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) {
+ if ((pos = strstr(program, "$*")) != NULL) {
// replace $* by given arguments
i = 1;
- while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) {
- ++i;
+ while ((pos = strstr(pos + 2, "$*")) != NULL) {
+ i++;
}
len = (int)STRLEN(p);
new_cmdline = xmalloc(STRLEN(program) + i * (size_t)(len - 2) + 1);
ptr = new_cmdline;
- while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) {
+ while ((pos = strstr(program, "$*")) != NULL) {
i = (size_t)(pos - program);
memcpy(ptr, program, i);
STRCPY(ptr += i, p);
@@ -4405,7 +4402,7 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
STRCAT(new_cmdline, " ");
STRCAT(new_cmdline, p);
}
- msg_make(p);
+ msg_make((char_u *)p);
// 'eap->cmd' is not set here, because it is not used at CMD_make
xfree(*cmdlinep);
@@ -4422,9 +4419,9 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
{
int has_wildcards; // need to expand wildcards
- char_u *repl;
+ char *repl;
size_t srclen;
- char_u *p;
+ char *p;
int escaped;
// Skip a regexp pattern for ":vimgrep[add] pat file..."
@@ -4435,12 +4432,12 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
* the file name contains a wildcard it should not cause expanding.
* (it will be expanded anyway if there is a wildcard before replacing).
*/
- has_wildcards = path_has_wildcard(p);
+ has_wildcards = path_has_wildcard((char_u *)p);
while (*p != NUL) {
// Skip over `=expr`, wildcards in it are not expanded.
if (p[0] == '`' && p[1] == '=') {
p += 2;
- (void)skip_expr(&p);
+ (void)skip_expr((char_u **)&p);
if (*p == '`') {
++p;
}
@@ -4458,8 +4455,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
/*
* Try to find a match at this position.
*/
- repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
- errormsgp, &escaped);
+ repl = (char *)eval_vars((char_u *)p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
+ errormsgp, &escaped);
if (*errormsgp != NULL) { // error detected
return FAIL;
}
@@ -4470,10 +4467,10 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
// Wildcards won't be expanded below, the replacement is taken
// literally. But do expand "~/file", "~user/file" and "$HOME/file".
- if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) {
- char_u *l = repl;
+ if (vim_strchr((char_u *)repl, '$') != NULL || vim_strchr((char_u *)repl, '~') != NULL) {
+ char *l = repl;
- repl = expand_env_save(repl);
+ repl = (char *)expand_env_save((char_u *)repl);
xfree(l);
}
@@ -4493,11 +4490,11 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
&& eap->cmdidx != CMD_make
&& eap->cmdidx != CMD_terminal
&& !(eap->argt & EX_NOSPC)) {
- char_u *l;
+ char *l;
#ifdef BACKSLASH_IN_FILENAME
// Don't escape a backslash here, because rem_backslash() doesn't
// remove it later.
- static char_u *nobslash = (char_u *)" \t\"|";
+ static char *nobslash = " \t\"|";
# define ESCAPE_CHARS nobslash
#else
# define ESCAPE_CHARS escape_chars
@@ -4505,7 +4502,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
for (l = repl; *l; ++l) {
if (vim_strchr(ESCAPE_CHARS, *l) != NULL) {
- l = vim_strsave_escaped(repl, ESCAPE_CHARS);
+ l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS);
xfree(repl);
repl = l;
break;
@@ -4517,15 +4514,15 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
if ((eap->usefilter
|| eap->cmdidx == CMD_bang
|| eap->cmdidx == CMD_terminal)
- && strpbrk((char *)repl, "!") != NULL) {
- char_u *l;
+ && strpbrk(repl, "!") != NULL) {
+ char *l;
- l = vim_strsave_escaped(repl, (char_u *)"!");
+ l = (char *)vim_strsave_escaped((char_u *)repl, (char_u *)"!");
xfree(repl);
repl = l;
}
- p = repl_cmdline(eap, p, srclen, repl, cmdlinep);
+ p = repl_cmdline(eap, p, srclen, repl, (char **)cmdlinep);
xfree(repl);
}
@@ -4547,12 +4544,12 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
|| vim_strchr(eap->arg, '~') != NULL) {
expand_env_esc(eap->arg, NameBuff, MAXPATHL, true, true, NULL);
has_wildcards = path_has_wildcard(NameBuff);
- p = NameBuff;
+ p = (char *)NameBuff;
} else {
p = NULL;
}
if (p != NULL) {
- (void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, cmdlinep);
+ (void)repl_cmdline(eap, (char *)eap->arg, STRLEN(eap->arg), p, (char **)cmdlinep);
}
}
@@ -4575,11 +4572,11 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
if (p_wic) {
options += WILD_ICASE;
}
- p = ExpandOne(&xpc, eap->arg, NULL, options, WILD_EXPAND_FREE);
+ p = (char *)ExpandOne(&xpc, eap->arg, NULL, options, WILD_EXPAND_FREE);
if (p == NULL) {
return FAIL;
}
- (void)repl_cmdline(eap, eap->arg, STRLEN(eap->arg), p, cmdlinep);
+ (void)repl_cmdline(eap, (char *)eap->arg, STRLEN(eap->arg), p, (char **)cmdlinep);
xfree(p);
}
}
@@ -4592,8 +4589,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
/// "repl" is the replacement string.
///
/// @return a pointer to the character after the replaced string.
-static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen, char_u *repl,
- char_u **cmdlinep)
+static char *repl_cmdline(exarg_T *eap, char *src, size_t srclen, char *repl, char **cmdlinep)
{
/*
* The new command line is build in new_cmdline[].
@@ -4605,7 +4601,7 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen, char_u *re
if (eap->nextcmd != NULL) {
i += STRLEN(eap->nextcmd); // add space for next command
}
- char_u *new_cmdline = xmalloc(i);
+ char *new_cmdline = xmalloc(i);
/*
* Copy the stuff before the expanded part.
@@ -4624,12 +4620,12 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen, char_u *re
if (eap->nextcmd != NULL) { // append next command
i = STRLEN(new_cmdline) + 1;
STRCPY(new_cmdline + i, eap->nextcmd);
- eap->nextcmd = new_cmdline + i;
+ eap->nextcmd = (char_u *)new_cmdline + i;
}
eap->cmd = new_cmdline + (eap->cmd - *cmdlinep);
- eap->arg = new_cmdline + (eap->arg - *cmdlinep);
- if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) {
- eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep);
+ eap->arg = (char_u *)new_cmdline + ((char *)eap->arg - *cmdlinep);
+ if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != (char_u *)dollar_command) {
+ eap->do_ecmd_cmd = (char_u *)new_cmdline + ((char *)eap->do_ecmd_cmd - *cmdlinep);
}
xfree(*cmdlinep);
*cmdlinep = new_cmdline;
@@ -4640,9 +4636,7 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen, char_u *re
/// Check for '|' to separate commands and '"' to start comments.
void separate_nextcmd(exarg_T *eap)
{
- char_u *p;
-
- p = skip_grep_pat(eap);
+ char *p = skip_grep_pat(eap);
for (; *p; MB_PTR_ADV(p)) {
if (*p == Ctrl_V) {
@@ -4658,7 +4652,7 @@ void separate_nextcmd(exarg_T *eap)
} else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) {
// Skip over `=expr` when wildcards are expanded.
p += 2;
- (void)skip_expr(&p);
+ (void)skip_expr((char_u **)&p);
if (*p == NUL) { // stop at NUL after CTRL-V
break;
}
@@ -4668,11 +4662,9 @@ void separate_nextcmd(exarg_T *eap)
// :redir @" doesn't either.
(*p == '"'
&& !(eap->argt & EX_NOTRLCOM)
- && (eap->cmdidx != CMD_at || p != eap->arg)
+ && (eap->cmdidx != CMD_at || (char_u *)p != eap->arg)
&& (eap->cmdidx != CMD_redir
- || p != eap->arg + 1 || p[-1] != '@'))
- || *p == '|'
- || *p == '\n') {
+ || (char_u *)p != eap->arg + 1 || p[-1] != '@')) || *p == '|' || *p == '\n') {
// We remove the '\' before the '|', unless EX_CTRLV is used
// AND 'b' is present in 'cpoptions'.
if ((vim_strchr(p_cpo, CPO_BAR) == NULL
@@ -4680,7 +4672,7 @@ void separate_nextcmd(exarg_T *eap)
STRMOVE(p - 1, p); // remove the '\'
p--;
} else {
- eap->nextcmd = check_nextcmd(p);
+ eap->nextcmd = check_nextcmd((char_u *)p);
*p = NUL;
break;
}
@@ -4693,15 +4685,15 @@ void separate_nextcmd(exarg_T *eap)
}
/// get + command from ex argument
-static char_u *getargcmd(char_u **argp)
+static char *getargcmd(char **argp)
{
- char_u *arg = *argp;
- char_u *command = NULL;
+ char *arg = *argp;
+ char *command = NULL;
if (*arg == '+') { // +[command]
++arg;
if (ascii_isspace(*arg) || *arg == '\0') {
- command = dollar_command;
+ command = (char *)dollar_command;
} else {
command = arg;
arg = skip_cmd_arg(command, TRUE);
@@ -4710,7 +4702,7 @@ static char_u *getargcmd(char_u **argp)
}
}
- arg = skipwhite(arg); // skip over spaces
+ arg = (char *)skipwhite((char_u *)arg); // skip over spaces
*argp = arg;
}
return command;
@@ -4719,7 +4711,7 @@ static char_u *getargcmd(char_u **argp)
/// Find end of "+command" argument. Skip over "\ " and "\\".
///
/// @param rembs TRUE to halve the number of backslashes
-static char_u *skip_cmd_arg(char_u *p, int rembs)
+static char *skip_cmd_arg(char *p, int rembs)
{
while (*p && !ascii_isspace(*p)) {
if (*p == '\\' && p[1] != NUL) {
@@ -4754,10 +4746,10 @@ int get_bad_opt(const char_u *p, exarg_T *eap)
/// @return FAIL or OK.
static int getargopt(exarg_T *eap)
{
- char_u *arg = eap->arg + 2;
+ char *arg = (char *)eap->arg + 2;
int *pp = NULL;
int bad_char_idx;
- char_u *p;
+ char *p;
// ":edit ++[no]bin[ary] file"
if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) {
@@ -4770,14 +4762,14 @@ static int getargopt(exarg_T *eap)
if (!checkforcmd(&arg, "binary", 3)) {
return FAIL;
}
- eap->arg = skipwhite(arg);
+ eap->arg = skipwhite((char_u *)arg);
return OK;
}
// ":read ++edit file"
if (STRNCMP(arg, "edit", 4) == 0) {
- eap->read_edit = TRUE;
- eap->arg = skipwhite(arg + 4);
+ eap->read_edit = true;
+ eap->arg = skipwhite((char_u *)arg + 4);
return OK;
}
@@ -4803,26 +4795,26 @@ static int getargopt(exarg_T *eap)
return FAIL;
}
- ++arg;
+ arg++;
*pp = (int)(arg - eap->cmd);
- arg = skip_cmd_arg(arg, FALSE);
- eap->arg = skipwhite(arg);
+ arg = skip_cmd_arg(arg, false);
+ eap->arg = skipwhite((char_u *)arg);
*arg = NUL;
if (pp == &eap->force_ff) {
- if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) {
+ if (check_ff_value((char_u *)eap->cmd + eap->force_ff) == FAIL) {
return FAIL;
}
- eap->force_ff = eap->cmd[eap->force_ff];
+ eap->force_ff = (char_u)eap->cmd[eap->force_ff];
} else if (pp == &eap->force_enc) {
// Make 'fileencoding' lower case.
for (p = eap->cmd + eap->force_enc; *p != NUL; p++) {
- *p = (char_u)TOLOWER_ASC(*p);
+ *p = (char)TOLOWER_ASC(*p);
}
} else {
// Check ++bad= argument. Must be a single-byte character, "keep" or
// "drop".
- if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) {
+ if (get_bad_opt((char_u *)eap->cmd + bad_char_idx, eap) == FAIL) {
return FAIL;
}
}
@@ -4840,8 +4832,8 @@ static int get_tabpage_arg(exarg_T *eap)
int unaccept_arg0 = (eap->cmdidx == CMD_tabmove) ? 0 : 1;
if (eap->arg && *eap->arg != NUL) {
- char_u *p = eap->arg;
- char_u *p_save;
+ char *p = (char *)eap->arg;
+ char *p_save;
int relative = 0; // argument +N/-N means: go to N places to the
// right/left relative to the current position.
@@ -4854,7 +4846,7 @@ static int get_tabpage_arg(exarg_T *eap)
}
p_save = p;
- tab_number = (int)getdigits(&p, false, tab_number);
+ tab_number = (int)getdigits((char_u **)&p, false, tab_number);
if (relative == 0) {
if (STRCMP(p, "$") == 0) {
@@ -4863,7 +4855,7 @@ static int get_tabpage_arg(exarg_T *eap)
if (valid_tabpage(lastused_tabpage)) {
tab_number = tabpage_index(lastused_tabpage);
} else {
- eap->errmsg = ex_errmsg(e_invargval, eap->arg);
+ eap->errmsg = ex_errmsg(e_invargval, (char *)eap->arg);
tab_number = 0;
goto theend;
}
@@ -4937,7 +4929,7 @@ static void ex_map(exarg_T *eap)
*/
if (secure) {
secure = 2;
- msg_outtrans(eap->cmd);
+ msg_outtrans((char_u *)eap->cmd);
msg_putchar('\n');
}
do_exmap(eap, FALSE);
@@ -4952,13 +4944,13 @@ static void ex_unmap(exarg_T *eap)
/// ":mapclear" and friends.
static void ex_mapclear(exarg_T *eap)
{
- map_clear_mode(eap->cmd, eap->arg, eap->forceit, false);
+ map_clear_mode((char_u *)eap->cmd, eap->arg, eap->forceit, false);
}
/// ":abclear" and friends.
static void ex_abclear(exarg_T *eap)
{
- map_clear_mode(eap->cmd, eap->arg, true, true);
+ map_clear_mode((char_u *)eap->cmd, eap->arg, true, true);
}
static void ex_autocmd(exarg_T *eap)
@@ -4978,11 +4970,11 @@ static void ex_autocmd(exarg_T *eap)
/// ":doautocmd": Apply the automatic commands to the current buffer.
static void ex_doautocmd(exarg_T *eap)
{
- char_u *arg = eap->arg;
- int call_do_modelines = check_nomodeline(&arg);
+ char *arg = (char *)eap->arg;
+ int call_do_modelines = check_nomodeline((char_u **)&arg);
bool did_aucmd;
- (void)do_doautocmd(arg, false, &did_aucmd);
+ (void)do_doautocmd((char_u *)arg, false, &did_aucmd);
// Only when there is no <nomodeline>.
if (call_do_modelines && did_aucmd) {
do_modelines(0);
@@ -5096,10 +5088,10 @@ char_u *find_nextcmd(const char_u *p)
/// @return NULL if it isn't, the following character if it is.
char_u *check_nextcmd(char_u *p)
{
- char_u *s = skipwhite(p);
+ char *s = (char *)skipwhite(p);
if (*s == '|' || *s == '\n') {
- return (s + 1);
+ return (char_u *)(s + 1);
} else {
return NULL;
}
@@ -5121,12 +5113,12 @@ static int check_more(int message, bool forceit)
&& ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) {
if (message) {
if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) {
- char_u buff[DIALOG_MSG_SIZE];
+ char buff[DIALOG_MSG_SIZE];
vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
NGETTEXT("%d more file to edit. Quit anyway?",
"%d more files to edit. Quit anyway?", (unsigned long)n), n);
- if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) {
+ if (vim_dialog_yesno(VIM_QUESTION, NULL, (char_u *)buff, 1) == VIM_YES) {
return OK;
}
return FAIL;
@@ -5144,7 +5136,7 @@ static int check_more(int message, bool forceit)
char_u *get_command_name(expand_T *xp, int idx)
{
if (idx >= CMD_SIZE) {
- return expand_user_command_name(idx);
+ return (char_u *)expand_user_command_name(idx);
}
return cmdnames[idx].cmd_name;
}
@@ -5167,21 +5159,21 @@ char *uc_validate_name(char *name)
return name;
}
-int uc_add_command(char_u *name, size_t name_len, char_u *rep, uint32_t argt, long def, int flags,
- int compl, char_u *compl_arg, LuaRef compl_luaref, cmd_addr_T addr_type,
+int uc_add_command(char *name, size_t name_len, char *rep, uint32_t argt, long def, int flags,
+ int compl, char *compl_arg, LuaRef compl_luaref, cmd_addr_T addr_type,
LuaRef luaref, bool force)
FUNC_ATTR_NONNULL_ARG(1, 3)
{
ucmd_T *cmd = NULL;
int i;
int cmp = 1;
- char_u *rep_buf = NULL;
+ char *rep_buf = NULL;
garray_T *gap;
- replace_termcodes(rep, STRLEN(rep), &rep_buf, 0, NULL, CPO_TO_CPO_FLAGS);
+ replace_termcodes((char_u *)rep, STRLEN(rep), (char_u **)&rep_buf, 0, NULL, CPO_TO_CPO_FLAGS);
if (rep_buf == NULL) {
// Can't replace termcodes - try using the string as is
- rep_buf = vim_strsave(rep);
+ rep_buf = xstrdup(rep);
}
// get address of growarray: global or in curbuf
@@ -5237,24 +5229,24 @@ int uc_add_command(char_u *name, size_t name_len, char_u *rep, uint32_t argt, lo
if (cmp != 0) {
ga_grow(gap, 1);
- char_u *const p = vim_strnsave(name, name_len);
+ char *const p = xstrnsave(name, name_len);
cmd = USER_CMD_GA(gap, i);
memmove(cmd + 1, cmd, (size_t)(gap->ga_len - i) * sizeof(ucmd_T));
++gap->ga_len;
- cmd->uc_name = p;
+ cmd->uc_name = (char_u *)p;
}
- cmd->uc_rep = rep_buf;
+ cmd->uc_rep = (char_u *)rep_buf;
cmd->uc_argt = argt;
cmd->uc_def = def;
cmd->uc_compl = compl;
cmd->uc_script_ctx = current_sctx;
cmd->uc_script_ctx.sc_lnum += sourcing_lnum;
nlua_set_sctx(&cmd->uc_script_ctx);
- cmd->uc_compl_arg = compl_arg;
+ cmd->uc_compl_arg = (char_u *)compl_arg;
cmd->uc_compl_luaref = compl_luaref;
cmd->uc_addr_type = addr_type;
cmd->uc_luaref = luaref;
@@ -5346,7 +5338,7 @@ static char *get_command_complete(int arg)
}
}
-static void uc_list(char_u *name, size_t name_len)
+static void uc_list(char *name, size_t name_len)
{
int i, j;
bool found = false;
@@ -5508,11 +5500,11 @@ static void uc_list(char_u *name, size_t name_len)
}
}
-static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def, int *flags,
- int *complp, char_u **compl_arg, cmd_addr_T *addr_type_arg)
+static int uc_scan_attr(char *attr, size_t len, uint32_t *argt, long *def, int *flags, int *complp,
+ char_u **compl_arg, cmd_addr_T *addr_type_arg)
FUNC_ATTR_NONNULL_ALL
{
- char_u *p;
+ char *p;
if (len == 0) {
emsg(_("E175: No attribute specified"));
@@ -5532,7 +5524,7 @@ static int uc_scan_attr(char_u *attr, size_t len, uint32_t *argt, long *def, int
*argt |= EX_TRLBAR;
} else {
int i;
- char_u *val = NULL;
+ char *val = NULL;
size_t vallen = 0;
size_t attrlen = len;
@@ -5578,7 +5570,7 @@ two_count:
return FAIL;
}
- *def = getdigits_long(&p, true, 0);
+ *def = getdigits_long((char_u **)&p, true, 0);
*argt |= EX_ZEROR;
if (p != val + vallen || vallen == 0) {
@@ -5604,7 +5596,7 @@ invalid_count:
goto two_count;
}
- *def = getdigits_long(&p, true, 0);
+ *def = getdigits_long((char_u **)&p, true, 0);
if (p != val + vallen) {
goto invalid_count;
@@ -5620,7 +5612,7 @@ invalid_count:
return FAIL;
}
- if (parse_compl_arg(val, (int)vallen, complp, argt, compl_arg)
+ if (parse_compl_arg(val, (int)vallen, complp, argt, (char **)compl_arg)
== FAIL) {
return FAIL;
}
@@ -5637,7 +5629,7 @@ invalid_count:
*argt |= EX_ZEROR;
}
} else {
- char_u ch = attr[len];
+ char ch = attr[len];
attr[len] = '\0';
semsg(_("E181: Invalid attribute: %s"), attr);
attr[len] = ch;
@@ -5653,34 +5645,34 @@ static char e_complete_used_without_nargs[] = N_("E1208: -complete used without
/// ":command ..."
static void ex_command(exarg_T *eap)
{
- char_u *name;
- char_u *end;
- char_u *p;
+ char *name;
+ char *end;
+ char *p;
uint32_t argt = 0;
long def = -1;
int flags = 0;
int compl = EXPAND_NOTHING;
- char_u *compl_arg = NULL;
+ char *compl_arg = NULL;
cmd_addr_T addr_type_arg = ADDR_NONE;
int has_attr = (eap->arg[0] == '-');
size_t name_len;
- p = eap->arg;
+ p = (char *)eap->arg;
// Check for attributes
while (*p == '-') {
- ++p;
- end = skiptowhite(p);
- if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, &compl_arg,
+ p++;
+ end = (char *)skiptowhite((char_u *)p);
+ if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, (char_u **)&compl_arg,
&addr_type_arg) == FAIL) {
return;
}
- p = skipwhite(end);
+ p = (char *)skipwhite((char_u *)end);
}
// Get the name (if any) and skip to the following argument.
name = p;
- end = (char_u *)uc_validate_name((char *)name);
+ end = uc_validate_name(name);
if (!end) {
emsg(_("E182: Invalid command name"));
return;
@@ -5689,7 +5681,7 @@ static void ex_command(exarg_T *eap)
// If there is nothing after the name, and no attributes were specified,
// we are listing commands
- p = skipwhite(end);
+ p = (char *)skipwhite((char_u *)end);
if (!has_attr && ends_excmd(*p)) {
uc_list(name, name_len);
} else if (!ASCII_ISUPPER(*name)) {
@@ -5699,7 +5691,8 @@ static void ex_command(exarg_T *eap)
} else if (compl > 0 && (argt & EX_EXTRA) == 0) {
emsg(_(e_complete_used_without_nargs));
} else {
- uc_add_command(name, name_len, p, argt, def, flags, compl, compl_arg, LUA_NOREF,
+ uc_add_command(name, name_len, p, argt, def, flags, compl,
+ compl_arg, LUA_NOREF,
addr_type_arg, LUA_NOREF, eap->forceit);
}
}
@@ -5733,12 +5726,12 @@ static void ex_delcommand(exarg_T *eap)
ucmd_T *cmd = NULL;
int res = -1;
garray_T *gap;
- const char_u *arg = eap->arg;
+ const char *arg = (char *)eap->arg;
bool buffer_only = false;
if (STRNCMP(arg, "-buffer", 7) == 0 && ascii_iswhite(arg[7])) {
buffer_only = true;
- arg = skipwhite(arg + 7);
+ arg = (char *)skipwhite((char_u *)arg + 7);
}
gap = &curbuf->b_ucmds;
@@ -5817,11 +5810,11 @@ bool uc_split_args_iter(const char_u *arg, size_t arglen, size_t *end, char *buf
}
/// split and quote args for <f-args>
-static char_u *uc_split_args(char_u *arg, size_t *lenp)
+static char *uc_split_args(char *arg, size_t *lenp)
{
- char_u *buf;
- char_u *p;
- char_u *q;
+ char *buf;
+ char *p;
+ char *q;
int len;
// Precalculate length
@@ -5839,13 +5832,13 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp)
len += 2;
p += 1;
} else if (ascii_iswhite(*p)) {
- p = skipwhite(p);
+ p = (char *)skipwhite((char_u *)p);
if (*p == NUL) {
break;
}
len += 3; // ","
} else {
- const int charlen = utfc_ptr2len(p);
+ const int charlen = utfc_ptr2len((char_u *)p);
len += charlen;
p += charlen;
@@ -5869,7 +5862,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp)
*q++ = '\\';
*q++ = *p++;
} else if (ascii_iswhite(*p)) {
- p = skipwhite(p);
+ p = (char *)skipwhite((char_u *)p);
if (*p == NUL) {
break;
}
@@ -5877,7 +5870,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp)
*q++ = ',';
*q++ = '"';
} else {
- mb_copy_char((const char_u **)&p, &q);
+ mb_copy_char((const char_u **)&p, (char_u **)&q);
}
}
*q++ = '"';
@@ -5916,11 +5909,11 @@ static size_t add_cmd_modifier(char *buf, char *mod_str, bool *multi_mods)
///
/// @return the length of the replacement, which has been added to "buf".
/// Return -1 if there was no match, and only the "<" has been copied.
-static size_t uc_check_code(char_u *code, size_t len, char_u *buf, ucmd_T *cmd, exarg_T *eap,
- char_u **split_buf, size_t *split_len)
+static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exarg_T *eap,
+ char **split_buf, size_t *split_len)
{
size_t result = 0;
- char_u *p = code + 1;
+ char *p = code + 1;
size_t l = len - 2;
int quote = 0;
enum {
@@ -5995,7 +5988,7 @@ static size_t uc_check_code(char_u *code, size_t len, char_u *buf, ucmd_T *cmd,
break;
case 1: // Quote, but don't split
result = STRLEN(eap->arg) + 2;
- for (p = eap->arg; *p; p++) {
+ for (p = (char *)eap->arg; *p; p++) {
if (*p == '\\' || *p == '"') {
result++;
}
@@ -6003,7 +5996,7 @@ static size_t uc_check_code(char_u *code, size_t len, char_u *buf, ucmd_T *cmd,
if (buf != NULL) {
*buf++ = '"';
- for (p = eap->arg; *p; p++) {
+ for (p = (char *)eap->arg; *p; p++) {
if (*p == '\\' || *p == '"') {
*buf++ = '\\';
}
@@ -6016,7 +6009,7 @@ static size_t uc_check_code(char_u *code, size_t len, char_u *buf, ucmd_T *cmd,
case 2: // Quote and split (<f-args>)
// This is hard, so only do it once, and cache the result
if (*split_buf == NULL) {
- *split_buf = uc_split_args(eap->arg, split_len);
+ *split_buf = uc_split_args((char *)eap->arg, split_len);
}
result = *split_len;
@@ -6088,7 +6081,7 @@ static size_t uc_check_code(char_u *code, size_t len, char_u *buf, ucmd_T *cmd,
*buf = '\0';
}
- result += uc_mods((char *)buf);
+ result += uc_mods(buf);
if (quote && buf != NULL) {
buf += result - 2;
@@ -6106,7 +6099,7 @@ static size_t uc_check_code(char_u *code, size_t len, char_u *buf, ucmd_T *cmd,
*buf++ = '\'';
}
if (eap->regname) {
- *buf++ = (char_u)eap->regname;
+ *buf++ = (char)eap->regname;
}
if (quote) {
*buf = '\'';
@@ -6205,17 +6198,17 @@ size_t uc_mods(char *buf)
static void do_ucmd(exarg_T *eap)
{
- char_u *buf;
- char_u *p;
- char_u *q;
+ char *buf;
+ char *p;
+ char *q;
- char_u *start;
- char_u *end = NULL;
- char_u *ksp;
+ char *start;
+ char *end = NULL;
+ char *ksp;
size_t len, totlen;
size_t split_len = 0;
- char_u *split_buf = NULL;
+ char *split_buf = NULL;
ucmd_T *cmd;
if (eap->cmdidx == CMD_USER) {
@@ -6236,20 +6229,20 @@ static void do_ucmd(exarg_T *eap)
*/
buf = NULL;
for (;;) {
- p = cmd->uc_rep; // source
+ p = (char *)cmd->uc_rep; // source
q = buf; // destination
totlen = 0;
for (;;) {
- start = vim_strchr(p, '<');
+ start = (char *)vim_strchr((char_u *)p, '<');
if (start != NULL) {
- end = vim_strchr(start + 1, '>');
+ end = (char *)vim_strchr((char_u *)start + 1, '>');
}
if (buf != NULL) {
- for (ksp = p; *ksp != NUL && *ksp != K_SPECIAL; ksp++) {}
- if (*ksp == K_SPECIAL
+ for (ksp = p; *ksp != NUL && (char_u)(*ksp) != K_SPECIAL; ksp++) {}
+ if ((char_u)(*ksp) == K_SPECIAL
&& (start == NULL || ksp < start || end == NULL)
- && (ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)) {
+ && ((char_u)ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)) {
// K_SPECIAL has been put in the buffer as K_SPECIAL
// KS_SPECIAL KE_FILLER, like for mappings, but
// do_cmdline() doesn't handle that, so convert it back.
@@ -6258,7 +6251,7 @@ static void do_ucmd(exarg_T *eap)
memmove(q, p, len);
q += len;
}
- *q++ = K_SPECIAL;
+ *q++ = (char)K_SPECIAL;
p = ksp + 3;
continue;
}
@@ -6281,8 +6274,7 @@ static void do_ucmd(exarg_T *eap)
q += len;
}
- len = uc_check_code(start, (size_t)(end - start), q, cmd, eap,
- &split_buf, &split_len);
+ len = uc_check_code(start, (size_t)(end - start), q, cmd, eap, &split_buf, &split_len);
if (len == (size_t)-1) {
// no match, continue after '<'
p = start + 1;
@@ -6324,9 +6316,9 @@ static void do_ucmd(exarg_T *eap)
xfree(split_buf);
}
-static char_u *expand_user_command_name(int idx)
+static char *expand_user_command_name(int idx)
{
- return get_user_commands(NULL, idx - CMD_SIZE);
+ return (char *)get_user_commands(NULL, idx - CMD_SIZE);
}
/// Function given to ExpandGeneric() to obtain the list of user address type names.
@@ -6356,17 +6348,17 @@ char_u *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx)
/// CMD_USER_BUF.
///
/// @return NULL if the command is not found.
-static char_u *get_user_command_name(int idx, int cmdidx)
+static char *get_user_command_name(int idx, int cmdidx)
{
if (cmdidx == CMD_USER && idx < ucmds.ga_len) {
- return USER_CMD(idx)->uc_name;
+ return (char *)USER_CMD(idx)->uc_name;
}
if (cmdidx == CMD_USER_BUF) {
// In cmdwin, the alternative buffer should be used.
const buf_T *const buf = prevwin_curwin()->w_buffer;
if (idx < buf->b_ucmds.ga_len) {
- return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
+ return (char *)USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
}
}
return NULL;
@@ -6412,7 +6404,7 @@ char_u *get_user_cmd_complete(expand_T *xp, int idx)
}
/// Parse address type argument
-int parse_addr_type_arg(char_u *value, int vallen, cmd_addr_T *addr_type_arg)
+int parse_addr_type_arg(char *value, int vallen, cmd_addr_T *addr_type_arg)
FUNC_ATTR_NONNULL_ALL
{
int i, a, b;
@@ -6427,7 +6419,7 @@ int parse_addr_type_arg(char_u *value, int vallen, cmd_addr_T *addr_type_arg)
}
if (addr_type_complete[i].expand == ADDR_NONE) {
- char_u *err = value;
+ char *err = value;
for (i = 0; err[i] != NUL && !ascii_iswhite(err[i]); i++) {}
err[i] = NUL;
@@ -6444,11 +6436,10 @@ int parse_addr_type_arg(char_u *value, int vallen, cmd_addr_T *addr_type_arg)
/// copied to allocated memory and stored in "*compl_arg".
///
/// @return FAIL if something is wrong.
-int parse_compl_arg(const char_u *value, int vallen, int *complp, uint32_t *argt,
- char_u **compl_arg)
+int parse_compl_arg(const char *value, int vallen, int *complp, uint32_t *argt, char **compl_arg)
FUNC_ATTR_NONNULL_ALL
{
- const char_u *arg = NULL;
+ const char *arg = NULL;
size_t arglen = 0;
int i;
int valend = vallen;
@@ -6456,7 +6447,7 @@ int parse_compl_arg(const char_u *value, int vallen, int *complp, uint32_t *argt
// Look for any argument part - which is the part after any ','
for (i = 0; i < vallen; ++i) {
if (value[i] == ',') {
- arg = &value[i + 1];
+ arg = (char *)&value[i + 1];
arglen = (size_t)(vallen - i - 1);
valend = i;
break;
@@ -6497,7 +6488,7 @@ int parse_compl_arg(const char_u *value, int vallen, int *complp, uint32_t *argt
}
if (arg != NULL) {
- *compl_arg = vim_strnsave(arg, arglen);
+ *compl_arg = xstrnsave(arg, arglen);
}
return OK;
}
@@ -6520,16 +6511,16 @@ int cmdcomplete_str_to_type(const char *complete_str)
static void ex_colorscheme(exarg_T *eap)
{
if (*eap->arg == NUL) {
- char_u *expr = vim_strsave((char_u *)"g:colors_name");
- char_u *p = NULL;
+ char *expr = xstrdup("g:colors_name");
+ char *p = NULL;
emsg_off++;
- p = eval_to_string(expr, NULL, false);
+ p = (char *)eval_to_string((char_u *)expr, NULL, false);
emsg_off--;
xfree(expr);
if (p != NULL) {
- msg((char *)p);
+ msg(p);
xfree(p);
} else {
msg("default");
@@ -6850,7 +6841,7 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
int done = 0;
win_T *wp;
int h = tabline_height();
- char_u prev_idx[NUMBUFLEN];
+ char prev_idx[NUMBUFLEN];
// Limit to 1000 windows, autocommands may add a window while we close
// one. OK, so I'm paranoid...
@@ -7059,11 +7050,11 @@ void alist_new(void)
/// numbers to be re-used.
void alist_expand(int *fnum_list, int fnum_len)
{
- char_u **old_arg_files;
+ char **old_arg_files;
int old_arg_count;
- char_u **new_arg_files;
+ char **new_arg_files;
int new_arg_file_count;
- char_u *save_p_su = p_su;
+ char *save_p_su = p_su;
int i;
/* Don't use 'suffixes' here. This should work like the shell did the
@@ -7089,7 +7080,7 @@ void alist_expand(int *fnum_list, int fnum_len)
/// Set the argument list for the current window.
/// Takes over the allocated files[] and the allocated fnames in it.
-void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum_list, int fnum_len)
+void alist_set(alist_T *al, int count, char **files, int use_curbuf, int *fnum_list, int fnum_len)
{
int i;
static int recursive = 0;
@@ -7116,7 +7107,7 @@ void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum
/* May set buffer name of a buffer previously used for the
* argument list, so that it's re-used by alist_add. */
if (fnum_list != NULL && i < fnum_len) {
- buf_set_name(fnum_list[i], files[i]);
+ buf_set_name(fnum_list[i], (char_u *)files[i]);
}
alist_add(al, files[i], use_curbuf ? 2 : 1);
@@ -7135,7 +7126,7 @@ void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum
/// "fname" must have been allocated and "al" must have been checked for room.
///
/// @param set_fnum 1: set buffer number; 2: re-use curbuf
-void alist_add(alist_T *al, char_u *fname, int set_fnum)
+void alist_add(alist_T *al, char *fname, int set_fnum)
{
if (fname == NULL) { // don't add NULL file names
return;
@@ -7143,10 +7134,10 @@ void alist_add(alist_T *al, char_u *fname, int set_fnum)
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(fname);
#endif
- AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname;
+ AARGLIST(al)[al->al_ga.ga_len].ae_fname = (char_u *)fname;
if (set_fnum > 0) {
AARGLIST(al)[al->al_ga.ga_len].ae_fnum =
- buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0));
+ buflist_add((char_u *)fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0));
}
++al->al_ga.ga_len;
}
@@ -7218,7 +7209,7 @@ static void ex_wrongmodifier(exarg_T *eap)
void ex_splitview(exarg_T *eap)
{
win_T *old_curwin = curwin;
- char_u *fname = NULL;
+ char *fname = NULL;
const bool use_tab = eap->cmdidx == CMD_tabedit
|| eap->cmdidx == CMD_tabfind
|| eap->cmdidx == CMD_tabnew;
@@ -7235,12 +7226,12 @@ void ex_splitview(exarg_T *eap)
}
if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) {
- fname = find_file_in_path(eap->arg, STRLEN(eap->arg),
- FNAME_MESS, TRUE, curbuf->b_ffname);
+ fname = (char *)find_file_in_path(eap->arg, STRLEN(eap->arg),
+ FNAME_MESS, true, curbuf->b_ffname);
if (fname == NULL) {
goto theend;
}
- eap->arg = fname;
+ eap->arg = (char_u *)fname;
}
/*
@@ -7284,7 +7275,7 @@ void tabpage_new(void)
memset(&ea, 0, sizeof(ea));
ea.cmdidx = CMD_tabnew;
- ea.cmd = (char_u *)"tabn";
+ ea.cmd = "tabn";
ea.arg = (char_u *)"";
ex_splitview(&ea);
}
@@ -7305,9 +7296,9 @@ static void ex_tabnext(exarg_T *eap)
case CMD_tabprevious:
case CMD_tabNext:
if (eap->arg && *eap->arg != NUL) {
- char_u *p = eap->arg;
- char_u *p_save = p;
- tab_number = (int)getdigits(&p, false, 0);
+ char *p = (char *)eap->arg;
+ char *p_save = p;
+ tab_number = (int)getdigits((char_u **)&p, false, 0);
if (p == p_save || *p_save == '-' || *p_save == '+' || *p != NUL
|| tab_number == 0) {
// No numbers as argument.
@@ -7436,23 +7427,23 @@ static void ex_resize(exarg_T *eap)
/// ":find [+command] <file>" command.
static void ex_find(exarg_T *eap)
{
- char_u *fname;
+ char *fname;
linenr_T count;
- fname = find_file_in_path(eap->arg, STRLEN(eap->arg),
- FNAME_MESS, TRUE, curbuf->b_ffname);
+ fname = (char *)find_file_in_path(eap->arg, STRLEN(eap->arg),
+ FNAME_MESS, true, curbuf->b_ffname);
if (eap->addr_count > 0) {
// Repeat finding the file "count" times. This matters when it
// appears several times in the path.
count = eap->line2;
while (fname != NULL && --count > 0) {
xfree(fname);
- fname = find_file_in_path(NULL, 0, FNAME_MESS, FALSE, curbuf->b_ffname);
+ fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, curbuf->b_ffname);
}
}
if (fname != NULL) {
- eap->arg = fname;
+ eap->arg = (char_u *)fname;
do_exedit(eap, NULL);
xfree(fname);
}
@@ -7669,11 +7660,11 @@ static void ex_syncbind(exarg_T *eap)
did_syncbind = true;
checkpcmark();
if (old_linenr != curwin->w_cursor.lnum) {
- char_u ctrl_o[2];
+ char ctrl_o[2];
ctrl_o[0] = Ctrl_O;
ctrl_o[1] = 0;
- ins_typebuf(ctrl_o, REMAP_NONE, 0, true, false);
+ ins_typebuf((char_u *)ctrl_o, REMAP_NONE, 0, true, false);
}
}
}
@@ -7732,7 +7723,7 @@ static void ex_read(exarg_T *eap)
}
}
-static char_u *prev_dir = NULL;
+static char *prev_dir = NULL;
#if defined(EXITFREE)
void free_cd_dir(void)
@@ -7744,14 +7735,14 @@ void free_cd_dir(void)
#endif
/// Get the previous directory for the given chdir scope.
-static char_u *get_prevdir(CdScope scope)
+static char *get_prevdir(CdScope scope)
{
switch (scope) {
case kCdScopeTabpage:
- return curtab->tp_prevdir;
+ return (char *)curtab->tp_prevdir;
break;
case kCdScopeWindow:
- return curwin->w_prevdir;
+ return (char *)curwin->w_prevdir;
break;
default:
return prev_dir;
@@ -7772,10 +7763,10 @@ static void post_chdir(CdScope scope, bool trigger_dirchanged)
}
if (scope < kCdScopeGlobal) {
- char_u *pdir = get_prevdir(scope);
+ char *pdir = get_prevdir(scope);
// If still in global directory, set CWD as the global directory.
if (globaldir == NULL && pdir != NULL) {
- globaldir = vim_strsave(pdir);
+ globaldir = vim_strsave((char_u *)pdir);
}
}
@@ -7810,13 +7801,13 @@ static void post_chdir(CdScope scope, bool trigger_dirchanged)
/// @param new_dir The directory to change to.
/// @param scope Scope of the function call (global, tab or window).
/// @return true if the directory is successfully changed.
-bool changedir_func(char_u *new_dir, CdScope scope)
+bool changedir_func(char *new_dir, CdScope scope)
{
if (new_dir == NULL || allbuf_locked()) {
return false;
}
- char_u *pdir = NULL;
+ char *pdir = NULL;
// ":cd -": Change to previous directory
if (STRCMP(new_dir, "-") == 0) {
pdir = get_prevdir(scope);
@@ -7828,7 +7819,7 @@ bool changedir_func(char_u *new_dir, CdScope scope)
}
if (os_dirname(NameBuff, MAXPATHL) == OK) {
- pdir = vim_strsave(NameBuff);
+ pdir = (char *)vim_strsave(NameBuff);
} else {
pdir = NULL;
}
@@ -7842,26 +7833,26 @@ bool changedir_func(char_u *new_dir, CdScope scope)
#endif
// Use NameBuff for home directory name.
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
- new_dir = NameBuff;
+ new_dir = (char *)NameBuff;
}
- bool dir_differs = pdir == NULL || pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
+ bool dir_differs = pdir == NULL || pathcmp(pdir, new_dir, -1) != 0;
if (dir_differs) {
- do_autocmd_dirchanged((char *)new_dir, scope, kCdCauseManual, true);
- if (vim_chdir(new_dir) != 0) {
+ do_autocmd_dirchanged(new_dir, scope, kCdCauseManual, true);
+ if (vim_chdir((char_u *)new_dir) != 0) {
emsg(_(e_failed));
xfree(pdir);
return false;
}
}
- char_u **pp;
+ char **pp;
switch (scope) {
case kCdScopeTabpage:
- pp = &curtab->tp_prevdir;
+ pp = (char **)&curtab->tp_prevdir;
break;
case kCdScopeWindow:
- pp = &curwin->w_prevdir;
+ pp = (char **)&curwin->w_prevdir;
break;
default:
pp = &prev_dir;
@@ -7877,8 +7868,7 @@ bool changedir_func(char_u *new_dir, CdScope scope)
/// ":cd", ":tcd", ":lcd", ":chdir", "tchdir" and ":lchdir".
void ex_cd(exarg_T *eap)
{
- char_u *new_dir;
- new_dir = eap->arg;
+ char *new_dir = (char *)eap->arg;
#if !defined(UNIX)
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
if (*new_dir == NUL && !p_cdh) {
@@ -7984,10 +7974,8 @@ void do_sleep(long msec)
static void do_exmap(exarg_T *eap, int isabbrev)
{
int mode;
- char_u *cmdp;
-
- cmdp = eap->cmd;
- mode = get_map_mode(&cmdp, eap->forceit || isabbrev);
+ char *cmdp = eap->cmd;
+ mode = get_map_mode((char_u **)&cmdp, eap->forceit || isabbrev);
switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'),
eap->arg, mode, isabbrev)) {
@@ -8003,16 +7991,16 @@ static void do_exmap(exarg_T *eap, int isabbrev)
/// ":winsize" command (obsolete).
static void ex_winsize(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char *arg = (char *)eap->arg;
if (!ascii_isdigit(*arg)) {
semsg(_(e_invarg2), arg);
return;
}
- int w = getdigits_int(&arg, false, 10);
- arg = skipwhite(arg);
- char_u *p = arg;
- int h = getdigits_int(&arg, false, 10);
+ int w = getdigits_int((char_u **)&arg, false, 10);
+ arg = (char *)skipwhite((char_u *)arg);
+ char *p = arg;
+ int h = getdigits_int((char_u **)&arg, false, 10);
if (*p != NUL && *arg == NUL) {
screen_resize(w, h);
} else {
@@ -8023,7 +8011,7 @@ static void ex_winsize(exarg_T *eap)
static void ex_wincmd(exarg_T *eap)
{
int xchar = NUL;
- char_u *p;
+ char *p;
if (*eap->arg == 'g' || *eap->arg == Ctrl_G) {
// CTRL-W g and CTRL-W CTRL-G have an extra command character
@@ -8032,13 +8020,13 @@ static void ex_wincmd(exarg_T *eap)
return;
}
xchar = eap->arg[1];
- p = eap->arg + 2;
+ p = (char *)eap->arg + 2;
} else {
- p = eap->arg + 1;
+ p = (char *)eap->arg + 1;
}
- eap->nextcmd = check_nextcmd(p);
- p = skipwhite(p);
+ eap->nextcmd = check_nextcmd((char_u *)p);
+ p = (char *)skipwhite((char_u *)p);
if (*p != NUL && *p != '"' && eap->nextcmd == NULL) {
emsg(_(e_invarg));
} else if (!eap->skip) {
@@ -8115,7 +8103,7 @@ static void ex_put(exarg_T *eap)
/// Handle ":copy" and ":move".
static void ex_copymove(exarg_T *eap)
{
- long n = get_address(eap, &eap->arg, eap->addr_type, false, false, false, 1);
+ long n = get_address(eap, (char **)&eap->arg, eap->addr_type, false, false, false, 1);
if (eap->arg == NULL) { // error detected
eap->nextcmd = NULL;
return;
@@ -8263,18 +8251,18 @@ static void ex_undo(exarg_T *eap)
static void ex_wundo(exarg_T *eap)
{
- char_u hash[UNDO_HASH_SIZE];
+ char hash[UNDO_HASH_SIZE];
- u_compute_hash(curbuf, hash);
- u_write_undo((char *)eap->arg, eap->forceit, curbuf, hash);
+ u_compute_hash(curbuf, (char_u *)hash);
+ u_write_undo((char *)eap->arg, eap->forceit, curbuf, (char_u *)hash);
}
static void ex_rundo(exarg_T *eap)
{
- char_u hash[UNDO_HASH_SIZE];
+ char hash[UNDO_HASH_SIZE];
- u_compute_hash(curbuf, hash);
- u_read_undo((char *)eap->arg, hash, NULL);
+ u_compute_hash(curbuf, (char_u *)hash);
+ u_read_undo((char *)eap->arg, (char_u *)hash, NULL);
}
/// ":redo".
@@ -8289,12 +8277,12 @@ static void ex_later(exarg_T *eap)
long count = 0;
bool sec = false;
bool file = false;
- char_u *p = eap->arg;
+ char *p = (char *)eap->arg;
if (*p == NUL) {
count = 1;
} else if (isdigit(*p)) {
- count = getdigits_long(&p, false, 0);
+ count = getdigits_long((char_u **)&p, false, 0);
switch (*p) {
case 's':
++p; sec = true; break;
@@ -8321,8 +8309,8 @@ static void ex_later(exarg_T *eap)
static void ex_redir(exarg_T *eap)
{
char *mode;
- char_u *fname;
- char_u *arg = eap->arg;
+ char *fname;
+ char *arg = (char *)eap->arg;
if (STRICMP(eap->arg, "END") == 0) {
close_redir();
@@ -8335,24 +8323,24 @@ static void ex_redir(exarg_T *eap)
} else {
mode = "w";
}
- arg = skipwhite(arg);
+ arg = (char *)skipwhite((char_u *)arg);
close_redir();
// Expand environment variables and "~/".
- fname = expand_env_save(arg);
+ fname = (char *)expand_env_save((char_u *)arg);
if (fname == NULL) {
return;
}
- redir_fd = open_exfile(fname, eap->forceit, mode);
+ redir_fd = open_exfile((char_u *)fname, eap->forceit, mode);
xfree(fname);
} else if (*arg == '@') {
// redirect to a register a-z (resp. A-Z for appending)
close_redir();
++arg;
if (valid_yank_reg(*arg, true) && *arg != '_') {
- redir_reg = *arg++;
+ redir_reg = (char_u)(*arg++);
if (*arg == '>' && arg[1] == '>') { // append
arg += 2;
} else {
@@ -8385,7 +8373,7 @@ static void ex_redir(exarg_T *eap)
append = FALSE;
}
- if (var_redir_start(skipwhite(arg), append) == OK) {
+ if (var_redir_start(skipwhite((char_u *)arg), append) == OK) {
redir_vname = 1;
}
} else { // TODO(vim): redirect to a buffer
@@ -8627,9 +8615,9 @@ static void ex_normal(exarg_T *eap)
return;
}
save_state_T save_state;
- char_u *arg = NULL;
+ char *arg = NULL;
int l;
- char_u *p;
+ char *p;
if (ex_normal_lock > 0) {
emsg(_(e_secure));
@@ -8647,9 +8635,9 @@ static void ex_normal(exarg_T *eap)
int len = 0;
// Count the number of characters to be escaped.
- for (p = eap->arg; *p != NUL; p++) {
- for (l = utfc_ptr2len(p) - 1; l > 0; l--) {
- if (*++p == K_SPECIAL) { // trailbyte K_SPECIAL
+ for (p = (char *)eap->arg; *p != NUL; p++) {
+ for (l = utfc_ptr2len((char_u *)p) - 1; l > 0; l--) {
+ if (*++p == (char)K_SPECIAL) { // trailbyte K_SPECIAL
len += 2;
}
}
@@ -8657,12 +8645,12 @@ static void ex_normal(exarg_T *eap)
if (len > 0) {
arg = xmalloc(STRLEN(eap->arg) + (size_t)len + 1);
len = 0;
- for (p = eap->arg; *p != NUL; ++p) {
+ for (p = (char *)eap->arg; *p != NUL; p++) {
arg[len++] = *p;
- for (l = utfc_ptr2len(p) - 1; l > 0; l--) {
+ for (l = utfc_ptr2len((char_u *)p) - 1; l > 0; l--) {
arg[len++] = *++p;
- if (*p == K_SPECIAL) {
- arg[len++] = KS_SPECIAL;
+ if (*p == (char)K_SPECIAL) {
+ arg[len++] = (char)KS_SPECIAL;
arg[len++] = KE_FILLER;
}
}
@@ -8683,7 +8671,7 @@ static void ex_normal(exarg_T *eap)
check_cursor_moved(curwin);
}
- exec_normal_cmd(arg != NULL ? arg : eap->arg,
+ exec_normal_cmd(arg != NULL ? (char_u *)arg : eap->arg,
eap->forceit ? REMAP_NONE : REMAP_YES, false);
} while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
}
@@ -8791,7 +8779,7 @@ static void ex_findpat(exarg_T *eap)
{
bool whole = true;
long n;
- char_u *p;
+ char *p;
int action;
switch (cmdnames[eap->cmdidx].cmd_name[2]) {
@@ -8821,16 +8809,16 @@ static void ex_findpat(exarg_T *eap)
if (*eap->arg == '/') { // Match regexp, not just whole words
whole = false;
eap->arg++;
- p = skip_regexp(eap->arg, '/', p_magic, NULL);
+ p = (char *)skip_regexp(eap->arg, '/', p_magic, NULL);
if (*p) {
*p++ = NUL;
- p = skipwhite(p);
+ p = (char *)skipwhite((char_u *)p);
// Check for trailing illegal characters.
if (!ends_excmd(*p)) {
eap->errmsg = e_trailing;
} else {
- eap->nextcmd = check_nextcmd(p);
+ eap->nextcmd = check_nextcmd((char_u *)p);
}
}
}
@@ -8846,7 +8834,7 @@ static void ex_findpat(exarg_T *eap)
static void ex_ptag(exarg_T *eap)
{
g_do_tagpreview = (int)p_pvh; // will be reset to 0 in ex_tag_cmd()
- ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
+ ex_tag_cmd(eap, (char *)cmdnames[eap->cmdidx].cmd_name + 1);
}
/// ":pedit"
@@ -8876,7 +8864,7 @@ static void ex_stag(exarg_T *eap)
postponed_split = -1;
postponed_split_flags = cmdmod.split;
postponed_split_tab = cmdmod.tab;
- ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
+ ex_tag_cmd(eap, (char *)cmdnames[eap->cmdidx].cmd_name + 1);
postponed_split_flags = 0;
postponed_split_tab = 0;
}
@@ -8884,10 +8872,10 @@ static void ex_stag(exarg_T *eap)
/// ":tag", ":tselect", ":tjump", ":tnext", etc.
static void ex_tag(exarg_T *eap)
{
- ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name);
+ ex_tag_cmd(eap, (char *)cmdnames[eap->cmdidx].cmd_name);
}
-static void ex_tag_cmd(exarg_T *eap, char_u *name)
+static void ex_tag_cmd(exarg_T *eap, char *name)
{
int cmd;
@@ -9017,9 +9005,9 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
int *escaped)
{
int i;
- char_u *s;
- char_u *result;
- char_u *resultbuf = NULL;
+ char *s;
+ char *result;
+ char *resultbuf = NULL;
size_t resultlen;
buf_T *buf;
int valid = VALID_HEAD | VALID_PATH; // Assume valid result.
@@ -9057,7 +9045,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
if (spec_idx == SPEC_CWORD
|| spec_idx == SPEC_CCWORD
|| spec_idx == SPEC_CEXPR) {
- resultlen = find_ident_under_cursor(&result,
+ resultlen = find_ident_under_cursor((char_u **)&result,
spec_idx == SPEC_CWORD
? (FIND_IDENT | FIND_STRING)
: (spec_idx == SPEC_CEXPR
@@ -9078,10 +9066,10 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
switch (spec_idx) {
case SPEC_PERC: // '%': current file
if (curbuf->b_fname == NULL) {
- result = (char_u *)"";
+ result = "";
valid = 0; // Must have ":p:h" to be valid
} else {
- result = curbuf->b_fname;
+ result = (char *)curbuf->b_fname;
tilde_file = STRCMP(result, "~") == 0;
}
break;
@@ -9097,16 +9085,16 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
skip_mod = true;
break;
}
- s = src + 1;
+ s = (char *)src + 1;
if (*s == '<') { // "#<99" uses v:oldfiles.
s++;
}
- i = getdigits_int(&s, false, 0);
- if (s == src + 2 && src[1] == '-') {
+ i = getdigits_int((char_u **)&s, false, 0);
+ if ((char_u *)s == src + 2 && src[1] == '-') {
// just a minus sign, don't skip over it
s--;
}
- *usedlen = (size_t)(s - src); // length of what we expand
+ *usedlen = (size_t)((char_u *)s - src); // length of what we expand
if (src[1] == '<' && i != 0) {
if (*usedlen < 2) {
@@ -9114,8 +9102,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
*usedlen = 1;
return NULL;
}
- result = (char_u *)tv_list_find_str(get_vim_var_list(VV_OLDFILES),
- i - 1);
+ result = (char *)tv_list_find_str(get_vim_var_list(VV_OLDFILES), i - 1);
if (result == NULL) {
*errormsg = "";
return NULL;
@@ -9133,17 +9120,17 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
*lnump = ECMD_LAST;
}
if (buf->b_fname == NULL) {
- result = (char_u *)"";
+ result = "";
valid = 0; // Must have ":p:h" to be valid
} else {
- result = buf->b_fname;
+ result = (char *)buf->b_fname;
tilde_file = STRCMP(result, "~") == 0;
}
}
break;
case SPEC_CFILE: // file name under cursor
- result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
+ result = (char *)file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
if (result == NULL) {
*errormsg = "";
return NULL;
@@ -9158,17 +9145,17 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
&& !strequal("/", (char *)autocmd_fname)) {
// Still need to turn the fname into a full path. It was
// postponed to avoid a delay when <afile> is not used.
- result = (char_u *)FullName_save((char *)autocmd_fname, false);
+ result = FullName_save((char *)autocmd_fname, false);
// Copy into `autocmd_fname`, don't reassign it. #8165
STRLCPY(autocmd_fname, result, MAXPATHL);
xfree(result);
}
- result = autocmd_fname;
+ result = (char *)autocmd_fname;
if (result == NULL) {
*errormsg = _("E495: no autocommand file name to substitute for \"<afile>\"");
return NULL;
}
- result = path_try_shorten_fname(result);
+ result = (char *)path_try_shorten_fname((char_u *)result);
break;
case SPEC_ABUF: // buffer number for autocommand
@@ -9177,11 +9164,11 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
return NULL;
}
snprintf(strbuf, sizeof(strbuf), "%d", autocmd_bufnr);
- result = (char_u *)strbuf;
+ result = strbuf;
break;
case SPEC_AMATCH: // match name for autocommand
- result = autocmd_match;
+ result = (char *)autocmd_match;
if (result == NULL) {
*errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\"");
return NULL;
@@ -9189,7 +9176,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
break;
case SPEC_SFILE: // file name for ":so" command
- result = sourcing_name;
+ result = (char *)sourcing_name;
if (result == NULL) {
*errormsg = _("E498: no :source file name to substitute for \"<sfile>\"");
return NULL;
@@ -9202,7 +9189,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
return NULL;
}
snprintf(strbuf, sizeof(strbuf), "%" PRIdLINENR, sourcing_lnum);
- result = (char_u *)strbuf;
+ result = strbuf;
break;
case SPEC_SFLNUM: // line in script file
@@ -9212,7 +9199,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
}
snprintf((char *)strbuf, sizeof(strbuf), "%" PRIdLINENR,
current_sctx.sc_lnum + sourcing_lnum);
- result = (char_u *)strbuf;
+ result = strbuf;
break;
case SPEC_SID:
@@ -9222,13 +9209,13 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
}
snprintf(strbuf, sizeof(strbuf), "<SNR>%" PRIdSCID "_",
current_sctx.sc_sid);
- result = (char_u *)strbuf;
+ result = strbuf;
break;
default:
// should not happen
*errormsg = "";
- result = (char_u *)""; // avoid gcc warning
+ result = ""; // avoid gcc warning
break;
}
@@ -9237,12 +9224,13 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
// Remove the file name extension.
if (src[*usedlen] == '<') {
(*usedlen)++;
- if ((s = STRRCHR(result, '.')) != NULL && s >= path_tail(result)) {
+ if ((s = (char *)STRRCHR(result, '.')) != NULL
+ && (char_u *)s >= path_tail((char_u *)result)) {
resultlen = (size_t)(s - result);
}
} else if (!skip_mod) {
- valid |= modify_fname(src, tilde_file, usedlen, &result,
- &resultbuf, &resultlen);
+ valid |= modify_fname(src, tilde_file, usedlen, (char_u **)&result,
+ (char_u **)&resultbuf, &resultlen);
if (result == NULL) {
*errormsg = "";
return NULL;
@@ -9259,21 +9247,21 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
}
result = NULL;
} else {
- result = vim_strnsave(result, resultlen);
+ result = xstrnsave(result, resultlen);
}
xfree(resultbuf);
- return result;
+ return (char_u *)result;
}
/// Concatenate all files in the argument list, separated by spaces, and return
/// it in one allocated string.
/// Spaces and backslashes in the file names are escaped with a backslash.
-static char_u *arg_all(void)
+static char *arg_all(void)
{
int len;
int idx;
- char_u *retval = NULL;
- char_u *p;
+ char *retval = NULL;
+ char *p;
/*
* Do this loop two times:
@@ -9282,8 +9270,8 @@ static char_u *arg_all(void)
*/
for (;;) {
len = 0;
- for (idx = 0; idx < ARGCOUNT; ++idx) {
- p = alist_name(&ARGLIST[idx]);
+ for (idx = 0; idx < ARGCOUNT; idx++) {
+ p = (char *)alist_name(&ARGLIST[idx]);
if (p == NULL) {
continue;
}
@@ -9329,24 +9317,24 @@ static char_u *arg_all(void)
/// Expand the <sfile> string in "arg".
///
/// @return an allocated string, or NULL for any error.
-char_u *expand_sfile(char_u *arg)
+char *expand_sfile(char *arg)
{
char *errormsg;
size_t len;
- char_u *result;
- char_u *newres;
- char_u *repl;
+ char *result;
+ char *newres;
+ char *repl;
size_t srclen;
- char_u *p;
+ char *p;
- result = vim_strsave(arg);
+ result = xstrdup(arg);
for (p = result; *p;) {
if (STRNCMP(p, "<sfile>", 7) != 0) {
++p;
} else {
// replace "<sfile>" with the sourced file name, and do ":" stuff
- repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL);
+ repl = (char *)eval_vars((char_u *)p, (char_u *)result, &srclen, NULL, &errormsg, NULL);
if (errormsg != NULL) {
if (*errormsg) {
emsg(errormsg);
@@ -9377,9 +9365,9 @@ char_u *expand_sfile(char_u *arg)
/// ":rshada" and ":wshada".
static void ex_shada(exarg_T *eap)
{
- char_u *save_shada;
+ char *save_shada;
- save_shada = p_shada;
+ save_shada = (char *)p_shada;
if (*p_shada == NUL) {
p_shada = (char_u *)"'100";
}
@@ -9388,17 +9376,17 @@ static void ex_shada(exarg_T *eap)
} else {
shada_write_file((char *)eap->arg, eap->forceit);
}
- p_shada = save_shada;
+ p_shada = (char_u *)save_shada;
}
/// Make a dialog message in "buff[DIALOG_MSG_SIZE]".
/// "format" must contain "%s".
-void dialog_msg(char_u *buff, char *format, char_u *fname)
+void dialog_msg(char *buff, char *format, char *fname)
{
if (fname == NULL) {
- fname = (char_u *)_("Untitled");
+ fname = _("Untitled");
}
- vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname);
+ vim_snprintf(buff, DIALOG_MSG_SIZE, format, fname);
}
/// ":behave {mswin,xterm}"
@@ -9463,7 +9451,7 @@ static TriState filetype_indent = kNone;
/// indent off: load indoff.vim
static void ex_filetype(exarg_T *eap)
{
- char_u *arg = eap->arg;
+ char *arg = (char *)eap->arg;
bool plugin = false;
bool indent = false;
@@ -9480,12 +9468,12 @@ static void ex_filetype(exarg_T *eap)
for (;;) {
if (STRNCMP(arg, "plugin", 6) == 0) {
plugin = true;
- arg = skipwhite(arg + 6);
+ arg = (char *)skipwhite((char_u *)arg + 6);
continue;
}
if (STRNCMP(arg, "indent", 6) == 0) {
indent = true;
- arg = skipwhite(arg + 6);
+ arg = (char *)skipwhite((char_u *)arg + 6);
continue;
}
break;
@@ -9558,14 +9546,14 @@ void filetype_maybe_enable(void)
static void ex_setfiletype(exarg_T *eap)
{
if (!did_filetype) {
- char_u *arg = eap->arg;
+ char *arg = (char *)eap->arg;
if (STRNCMP(arg, "FALLBACK ", 9) == 0) {
arg += 9;
}
- set_option_value("filetype", 0L, (char *)arg, OPT_LOCAL);
- if (arg != eap->arg) {
+ set_option_value("filetype", 0L, arg, OPT_LOCAL);
+ if ((char_u *)arg != eap->arg) {
did_filetype = false;
}
}
@@ -9685,7 +9673,7 @@ static void ex_terminal(exarg_T *eap)
/// @param[in] cmd Commandline to check. May start with a range or modifier.
///
/// @return true if `cmd` is previewable
-bool cmd_can_preview(char_u *cmd)
+bool cmd_can_preview(char *cmd)
{
if (cmd == NULL) {
return false;
@@ -9705,9 +9693,9 @@ bool cmd_can_preview(char_u *cmd)
// parse the command line
ea.cmd = skip_range(cmd, NULL);
if (*ea.cmd == '*') {
- ea.cmd = skipwhite(ea.cmd + 1);
+ ea.cmd = (char *)skipwhite((char_u *)ea.cmd + 1);
}
- char_u *end = find_command(&ea, NULL);
+ char *end = find_command(&ea, NULL);
switch (ea.cmdidx) {
case CMD_substitute:
@@ -9809,9 +9797,9 @@ Dictionary commands_array(buf_T *buf)
return rv;
}
-void verify_command(char_u *cmd)
+void verify_command(char *cmd)
{
- if (strcmp("smile", (char *)cmd)) {
+ if (strcmp("smile", cmd)) {
return; // acceptable non-existing command
}
msg(" #xxn` #xnxx` ,+x@##@Mz;` .xxx"
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 43865b1a21..f91371d3ad 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -2045,7 +2045,7 @@ int has_loop_cmd(char_u *p)
while (*p == ' ' || *p == '\t' || *p == ':') {
++p;
}
- len = modifier_len(p);
+ len = modifier_len((char *)p);
if (len == 0) {
break;
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 49e4428b5f..6550c5cbf3 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -390,13 +390,13 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
memset(&ea, 0, sizeof(ea));
ea.line1 = 1;
ea.line2 = 1;
- ea.cmd = ccline.cmdbuff;
+ ea.cmd = (char *)ccline.cmdbuff;
ea.addr_type = ADDR_LINES;
parse_command_modifiers(&ea, &dummy, true);
cmdmod = save_cmdmod;
- cmd = skip_range(ea.cmd, NULL);
+ cmd = (char_u *)skip_range(ea.cmd, NULL);
if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) {
goto theend;
}
@@ -2349,7 +2349,7 @@ static int command_line_changed(CommandLineState *s)
&& *p_icm != NUL // 'inccommand' is set
&& curbuf->b_p_ma // buffer is modifiable
&& cmdline_star == 0 // not typing a password
- && cmd_can_preview(ccline.cmdbuff)
+ && cmd_can_preview((char *)ccline.cmdbuff)
&& !vpeekc_any()) {
// Show 'inccommand' preview. It works like this:
// 1. Do the command.
@@ -2359,7 +2359,7 @@ static int command_line_changed(CommandLineState *s)
State |= CMDPREVIEW;
emsg_silent++; // Block error reporting as the command may be incomplete
msg_silent++; // Block messages, namely ones that prompt
- do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT|DOCMD_PREVIEW);
+ do_cmdline((char *)ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT|DOCMD_PREVIEW);
msg_silent--; // Unblock messages
emsg_silent--; // Unblock error reporting
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index f1195f1644..7ca7abccdc 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -690,7 +690,7 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
* Decide which 'encoding' to use or use first.
*/
if (eap != NULL && eap->force_enc != 0) {
- fenc = enc_canonize(eap->cmd + eap->force_enc);
+ fenc = enc_canonize((char_u *)eap->cmd + eap->force_enc);
fenc_alloced = true;
keep_dest_enc = true;
} else if (curbuf->b_p_bin) {
@@ -2027,7 +2027,7 @@ void prep_exarg(exarg_T *eap, const buf_T *buf)
const size_t cmd_len = 15 + STRLEN(buf->b_p_fenc);
eap->cmd = xmalloc(cmd_len);
- snprintf((char *)eap->cmd, cmd_len, "e ++enc=%s", buf->b_p_fenc);
+ snprintf(eap->cmd, cmd_len, "e ++enc=%s", buf->b_p_fenc);
eap->force_enc = 8;
eap->bad_char = buf->b_bad_char;
eap->force_ff = *buf->b_p_ff;
@@ -2062,7 +2062,7 @@ void set_file_options(int set_options, exarg_T *eap)
void set_forced_fenc(exarg_T *eap)
{
if (eap->force_enc != 0) {
- char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
+ char_u *fenc = enc_canonize((char_u *)eap->cmd + eap->force_enc);
set_string_option_direct("fenc", -1, fenc, OPT_FREE|OPT_LOCAL, 0);
xfree(fenc);
}
@@ -3066,7 +3066,7 @@ nobackup:
// Check for forced 'fileencoding' from "++opt=val" argument.
if (eap != NULL && eap->force_enc != 0) {
- fenc = eap->cmd + eap->force_enc;
+ fenc = (char_u *)eap->cmd + eap->force_enc;
fenc = enc_canonize(fenc);
fenc_tofree = fenc;
} else {
diff --git a/src/nvim/main.c b/src/nvim/main.c
index c0b565fff7..480b5ab0b5 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1376,7 +1376,7 @@ scripterror:
int alist_fnum_flag = edit_stdin(had_stdin_file, parmp)
? 1 // add buffer nr after exp.
: 2; // add buffer number now and use curbuf
- alist_add(&global_alist, p, alist_fnum_flag);
+ alist_add(&global_alist, (char *)p, alist_fnum_flag);
}
// If there are no more letters after the current "-", go to next argument.