diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2022-12-26 12:50:04 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-26 12:50:04 +0000 |
commit | 465de3a57b815f1188c707e7c083950c81652536 (patch) | |
tree | 6a1e8783bb5f269282668c258f0b893bd961a888 /src/cmdhist.c | |
parent | b3d614369fceb891819badc941f80f08f57831f9 (diff) |
patch 9.0.1098: code uses too much indentv9.0.1098
Problem: Code uses too much indent.
Solution: Use an early return. (Yegappan Lakshmanan, closes #11747)
Diffstat (limited to 'src/cmdhist.c')
-rw-r--r-- | src/cmdhist.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/cmdhist.c b/src/cmdhist.c index ea955478ef..d398ca7a68 100644 --- a/src/cmdhist.c +++ b/src/cmdhist.c @@ -460,44 +460,46 @@ del_history_entry(int histype, char_u *str) int last; 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 - if (hislen != 0 - && histype >= 0 - && histype < HIST_COUNT - && *str != NUL - && (idx = hisidx[histype]) >= 0 - && (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING)) - != NULL) + + i = last = idx; + do { - i = last = idx; - do + hisptr = &history[histype][i]; + if (hisptr->hisstr == NULL) + break; + if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) { - hisptr = &history[histype][i]; - if (hisptr->hisstr == NULL) - break; - if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) + found = TRUE; + vim_free(hisptr->hisstr); + clear_hist_entry(hisptr); + } + else + { + if (i != last) { - found = TRUE; - vim_free(hisptr->hisstr); + history[histype][last] = *hisptr; clear_hist_entry(hisptr); } - else - { - if (i != last) - { - history[histype][last] = *hisptr; - clear_hist_entry(hisptr); - } - if (--last < 0) - last += hislen; - } - if (--i < 0) - i += hislen; - } while (i != idx); - if (history[histype][idx].hisstr == NULL) - hisidx[histype] = -1; - } + if (--last < 0) + last += hislen; + } + if (--i < 0) + i += hislen; + } while (i != idx); + + if (history[histype][idx].hisstr == NULL) + hisidx[histype] = -1; + vim_regfree(regmatch.regprog); return found; } |