mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 9.0.1245: code is indented more than necessary
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11879)
This commit is contained in:
committed by
Bram Moolenaar
parent
0f843ef091
commit
032713f829
18
src/tag.c
18
src/tag.c
@@ -3263,8 +3263,9 @@ static garray_T tag_fnames = GA_EMPTY;
|
||||
static void
|
||||
found_tagfile_cb(char_u *fname, void *cookie UNUSED)
|
||||
{
|
||||
if (ga_grow(&tag_fnames, 1) == OK)
|
||||
{
|
||||
if (ga_grow(&tag_fnames, 1) == FAIL)
|
||||
return;
|
||||
|
||||
char_u *tag_fname = vim_strsave(fname);
|
||||
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
@@ -3272,7 +3273,6 @@ found_tagfile_cb(char_u *fname, void *cookie UNUSED)
|
||||
#endif
|
||||
simplify_filename(tag_fname);
|
||||
((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] = tag_fname;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(EXITFREE) || defined(PROTO)
|
||||
@@ -3587,8 +3587,9 @@ parse_match(
|
||||
tagp->tagline = 0;
|
||||
tagp->command_end = NULL;
|
||||
|
||||
if (retval == OK)
|
||||
{
|
||||
if (retval != OK)
|
||||
return retval;
|
||||
|
||||
// Try to find a kind field: "kind:<kind>" or just "<kind>"
|
||||
p = tagp->command;
|
||||
if (find_extra(&p) == OK)
|
||||
@@ -3635,7 +3636,6 @@ parse_match(
|
||||
;
|
||||
tagp->user_data_end = p;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -4372,8 +4372,9 @@ get_tags(list_T *list, char_u *pat, char_u *buf_fname)
|
||||
|
||||
ret = find_tags(pat, &num_matches, &matches,
|
||||
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname);
|
||||
if (ret == OK && num_matches > 0)
|
||||
{
|
||||
if (ret != OK || num_matches <= 0)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < num_matches; ++i)
|
||||
{
|
||||
if (parse_match(matches[i], &tp) == FAIL)
|
||||
@@ -4459,7 +4460,6 @@ get_tags(list_T *list, char_u *pat, char_u *buf_fname)
|
||||
vim_free(matches[i]);
|
||||
}
|
||||
vim_free(matches);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
108
src/term.c
108
src/term.c
@@ -1644,8 +1644,9 @@ set_color_count(int nr)
|
||||
static void
|
||||
may_adjust_color_count(int val)
|
||||
{
|
||||
if (val != t_colors)
|
||||
{
|
||||
if (val == t_colors)
|
||||
return;
|
||||
|
||||
// Nr of colors changed, initialize highlighting and redraw everything.
|
||||
// This causes a redraw, which usually clears the message. Try keeping
|
||||
// the message if it might work.
|
||||
@@ -1661,7 +1662,6 @@ may_adjust_color_count(int val)
|
||||
#else
|
||||
redraw_asap(UPD_CLEAR);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_TGETENT
|
||||
@@ -2419,13 +2419,14 @@ getlinecol(
|
||||
{
|
||||
char_u tbuf[TBUFSZ];
|
||||
|
||||
if (T_NAME != NULL && *T_NAME != NUL && invoke_tgetent(tbuf, T_NAME) == NULL)
|
||||
{
|
||||
if (T_NAME == NULL || *T_NAME == NUL
|
||||
|| invoke_tgetent(tbuf, T_NAME) != NULL)
|
||||
return;
|
||||
|
||||
if (*cp == 0)
|
||||
*cp = tgetnum("co");
|
||||
if (*rp == 0)
|
||||
*rp = tgetnum("li");
|
||||
}
|
||||
}
|
||||
#endif // defined(HAVE_TGETENT) && defined(UNIX)
|
||||
|
||||
@@ -2569,15 +2570,15 @@ term_is_8bit(char_u *name)
|
||||
static int
|
||||
term_7to8bit(char_u *p)
|
||||
{
|
||||
if (*p == ESC)
|
||||
{
|
||||
if (*p != ESC)
|
||||
return 0;
|
||||
|
||||
if (p[1] == '[')
|
||||
return CSI;
|
||||
if (p[1] == ']')
|
||||
else if (p[1] == ']')
|
||||
return OSC;
|
||||
if (p[1] == 'O')
|
||||
else if (p[1] == 'O')
|
||||
return 0x8f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2712,8 +2713,9 @@ out_flush(void)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (out_pos != 0)
|
||||
{
|
||||
if (out_pos == 0)
|
||||
return;
|
||||
|
||||
// set out_pos to 0 before ui_write, to avoid recursiveness
|
||||
len = out_pos;
|
||||
out_pos = 0;
|
||||
@@ -2732,7 +2734,6 @@ out_flush(void)
|
||||
ch_log_output = FALSE; // only log once
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2846,8 +2847,9 @@ out_str_nf(char_u *s)
|
||||
void
|
||||
out_str_cf(char_u *s)
|
||||
{
|
||||
if (s != NULL && *s)
|
||||
{
|
||||
if (s == NULL || *s == NUL)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_TGETENT
|
||||
char_u *p;
|
||||
#endif
|
||||
@@ -2905,7 +2907,6 @@ out_str_cf(char_u *s)
|
||||
// For testing we write one string at a time.
|
||||
if (p_wd)
|
||||
out_flush();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2917,8 +2918,9 @@ out_str_cf(char_u *s)
|
||||
void
|
||||
out_str(char_u *s)
|
||||
{
|
||||
if (s != NULL && *s)
|
||||
{
|
||||
if (s == NULL || *s == NUL)
|
||||
return;
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
// Don't use tputs() when GUI is used, ncurses crashes.
|
||||
if (gui.in_use)
|
||||
@@ -2940,7 +2942,6 @@ out_str(char_u *s)
|
||||
// For testing we write one string at a time.
|
||||
if (p_wd)
|
||||
out_flush();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3468,14 +3469,13 @@ get_long_from_buf(char_u *buf, long_u *val)
|
||||
|
||||
*val = 0;
|
||||
len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u));
|
||||
if (len != -1)
|
||||
{
|
||||
if (len == -1)
|
||||
return -1;
|
||||
for (i = 0; i < (int)sizeof(long_u); i++)
|
||||
{
|
||||
shift = 8 * (sizeof(long_u) - 1 - i);
|
||||
*val += (long_u)bytes[i] << shift;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
@@ -3598,19 +3598,19 @@ shell_resized_check(void)
|
||||
int old_Rows = Rows;
|
||||
int old_Columns = Columns;
|
||||
|
||||
if (!exiting
|
||||
if (exiting
|
||||
#ifdef FEAT_GUI
|
||||
// Do not get the size when executing a shell command during
|
||||
// startup.
|
||||
&& !gui.starting
|
||||
|| gui.starting
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return;
|
||||
|
||||
(void)ui_get_shellsize();
|
||||
check_shellsize();
|
||||
if (old_Rows != Rows || old_Columns != Columns)
|
||||
shell_resized();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3843,8 +3843,9 @@ settmode(tmode_T tmode)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (full_screen)
|
||||
{
|
||||
if (!full_screen)
|
||||
return;
|
||||
|
||||
/*
|
||||
* When returning after calling a shell cur_tmode is TMODE_UNKNOWN,
|
||||
* set the terminal to raw mode, even though we think it already is,
|
||||
@@ -3901,14 +3902,14 @@ settmode(tmode_T tmode)
|
||||
#ifdef FEAT_TERMRESPONSE
|
||||
may_req_termresponse();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
starttermcap(void)
|
||||
{
|
||||
if (full_screen && !termcap_active)
|
||||
{
|
||||
if (!full_screen || termcap_active)
|
||||
return;
|
||||
|
||||
MAY_WANT_TO_LOG_THIS;
|
||||
|
||||
out_str(T_TI); // start termcap mode
|
||||
@@ -3937,7 +3938,6 @@ starttermcap(void)
|
||||
check_for_codes_from_term();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3945,8 +3945,10 @@ stoptermcap(void)
|
||||
{
|
||||
screen_stop_highlight();
|
||||
reset_cterm_colors();
|
||||
if (termcap_active)
|
||||
{
|
||||
|
||||
if (!termcap_active)
|
||||
return;
|
||||
|
||||
#ifdef FEAT_TERMRESPONSE
|
||||
# ifdef FEAT_GUI
|
||||
if (!gui.in_use && !gui.starting)
|
||||
@@ -4001,7 +4003,6 @@ stoptermcap(void)
|
||||
// Kitty keyboard protocol
|
||||
screen_start(); // don't know where cursor is now
|
||||
out_flush();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FEAT_TERMRESPONSE) || defined(PROTO)
|
||||
@@ -4219,13 +4220,13 @@ swapping_screen(void)
|
||||
void
|
||||
scroll_start(void)
|
||||
{
|
||||
if (*T_VS != NUL && *T_CVS != NUL)
|
||||
{
|
||||
if (*T_VS == NUL || *T_CVS == NUL)
|
||||
return;
|
||||
|
||||
MAY_WANT_TO_LOG_THIS;
|
||||
out_str(T_VS);
|
||||
out_str(T_CVS);
|
||||
screen_start(); // don't know where cursor is now
|
||||
}
|
||||
}
|
||||
|
||||
// True if cursor is not visible
|
||||
@@ -4355,13 +4356,13 @@ term_cursor_mode(int forced)
|
||||
void
|
||||
term_cursor_color(char_u *color)
|
||||
{
|
||||
if (*T_CSC != NUL)
|
||||
{
|
||||
if (*T_CSC == NUL)
|
||||
return;
|
||||
|
||||
out_str(T_CSC); // set cursor color start
|
||||
out_str_nf(color);
|
||||
out_str(T_CEC); // set cursor color end
|
||||
out_flush();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -4922,8 +4923,9 @@ modifiers2keycode(int modifiers, int *key, char_u *string)
|
||||
{
|
||||
int new_slen = 0;
|
||||
|
||||
if (modifiers != 0)
|
||||
{
|
||||
if (modifiers == 0)
|
||||
return 0;
|
||||
|
||||
// Some keys have the modifier included. Need to handle that here to
|
||||
// make mappings work. This may result in a special key, such as
|
||||
// K_S_TAB.
|
||||
@@ -4934,7 +4936,6 @@ modifiers2keycode(int modifiers, int *key, char_u *string)
|
||||
string[new_slen++] = (int)KS_MODIFIER;
|
||||
string[new_slen++] = modifiers;
|
||||
}
|
||||
}
|
||||
return new_slen;
|
||||
}
|
||||
|
||||
@@ -6523,12 +6524,12 @@ check_termcode(
|
||||
void
|
||||
term_get_fg_color(char_u *r, char_u *g, char_u *b)
|
||||
{
|
||||
if (rfg_status.tr_progress == STATUS_GOT)
|
||||
{
|
||||
if (rfg_status.tr_progress != STATUS_GOT)
|
||||
return;
|
||||
|
||||
*r = fg_r;
|
||||
*g = fg_g;
|
||||
*b = fg_b;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6537,12 +6538,12 @@ term_get_fg_color(char_u *r, char_u *g, char_u *b)
|
||||
void
|
||||
term_get_bg_color(char_u *r, char_u *g, char_u *b)
|
||||
{
|
||||
if (rbg_status.tr_progress == STATUS_GOT)
|
||||
{
|
||||
if (rbg_status.tr_progress != STATUS_GOT)
|
||||
return;
|
||||
|
||||
*r = bg_r;
|
||||
*g = bg_g;
|
||||
*b = bg_b;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7283,15 +7284,14 @@ find_first_tcap(
|
||||
int code)
|
||||
{
|
||||
tcap_entry_T *p = find_builtin_term(name);
|
||||
if (p != NULL)
|
||||
{
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
while (p->bt_string != NULL)
|
||||
{
|
||||
if (p->bt_entry == code)
|
||||
return p;
|
||||
++p;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
|
107
src/terminal.c
107
src/terminal.c
@@ -259,8 +259,9 @@ parse_termwinsize(win_T *wp, int *rows, int *cols)
|
||||
*rows = 0;
|
||||
*cols = 0;
|
||||
|
||||
if (*wp->w_p_tws != NUL)
|
||||
{
|
||||
if (*wp->w_p_tws == NUL)
|
||||
return FALSE;
|
||||
|
||||
char_u *p = vim_strchr(wp->w_p_tws, 'x');
|
||||
|
||||
// Syntax of value was already checked when it's set.
|
||||
@@ -271,7 +272,6 @@ parse_termwinsize(win_T *wp, int *rows, int *cols)
|
||||
}
|
||||
*rows = atoi((char *)wp->w_p_tws);
|
||||
*cols = atoi((char *)p + 1);
|
||||
}
|
||||
return minsize;
|
||||
}
|
||||
|
||||
@@ -1620,10 +1620,11 @@ term_job_running_check(term_T *term, int check_job_status)
|
||||
{
|
||||
// Also consider the job finished when the channel is closed, to avoid a
|
||||
// race condition when updating the title.
|
||||
if (term != NULL
|
||||
&& term->tl_job != NULL
|
||||
&& channel_is_open(term->tl_job->jv_channel))
|
||||
{
|
||||
if (term == NULL
|
||||
|| term->tl_job == NULL
|
||||
|| !channel_is_open(term->tl_job->jv_channel))
|
||||
return FALSE;
|
||||
|
||||
job_T *job = term->tl_job;
|
||||
|
||||
// Careful: Checking the job status may invoke callbacks, which close
|
||||
@@ -1633,8 +1634,6 @@ term_job_running_check(term_T *term, int check_job_status)
|
||||
job_status(job);
|
||||
return (job->jv_status == JOB_STARTED
|
||||
|| (job->jv_channel != NULL && job->jv_channel->ch_keep_open));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1807,8 +1806,9 @@ equal_celattr(cellattr_T *a, cellattr_T *b)
|
||||
static int
|
||||
add_empty_scrollback(term_T *term, cellattr_T *fill_attr, int lnum)
|
||||
{
|
||||
if (ga_grow(&term->tl_scrollback, 1) == OK)
|
||||
{
|
||||
if (ga_grow(&term->tl_scrollback, 1) == FAIL)
|
||||
return FALSE;
|
||||
|
||||
sb_line_T *line = (sb_line_T *)term->tl_scrollback.ga_data
|
||||
+ term->tl_scrollback.ga_len;
|
||||
|
||||
@@ -1827,8 +1827,6 @@ add_empty_scrollback(term_T *term, cellattr_T *fill_attr, int lnum)
|
||||
line->sb_fill_attr = *fill_attr;
|
||||
++term->tl_scrollback.ga_len;
|
||||
return OK;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2409,8 +2407,9 @@ term_paste_register(int prev_c UNUSED)
|
||||
return;
|
||||
|
||||
l = (list_T *)get_reg_contents(c, GREG_LIST);
|
||||
if (l != NULL)
|
||||
{
|
||||
if (l == NULL)
|
||||
return;
|
||||
|
||||
type = get_reg_type(c, ®len);
|
||||
FOR_ALL_LIST_ITEMS(l, item)
|
||||
{
|
||||
@@ -2445,7 +2444,6 @@ term_paste_register(int prev_c UNUSED)
|
||||
(char_u *)"\r", 1, NULL);
|
||||
}
|
||||
list_free(l);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2615,8 +2613,9 @@ term_win_entered()
|
||||
{
|
||||
term_T *term = curbuf->b_term;
|
||||
|
||||
if (term != NULL)
|
||||
{
|
||||
if (term == NULL)
|
||||
return;
|
||||
|
||||
if (term_use_loop_check(TRUE))
|
||||
{
|
||||
reset_VIsual_and_resel();
|
||||
@@ -2626,7 +2625,6 @@ term_win_entered()
|
||||
mouse_was_outside = FALSE;
|
||||
enter_mouse_col = mouse_col;
|
||||
enter_mouse_row = mouse_row;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2634,8 +2632,9 @@ term_focus_change(int in_focus)
|
||||
{
|
||||
term_T *term = curbuf->b_term;
|
||||
|
||||
if (term != NULL && term->tl_vterm != NULL)
|
||||
{
|
||||
if (term == NULL || term->tl_vterm == NULL)
|
||||
return;
|
||||
|
||||
VTermState *state = vterm_obtain_state(term->tl_vterm);
|
||||
|
||||
if (in_focus)
|
||||
@@ -2643,7 +2642,6 @@ term_focus_change(int in_focus)
|
||||
else
|
||||
vterm_state_focus_out(state);
|
||||
term_forward_output(term);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2886,13 +2884,13 @@ theend:
|
||||
static void
|
||||
may_toggle_cursor(term_T *term)
|
||||
{
|
||||
if (in_terminal_loop == term)
|
||||
{
|
||||
if (in_terminal_loop != term)
|
||||
return;
|
||||
|
||||
if (term->tl_cursor_visible)
|
||||
cursor_on();
|
||||
else
|
||||
cursor_off();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3320,8 +3318,9 @@ handle_resize(int rows, int cols, void *user)
|
||||
static void
|
||||
limit_scrollback(term_T *term, garray_T *gap, int update_buffer)
|
||||
{
|
||||
if (gap->ga_len >= term->tl_buffer->b_p_twsl)
|
||||
{
|
||||
if (gap->ga_len < term->tl_buffer->b_p_twsl)
|
||||
return;
|
||||
|
||||
int todo = term->tl_buffer->b_p_twsl / 10;
|
||||
int i;
|
||||
|
||||
@@ -3340,7 +3339,6 @@ limit_scrollback(term_T *term, garray_T *gap, int update_buffer)
|
||||
sizeof(sb_line_T) * gap->ga_len);
|
||||
if (update_buffer)
|
||||
term->tl_scrollback_scrolled -= todo;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3371,8 +3369,9 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user)
|
||||
|
||||
limit_scrollback(term, gap, update_buffer);
|
||||
|
||||
if (ga_grow(gap, 1) == OK)
|
||||
{
|
||||
if (ga_grow(gap, 1) == FAIL)
|
||||
return 0;
|
||||
|
||||
cellattr_T *p = NULL;
|
||||
int len = 0;
|
||||
int i;
|
||||
@@ -3442,7 +3441,6 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user)
|
||||
ga_init(&ga); // text is kept in tl_scrollback_postponed
|
||||
}
|
||||
++gap->ga_len;
|
||||
}
|
||||
return 0; // ignored
|
||||
}
|
||||
|
||||
@@ -3612,17 +3610,16 @@ term_after_channel_closed(term_T *term)
|
||||
int
|
||||
may_close_term_popup(void)
|
||||
{
|
||||
if (popup_is_popup(curwin) && curbuf->b_term != NULL
|
||||
&& !term_job_running_not_none(curbuf->b_term))
|
||||
{
|
||||
if (!popup_is_popup(curwin) || curbuf->b_term == NULL
|
||||
|| term_job_running_not_none(curbuf->b_term))
|
||||
return FAIL;
|
||||
|
||||
win_T *pwin = curwin;
|
||||
|
||||
if (win_valid(prevwin))
|
||||
win_enter(prevwin, FALSE);
|
||||
popup_close_with_retval(pwin, 0);
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4002,12 +3999,12 @@ term_did_update_window(win_T *wp)
|
||||
{
|
||||
term_T *term = wp->w_buffer->b_term;
|
||||
|
||||
if (term != NULL && term->tl_vterm != NULL && !term->tl_normal_mode
|
||||
&& wp->w_redr_type == 0)
|
||||
{
|
||||
if (term == NULL || term->tl_vterm == NULL || term->tl_normal_mode
|
||||
|| wp->w_redr_type != 0)
|
||||
return;
|
||||
|
||||
term->tl_dirty_row_start = MAX_ROW;
|
||||
term->tl_dirty_row_end = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4040,8 +4037,9 @@ term_change_in_curbuf(void)
|
||||
{
|
||||
term_T *term = curbuf->b_term;
|
||||
|
||||
if (term_is_finished(curbuf) && term->tl_scrollback.ga_len > 0)
|
||||
{
|
||||
if (!term_is_finished(curbuf) || term->tl_scrollback.ga_len <= 0)
|
||||
return;
|
||||
|
||||
free_scrollback(term);
|
||||
redraw_buf_later(term->tl_buffer, UPD_NOT_VALID);
|
||||
|
||||
@@ -4049,7 +4047,6 @@ term_change_in_curbuf(void)
|
||||
// abandoned when changed.
|
||||
set_string_option_direct((char_u *)"buftype", -1,
|
||||
(char_u *)"", OPT_FREE|OPT_LOCAL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4908,8 +4905,9 @@ term_update_colors_all(void)
|
||||
char_u *
|
||||
term_get_status_text(term_T *term)
|
||||
{
|
||||
if (term->tl_status_text == NULL)
|
||||
{
|
||||
if (term->tl_status_text != NULL)
|
||||
return term->tl_status_text;
|
||||
|
||||
char_u *txt;
|
||||
size_t len;
|
||||
char_u *fname;
|
||||
@@ -4935,7 +4933,6 @@ term_get_status_text(term_T *term)
|
||||
if (term->tl_status_text != NULL)
|
||||
vim_snprintf((char *)term->tl_status_text, len, "%s [%s]",
|
||||
fname, txt);
|
||||
}
|
||||
return term->tl_status_text;
|
||||
}
|
||||
|
||||
@@ -5236,11 +5233,11 @@ dump_is_corrupt(garray_T *gap)
|
||||
static void
|
||||
append_cell(garray_T *gap, cellattr_T *cell)
|
||||
{
|
||||
if (ga_grow(gap, 1) == OK)
|
||||
{
|
||||
if (ga_grow(gap, 1) == FAIL)
|
||||
return;
|
||||
|
||||
*(((cellattr_T *)gap->ga_data) + gap->ga_len) = *cell;
|
||||
++gap->ga_len;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -6036,15 +6033,15 @@ f_term_getcursor(typval_T *argvars, typval_T *rettv)
|
||||
list_append_number(l, term->tl_cursor_pos.col + 1);
|
||||
|
||||
d = dict_alloc();
|
||||
if (d != NULL)
|
||||
{
|
||||
if (d == NULL)
|
||||
return;
|
||||
|
||||
dict_add_number(d, "visible", term->tl_cursor_visible);
|
||||
dict_add_number(d, "blink", blink_state_is_inverted()
|
||||
? !term->tl_cursor_blink : term->tl_cursor_blink);
|
||||
dict_add_number(d, "shape", term->tl_cursor_shape);
|
||||
dict_add_string(d, "color", cursor_color_get(term->tl_cursor_color));
|
||||
list_append_dict(l, d);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7692,8 +7689,9 @@ term_free_vterm(term_T *term)
|
||||
term_report_winsize(term_T *term, int rows, int cols)
|
||||
{
|
||||
// Use an ioctl() to report the new window size to the job.
|
||||
if (term->tl_job != NULL && term->tl_job->jv_channel != NULL)
|
||||
{
|
||||
if (term->tl_job == NULL || term->tl_job->jv_channel == NULL)
|
||||
return;
|
||||
|
||||
int fd = -1;
|
||||
int part;
|
||||
|
||||
@@ -7705,7 +7703,6 @@ term_report_winsize(term_T *term, int rows, int cols)
|
||||
}
|
||||
if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK)
|
||||
mch_signal_job(term->tl_job, (char_u *)"winch");
|
||||
}
|
||||
}
|
||||
|
||||
# endif
|
||||
|
@@ -55,8 +55,10 @@ ga_concat_esc(garray_T *gap, char_u *p, int clen)
|
||||
mch_memmove(buf, p, clen);
|
||||
buf[clen] = NUL;
|
||||
ga_concat(gap, buf);
|
||||
return;
|
||||
}
|
||||
else switch (*p)
|
||||
|
||||
switch (*p)
|
||||
{
|
||||
case BS: ga_concat(gap, (char_u *)"\\b"); break;
|
||||
case ESC: ga_concat(gap, (char_u *)"\\e"); break;
|
||||
|
@@ -752,8 +752,9 @@ check_auto_format(
|
||||
int c = ' ';
|
||||
int cc;
|
||||
|
||||
if (did_add_space)
|
||||
{
|
||||
if (!did_add_space)
|
||||
return;
|
||||
|
||||
cc = gchar_cursor();
|
||||
if (!WHITECHAR(cc))
|
||||
// Somehow the space was removed already.
|
||||
@@ -773,7 +774,6 @@ check_auto_format(
|
||||
did_add_space = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1939,8 +1939,9 @@ f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
}
|
||||
|
||||
hi = find_prop_type_hi(name, buf);
|
||||
if (hi != NULL)
|
||||
{
|
||||
if (hi == NULL)
|
||||
return;
|
||||
|
||||
hashtab_T *ht;
|
||||
proptype_T *prop = HI2PT(hi);
|
||||
|
||||
@@ -1960,7 +1961,6 @@ f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
// currently visibile text properties will disappear
|
||||
redraw_all_later(UPD_CLEAR);
|
||||
changed_window_setting_buf(buf == NULL ? curbuf : buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1982,8 +1982,10 @@ f_prop_type_get(typval_T *argvars, typval_T *rettv)
|
||||
semsg(_(e_invalid_argument_str), "\"\"");
|
||||
return;
|
||||
}
|
||||
if (rettv_dict_alloc(rettv) == OK)
|
||||
{
|
||||
|
||||
if (rettv_dict_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
proptype_T *prop = NULL;
|
||||
buf_T *buf = NULL;
|
||||
|
||||
@@ -1994,8 +1996,9 @@ f_prop_type_get(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
|
||||
prop = find_prop_type(name, buf);
|
||||
if (prop != NULL)
|
||||
{
|
||||
if (prop == NULL)
|
||||
return;
|
||||
|
||||
dict_T *d = rettv->vval.v_dict;
|
||||
|
||||
if (prop->pt_hl_id > 0)
|
||||
@@ -2009,8 +2012,6 @@ f_prop_type_get(typval_T *argvars, typval_T *rettv)
|
||||
(prop->pt_flags & PT_FLAG_INS_END_INCL) ? 1 : 0);
|
||||
if (buf != NULL)
|
||||
dict_add_number(d, "bufnr", buf->b_fnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2040,8 +2041,9 @@ f_prop_type_list(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
buf_T *buf = NULL;
|
||||
|
||||
if (rettv_list_alloc(rettv) == OK)
|
||||
{
|
||||
if (rettv_list_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
@@ -2057,7 +2059,6 @@ f_prop_type_list(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
}
|
||||
else if (buf->b_proptypes != NULL)
|
||||
list_types(buf->b_proptypes, rettv->vval.v_list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
36
src/time.c
36
src/time.c
@@ -302,9 +302,11 @@ f_strftime(typval_T *argvars, typval_T *rettv)
|
||||
curtime = vim_localtime(&seconds, &tmval);
|
||||
// MSVC returns NULL for an invalid value of seconds.
|
||||
if (curtime == NULL)
|
||||
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
|
||||
else
|
||||
{
|
||||
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
|
||||
return;
|
||||
}
|
||||
|
||||
# ifdef MSWIN
|
||||
WCHAR result_buf[256];
|
||||
WCHAR *wp;
|
||||
@@ -342,7 +344,6 @@ f_strftime(typval_T *argvars, typval_T *rettv)
|
||||
convert_setup(&conv, NULL, NULL);
|
||||
vim_free(enc);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -672,12 +673,12 @@ find_timer(long id)
|
||||
{
|
||||
timer_T *timer;
|
||||
|
||||
if (id >= 0)
|
||||
{
|
||||
if (id < 0)
|
||||
return NULL;
|
||||
|
||||
FOR_ALL_TIMERS(timer)
|
||||
if (timer->tr_id == id)
|
||||
return timer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -791,7 +792,9 @@ timer_valid(timer_T *timer)
|
||||
{
|
||||
if (timer == NULL)
|
||||
return FALSE;
|
||||
for (timer_T *t = first_timer; t != NULL; t = t->tr_next)
|
||||
|
||||
timer_T *t;
|
||||
FOR_ALL_TIMERS(t)
|
||||
if (t == timer)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
@@ -848,15 +851,16 @@ f_timer_pause(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
return;
|
||||
|
||||
if (argvars[0].v_type != VAR_NUMBER)
|
||||
emsg(_(e_number_expected));
|
||||
else
|
||||
{
|
||||
emsg(_(e_number_expected));
|
||||
return;
|
||||
}
|
||||
|
||||
int paused = (int)tv_get_bool(&argvars[1]);
|
||||
|
||||
timer = find_timer((int)tv_get_number(&argvars[0]));
|
||||
if (timer != NULL)
|
||||
timer->tr_paused = paused;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -904,14 +908,14 @@ f_timer_start(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
timer = create_timer(msec, repeat);
|
||||
if (timer == NULL)
|
||||
free_callback(&callback);
|
||||
else
|
||||
{
|
||||
free_callback(&callback);
|
||||
return;
|
||||
}
|
||||
set_callback(&timer->tr_callback, &callback);
|
||||
if (callback.cb_free_name)
|
||||
vim_free(callback.cb_name);
|
||||
rettv->vval.v_number = (varnumber_T)timer->tr_id;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1019,8 +1023,9 @@ time_msg(
|
||||
static struct timeval start;
|
||||
struct timeval now;
|
||||
|
||||
if (time_fd != NULL)
|
||||
{
|
||||
if (time_fd == NULL)
|
||||
return;
|
||||
|
||||
if (strstr(mesg, "STARTING") != NULL)
|
||||
{
|
||||
gettimeofday(&start, NULL);
|
||||
@@ -1040,7 +1045,6 @@ time_msg(
|
||||
time_diff(&prev_timeval, &now);
|
||||
prev_timeval = now;
|
||||
fprintf(time_fd, ": %s\n", mesg);
|
||||
}
|
||||
}
|
||||
# endif // STARTUPTIME
|
||||
#endif // FEAT_EVAL
|
||||
|
12
src/typval.c
12
src/typval.c
@@ -52,8 +52,9 @@ alloc_string_tv(char_u *s)
|
||||
void
|
||||
free_tv(typval_T *varp)
|
||||
{
|
||||
if (varp != NULL)
|
||||
{
|
||||
if (varp == NULL)
|
||||
return;
|
||||
|
||||
switch (varp->v_type)
|
||||
{
|
||||
case VAR_FUNC:
|
||||
@@ -102,7 +103,6 @@ free_tv(typval_T *varp)
|
||||
break;
|
||||
}
|
||||
vim_free(varp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -111,8 +111,9 @@ free_tv(typval_T *varp)
|
||||
void
|
||||
clear_tv(typval_T *varp)
|
||||
{
|
||||
if (varp != NULL)
|
||||
{
|
||||
if (varp == NULL)
|
||||
return;
|
||||
|
||||
switch (varp->v_type)
|
||||
{
|
||||
case VAR_FUNC:
|
||||
@@ -174,7 +175,6 @@ clear_tv(typval_T *varp)
|
||||
break;
|
||||
}
|
||||
varp->v_lock = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1245,
|
||||
/**/
|
||||
1244,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user