mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: replace char_u variables and functions with char (#18288)
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
parent
fcdf24d8be
commit
3c23100130
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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])
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user