mirror of
https://github.com/vim/vim.git
synced 2025-08-31 20:53:42 -04:00
patch 9.0.1221: 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 #11833)
This commit is contained in:
parent
4aecaa168e
commit
f97a295cca
@ -1367,14 +1367,14 @@ failed:
|
||||
void
|
||||
ui_remove_balloon(void)
|
||||
{
|
||||
if (balloon_array != NULL)
|
||||
{
|
||||
if (balloon_array == NULL)
|
||||
return;
|
||||
|
||||
pum_undisplay();
|
||||
while (balloon_arraysize > 0)
|
||||
vim_free(balloon_array[--balloon_arraysize].pum_text);
|
||||
VIM_CLEAR(balloon_array);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Terminal version of a balloon, uses the popup menu code.
|
||||
@ -1410,8 +1410,9 @@ ui_post_balloon(char_u *mesg, list_T *list)
|
||||
else
|
||||
balloon_arraysize = split_message(mesg, &balloon_array);
|
||||
|
||||
if (balloon_arraysize > 0)
|
||||
{
|
||||
if (balloon_arraysize <= 0)
|
||||
return;
|
||||
|
||||
pum_array = balloon_array;
|
||||
pum_size = balloon_arraysize;
|
||||
pum_compute_size();
|
||||
@ -1423,7 +1424,6 @@ ui_post_balloon(char_u *mesg, list_T *list)
|
||||
pum_first = 0;
|
||||
pum_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when the mouse moved, may remove any displayed balloon.
|
||||
|
171
src/popupwin.c
171
src/popupwin.c
@ -98,12 +98,15 @@ set_padding_border(dict_T *dict, int *array, char *name, int max_val)
|
||||
dictitem_T *di;
|
||||
|
||||
di = dict_find(dict, (char_u *)name, -1);
|
||||
if (di != NULL)
|
||||
{
|
||||
if (di == NULL)
|
||||
return;
|
||||
|
||||
if (di->di_tv.v_type != VAR_LIST)
|
||||
emsg(_(e_list_required));
|
||||
else
|
||||
{
|
||||
emsg(_(e_list_required));
|
||||
return;
|
||||
}
|
||||
|
||||
list_T *list = di->di_tv.vval.v_list;
|
||||
listitem_T *li;
|
||||
int i;
|
||||
@ -111,8 +114,9 @@ set_padding_border(dict_T *dict, int *array, char *name, int max_val)
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
array[i] = 1;
|
||||
if (list != NULL)
|
||||
{
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
CHECK_LIST_MATERIALIZE(list);
|
||||
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
|
||||
++i, li = li->li_next)
|
||||
@ -122,9 +126,6 @@ set_padding_border(dict_T *dict, int *array, char *name, int max_val)
|
||||
array[i] = nr > max_val ? max_val : nr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Used when popup options contain "moved": set default moved values.
|
||||
@ -147,12 +148,12 @@ set_moved_columns(win_T *wp, int flags)
|
||||
char_u *ptr;
|
||||
int len = find_ident_under_cursor(&ptr, flags | FIND_NOERROR);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
wp->w_popup_mincol = (int)(ptr - ml_get_curline());
|
||||
wp->w_popup_maxcol = wp->w_popup_mincol + len - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Used when popup options contain "mousemoved": set default moved values.
|
||||
@ -169,8 +170,9 @@ set_mousemoved_values(win_T *wp)
|
||||
update_popup_uses_mouse_move(void)
|
||||
{
|
||||
popup_uses_mouse_move = FALSE;
|
||||
if (popup_visible)
|
||||
{
|
||||
if (!popup_visible)
|
||||
return;
|
||||
|
||||
win_T *wp;
|
||||
|
||||
FOR_ALL_POPUPWINS(wp)
|
||||
@ -186,7 +188,6 @@ update_popup_uses_mouse_move(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Used when popup options contain "moved" with "word" or "WORD".
|
||||
@ -201,8 +202,9 @@ set_mousemoved_columns(win_T *wp, int flags)
|
||||
colnr_T mcol;
|
||||
|
||||
if (find_word_under_cursor(mouse_row, mouse_col, TRUE, flags,
|
||||
&textwp, &pos.lnum, &text, NULL, &col) == OK)
|
||||
{
|
||||
&textwp, &pos.lnum, &text, NULL, &col) != OK)
|
||||
return;
|
||||
|
||||
// convert text column to mouse column
|
||||
pos.col = col;
|
||||
pos.coladd = 0;
|
||||
@ -214,7 +216,6 @@ set_mousemoved_columns(win_T *wp, int flags)
|
||||
wp->w_popup_mouse_maxcol = mcol;
|
||||
vim_free(text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if "row"/"col" is on the border of the popup.
|
||||
@ -390,8 +391,9 @@ popup_is_in_scrollbar(win_T *wp, int row, int col)
|
||||
void
|
||||
popup_handle_scrollbar_click(win_T *wp, int row, int col)
|
||||
{
|
||||
if (popup_is_in_scrollbar(wp, row, col))
|
||||
{
|
||||
if (!popup_is_in_scrollbar(wp, row, col))
|
||||
return;
|
||||
|
||||
int height = popup_height(wp);
|
||||
int new_topline = wp->w_topline;
|
||||
|
||||
@ -404,8 +406,10 @@ popup_handle_scrollbar_click(win_T *wp, int row, int col)
|
||||
else if (wp->w_topline > 1)
|
||||
// click on upper half, scroll up.
|
||||
--new_topline;
|
||||
if (new_topline != wp->w_topline)
|
||||
{
|
||||
|
||||
if (new_topline == wp->w_topline)
|
||||
return;
|
||||
|
||||
set_topline(wp, new_topline);
|
||||
if (wp == curwin)
|
||||
{
|
||||
@ -423,8 +427,6 @@ popup_handle_scrollbar_click(win_T *wp, int row, int col)
|
||||
popup_set_firstline(wp);
|
||||
redraw_win_later(wp, UPD_NOT_VALID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FEAT_TIMERS)
|
||||
/*
|
||||
@ -441,8 +443,9 @@ popup_add_timeout(win_T *wp, int time, int close)
|
||||
vim_snprintf((char *)cbbuf, sizeof(cbbuf),
|
||||
close ? "(_) => popup_close(%d)" : "(_) => popup_hide(%d)",
|
||||
wp->w_id);
|
||||
if (get_lambda_tv_and_compile(&ptr, &tv, FALSE, &EVALARG_EVALUATE) == OK)
|
||||
{
|
||||
if (get_lambda_tv_and_compile(&ptr, &tv, FALSE, &EVALARG_EVALUATE) != OK)
|
||||
return;
|
||||
|
||||
wp->w_popup_timer = create_timer(time, 0);
|
||||
callback_T cb = get_callback(&tv);
|
||||
if (cb.cb_name != NULL && !cb.cb_free_name)
|
||||
@ -453,7 +456,6 @@ popup_add_timeout(win_T *wp, int time, int close)
|
||||
wp->w_popup_timer->tr_callback = cb;
|
||||
clear_tv(&tv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static poppos_T
|
||||
@ -619,8 +621,9 @@ check_highlight(dict_T *dict, char *name, char_u **pval)
|
||||
char_u *str;
|
||||
|
||||
di = dict_find(dict, (char_u *)name, -1);
|
||||
if (di != NULL)
|
||||
{
|
||||
if (di == NULL)
|
||||
return;
|
||||
|
||||
if (di->di_tv.v_type != VAR_STRING)
|
||||
semsg(_(e_invalid_value_for_argument_str), name);
|
||||
else
|
||||
@ -630,7 +633,6 @@ check_highlight(dict_T *dict, char *name, char_u **pval)
|
||||
*pval = vim_strsave(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Scroll to show the line with the cursor.
|
||||
@ -990,19 +992,18 @@ apply_general_options(win_T *wp, dict_T *dict)
|
||||
}
|
||||
|
||||
di = dict_find(dict, (char_u *)"callback", -1);
|
||||
if (di != NULL)
|
||||
{
|
||||
callback_T callback = get_callback(&di->di_tv);
|
||||
if (di == NULL)
|
||||
return;
|
||||
|
||||
callback_T callback = get_callback(&di->di_tv);
|
||||
if (callback.cb_name == NULL)
|
||||
return;
|
||||
|
||||
if (callback.cb_name != NULL)
|
||||
{
|
||||
free_callback(&wp->w_close_cb);
|
||||
set_callback(&wp->w_close_cb, &callback);
|
||||
if (callback.cb_free_name)
|
||||
vim_free(callback.cb_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through the options in "dict" and apply them to popup window "wp".
|
||||
@ -2715,14 +2716,14 @@ popup_hide(win_T *wp)
|
||||
if (error_if_term_popup_window())
|
||||
return;
|
||||
#endif
|
||||
if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
|
||||
{
|
||||
if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
|
||||
return;
|
||||
|
||||
wp->w_popup_flags |= POPF_HIDDEN;
|
||||
// Do not decrement b_nwindows, we still reference the buffer.
|
||||
redraw_all_later(UPD_NOT_VALID);
|
||||
popup_mask_refresh = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* popup_hide({id})
|
||||
@ -2738,23 +2739,23 @@ f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
|
||||
id = (int)tv_get_number(argvars);
|
||||
wp = find_popup_win(id);
|
||||
if (wp != NULL)
|
||||
{
|
||||
if (wp == NULL)
|
||||
return;
|
||||
|
||||
popup_hide(wp);
|
||||
wp->w_popup_flags |= POPF_HIDDEN_FORCE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
popup_show(win_T *wp)
|
||||
{
|
||||
if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
|
||||
{
|
||||
if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
|
||||
return;
|
||||
|
||||
wp->w_popup_flags &= ~POPF_HIDDEN;
|
||||
redraw_all_later(UPD_NOT_VALID);
|
||||
popup_mask_refresh = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* popup_show({id})
|
||||
@ -2770,8 +2771,9 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
|
||||
id = (int)tv_get_number(argvars);
|
||||
wp = find_popup_win(id);
|
||||
if (wp != NULL)
|
||||
{
|
||||
if (wp == NULL)
|
||||
return;
|
||||
|
||||
wp->w_popup_flags &= ~POPF_HIDDEN_FORCE;
|
||||
popup_show(wp);
|
||||
#ifdef FEAT_QUICKFIX
|
||||
@ -2779,7 +2781,6 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
pum_position_info_popup(wp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* popup_settext({id}, {text})
|
||||
@ -2797,16 +2798,16 @@ f_popup_settext(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
|
||||
id = (int)tv_get_number(&argvars[0]);
|
||||
wp = find_popup_win(id);
|
||||
if (wp != NULL)
|
||||
{
|
||||
if (check_for_string_or_list_arg(argvars, 1) != FAIL)
|
||||
{
|
||||
if (wp == NULL)
|
||||
return;
|
||||
|
||||
if (check_for_string_or_list_arg(argvars, 1) == FAIL)
|
||||
return;
|
||||
|
||||
popup_set_buffer_text(wp->w_buffer, argvars[1]);
|
||||
redraw_win_later(wp, UPD_NOT_VALID);
|
||||
popup_adjust_position(wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
popup_free(win_T *wp)
|
||||
@ -3011,8 +3012,9 @@ f_popup_getpos(typval_T *argvars, typval_T *rettv)
|
||||
int top_extra;
|
||||
int left_extra;
|
||||
|
||||
if (rettv_dict_alloc(rettv) == OK)
|
||||
{
|
||||
if (rettv_dict_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
@ -3047,7 +3049,6 @@ f_popup_getpos(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
hash_unlock(&dict->dv_hashtab);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* popup_list()
|
||||
@ -3102,14 +3103,14 @@ get_padding_border(dict_T *dict, int *array, char *name)
|
||||
return;
|
||||
|
||||
list = list_alloc();
|
||||
if (list != NULL)
|
||||
{
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
dict_add_list(dict, name, list);
|
||||
if (array[0] != 1 || array[1] != 1 || array[2] != 1 || array[3] != 1)
|
||||
for (i = 0; i < 4; ++i)
|
||||
list_append_number(list, array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* For popup_getoptions(): add a "borderhighlight" entry to "dict".
|
||||
@ -3127,13 +3128,13 @@ get_borderhighlight(dict_T *dict, win_T *wp)
|
||||
return;
|
||||
|
||||
list = list_alloc();
|
||||
if (list != NULL)
|
||||
{
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
dict_add_list(dict, "borderhighlight", list);
|
||||
for (i = 0; i < 4; ++i)
|
||||
list_append_string(list, wp->w_border_highlight[i], -1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* For popup_getoptions(): add a "borderchars" entry to "dict".
|
||||
@ -3153,8 +3154,9 @@ get_borderchars(dict_T *dict, win_T *wp)
|
||||
return;
|
||||
|
||||
list = list_alloc();
|
||||
if (list != NULL)
|
||||
{
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
dict_add_list(dict, "borderchars", list);
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
@ -3162,7 +3164,6 @@ get_borderchars(dict_T *dict, win_T *wp)
|
||||
list_append_string(list, buf, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* For popup_getoptions(): add a "moved" and "mousemoved" entry to "dict".
|
||||
@ -3181,14 +3182,14 @@ get_moved_list(dict_T *dict, win_T *wp)
|
||||
list_append_number(list, wp->w_popup_maxcol);
|
||||
}
|
||||
list = list_alloc();
|
||||
if (list != NULL)
|
||||
{
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
dict_add_list(dict, "mousemoved", list);
|
||||
list_append_number(list, wp->w_popup_mouse_row);
|
||||
list_append_number(list, wp->w_popup_mouse_mincol);
|
||||
list_append_number(list, wp->w_popup_mouse_maxcol);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* popup_getoptions({id})
|
||||
@ -3202,8 +3203,9 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
|
||||
tabpage_T *tp;
|
||||
int i;
|
||||
|
||||
if (rettv_dict_alloc(rettv) == OK)
|
||||
{
|
||||
if (rettv_dict_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
@ -3300,7 +3302,6 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
|
||||
? (long)wp->w_popup_timer->tr_interval : 0L);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(FEAT_TERMINAL) || defined(PROTO)
|
||||
/*
|
||||
@ -3640,8 +3641,9 @@ popup_masked(win_T *wp, int width, int height, int screencol, int screenline)
|
||||
static void
|
||||
update_popup_transparent(win_T *wp, int val)
|
||||
{
|
||||
if (wp->w_popup_mask != NULL)
|
||||
{
|
||||
if (wp->w_popup_mask == NULL)
|
||||
return;
|
||||
|
||||
int width = popup_width(wp);
|
||||
int height = popup_height(wp);
|
||||
listitem_T *lio, *li;
|
||||
@ -3684,7 +3686,6 @@ update_popup_transparent(win_T *wp, int val)
|
||||
+ col + wp->w_wincol] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Only called when popup window "wp" is hidden: If the window is positioned
|
||||
@ -4508,8 +4509,9 @@ popup_close_info(void)
|
||||
win_T *
|
||||
popup_get_message_win(void)
|
||||
{
|
||||
if (message_win == NULL)
|
||||
{
|
||||
if (message_win != NULL)
|
||||
return message_win;
|
||||
|
||||
int i;
|
||||
|
||||
message_win = popup_create(NULL, NULL, TYPE_MESSAGE_WIN);
|
||||
@ -4534,7 +4536,6 @@ popup_get_message_win(void)
|
||||
|
||||
if (message_win->w_popup_timer != NULL)
|
||||
message_win->w_popup_timer->tr_keep = TRUE;
|
||||
}
|
||||
return message_win;
|
||||
}
|
||||
|
||||
@ -4545,8 +4546,9 @@ popup_get_message_win(void)
|
||||
void
|
||||
popup_show_message_win(void)
|
||||
{
|
||||
if (message_win != NULL)
|
||||
{
|
||||
if (message_win == NULL)
|
||||
return;
|
||||
|
||||
if ((message_win->w_popup_flags & POPF_HIDDEN) != 0)
|
||||
{
|
||||
// the highlight may have changed.
|
||||
@ -4555,7 +4557,6 @@ popup_show_message_win(void)
|
||||
}
|
||||
start_message_win_timer = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
may_start_message_win_timer(win_T *wp)
|
||||
@ -4664,8 +4665,9 @@ popup_win_closed(win_T *win)
|
||||
void
|
||||
popup_set_title(win_T *wp)
|
||||
{
|
||||
if (wp->w_buffer->b_fname != NULL)
|
||||
{
|
||||
if (wp->w_buffer->b_fname == NULL)
|
||||
return;
|
||||
|
||||
char_u dirname[MAXPATHL];
|
||||
size_t len;
|
||||
|
||||
@ -4680,7 +4682,6 @@ popup_set_title(win_T *wp)
|
||||
wp->w_buffer->b_fname);
|
||||
redraw_win_later(wp, UPD_VALID);
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(FEAT_QUICKFIX) || defined(PROTO)
|
||||
/*
|
||||
|
@ -910,8 +910,9 @@ script_prof_restore(proftime_T *tm)
|
||||
{
|
||||
scriptitem_T *si;
|
||||
|
||||
if (SCRIPT_ID_VALID(current_sctx.sc_sid))
|
||||
{
|
||||
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
|
||||
return;
|
||||
|
||||
si = SCRIPT_ITEM(current_sctx.sc_sid);
|
||||
if (si->sn_prof_on && --si->sn_pr_nest == 0)
|
||||
{
|
||||
@ -921,7 +922,6 @@ script_prof_restore(proftime_T *tm)
|
||||
profile_add(&si->sn_prl_children, &si->sn_pr_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump the profiling results for all scripts in file "fd".
|
||||
@ -1009,8 +1009,9 @@ profile_dump(void)
|
||||
{
|
||||
FILE *fd;
|
||||
|
||||
if (profile_fname != NULL)
|
||||
{
|
||||
if (profile_fname == NULL)
|
||||
return;
|
||||
|
||||
fd = mch_fopen((char *)profile_fname, "w");
|
||||
if (fd == NULL)
|
||||
semsg(_(e_cant_open_file_str), profile_fname);
|
||||
@ -1021,7 +1022,6 @@ profile_dump(void)
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when starting to read a script line.
|
||||
|
@ -1898,15 +1898,15 @@ qf_store_title(qf_list_T *qfl, char_u *title)
|
||||
{
|
||||
VIM_CLEAR(qfl->qf_title);
|
||||
|
||||
if (title != NULL)
|
||||
{
|
||||
if (title == NULL)
|
||||
return;
|
||||
|
||||
char_u *p = alloc_id(STRLEN(title) + 2, aid_qf_title);
|
||||
|
||||
qfl->qf_title = p;
|
||||
if (p != NULL)
|
||||
STRCPY(p, title);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The title of a quickfix/location list is set, by default, to the command
|
||||
@ -1976,13 +1976,13 @@ locstack_queue_delreq(qf_info_T *qi)
|
||||
qf_delq_T *q;
|
||||
|
||||
q = ALLOC_ONE(qf_delq_T);
|
||||
if (q != NULL)
|
||||
{
|
||||
if (q == NULL)
|
||||
return;
|
||||
|
||||
q->qi = qi;
|
||||
q->next = qf_delq_head;
|
||||
qf_delq_head = q;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the global quickfix stack window buffer number.
|
||||
@ -2002,8 +2002,9 @@ wipe_qf_buffer(qf_info_T *qi)
|
||||
{
|
||||
buf_T *qfbuf;
|
||||
|
||||
if (qi->qf_bufnr != INVALID_QFBUFNR)
|
||||
{
|
||||
if (qi->qf_bufnr == INVALID_QFBUFNR)
|
||||
return;
|
||||
|
||||
qfbuf = buflist_findnr(qi->qf_bufnr);
|
||||
if (qfbuf != NULL && qfbuf->b_nwindows == 0)
|
||||
{
|
||||
@ -2013,7 +2014,6 @@ wipe_qf_buffer(qf_info_T *qi)
|
||||
qi->qf_bufnr = INVALID_QFBUFNR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a location list stack
|
||||
@ -2231,12 +2231,12 @@ qf_alloc_stack(qfltype_T qfltype)
|
||||
qf_info_T *qi;
|
||||
|
||||
qi = ALLOC_CLEAR_ONE_ID(qf_info_T, aid_qf_qfinfo);
|
||||
if (qi != NULL)
|
||||
{
|
||||
if (qi == NULL)
|
||||
return NULL;
|
||||
|
||||
qi->qf_refcount++;
|
||||
qi->qfl_type = qfltype;
|
||||
qi->qf_bufnr = INVALID_QFBUFNR;
|
||||
}
|
||||
return qi;
|
||||
}
|
||||
|
||||
@ -4573,8 +4573,9 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
|
||||
|
||||
// Check if a buffer for the quickfix list exists. Update it.
|
||||
buf = qf_find_buf(qi);
|
||||
if (buf != NULL)
|
||||
{
|
||||
if (buf == NULL)
|
||||
return;
|
||||
|
||||
linenr_T old_line_count = buf->b_ml.ml_line_count;
|
||||
int qf_winid = 0;
|
||||
|
||||
@ -4631,7 +4632,6 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
|
||||
// always called after incr_quickfix_busy()
|
||||
decr_quickfix_busy();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an error line to the quickfix buffer.
|
||||
@ -4924,14 +4924,14 @@ qf_restore_list(qf_info_T *qi, int_u save_qfid)
|
||||
{
|
||||
int curlist;
|
||||
|
||||
if (qf_get_curlist(qi)->qf_id != save_qfid)
|
||||
{
|
||||
if (qf_get_curlist(qi)->qf_id == save_qfid)
|
||||
return OK;
|
||||
|
||||
curlist = qf_id2nr(qi, save_qfid);
|
||||
if (curlist < 0)
|
||||
// list is not present
|
||||
return FAIL;
|
||||
qi->qf_curlist = curlist;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -6544,8 +6544,9 @@ restore_start_dir(char_u *dirname_start)
|
||||
{
|
||||
char_u *dirname_now = alloc(MAXPATHL);
|
||||
|
||||
if (NULL != dirname_now)
|
||||
{
|
||||
if (dirname_now == NULL)
|
||||
return;
|
||||
|
||||
mch_dirname(dirname_now, MAXPATHL);
|
||||
if (STRCMP(dirname_start, dirname_now) != 0)
|
||||
{
|
||||
@ -6560,7 +6561,6 @@ restore_start_dir(char_u *dirname_start)
|
||||
}
|
||||
vim_free(dirname_now);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load file "fname" into a dummy buffer and return the buffer pointer,
|
||||
@ -6723,14 +6723,14 @@ wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
|
||||
static void
|
||||
unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
|
||||
{
|
||||
if (curbuf != buf) // safety check
|
||||
{
|
||||
if (curbuf == buf) // safety check
|
||||
return;
|
||||
|
||||
close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE, TRUE);
|
||||
|
||||
// When autocommands/'autochdir' option changed directory: go back.
|
||||
restore_start_dir(dirname_start);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||
/*
|
||||
@ -6862,8 +6862,9 @@ qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
|
||||
list_T *l;
|
||||
|
||||
// Only a List value is supported
|
||||
if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
|
||||
{
|
||||
if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL)
|
||||
return FAIL;
|
||||
|
||||
// If errorformat is supplied then use it, otherwise use the 'efm'
|
||||
// option setting
|
||||
if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL)
|
||||
@ -6891,7 +6892,6 @@ qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
|
||||
}
|
||||
dict_add_list(retdict, "items", l);
|
||||
status = OK;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -7632,12 +7632,12 @@ qf_setprop_qftf(qf_info_T *qi UNUSED, qf_list_T *qfl, dictitem_T *di)
|
||||
|
||||
free_callback(&qfl->qf_qftf_cb);
|
||||
cb = get_callback(&di->di_tv);
|
||||
if (cb.cb_name != NULL && *cb.cb_name != NUL)
|
||||
{
|
||||
if (cb.cb_name == NULL || *cb.cb_name == NUL)
|
||||
return OK;
|
||||
|
||||
set_callback(&qfl->qf_qftf_cb, &cb);
|
||||
if (cb.cb_free_name)
|
||||
vim_free(cb.cb_name);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@ -8126,12 +8126,12 @@ ex_cexpr(exarg_T *eap)
|
||||
// Evaluate the expression. When the result is a string or a list we can
|
||||
// use it to fill the errorlist.
|
||||
tv = eval_expr(eap->arg, eap);
|
||||
if (tv != NULL)
|
||||
{
|
||||
if (tv == NULL)
|
||||
return;
|
||||
|
||||
(void)cexpr_core(eap, tv);
|
||||
free_tv(tv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
18
src/regexp.c
18
src/regexp.c
@ -710,8 +710,9 @@ peekchr(void)
|
||||
{
|
||||
static int after_slash = FALSE;
|
||||
|
||||
if (curchr == -1)
|
||||
{
|
||||
if (curchr != -1)
|
||||
return curchr;
|
||||
|
||||
switch (curchr = regparse[0])
|
||||
{
|
||||
case '.':
|
||||
@ -859,7 +860,6 @@ peekchr(void)
|
||||
if (has_mbyte)
|
||||
curchr = (*mb_ptr2char)(regparse);
|
||||
}
|
||||
}
|
||||
|
||||
return curchr;
|
||||
}
|
||||
@ -1384,8 +1384,9 @@ prog_magic_wrong(void)
|
||||
static void
|
||||
cleanup_subexpr(void)
|
||||
{
|
||||
if (rex.need_clear_subexpr)
|
||||
{
|
||||
if (!rex.need_clear_subexpr)
|
||||
return;
|
||||
|
||||
if (REG_MULTI)
|
||||
{
|
||||
// Use 0xff to set lnum to -1
|
||||
@ -1399,14 +1400,14 @@ cleanup_subexpr(void)
|
||||
}
|
||||
rex.need_clear_subexpr = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_SYN_HL
|
||||
static void
|
||||
cleanup_zsubexpr(void)
|
||||
{
|
||||
if (rex.need_clear_zsubexpr)
|
||||
{
|
||||
if (!rex.need_clear_zsubexpr)
|
||||
return;
|
||||
|
||||
if (REG_MULTI)
|
||||
{
|
||||
// Use 0xff to set lnum to -1
|
||||
@ -1420,7 +1421,6 @@ cleanup_zsubexpr(void)
|
||||
}
|
||||
rex.need_clear_zsubexpr = FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -3187,8 +3187,9 @@ save_subexpr(regbehind_T *bp)
|
||||
// When "rex.need_clear_subexpr" is set we don't need to save the values,
|
||||
// only remember that this flag needs to be set again when restoring.
|
||||
bp->save_need_clear_subexpr = rex.need_clear_subexpr;
|
||||
if (!rex.need_clear_subexpr)
|
||||
{
|
||||
if (rex.need_clear_subexpr)
|
||||
return;
|
||||
|
||||
for (i = 0; i < NSUBEXP; ++i)
|
||||
{
|
||||
if (REG_MULTI)
|
||||
@ -3203,7 +3204,6 @@ save_subexpr(regbehind_T *bp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore the subexpr from "bp".
|
||||
@ -3215,8 +3215,9 @@ restore_subexpr(regbehind_T *bp)
|
||||
|
||||
// Only need to restore saved values when they are not to be cleared.
|
||||
rex.need_clear_subexpr = bp->save_need_clear_subexpr;
|
||||
if (!rex.need_clear_subexpr)
|
||||
{
|
||||
if (rex.need_clear_subexpr)
|
||||
return;
|
||||
|
||||
for (i = 0; i < NSUBEXP; ++i)
|
||||
{
|
||||
if (REG_MULTI)
|
||||
@ -3231,7 +3232,6 @@ restore_subexpr(regbehind_T *bp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* regmatch - main matching routine
|
||||
|
@ -487,8 +487,9 @@ nfa_get_match_text(nfa_state_T *start)
|
||||
return NULL;
|
||||
|
||||
ret = alloc(len);
|
||||
if (ret != NULL)
|
||||
{
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
p = start->out->out; // skip first char, it goes into regstart
|
||||
s = ret;
|
||||
while (p->c > 0)
|
||||
@ -500,7 +501,6 @@ nfa_get_match_text(nfa_state_T *start)
|
||||
p = p->out;
|
||||
}
|
||||
*s = NUL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2782,8 +2782,9 @@ nfa_postfix_dump(char_u *expr, int retval)
|
||||
FILE *f;
|
||||
|
||||
f = fopen(NFA_REGEXP_DUMP_LOG, "a");
|
||||
if (f != NULL)
|
||||
{
|
||||
if (f == NULL)
|
||||
return;
|
||||
|
||||
fprintf(f, "\n-------------------------\n");
|
||||
if (retval == FAIL)
|
||||
fprintf(f, ">>> NFA engine failed... \n");
|
||||
@ -2801,7 +2802,6 @@ nfa_postfix_dump(char_u *expr, int retval)
|
||||
fprintf(f, "\n\n");
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the NFA starting with a root node "state".
|
||||
@ -2883,8 +2883,9 @@ nfa_dump(nfa_regprog_T *prog)
|
||||
{
|
||||
FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a");
|
||||
|
||||
if (debugf != NULL)
|
||||
{
|
||||
if (debugf == NULL)
|
||||
return;
|
||||
|
||||
nfa_print_state(debugf, prog->start);
|
||||
|
||||
if (prog->reganch)
|
||||
@ -2897,7 +2898,6 @@ nfa_dump(nfa_regprog_T *prog)
|
||||
|
||||
fclose(debugf);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_LOG
|
||||
#endif // DEBUG
|
||||
|
||||
@ -4096,8 +4096,9 @@ clear_sub(regsub_T *sub)
|
||||
copy_sub(regsub_T *to, regsub_T *from)
|
||||
{
|
||||
to->in_use = from->in_use;
|
||||
if (from->in_use > 0)
|
||||
{
|
||||
if (from->in_use <= 0)
|
||||
return;
|
||||
|
||||
// Copy the match start and end positions.
|
||||
if (REG_MULTI)
|
||||
{
|
||||
@ -4111,7 +4112,6 @@ copy_sub(regsub_T *to, regsub_T *from)
|
||||
&from->list.line[0],
|
||||
sizeof(struct linepos) * from->in_use);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Like copy_sub() but exclude the main match.
|
||||
@ -4121,8 +4121,9 @@ copy_sub_off(regsub_T *to, regsub_T *from)
|
||||
{
|
||||
if (to->in_use < from->in_use)
|
||||
to->in_use = from->in_use;
|
||||
if (from->in_use > 1)
|
||||
{
|
||||
if (from->in_use <= 1)
|
||||
return;
|
||||
|
||||
// Copy the match start and end positions.
|
||||
if (REG_MULTI)
|
||||
mch_memmove(&to->list.multi[1],
|
||||
@ -4133,7 +4134,6 @@ copy_sub_off(regsub_T *to, regsub_T *from)
|
||||
&from->list.line[1],
|
||||
sizeof(struct linepos) * (from->in_use - 1));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Like copy_sub() but only do the end of the main match if \ze is present.
|
||||
@ -4141,8 +4141,9 @@ copy_sub_off(regsub_T *to, regsub_T *from)
|
||||
static void
|
||||
copy_ze_off(regsub_T *to, regsub_T *from)
|
||||
{
|
||||
if (rex.nfa_has_zend)
|
||||
{
|
||||
if (!rex.nfa_has_zend)
|
||||
return;
|
||||
|
||||
if (REG_MULTI)
|
||||
{
|
||||
if (from->list.multi[0].end_lnum >= 0)
|
||||
@ -4157,7 +4158,6 @@ copy_ze_off(regsub_T *to, regsub_T *from)
|
||||
to->list.line[0].end = from->list.line[0].end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if "sub1" and "sub2" have the same start positions.
|
||||
@ -7568,13 +7568,13 @@ fail:
|
||||
static void
|
||||
nfa_regfree(regprog_T *prog)
|
||||
{
|
||||
if (prog != NULL)
|
||||
{
|
||||
if (prog == NULL)
|
||||
return;
|
||||
|
||||
vim_free(((nfa_regprog_T *)prog)->match_text);
|
||||
vim_free(((nfa_regprog_T *)prog)->pattern);
|
||||
vim_free(prog);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Match a regexp against a string.
|
||||
|
@ -294,8 +294,9 @@ get_register(
|
||||
|
||||
get_yank_register(name, 0);
|
||||
reg = ALLOC_ONE(yankreg_T);
|
||||
if (reg != NULL)
|
||||
{
|
||||
if (reg == NULL)
|
||||
return (void *)NULL;
|
||||
|
||||
*reg = *y_current;
|
||||
if (copy)
|
||||
{
|
||||
@ -312,7 +313,6 @@ get_register(
|
||||
}
|
||||
else
|
||||
y_current->y_array = NULL;
|
||||
}
|
||||
return (void *)reg;
|
||||
}
|
||||
|
||||
@ -716,8 +716,9 @@ put_reedit_in_typebuf(int silent)
|
||||
{
|
||||
char_u buf[3];
|
||||
|
||||
if (restart_edit != NUL)
|
||||
{
|
||||
if (restart_edit == NUL)
|
||||
return;
|
||||
|
||||
if (restart_edit == 'V')
|
||||
{
|
||||
buf[0] = 'g';
|
||||
@ -732,7 +733,6 @@ put_reedit_in_typebuf(int silent)
|
||||
if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK)
|
||||
restart_edit = NUL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert register contents "s" into the typeahead buffer, so that it will be
|
||||
@ -1097,15 +1097,15 @@ clear_registers(void)
|
||||
static void
|
||||
free_yank(long n)
|
||||
{
|
||||
if (y_current->y_array != NULL)
|
||||
{
|
||||
if (y_current->y_array == NULL)
|
||||
return;
|
||||
|
||||
long i;
|
||||
|
||||
for (i = n; --i >= 0; )
|
||||
vim_free(y_current->y_array[i]);
|
||||
VIM_CLEAR(y_current->y_array);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_yank_all(void)
|
||||
@ -2695,10 +2695,10 @@ get_reg_contents(int regname, int flags)
|
||||
}
|
||||
|
||||
retval = alloc(len + 1);
|
||||
if (retval == NULL)
|
||||
return NULL;
|
||||
|
||||
// Copy the lines of the yank register into the string.
|
||||
if (retval != NULL)
|
||||
{
|
||||
len = 0;
|
||||
for (i = 0; i < y_current->y_size; ++i)
|
||||
{
|
||||
@ -2711,7 +2711,6 @@ get_reg_contents(int regname, int flags)
|
||||
retval[len++] = '\n';
|
||||
}
|
||||
retval[len] = NUL;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1221,
|
||||
/**/
|
||||
1220,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user