refactor: replace char_u variables and functions with char (#18288)

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
dundargoc 2022-04-30 16:48:00 +02:00 committed by GitHub
parent fcdf24d8be
commit 3c23100130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 492 additions and 508 deletions

View File

@ -1526,7 +1526,7 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
} }
if (opts->addr.type == kObjectTypeString) { 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) { &addr_type_arg) != OK) {
api_set_error(err, kErrorTypeValidation, "Invalid value for 'addr'"); api_set_error(err, kErrorTypeValidation, "Invalid value for 'addr'");
goto err; goto err;
@ -1574,9 +1574,9 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
compl = EXPAND_USER_LUA; compl = EXPAND_USER_LUA;
compl_luaref = api_new_luaref(opts->complete.data.luaref); compl_luaref = api_new_luaref(opts->complete.data.luaref);
} else if (opts->complete.type == kObjectTypeString) { } 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, (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'"); api_set_error(err, kErrorTypeValidation, "Invalid value for 'complete'");
goto err; goto err;
} }
@ -1603,9 +1603,8 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
goto err; goto err;
} }
if (uc_add_command((char_u *)name.data, name.size, (char_u *)rep, argt, def, flags, if (uc_add_command(name.data, name.size, rep, argt, def, flags, compl, compl_arg, compl_luaref,
compl, (char_u *)compl_arg, compl_luaref, addr_type_arg, luaref, addr_type_arg, luaref, force) != OK) {
force) != OK) {
api_set_error(err, kErrorTypeException, "Failed to create user command"); api_set_error(err, kErrorTypeException, "Failed to create user command");
goto err; goto err;
} }

View File

@ -568,7 +568,7 @@ void nvim_set_current_dir(String dir, Error *err)
try_start(); try_start();
if (!changedir_func(string, kCdScopeGlobal)) { if (!changedir_func((char *)string, kCdScopeGlobal)) {
if (!try_end(err)) { if (!try_end(err)) {
api_set_error(err, kErrorTypeException, "Failed to change directory"); api_set_error(err, kErrorTypeException, "Failed to change directory");
} }

View File

@ -831,7 +831,7 @@ void do_autocmd(char_u *arg_in, int forceit)
// Find the start of the commands. // Find the start of the commands.
// Expand <sfile> in it. // Expand <sfile> in it.
if (*cmd != NUL) { if (*cmd != NUL) {
cmd = expand_sfile(cmd); cmd = (char_u *)expand_sfile((char *)cmd);
if (cmd == NULL) { // some error if (cmd == NULL) { // some error
return; return;
} }

View File

@ -263,8 +263,7 @@ void do_debug(char_u *cmd)
// don't debug this command // don't debug this command
n = debug_break_level; n = debug_break_level;
debug_break_level = -1; debug_break_level = -1;
(void)do_cmdline(cmdline, getexline, NULL, (void)do_cmdline((char *)cmdline, getexline, NULL, DOCMD_VERBOSE|DOCMD_EXCRESET);
DOCMD_VERBOSE|DOCMD_EXCRESET);
debug_break_level = n; debug_break_level = n;
} }
lines_left = Rows - 1; lines_left = Rows - 1;
@ -406,7 +405,7 @@ void dbg_check_breakpoint(exarg_T *eap)
debug_breakpoint_name + (*p == NUL ? 0 : 3), debug_breakpoint_name + (*p == NUL ? 0 : 3),
(int64_t)debug_breakpoint_lnum); (int64_t)debug_breakpoint_lnum);
debug_breakpoint_name = NULL; debug_breakpoint_name = NULL;
do_debug(eap->cmd); do_debug((char_u *)eap->cmd);
} else { } else {
debug_skipped = true; debug_skipped = true;
debug_skipped_name = debug_breakpoint_name; 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) { } else if (ex_nesting_level <= debug_break_level) {
if (!eap->skip) { if (!eap->skip) {
do_debug(eap->cmd); do_debug((char_u *)eap->cmd);
} else { } else {
debug_skipped = true; debug_skipped = true;
debug_skipped_name = NULL; debug_skipped_name = NULL;

View File

@ -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); const int xp_namelen = (int)strlen(xp_name);
uint32_t argt; uint32_t argt;
if (parse_compl_arg((char_u *)xp_name, xp_namelen, &xp_type, if (parse_compl_arg(xp_name, xp_namelen, &xp_type,
&argt, (char_u **)&xp_arg) == FAIL) { &argt, &xp_arg) == FAIL) {
return; return;
} }
} }
@ -9579,8 +9579,7 @@ void ex_execute(exarg_T *eap)
did_emsg = save_did_emsg; did_emsg = save_did_emsg;
} }
} else if (eap->cmdidx == CMD_execute) { } else if (eap->cmdidx == CMD_execute) {
do_cmdline((char_u *)ga.ga_data, do_cmdline(ga.ga_data, eap->getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE);
eap->getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE);
} }
} }

