refactor: follow style guide

- reduce variable scope
- prefer initialization over declaration and assignment
- use bool to represent boolean values
This commit is contained in:
dundargoc
2023-11-12 15:54:54 +01:00
committed by dundargoc
parent 48bcc7b971
commit 28f4f3c484
42 changed files with 287 additions and 554 deletions

View File

@@ -519,14 +519,12 @@ static int del_history_idx(int histype, int idx)
/// "histadd()" function
void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
HistoryType histype;
rettv->vval.v_number = false;
if (check_secure()) {
return;
}
const char *str = tv_get_string_chk(&argvars[0]); // NULL on type error
histype = str != NULL ? get_histtype(str, strlen(str), false) : HIST_INVALID;
HistoryType histype = str != NULL ? get_histtype(str, strlen(str), false) : HIST_INVALID;
if (histype == HIST_INVALID) {
return;
}
@@ -605,7 +603,6 @@ void ex_history(exarg_T *eap)
int histype2 = HIST_CMD;
int hisidx1 = 1;
int hisidx2 = -1;
int i;
char *end;
char *arg = eap->arg;
@@ -661,7 +658,7 @@ void ex_history(exarg_T *eap)
k = (-k > hislen) ? 0 : hist[(hislen + k + idx + 1) % hislen].hisnum;
}
if (idx >= 0 && j <= k) {
for (i = idx + 1; !got_int; i++) {
for (int i = idx + 1; !got_int; i++) {
if (i == hislen) {
i = 0;
}