mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
Merge pull request #17226 from dundargoc/refactor/remove-redundant-code
vim-patch:8.2.4241: some type casts are redundant
This commit is contained in:
commit
89e308d7da
@ -139,10 +139,10 @@ bool try_end(Error *err)
|
||||
got_int = false;
|
||||
} else if (msg_list != NULL && *msg_list != NULL) {
|
||||
int should_free;
|
||||
char *msg = (char *)get_exception_string(*msg_list,
|
||||
ET_ERROR,
|
||||
NULL,
|
||||
&should_free);
|
||||
char *msg = get_exception_string(*msg_list,
|
||||
ET_ERROR,
|
||||
NULL,
|
||||
&should_free);
|
||||
api_set_error(err, kErrorTypeException, "%s", msg);
|
||||
free_global_msglist();
|
||||
|
||||
@ -720,7 +720,6 @@ fail_and_free:
|
||||
xfree(parsed_args.rhs);
|
||||
xfree(parsed_args.orig_rhs);
|
||||
XFREE_CLEAR(parsed_args.desc);
|
||||
return;
|
||||
}
|
||||
|
||||
/// Collects `n` buffer lines into array `l`, optionally replacing newlines
|
||||
|
@ -268,7 +268,7 @@ void do_debug(char_u *cmd)
|
||||
DOCMD_VERBOSE|DOCMD_EXCRESET);
|
||||
debug_break_level = n;
|
||||
}
|
||||
lines_left = (int)(Rows - 1);
|
||||
lines_left = Rows - 1;
|
||||
}
|
||||
xfree(cmdline);
|
||||
|
||||
@ -277,7 +277,7 @@ void do_debug(char_u *cmd)
|
||||
redraw_all_later(NOT_VALID);
|
||||
need_wait_return = false;
|
||||
msg_scroll = save_msg_scroll;
|
||||
lines_left = (int)(Rows - 1);
|
||||
lines_left = Rows - 1;
|
||||
State = save_State;
|
||||
debug_mode = false;
|
||||
did_emsg = save_did_emsg;
|
||||
|
@ -1366,7 +1366,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
|
||||
ui_cursor_goto(Rows - 1, 0);
|
||||
|
||||
if (do_out) {
|
||||
if (u_save((line2), (linenr_T)(line2 + 1)) == FAIL) {
|
||||
if (u_save(line2, (linenr_T)(line2 + 1)) == FAIL) {
|
||||
xfree(cmd_buf);
|
||||
goto error;
|
||||
}
|
||||
@ -3055,7 +3055,7 @@ void ex_append(exarg_T *eap)
|
||||
// it is the same as "start" -- Acevedo
|
||||
if (!cmdmod.lockmarks) {
|
||||
curbuf->b_op_start.lnum
|
||||
= (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count;
|
||||
= (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count;
|
||||
if (eap->cmdidx != CMD_append) {
|
||||
curbuf->b_op_start.lnum--;
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ static void catch_exception(except_T *excp)
|
||||
{
|
||||
excp->caught = caught_stack;
|
||||
caught_stack = excp;
|
||||
set_vim_var_string(VV_EXCEPTION, (char *)excp->value, -1);
|
||||
set_vim_var_string(VV_EXCEPTION, excp->value, -1);
|
||||
if (*excp->throw_name != NUL) {
|
||||
if (excp->throw_lnum != 0) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64),
|
||||
@ -650,7 +650,7 @@ static void finish_exception(except_T *excp)
|
||||
}
|
||||
caught_stack = caught_stack->caught;
|
||||
if (caught_stack != NULL) {
|
||||
set_vim_var_string(VV_EXCEPTION, (char *)caught_stack->value, -1);
|
||||
set_vim_var_string(VV_EXCEPTION, caught_stack->value, -1);
|
||||
if (*caught_stack->throw_name != NUL) {
|
||||
if (caught_stack->throw_lnum != 0) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
@ -733,7 +733,7 @@ static void report_pending(int action, int pending, void *value)
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
mesg, _("Exception"));
|
||||
mesg = (char *)concat_str(IObuff, (char_u *)": %s");
|
||||
s = (char *)((except_T *)value)->value;
|
||||
s = ((except_T *)value)->value;
|
||||
} else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) {
|
||||
s = _("Error and interrupt");
|
||||
} else if (pending & CSTP_ERROR) {
|
||||
@ -1620,7 +1620,7 @@ void ex_endtry(exarg_T *eap)
|
||||
// the finally clause. The latter case need not be tested since then
|
||||
// anything pending has already been discarded.
|
||||
bool skip = did_emsg || got_int || current_exception
|
||||
|| !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE);
|
||||
|| !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE);
|
||||
|
||||
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
|
||||
eap->errmsg = get_end_emsg(cstack);
|
||||
|
@ -311,7 +311,7 @@ static char_u *get_healthcheck_names(expand_T *xp, int idx)
|
||||
healthchecks.last_gen = last_prompt_id;
|
||||
}
|
||||
return idx <
|
||||
(int)healthchecks.names.ga_len ? ((char_u **)(healthchecks.names.ga_data))[idx] : NULL;
|
||||
healthchecks.names.ga_len ? ((char_u **)(healthchecks.names.ga_data))[idx] : NULL;
|
||||
}
|
||||
|
||||
/// Transform healthcheck file path into it's name.
|
||||
|
@ -919,8 +919,8 @@ static int cs_find(exarg_T *eap)
|
||||
|
||||
|
||||
/// Common code for cscope find, shared by cs_find() and ex_cstag().
|
||||
static bool cs_find_common(char *opt, char *pat, int forceit, int verbose,
|
||||
bool use_ll, char_u *cmdline)
|
||||
static bool cs_find_common(char *opt, char *pat, int forceit, int verbose, bool use_ll,
|
||||
char_u *cmdline)
|
||||
{
|
||||
char *cmd;
|
||||
int *nummatches;
|
||||
@ -1594,7 +1594,6 @@ static char *cs_pathcomponents(char *path)
|
||||
char *s = path + strlen(path) - 1;
|
||||
for (int i = 0; i < p_cspc; i++) {
|
||||
while (s > path && *--s != '/') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((s > path && *s == '/')) {
|
||||
@ -1813,7 +1812,6 @@ static int cs_read_prompt(size_t i)
|
||||
static void sig_handler(int s)
|
||||
{
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -682,7 +682,7 @@ int nlua_call(lua_State *lstate)
|
||||
typval_T vim_args[MAX_FUNC_ARGS + 1];
|
||||
int i = 0; // also used for freeing the variables
|
||||
for (; i < nargs; i++) {
|
||||
lua_pushvalue(lstate, (int)i+2);
|
||||
lua_pushvalue(lstate, i+2);
|
||||
if (!nlua_pop_typval(lstate, &vim_args[i])) {
|
||||
api_set_error(&err, kErrorTypeException,
|
||||
"error converting argument %d", i+1);
|
||||
@ -747,7 +747,7 @@ static int nlua_rpc(lua_State *lstate, bool request)
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
|
||||
for (int i = 0; i < nargs; i++) {
|
||||
lua_pushvalue(lstate, (int)i+3);
|
||||
lua_pushvalue(lstate, i+3);
|
||||
ADD(args, nlua_pop_Object(lstate, false, &err));
|
||||
if (ERROR_SET(&err)) {
|
||||
api_free_array(args);
|
||||
|
@ -262,7 +262,6 @@ void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clea
|
||||
if (*s != NUL) {
|
||||
msg_outtrans_attr((char_u *)s, attr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -329,7 +328,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
|
||||
}
|
||||
retval = msg_end();
|
||||
|
||||
if (keep && retval && vim_strsize((char_u *)s) < (int)(Rows - cmdline_row - 1)
|
||||
if (keep && retval && vim_strsize((char_u *)s) < (Rows - cmdline_row - 1)
|
||||
* Columns + sc_col) {
|
||||
set_keep_msg((char *)s, 0);
|
||||
}
|
||||
@ -356,10 +355,10 @@ char_u *msg_strtrunc(char_u *s, int force)
|
||||
len = vim_strsize(s);
|
||||
if (msg_scrolled != 0) {
|
||||
// Use all the columns.
|
||||
room = (int)(Rows - msg_row) * Columns - 1;
|
||||
room = (Rows - msg_row) * Columns - 1;
|
||||
} else {
|
||||
// Use up to 'showcmd' column.
|
||||
room = (int)(Rows - msg_row - 1) * Columns + sc_col - 1;
|
||||
room = (Rows - msg_row - 1) * Columns + sc_col - 1;
|
||||
}
|
||||
if (len > room && room > 0) {
|
||||
// may have up to 18 bytes per cell (6 per char, up to two
|
||||
@ -873,7 +872,7 @@ char_u *msg_may_trunc(bool force, char_u *s)
|
||||
{
|
||||
int room;
|
||||
|
||||
room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
|
||||
room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
|
||||
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
|
||||
&& (int)STRLEN(s) - room > 0) {
|
||||
int size = vim_strsize(s);
|
||||
|
@ -1030,7 +1030,7 @@ static int normal_execute(VimState *state, int key)
|
||||
|
||||
s->need_flushbuf = add_to_showcmd(s->c);
|
||||
|
||||
while (normal_get_command_count(s)) { continue; }
|
||||
while (normal_get_command_count(s)) { }
|
||||
|
||||
if (s->c == K_EVENT) {
|
||||
// Save the count values so that ca.opcount and ca.count0 are exactly
|
||||
@ -4093,7 +4093,7 @@ static void nv_colon(cmdarg_T *cap)
|
||||
if (is_lua) {
|
||||
cmd_result = map_execute_lua();
|
||||
} else {
|
||||
// get a command line and execute it
|
||||
// get a command line and execute it
|
||||
cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL,
|
||||
cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0);
|
||||
}
|
||||
@ -6328,7 +6328,7 @@ static void nv_g_cmd(cmdarg_T *cap)
|
||||
curwin->w_set_curswant = true;
|
||||
break;
|
||||
|
||||
case 'M': {
|
||||
case 'M':
|
||||
oap->motion_type = kMTCharWise;
|
||||
oap->inclusive = false;
|
||||
i = linetabsize(get_cursor_line_ptr());
|
||||
@ -6338,8 +6338,7 @@ static void nv_g_cmd(cmdarg_T *cap)
|
||||
coladvance((colnr_T)(i / 2));
|
||||
}
|
||||
curwin->w_set_curswant = true;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case '_':
|
||||
/* "g_": to the last non-blank character in the line or <count> lines
|
||||
|
@ -381,8 +381,8 @@ static void shift_block(oparg_T *oap, int amount)
|
||||
}
|
||||
}
|
||||
for (; ascii_iswhite(*bd.textstart);) {
|
||||
// TODO: is passing bd.textstart for start of the line OK?
|
||||
incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, (bd.start_vcol));
|
||||
// TODO(fmoralesc): is passing bd.textstart for start of the line OK?
|
||||
incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, bd.start_vcol);
|
||||
total += incr;
|
||||
bd.start_vcol += incr;
|
||||
}
|
||||
@ -2789,8 +2789,6 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
||||
curbuf->b_op_end.col = MAXCOL;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy a block range into a register.
|
||||
|
@ -1781,7 +1781,7 @@ static char *illegal_char(char *errbuf, size_t errbuflen, int c)
|
||||
if (errbuf == NULL) {
|
||||
return "";
|
||||
}
|
||||
vim_snprintf((char *)errbuf, errbuflen, _("E539: Illegal character <%s>"),
|
||||
vim_snprintf(errbuf, errbuflen, _("E539: Illegal character <%s>"),
|
||||
(char *)transchar(c));
|
||||
return errbuf;
|
||||
}
|
||||
@ -2284,12 +2284,12 @@ static char *set_string_option(const int opt_idx, const char *const value, const
|
||||
*varp = s;
|
||||
|
||||
char *const saved_oldval = xstrdup(oldval);
|
||||
char *const saved_oldval_l = (oldval_l != NULL) ? xstrdup((char *)oldval_l) : 0;
|
||||
char *const saved_oldval_g = (oldval_g != NULL) ? xstrdup((char *)oldval_g) : 0;
|
||||
char *const saved_oldval_l = (oldval_l != NULL) ? xstrdup(oldval_l) : 0;
|
||||
char *const saved_oldval_g = (oldval_g != NULL) ? xstrdup(oldval_g) : 0;
|
||||
char *const saved_newval = xstrdup(s);
|
||||
|
||||
int value_checked = false;
|
||||
char *const r = did_set_string_option(opt_idx, (char_u **)varp, (int)true,
|
||||
char *const r = did_set_string_option(opt_idx, (char_u **)varp, true,
|
||||
(char_u *)oldval,
|
||||
NULL, 0, opt_flags, &value_checked);
|
||||
if (r == NULL) {
|
||||
@ -2777,7 +2777,7 @@ ambw_end:
|
||||
|
||||
if (!ascii_isdigit(*(s - 1))) {
|
||||
if (errbuf != NULL) {
|
||||
vim_snprintf((char *)errbuf, errbuflen,
|
||||
vim_snprintf(errbuf, errbuflen,
|
||||
_("E526: Missing number after <%s>"),
|
||||
transchar_byte(*(s - 1)));
|
||||
errmsg = errbuf;
|
||||
@ -2968,7 +2968,7 @@ ambw_end:
|
||||
}
|
||||
} else {
|
||||
if (errbuf != NULL) {
|
||||
vim_snprintf((char *)errbuf, errbuflen,
|
||||
vim_snprintf(errbuf, errbuflen,
|
||||
_("E535: Illegal character after <%c>"),
|
||||
*--s);
|
||||
errmsg = errbuf;
|
||||
@ -4429,7 +4429,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf,
|
||||
|
||||
// Don't change the value and return early if validation failed.
|
||||
if (errmsg != NULL) {
|
||||
return (char *)errmsg;
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
*pp = value;
|
||||
@ -4553,7 +4553,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf,
|
||||
// Check the (new) bounds for Rows and Columns here.
|
||||
if (p_lines < min_rows() && full_screen) {
|
||||
if (errbuf != NULL) {
|
||||
vim_snprintf((char *)errbuf, errbuflen,
|
||||
vim_snprintf(errbuf, errbuflen,
|
||||
_("E593: Need at least %d lines"), min_rows());
|
||||
errmsg = errbuf;
|
||||
}
|
||||
@ -4561,7 +4561,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf,
|
||||
}
|
||||
if (p_columns < MIN_COLUMNS && full_screen) {
|
||||
if (errbuf != NULL) {
|
||||
vim_snprintf((char *)errbuf, errbuflen,
|
||||
vim_snprintf(errbuf, errbuflen,
|
||||
_("E594: Need at least %d columns"), MIN_COLUMNS);
|
||||
errmsg = errbuf;
|
||||
}
|
||||
@ -4677,7 +4677,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf,
|
||||
}
|
||||
check_redraw(options[opt_idx].flags);
|
||||
|
||||
return (char *)errmsg;
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
/// Trigger the OptionSet autocommand.
|
||||
|
@ -291,7 +291,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
} else {
|
||||
assert(Columns - pum_col - pum_scrollbar >= INT_MIN
|
||||
&& Columns - pum_col - pum_scrollbar <= INT_MAX);
|
||||
pum_width = (int)(Columns - pum_col - pum_scrollbar);
|
||||
pum_width = Columns - pum_col - pum_scrollbar;
|
||||
}
|
||||
|
||||
if ((pum_width > max_width + pum_kind_width + pum_extra_width + 1)
|
||||
@ -352,12 +352,12 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
// not enough room, will use what we have
|
||||
if (pum_rl) {
|
||||
assert(Columns - 1 >= INT_MIN);
|
||||
pum_col = (int)(Columns - 1);
|
||||
pum_col = Columns - 1;
|
||||
} else {
|
||||
pum_col = 0;
|
||||
}
|
||||
assert(Columns - 1 >= INT_MIN);
|
||||
pum_width = (int)(Columns - 1);
|
||||
pum_width = Columns - 1;
|
||||
} else {
|
||||
if (max_width > p_pw) {
|
||||
// truncate
|
||||
@ -369,7 +369,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
} else {
|
||||
assert(Columns - max_width >= INT_MIN
|
||||
&& Columns - max_width <= INT_MAX);
|
||||
pum_col = (int)(Columns - max_width);
|
||||
pum_col = Columns - max_width;
|
||||
}
|
||||
pum_width = max_width - pum_scrollbar;
|
||||
}
|
||||
|
@ -6919,8 +6919,6 @@ void grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
|
||||
if (!grid->throttled) {
|
||||
ui_call_grid_scroll(grid->handle, row, end, col, col+width, -line_count, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// delete lines on the screen and move lines up.
|
||||
@ -6971,8 +6969,6 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
|
||||
if (!grid->throttled) {
|
||||
ui_call_grid_scroll(grid->handle, row, end, col, col+width, line_count, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1501,28 +1501,28 @@ static void sign_getinfo(sign_T *sp, dict_T *retdict)
|
||||
if (p == NULL) {
|
||||
p = "NONE";
|
||||
}
|
||||
tv_dict_add_str(retdict, S_LEN("linehl"), (char *)p);
|
||||
tv_dict_add_str(retdict, S_LEN("linehl"), p);
|
||||
}
|
||||
if (sp->sn_text_hl > 0) {
|
||||
p = get_highlight_name_ext(NULL, sp->sn_text_hl - 1, false);
|
||||
if (p == NULL) {
|
||||
p = "NONE";
|
||||
}
|
||||
tv_dict_add_str(retdict, S_LEN("texthl"), (char *)p);
|
||||
tv_dict_add_str(retdict, S_LEN("texthl"), p);
|
||||
}
|
||||
if (sp->sn_cul_hl > 0) {
|
||||
p = get_highlight_name_ext(NULL, sp->sn_cul_hl - 1, false);
|
||||
if (p == NULL) {
|
||||
p = "NONE";
|
||||
}
|
||||
tv_dict_add_str(retdict, S_LEN("culhl"), (char *)p);
|
||||
tv_dict_add_str(retdict, S_LEN("culhl"), p);
|
||||
}
|
||||
if (sp->sn_num_hl > 0) {
|
||||
p = get_highlight_name_ext(NULL, sp->sn_num_hl - 1, false);
|
||||
if (p == NULL) {
|
||||
p = "NONE";
|
||||
}
|
||||
tv_dict_add_str(retdict, S_LEN("numhl"), (char *)p);
|
||||
tv_dict_add_str(retdict, S_LEN("numhl"), p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,6 @@ static TermKeyResult tk_getkey(TermKey *tk, TermKeyKey *key, bool force)
|
||||
return force ? termkey_getkey_force(tk, key) : termkey_getkey(tk, key);
|
||||
}
|
||||
|
||||
static void tinput_timer_cb(TimeWatcher *watcher, void *data);
|
||||
|
||||
static void tk_getkeys(TermInput *input, bool force)
|
||||
{
|
||||
|
@ -2093,7 +2093,7 @@ void list_in_columns(char_u **items, int size, int current)
|
||||
|
||||
// The rightmost column doesn't need a separator.
|
||||
// Sacrifice it to fit in one more column if possible.
|
||||
int ncol = (int)(Columns + 1) / width;
|
||||
int ncol = (Columns + 1) / width;
|
||||
int nrow = item_count / ncol + (item_count % ncol ? 1 : 0);
|
||||
int cur_row = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user