mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 04:18:18 +00:00
vim-patch:9.0.1098: code uses too much indent (#21540)
Problem: Code uses too much indent.
Solution: Use an early return. (Yegappan Lakshmanan, closes vim/vim#11747)
465de3a57b
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -439,24 +439,24 @@ int clr_history(const int histype)
|
||||
/// @param histype may be one of the HIST_ values.
|
||||
static int del_history_entry(int histype, char_u *str)
|
||||
{
|
||||
regmatch_T regmatch;
|
||||
histentry_T *hisptr;
|
||||
int idx;
|
||||
int i;
|
||||
int last;
|
||||
bool found = false;
|
||||
if (hislen == 0 || histype < 0 || histype >= HIST_COUNT || *str == NUL
|
||||
|| hisidx[histype] < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const int idx = hisidx[histype];
|
||||
regmatch_T regmatch;
|
||||
regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING);
|
||||
if (regmatch.regprog == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
regmatch.regprog = NULL;
|
||||
regmatch.rm_ic = false; // always match case
|
||||
if (hislen != 0
|
||||
&& histype >= 0
|
||||
&& histype < HIST_COUNT
|
||||
&& *str != NUL
|
||||
&& (idx = hisidx[histype]) >= 0
|
||||
&& (regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING)) != NULL) {
|
||||
i = last = idx;
|
||||
|
||||
bool found = false;
|
||||
int i = idx, last = idx;
|
||||
do {
|
||||
hisptr = &history[histype][i];
|
||||
histentry_T *hisptr = &history[histype][i];
|
||||
if (hisptr->hisstr == NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -476,10 +476,11 @@ static int del_history_entry(int histype, char_u *str)
|
||||
i += hislen;
|
||||
}
|
||||
} while (i != idx);
|
||||
|
||||
if (history[histype][idx].hisstr == NULL) {
|
||||
hisidx[histype] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
vim_regfree(regmatch.regprog);
|
||||
return found;
|
||||
}
|
||||
|
@@ -594,7 +594,10 @@ void ex_breakadd(exarg_T *eap)
|
||||
gap = &prof_ga;
|
||||
}
|
||||
|
||||
if (dbg_parsearg(eap->arg, gap) == OK) {
|
||||
if (dbg_parsearg(eap->arg, gap) != OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct debuggy *bp = &DEBUGGY(gap, gap->ga_len);
|
||||
bp->dbg_forceit = eap->forceit;
|
||||
|
||||
@@ -621,7 +624,6 @@ void ex_breakadd(exarg_T *eap)
|
||||
DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
|
||||
debug_tick++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ":debuggreedy".
|
||||
@@ -682,7 +684,9 @@ void ex_breakdel(exarg_T *eap)
|
||||
|
||||
if (todel < 0) {
|
||||
semsg(_("E161: Breakpoint not found: %s"), eap->arg);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!GA_EMPTY(gap)) {
|
||||
xfree(DEBUGGY(gap, todel).dbg_name);
|
||||
if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR
|
||||
@@ -707,7 +711,6 @@ void ex_breakdel(exarg_T *eap)
|
||||
if (GA_EMPTY(gap)) {
|
||||
ga_clear(gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ":breaklist".
|
||||
@@ -715,7 +718,9 @@ void ex_breaklist(exarg_T *eap)
|
||||
{
|
||||
if (GA_EMPTY(&dbg_breakp)) {
|
||||
msg(_("No breakpoints defined"));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < dbg_breakp.ga_len; i++) {
|
||||
struct debuggy *bp = &BREAKP(i);
|
||||
if (bp->dbg_type == DBG_FILE) {
|
||||
@@ -731,7 +736,6 @@ void ex_breaklist(exarg_T *eap)
|
||||
smsg(_("%3d expr %s"), bp->dbg_nr, bp->dbg_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Find a breakpoint for a function or sourced file.
|
||||
|
@@ -1147,6 +1147,7 @@ static int diff_file(diffio_T *dio)
|
||||
if (dio->dio_internal) {
|
||||
return diff_file_internal(dio);
|
||||
}
|
||||
|
||||
const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
|
||||
+ strlen(p_srr) + 27);
|
||||
char *const cmd = xmalloc(len);
|
||||
@@ -1350,14 +1351,19 @@ void ex_diffsplit(exarg_T *eap)
|
||||
// don't use a new tab page, each tab page has its own diffs
|
||||
cmdmod.cmod_tab = 0;
|
||||
|
||||
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
|
||||
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Pretend it was a ":split fname" command
|
||||
eap->cmdidx = CMD_split;
|
||||
curwin->w_p_diff = true;
|
||||
do_exedit(eap, old_curwin);
|
||||
|
||||
// split must have worked
|
||||
if (curwin != old_curwin) {
|
||||
if (curwin == old_curwin) { // split didn't work
|
||||
return;
|
||||
}
|
||||
|
||||
// Set 'diff', 'scrollbind' on and 'wrap' off.
|
||||
diff_win_options(curwin, true);
|
||||
if (win_valid(old_curwin)) {
|
||||
@@ -1372,8 +1378,6 @@ void ex_diffsplit(exarg_T *eap)
|
||||
// Now that lines are folded scroll to show the cursor at the same
|
||||
// relative position.
|
||||
scroll_to_fraction(curwin, curwin->w_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set options to show diffs for the current window.
|
||||
|
@@ -1826,7 +1826,10 @@ static void printdigraph(const digr_T *dp, result_T *previous)
|
||||
char_u buf[30];
|
||||
int list_width = 13;
|
||||
|
||||
if (dp->result != 0) {
|
||||
if (dp->result == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (previous != NULL) {
|
||||
for (int i = 0; header_table[i].dg_header != NULL; i++) {
|
||||
if (*previous < header_table[i].dg_start
|
||||
@@ -1873,7 +1876,6 @@ static void printdigraph(const digr_T *dp, result_T *previous)
|
||||
assert(p >= buf);
|
||||
vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result);
|
||||
msg_outtrans((char *)buf);
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the two digraph characters from a typval.
|
||||
|
Reference in New Issue
Block a user