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

@@ -354,11 +354,10 @@ void init_search_hl(win_T *wp, match_T *search_hl)
static int next_search_hl_pos(match_T *shl, linenr_T lnum, matchitem_T *match, colnr_T mincol)
FUNC_ATTR_NONNULL_ALL
{
int i;
int found = -1;
shl->lnum = 0;
for (i = match->mit_pos_cur; i < match->mit_pos_count; i++) {
for (int i = match->mit_pos_cur; i < match->mit_pos_count; i++) {
llpos_T *pos = &match->mit_pos_array[i];
if (pos->lnum == 0) {
@@ -902,7 +901,6 @@ void f_clearmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
void f_getmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
matchitem_T *cur;
int i;
win_T *win = get_optional_window(argvars, 0);
tv_list_alloc_ret(rettv, kListLenMayKnow);
@@ -915,7 +913,7 @@ void f_getmatches(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
dict_T *dict = tv_dict_alloc();
if (cur->mit_match.regprog == NULL) {
// match added with matchaddpos()
for (i = 0; i < cur->mit_pos_count; i++) {
for (int i = 0; i < cur->mit_pos_count; i++) {
llpos_T *llpos;
char buf[30]; // use 30 to avoid compiler warning