View File

@ -1018,7 +1018,7 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
scope = kCdScopeTabpage; scope = kCdScopeTabpage;
} }
if (!changedir_func(argvars[0].vval.v_string, scope)) { if (!changedir_func((char *)argvars[0].vval.v_string, scope)) {
// Directory change failed // Directory change failed
XFREE_CLEAR(rettv->vval.v_string); 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])); char_u *cmdstr = (char_u *)xstrdup(tv_get_string(&argvars[0]));
exarg_T eap = { exarg_T eap = {
.cmd = cmdstr, .cmd = (char *)cmdstr,
.arg = cmdstr, .arg = cmdstr,
.usefilter = false, .usefilter = false,
.nextcmd = NULL, .nextcmd = NULL,

View File

@ -2272,7 +2272,7 @@ void ex_function(exarg_T *eap)
for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {} for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {}
// Check for "endfunction". // Check for "endfunction".
if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) { if (checkforcmd((char **)&p, "endfunction", 4) && nesting-- == 0) {
if (*p == '!') { if (*p == '!') {
p++; p++;
} }
@ -2311,7 +2311,7 @@ void ex_function(exarg_T *eap)
} }
// Check for defining a function inside this function. // Check for defining a function inside this function.
if (checkforcmd(&p, "function", 2)) { if (checkforcmd((char **)&p, "function", 2)) {
if (*p == '!') { if (*p == '!') {
p = skipwhite(p + 1); p = skipwhite(p + 1);
} }
@ -2324,7 +2324,7 @@ void ex_function(exarg_T *eap)
} }
// Check for ":append", ":change", ":insert". // 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')) if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c' || (p[0] == 'c'
&& (!ASCII_ISALPHA(p[1]) && (!ASCII_ISALPHA(p[1])

View File

@ -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) { if (p_confirm || cmdmod.confirm) {
char_u buff[DIALOG_MSG_SIZE]; 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) { if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) {
return FAIL; 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) { if (p_confirm || cmdmod.confirm) {
char_u buff[DIALOG_MSG_SIZE]; char_u buff[DIALOG_MSG_SIZE];
dialog_msg(buff, dialog_msg((char *)buff,
_("Swap file \"%s\" exists, overwrite anyway?"), _("Swap file \"%s\" exists, overwrite anyway?"),
swapname); (char *)swapname);
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)
!= VIM_YES) { != VIM_YES) {
xfree(swapname); xfree(swapname);
@ -2150,14 +2150,14 @@ static int check_readonly(int *forceit, buf_T *buf)
char_u buff[DIALOG_MSG_SIZE]; char_u buff[DIALOG_MSG_SIZE];
if (buf->b_p_ro) { if (buf->b_p_ro) {
dialog_msg(buff, dialog_msg((char *)buff,
_("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"), _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
buf->b_fname); (char *)buf->b_fname);
} else { } else {
dialog_msg(buff, dialog_msg((char *)buff,
_( _("File permissions of \"%s\" are read-only.\nIt may still be possible to "
"File permissions of \"%s\" are read-only.\nIt may still be possible to write it.\nDo you wish to try?"), "write it.\nDo you wish to try?"),
buf->b_fname); (char *)buf->b_fname);
} }
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES) { 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); curbuf->b_last_used = time(NULL);
if (command != 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) { 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.lnum = lnum;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
if (*cmd == NUL || *cmd == '\n') { if (*cmd == NUL || *cmd == '\n') {
do_cmdline((char_u *)"p", NULL, NULL, DOCMD_NOWAIT); do_cmdline("p", NULL, NULL, DOCMD_NOWAIT);
} else { } else {
do_cmdline(cmd, NULL, NULL, DOCMD_NOWAIT); do_cmdline((char *)cmd, NULL, NULL, DOCMD_NOWAIT);
} }
} }

View File

@ -554,7 +554,7 @@ void dialog_changed(buf_T *buf, bool checkall)
.forceit = false, .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) { if (checkall) {
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1); ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1);
} else { } else {
@ -610,8 +610,8 @@ bool dialog_close_terminal(buf_T *buf)
{ {
char_u buff[DIALOG_MSG_SIZE]; char_u buff[DIALOG_MSG_SIZE];
dialog_msg(buff, _("Close \"%s\"?"), dialog_msg((char *)buff, _("Close \"%s\"?"),
(buf->b_fname != NULL) ? buf->b_fname : (char_u *)"?"); (buf->b_fname != NULL) ? (char *)buf->b_fname : "?");
int ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); 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); xfree(exp_files);
} else { } else {
assert(what == AL_SET); 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++; i++;
// execute the command // execute the command
if (execute) { if (execute) {
do_cmdline(eap->arg, eap->getline, eap->cookie, do_cmdline((char *)eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT);
DOCMD_VERBOSE + DOCMD_NOWAIT);
} }
if (eap->cmdidx == CMD_bufdo) { 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; sourcing_lnum = sourcing_lnum_backup;
} else { } else {
// Call do_cmdline, which will call getsourceline() to get the lines. // 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); DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
} }
retval = OK; retval = OK;

