0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.1098: code uses too much indent

Problem:    Code uses too much indent.
Solution:   Use an early return. (Yegappan Lakshmanan, closes #11747)
This commit is contained in:
Yegappan Lakshmanan
2022-12-26 12:50:04 +00:00
committed by Bram Moolenaar
parent b3d614369f
commit 465de3a57b
6 changed files with 226 additions and 222 deletions

View File

@@ -460,44 +460,46 @@ del_history_entry(int histype, char_u *str)
int last; int last;
int found = FALSE; int found = FALSE;
regmatch.regprog = NULL; if (hislen == 0 || histype < 0 || histype >= HIST_COUNT || *str == NUL
|| hisidx[histype] < 0)
return FALSE;
idx = hisidx[histype];
regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING);
if (regmatch.regprog == NULL)
return FALSE;
regmatch.rm_ic = FALSE; // always match case regmatch.rm_ic = FALSE; // always match case
if (hislen != 0
&& histype >= 0 i = last = idx;
&& histype < HIST_COUNT do
&& *str != NUL
&& (idx = hisidx[histype]) >= 0
&& (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING))
!= NULL)
{ {
i = last = idx; hisptr = &history[histype][i];
do if (hisptr->hisstr == NULL)
break;
if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0))
{ {
hisptr = &history[histype][i]; found = TRUE;
if (hisptr->hisstr == NULL) vim_free(hisptr->hisstr);
break; clear_hist_entry(hisptr);
if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0)) }
else
{
if (i != last)
{ {
found = TRUE; history[histype][last] = *hisptr;
vim_free(hisptr->hisstr);
clear_hist_entry(hisptr); clear_hist_entry(hisptr);
} }
else if (--last < 0)
{ last += hislen;
if (i != last) }
{ if (--i < 0)
history[histype][last] = *hisptr; i += hislen;
clear_hist_entry(hisptr); } while (i != idx);
}
if (--last < 0) if (history[histype][idx].hisstr == NULL)
last += hislen; hisidx[histype] = -1;
}
if (--i < 0)
i += hislen;
} while (i != idx);
if (history[histype][idx].hisstr == NULL)
hisidx[histype] = -1;
}
vim_regfree(regmatch.regprog); vim_regfree(regmatch.regprog);
return found; return found;
} }

View File

