mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -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:
committed by
Bram Moolenaar
parent
4aecaa168e
commit
f97a295cca
286
src/quickfix.c
286
src/quickfix.c
@@ -1898,14 +1898,14 @@ qf_store_title(qf_list_T *qfl, char_u *title)
|
||||
{
|
||||
VIM_CLEAR(qfl->qf_title);
|
||||
|
||||
if (title != NULL)
|
||||
{
|
||||
char_u *p = alloc_id(STRLEN(title) + 2, aid_qf_title);
|
||||
if (title == NULL)
|
||||
return;
|
||||
|
||||
qfl->qf_title = p;
|
||||
if (p != NULL)
|
||||
STRCPY(p, title);
|
||||
}
|
||||
char_u *p = alloc_id(STRLEN(title) + 2, aid_qf_title);
|
||||
|
||||
qfl->qf_title = p;
|
||||
if (p != NULL)
|
||||
STRCPY(p, title);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1976,12 +1976,12 @@ locstack_queue_delreq(qf_info_T *qi)
|
||||
qf_delq_T *q;
|
||||
|
||||
q = ALLOC_ONE(qf_delq_T);
|
||||
if (q != NULL)
|
||||
{
|
||||
q->qi = qi;
|
||||
q->next = qf_delq_head;
|
||||
qf_delq_head = q;
|
||||
}
|
||||
if (q == NULL)
|
||||
return;
|
||||
|
||||
q->qi = qi;
|
||||
q->next = qf_delq_head;
|
||||
qf_delq_head = q;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2002,16 +2002,16 @@ 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)
|
||||
{
|
||||
qfbuf = buflist_findnr(qi->qf_bufnr);
|
||||
if (qfbuf != NULL && qfbuf->b_nwindows == 0)
|
||||
{
|
||||
// If the quickfix buffer is not loaded in any window, then
|
||||
// wipe the buffer.
|
||||
close_buffer(NULL, qfbuf, DOBUF_WIPE, FALSE, FALSE);
|
||||
qi->qf_bufnr = INVALID_QFBUFNR;
|
||||
}
|
||||
// If the quickfix buffer is not loaded in any window, then
|
||||
// wipe the buffer.
|
||||
close_buffer(NULL, qfbuf, DOBUF_WIPE, FALSE, FALSE);
|
||||
qi->qf_bufnr = INVALID_QFBUFNR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
qi->qf_refcount++;
|
||||
qi->qfl_type = qfltype;
|
||||
qi->qf_bufnr = INVALID_QFBUFNR;
|
||||
}
|
||||
if (qi == NULL)
|
||||
return NULL;
|
||||
|
||||
qi->qf_refcount++;
|
||||
qi->qfl_type = qfltype;
|
||||
qi->qf_bufnr = INVALID_QFBUFNR;
|
||||
return qi;
|
||||
}
|
||||
|
||||
@@ -4573,64 +4573,64 @@ 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;
|
||||
|
||||
if (IS_LL_STACK(qi))
|
||||
{
|
||||
linenr_T old_line_count = buf->b_ml.ml_line_count;
|
||||
int qf_winid = 0;
|
||||
|
||||
if (IS_LL_STACK(qi))
|
||||
if (curwin->w_llist == qi)
|
||||
win = curwin;
|
||||
else
|
||||
{
|
||||
if (curwin->w_llist == qi)
|
||||
win = curwin;
|
||||
else
|
||||
{
|
||||
// Find the file window (non-quickfix) with this location list
|
||||
win = qf_find_win_with_loclist(qi);
|
||||
if (win == NULL)
|
||||
// File window is not found. Find the location list window.
|
||||
win = qf_find_win(qi);
|
||||
if (win == NULL)
|
||||
return;
|
||||
}
|
||||
qf_winid = win->w_id;
|
||||
// Find the file window (non-quickfix) with this location list
|
||||
win = qf_find_win_with_loclist(qi);
|
||||
if (win == NULL)
|
||||
// File window is not found. Find the location list window.
|
||||
win = qf_find_win(qi);
|
||||
if (win == NULL)
|
||||
return;
|
||||
}
|
||||
qf_winid = win->w_id;
|
||||
}
|
||||
|
||||
// autocommands may cause trouble
|
||||
incr_quickfix_busy();
|
||||
// autocommands may cause trouble
|
||||
incr_quickfix_busy();
|
||||
|
||||
int do_fill = TRUE;
|
||||
if (old_last == NULL)
|
||||
{
|
||||
// set curwin/curbuf to buf and save a few things
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
if (curbuf != buf)
|
||||
do_fill = FALSE; // failed to find a window for "buf"
|
||||
}
|
||||
|
||||
if (do_fill)
|
||||
{
|
||||
qf_update_win_titlevar(qi);
|
||||
|
||||
qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid);
|
||||
++CHANGEDTICK(buf);
|
||||
|
||||
int do_fill = TRUE;
|
||||
if (old_last == NULL)
|
||||
{
|
||||
// set curwin/curbuf to buf and save a few things
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
if (curbuf != buf)
|
||||
do_fill = FALSE; // failed to find a window for "buf"
|
||||
(void)qf_win_pos_update(qi, 0);
|
||||
|
||||
// restore curwin/curbuf and a few other things
|
||||
aucmd_restbuf(&aco);
|
||||
}
|
||||
|
||||
if (do_fill)
|
||||
{
|
||||
qf_update_win_titlevar(qi);
|
||||
|
||||
qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid);
|
||||
++CHANGEDTICK(buf);
|
||||
|
||||
if (old_last == NULL)
|
||||
{
|
||||
(void)qf_win_pos_update(qi, 0);
|
||||
|
||||
// restore curwin/curbuf and a few other things
|
||||
aucmd_restbuf(&aco);
|
||||
}
|
||||
}
|
||||
|
||||
// Only redraw when added lines are visible. This avoids flickering
|
||||
// when the added lines are not visible.
|
||||
if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline)
|
||||
redraw_buf_later(buf, UPD_NOT_VALID);
|
||||
|
||||
// always called after incr_quickfix_busy()
|
||||
decr_quickfix_busy();
|
||||
}
|
||||
|
||||
// Only redraw when added lines are visible. This avoids flickering
|
||||
// when the added lines are not visible.
|
||||
if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline)
|
||||
redraw_buf_later(buf, UPD_NOT_VALID);
|
||||
|
||||
// always called after incr_quickfix_busy()
|
||||
decr_quickfix_busy();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -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)
|
||||
{
|
||||
curlist = qf_id2nr(qi, save_qfid);
|
||||
if (curlist < 0)
|
||||
// list is not present
|
||||
return FAIL;
|
||||
qi->qf_curlist = curlist;
|
||||
}
|
||||
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,22 +6544,22 @@ restore_start_dir(char_u *dirname_start)
|
||||
{
|
||||
char_u *dirname_now = alloc(MAXPATHL);
|
||||
|
||||
if (NULL != dirname_now)
|
||||
{
|
||||
mch_dirname(dirname_now, MAXPATHL);
|
||||
if (STRCMP(dirname_start, dirname_now) != 0)
|
||||
{
|
||||
// If the directory has changed, change it back by building up an
|
||||
// appropriate ex command and executing it.
|
||||
exarg_T ea;
|
||||
if (dirname_now == NULL)
|
||||
return;
|
||||
|
||||
CLEAR_FIELD(ea);
|
||||
ea.arg = dirname_start;
|
||||
ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd;
|
||||
ex_cd(&ea);
|
||||
}
|
||||
vim_free(dirname_now);
|
||||
mch_dirname(dirname_now, MAXPATHL);
|
||||
if (STRCMP(dirname_start, dirname_now) != 0)
|
||||
{
|
||||
// If the directory has changed, change it back by building up an
|
||||
// appropriate ex command and executing it.
|
||||
exarg_T ea;
|
||||
|
||||
CLEAR_FIELD(ea);
|
||||
ea.arg = dirname_start;
|
||||
ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd;
|
||||
ex_cd(&ea);
|
||||
}
|
||||
vim_free(dirname_now);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6723,13 +6723,13 @@ 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
|
||||
{
|
||||
close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE, TRUE);
|
||||
if (curbuf == buf) // safety check
|
||||
return;
|
||||
|
||||
// When autocommands/'autochdir' option changed directory: go back.
|
||||
restore_start_dir(dirname_start);
|
||||
}
|
||||
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,37 +6862,37 @@ 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)
|
||||
{
|
||||
// If errorformat is supplied then use it, otherwise use the 'efm'
|
||||
// option setting
|
||||
if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL)
|
||||
{
|
||||
if (efm_di->di_tv.v_type != VAR_STRING ||
|
||||
efm_di->di_tv.vval.v_string == NULL)
|
||||
return FAIL;
|
||||
errorformat = efm_di->di_tv.vval.v_string;
|
||||
}
|
||||
|
||||
l = list_alloc();
|
||||
if (l == NULL)
|
||||
if (efm_di->di_tv.v_type != VAR_STRING ||
|
||||
efm_di->di_tv.vval.v_string == NULL)
|
||||
return FAIL;
|
||||
|
||||
qi = qf_alloc_stack(QFLT_INTERNAL);
|
||||
if (qi != NULL)
|
||||
{
|
||||
if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
|
||||
TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
|
||||
{
|
||||
(void)get_errorlist(qi, NULL, 0, 0, l);
|
||||
qf_free(&qi->qf_lists[0]);
|
||||
}
|
||||
free(qi);
|
||||
}
|
||||
dict_add_list(retdict, "items", l);
|
||||
status = OK;
|
||||
errorformat = efm_di->di_tv.vval.v_string;
|
||||
}
|
||||
|
||||
l = list_alloc();
|
||||
if (l == NULL)
|
||||
return FAIL;
|
||||
|
||||
qi = qf_alloc_stack(QFLT_INTERNAL);
|
||||
if (qi != NULL)
|
||||
{
|
||||
if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
|
||||
TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
|
||||
{
|
||||
(void)get_errorlist(qi, NULL, 0, 0, l);
|
||||
qf_free(&qi->qf_lists[0]);
|
||||
}
|
||||
free(qi);
|
||||
}
|
||||
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)
|
||||
{
|
||||
set_callback(&qfl->qf_qftf_cb, &cb);
|
||||
if (cb.cb_free_name)
|
||||
vim_free(cb.cb_name);
|
||||
}
|
||||
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,11 +8126,11 @@ 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)
|
||||
{
|
||||
(void)cexpr_core(eap, tv);
|
||||
free_tv(tv);
|
||||
}
|
||||
if (tv == NULL)
|
||||
return;
|
||||
|
||||
(void)cexpr_core(eap, tv);
|
||||
free_tv(tv);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user