View File

@ -176,7 +176,7 @@ enum {
struct exarg { struct exarg {
char_u *arg; ///< argument of the command char_u *arg; ///< argument of the command
char_u *nextcmd; ///< next command (NULL if none) 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 char_u **cmdlinep; ///< pointer to pointer of allocated cmdline
cmdidx_T cmdidx; ///< the index for the command cmdidx_T cmdidx; ///< the index for the command
uint32_t argt; ///< flags for the command uint32_t argt; ///< flags for the command

File diff suppressed because it is too large Load Diff

View File

@ -2045,7 +2045,7 @@ int has_loop_cmd(char_u *p)
while (*p == ' ' || *p == '\t' || *p == ':') { while (*p == ' ' || *p == '\t' || *p == ':') {
++p; ++p;
} }
len = modifier_len(p); len = modifier_len((char *)p);
if (len == 0) { if (len == 0) {
break; break;
} }

View File

@ -390,13 +390,13 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
memset(&ea, 0, sizeof(ea)); memset(&ea, 0, sizeof(ea));
ea.line1 = 1; ea.line1 = 1;
ea.line2 = 1; ea.line2 = 1;
ea.cmd = ccline.cmdbuff; ea.cmd = (char *)ccline.cmdbuff;
ea.addr_type = ADDR_LINES; ea.addr_type = ADDR_LINES;
parse_command_modifiers(&ea, &dummy, true); parse_command_modifiers(&ea, &dummy, true);
cmdmod = save_cmdmod; 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) { if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) {
goto theend; goto theend;
} }
@ -2349,7 +2349,7 @@ static int command_line_changed(CommandLineState *s)
&& *p_icm != NUL // 'inccommand' is set && *p_icm != NUL // 'inccommand' is set
&& curbuf->b_p_ma // buffer is modifiable && curbuf->b_p_ma // buffer is modifiable
&& cmdline_star == 0 // not typing a password && cmdline_star == 0 // not typing a password
&& cmd_can_preview(ccline.cmdbuff) && cmd_can_preview((char *)ccline.cmdbuff)
&& !vpeekc_any()) { && !vpeekc_any()) {
// Show 'inccommand' preview. It works like this: // Show 'inccommand' preview. It works like this:
// 1. Do the command. // 1. Do the command.
@ -2359,7 +2359,7 @@ static int command_line_changed(CommandLineState *s)
State |= CMDPREVIEW; State |= CMDPREVIEW;
emsg_silent++; // Block error reporting as the command may be incomplete emsg_silent++; // Block error reporting as the command may be incomplete
msg_silent++; // Block messages, namely ones that prompt 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 msg_silent--; // Unblock messages
emsg_silent--; // Unblock error reporting emsg_silent--; // Unblock error reporting

View File

@ -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. * Decide which 'encoding' to use or use first.
*/ */
if (eap != NULL && eap->force_enc != 0) { 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; fenc_alloced = true;
keep_dest_enc = true; keep_dest_enc = true;
} else if (curbuf->b_p_bin) { } 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); const size_t cmd_len = 15 + STRLEN(buf->b_p_fenc);
eap->cmd = xmalloc(cmd_len); 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->force_enc = 8;
eap->bad_char = buf->b_bad_char; eap->bad_char = buf->b_bad_char;
eap->force_ff = *buf->b_p_ff; 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) void set_forced_fenc(exarg_T *eap)
{ {
if (eap->force_enc != 0) { 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); set_string_option_direct("fenc", -1, fenc, OPT_FREE|OPT_LOCAL, 0);
xfree(fenc); xfree(fenc);
} }
@ -3066,7 +3066,7 @@ nobackup:
// Check for forced 'fileencoding' from "++opt=val" argument. // Check for forced 'fileencoding' from "++opt=val" argument.
if (eap != NULL && eap->force_enc != 0) { 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 = enc_canonize(fenc);
fenc_tofree = fenc; fenc_tofree = fenc;
} else { } else {

View File

@ -1376,7 +1376,7 @@ scripterror:
int alist_fnum_flag = edit_stdin(had_stdin_file, parmp) int alist_fnum_flag = edit_stdin(had_stdin_file, parmp)
? 1 // add buffer nr after exp. ? 1 // add buffer nr after exp.
: 2; // add buffer number now and use curbuf : 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. // If there are no more letters after the current "-", go to next argument.