@@ -682,44 +682,44 @@ ex_breakadd(exarg_T *eap)
gap = &prof_ga; gap = &prof_ga;
#endif #endif
if (dbg_parsearg(eap->arg, gap) == OK) if (dbg_parsearg(eap->arg, gap) != OK)
{ return;
bp = &DEBUGGY(gap, gap->ga_len);
bp->dbg_forceit = eap->forceit;
if (bp->dbg_type != DBG_EXPR) bp = &DEBUGGY(gap, gap->ga_len);
bp->dbg_forceit = eap->forceit;
if (bp->dbg_type != DBG_EXPR)
{
pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE);
if (pat != NULL)
{ {
pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE); bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (pat != NULL) vim_free(pat);
{
bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
vim_free(pat);
}
if (pat == NULL || bp->dbg_prog == NULL)
vim_free(bp->dbg_name);
else
{
if (bp->dbg_lnum == 0) // default line number is 1
bp->dbg_lnum = 1;
#ifdef FEAT_PROFILE
if (eap->cmdidx != CMD_profile)
#endif
{
DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp;
++debug_tick;
}
++gap->ga_len;
}
} }
if (pat == NULL || bp->dbg_prog == NULL)
vim_free(bp->dbg_name);
else else
{ {
// DBG_EXPR if (bp->dbg_lnum == 0) // default line number is 1
DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp; bp->dbg_lnum = 1;
++debug_tick; #ifdef FEAT_PROFILE
if (gap == &dbg_breakp) if (eap->cmdidx != CMD_profile)
has_expr_breakpoint = TRUE; #endif
{
DEBUGGY(gap, gap->ga_len).dbg_nr = ++last_breakp;
++debug_tick;
}
++gap->ga_len;
} }
} }
else
{
// DBG_EXPR
DEBUGGY(gap, gap->ga_len++).dbg_nr = ++last_breakp;
++debug_tick;
if (gap == &dbg_breakp)
has_expr_breakpoint = TRUE;
}
} }
/* /*
@@ -822,36 +822,37 @@ ex_breakdel(exarg_T *eap)
} }
if (todel < 0) if (todel < 0)
semsg(_(e_breakpoint_not_found_str), eap->arg);
else
{ {
while (gap->ga_len > 0) semsg(_(e_breakpoint_not_found_str), eap->arg);
{ return;
vim_free(DEBUGGY(gap, todel).dbg_name);
#ifdef FEAT_EVAL
if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR
&& DEBUGGY(gap, todel).dbg_val != NULL)
free_tv(DEBUGGY(gap, todel).dbg_val);
#endif
vim_regfree(DEBUGGY(gap, todel).dbg_prog);
--gap->ga_len;
if (todel < gap->ga_len)
mch_memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1),
(gap->ga_len - todel) * sizeof(struct debuggy));
#ifdef FEAT_PROFILE
if (eap->cmdidx == CMD_breakdel)
#endif
++debug_tick;
if (!del_all)
break;
}
// If all breakpoints were removed clear the array.
if (gap->ga_len == 0)
ga_clear(gap);
if (gap == &dbg_breakp)
update_has_expr_breakpoint();
} }
while (gap->ga_len > 0)
{
vim_free(DEBUGGY(gap, todel).dbg_name);
#ifdef FEAT_EVAL
if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR
&& DEBUGGY(gap, todel).dbg_val != NULL)
free_tv(DEBUGGY(gap, todel).dbg_val);
#endif
vim_regfree(DEBUGGY(gap, todel).dbg_prog);
--gap->ga_len;
if (todel < gap->ga_len)
mch_memmove(&DEBUGGY(gap, todel), &DEBUGGY(gap, todel + 1),
(gap->ga_len - todel) * sizeof(struct debuggy));
#ifdef FEAT_PROFILE
if (eap->cmdidx == CMD_breakdel)
#endif
++debug_tick;
if (!del_all)
break;
}
// If all breakpoints were removed clear the array.
if (gap->ga_len == 0)
ga_clear(gap);
if (gap == &dbg_breakp)
update_has_expr_breakpoint();
} }
/* /*
@@ -864,23 +865,26 @@ ex_breaklist(exarg_T *eap UNUSED)
int i; int i;
if (dbg_breakp.ga_len == 0) if (dbg_breakp.ga_len == 0)
{
msg(_("No breakpoints defined")); msg(_("No breakpoints defined"));
else return;
for (i = 0; i < dbg_breakp.ga_len; ++i) }
{
bp = &BREAKP(i); for (i = 0; i < dbg_breakp.ga_len; ++i)
if (bp->dbg_type == DBG_FILE) {
home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE); bp = &BREAKP(i);
if (bp->dbg_type != DBG_EXPR) if (bp->dbg_type == DBG_FILE)
smsg(_("%3d %s %s line %ld"), home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE);
if (bp->dbg_type != DBG_EXPR)
smsg(_("%3d %s %s line %ld"),
bp->dbg_nr, bp->dbg_nr,
bp->dbg_type == DBG_FUNC ? "func" : "file", bp->dbg_type == DBG_FUNC ? "func" : "file",
bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff, bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff,
(long)bp->dbg_lnum); (long)bp->dbg_lnum);
else else
smsg(_("%3d expr %s"), smsg(_("%3d expr %s"),
bp->dbg_nr, bp->dbg_name); bp->dbg_nr, bp->dbg_name);
} }
} }
/* /*

View File

@@ -1180,44 +1180,40 @@ diff_file(diffio_T *dio)
#endif #endif
// Use xdiff for generating the diff. // Use xdiff for generating the diff.
if (dio->dio_internal) if (dio->dio_internal)
{
return diff_file_internal(dio); return diff_file_internal(dio);
}
else
{
len = STRLEN(tmp_orig) + STRLEN(tmp_new)
+ STRLEN(tmp_diff) + STRLEN(p_srr) + 27;
cmd = alloc(len);
if (cmd == NULL)
return FAIL;
// We don't want $DIFF_OPTIONS to get in the way. len = STRLEN(tmp_orig) + STRLEN(tmp_new)
if (getenv("DIFF_OPTIONS")) + STRLEN(tmp_diff) + STRLEN(p_srr) + 27;
vim_setenv((char_u *)"DIFF_OPTIONS", (char_u *)""); cmd = alloc(len);
if (cmd == NULL)
return FAIL;
// Build the diff command and execute it. Always use -a, binary // We don't want $DIFF_OPTIONS to get in the way.
// differences are of no use. Ignore errors, diff returns if (getenv("DIFF_OPTIONS"))
// non-zero when differences have been found. vim_setenv((char_u *)"DIFF_OPTIONS", (char_u *)"");
vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s%s%s%s %s",
diff_a_works == FALSE ? "" : "-a ", // Build the diff command and execute it. Always use -a, binary
// differences are of no use. Ignore errors, diff returns
// non-zero when differences have been found.
vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s%s%s%s %s",
diff_a_works == FALSE ? "" : "-a ",
#if defined(MSWIN) #if defined(MSWIN)
diff_bin_works == TRUE ? "--binary " : "", diff_bin_works == TRUE ? "--binary " : "",
#else #else
"", "",
#endif #endif
(diff_flags & DIFF_IWHITE) ? "-b " : "", (diff_flags & DIFF_IWHITE) ? "-b " : "",
(diff_flags & DIFF_IWHITEALL) ? "-w " : "", (diff_flags & DIFF_IWHITEALL) ? "-w " : "",
(diff_flags & DIFF_IWHITEEOL) ? "-Z " : "", (diff_flags & DIFF_IWHITEEOL) ? "-Z " : "",
(diff_flags & DIFF_IBLANK) ? "-B " : "", (diff_flags & DIFF_IBLANK) ? "-B " : "",
(diff_flags & DIFF_ICASE) ? "-i " : "", (diff_flags & DIFF_ICASE) ? "-i " : "",
tmp_orig, tmp_new); tmp_orig, tmp_new);
append_redir(cmd, (int)len, p_srr, tmp_diff); append_redir(cmd, (int)len, p_srr, tmp_diff);
block_autocmds(); // avoid ShellCmdPost stuff block_autocmds(); // avoid ShellCmdPost stuff
(void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT); (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
unblock_autocmds(); unblock_autocmds();
vim_free(cmd); vim_free(cmd);
return OK; return OK;
}
} }
/* /*
@@ -1432,31 +1428,31 @@ ex_diffsplit(exarg_T *eap)
// don't use a new tab page, each tab page has its own diffs // don't use a new tab page, each tab page has its own diffs
cmdmod.cmod_tab = 0; 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);
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))
{ {
// Pretend it was a ":split fname" command diff_win_options(old_curwin, TRUE);
eap->cmdidx = CMD_split;
curwin->w_p_diff = TRUE;
do_exedit(eap, old_curwin);
if (curwin != old_curwin) // split must have worked if (bufref_valid(&old_curbuf))
{ // Move the cursor position to that of the old window.
// Set 'diff', 'scrollbind' on and 'wrap' off. curwin->w_cursor.lnum = diff_get_corresponding_line(
diff_win_options(curwin, TRUE); old_curbuf.br_buf, old_curwin->w_cursor.lnum);
if (win_valid(old_curwin))
{
diff_win_options(old_curwin, TRUE);
if (bufref_valid(&old_curbuf))
// Move the cursor position to that of the old window.
curwin->w_cursor.lnum = diff_get_corresponding_line(
old_curbuf.br_buf, old_curwin->w_cursor.lnum);
}
// Now that lines are folded scroll to show the cursor at the same
// relative position.
scroll_to_fraction(curwin, curwin->w_height);
}
} }
// Now that lines are folded scroll to show the cursor at the same
// relative position.
scroll_to_fraction(curwin, curwin->w_height);
} }
/* /*

View File

@@ -1681,14 +1681,14 @@ registerdigraph(int char1, int char2, int n)
} }
// Add a new digraph to the table. // Add a new digraph to the table.
if (ga_grow(&user_digraphs, 1) == OK) if (ga_grow(&user_digraphs, 1) != OK)
{ return;
dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;
dp->char1 = char1; dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;
dp->char2 = char2; dp->char1 = char1;
dp->result = n; dp->char2 = char2;
++user_digraphs.ga_len; dp->result = n;
} ++user_digraphs.ga_len;
} }
/* /*
@@ -1948,54 +1948,54 @@ printdigraph(digr_T *dp, result_T *previous)
else else
list_width = 11; list_width = 11;
if (dp->result != 0) if (dp->result == 0)
{ return;
#if defined(USE_UNICODE_DIGRAPHS) #if defined(USE_UNICODE_DIGRAPHS)
if (previous != NULL) if (previous != NULL)
{ {
int i; int i;
for (i = 0; header_table[i].dg_header != NULL; ++i) for (i = 0; header_table[i].dg_header != NULL; ++i)
if (*previous < header_table[i].dg_start if (*previous < header_table[i].dg_start
&& dp->result >= header_table[i].dg_start && dp->result >= header_table[i].dg_start
&& dp->result < header_table[i + 1].dg_start) && dp->result < header_table[i + 1].dg_start)
{ {
digraph_header(_(header_table[i].dg_header)); digraph_header(_(header_table[i].dg_header));
break; break;
} }
*previous = dp->result; *previous = dp->result;
}
#endif
if (msg_col > Columns - list_width)
msg_putchar('\n');
if (msg_col)
while (msg_col % list_width != 0)
msg_putchar(' ');
p = buf;
*p++ = dp->char1;
*p++ = dp->char2;
*p++ = ' ';
*p = NUL;
msg_outtrans(buf);
p = buf;
if (has_mbyte)
{
// add a space to draw a composing char on
if (enc_utf8 && utf_iscomposing(dp->result))
*p++ = ' ';
p += (*mb_char2bytes)(dp->result, p);
}
else
*p++ = (char_u)dp->result;
*p = NUL;
msg_outtrans_attr(buf, HL_ATTR(HLF_8));
p = buf;
if (char2cells(dp->result) == 1)
*p++ = ' ';
vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result);
msg_outtrans(buf);
} }
#endif
if (msg_col > Columns - list_width)
msg_putchar('\n');
if (msg_col)
while (msg_col % list_width != 0)
msg_putchar(' ');
p = buf;
*p++ = dp->char1;
*p++ = dp->char2;
*p++ = ' ';
*p = NUL;
msg_outtrans(buf);
p = buf;
if (has_mbyte)
{
// add a space to draw a composing char on
if (enc_utf8 && utf_iscomposing(dp->result))
*p++ = ' ';
p += (*mb_char2bytes)(dp->result, p);
}
else
*p++ = (char_u)dp->result;
*p = NUL;
msg_outtrans_attr(buf, HL_ATTR(HLF_8));
p = buf;
if (char2cells(dp->result) == 1)
*p++ = ' ';
vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result);
msg_outtrans(buf);
} }
# ifdef FEAT_EVAL # ifdef FEAT_EVAL

View File

@@ -225,19 +225,19 @@ handle_foldcolumn(win_T *wp, winlinevars_T *wlv)
// Allocate a buffer, "wlv->extra[]" may already be in use. // Allocate a buffer, "wlv->extra[]" may already be in use.
vim_free(wlv->p_extra_free); vim_free(wlv->p_extra_free);
wlv->p_extra_free = alloc(MAX_MCO * fdc + 1); wlv->p_extra_free = alloc(MAX_MCO * fdc + 1);
if (wlv->p_extra_free != NULL) if (wlv->p_extra_free == NULL)
{ return;
wlv->n_extra = (int)fill_foldcolumn(wlv->p_extra_free,
wp, FALSE, wlv->lnum); wlv->n_extra = (int)fill_foldcolumn(wlv->p_extra_free,
wlv->p_extra_free[wlv->n_extra] = NUL; wp, FALSE, wlv->lnum);
wlv->p_extra = wlv->p_extra_free; wlv->p_extra_free[wlv->n_extra] = NUL;
wlv->c_extra = NUL; wlv->p_extra = wlv->p_extra_free;
wlv->c_final = NUL; wlv->c_extra = NUL;
if (use_cursor_line_highlight(wp, wlv->lnum)) wlv->c_final = NUL;
wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_CLF)); if (use_cursor_line_highlight(wp, wlv->lnum))
else wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_CLF));
wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_FC)); else
} wlv->char_attr = hl_combine_attr(wlv->wcr_attr, HL_ATTR(HLF_FC));
} }
#endif #endif

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1098,
/**/ /**/
1097, 1097,
/**/ /**/