From 3b0df1780e2c8526bda5dead18ee7cc45925caba Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:23:44 +0200 Subject: refactor: uncrustify Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`. --- src/nvim/api/extmark.c | 2 +- src/nvim/api/options.c | 2 +- src/nvim/api/private/converter.c | 4 ++-- src/nvim/arglist.c | 4 ++-- src/nvim/autocmd.c | 2 +- src/nvim/buffer.c | 8 ++++---- src/nvim/buffer_defs.h | 2 +- src/nvim/bufwrite.c | 4 ++-- src/nvim/change.c | 2 +- src/nvim/charset.c | 4 ++-- src/nvim/cursor.c | 2 +- src/nvim/debugger.c | 2 +- src/nvim/decoration.c | 2 +- src/nvim/diff.c | 14 +++++++------- src/nvim/digraph.c | 2 +- src/nvim/drawline.c | 2 +- src/nvim/drawscreen.c | 8 ++++---- src/nvim/edit.c | 8 ++++---- src/nvim/eval.c | 18 +++++++++--------- src/nvim/eval/buffer.c | 2 +- src/nvim/eval/encode.c | 4 ++-- src/nvim/eval/funcs.c | 16 ++++++++-------- src/nvim/eval/typval.c | 2 +- src/nvim/eval/userfunc.c | 4 ++-- src/nvim/eval/vars.c | 6 +++--- src/nvim/ex_cmds.c | 8 ++++---- src/nvim/ex_docmd.c | 10 +++++----- src/nvim/ex_eval.c | 6 +++--- src/nvim/ex_getln.c | 4 ++-- src/nvim/file_search.c | 10 +++++----- src/nvim/fileio.c | 12 ++++++------ src/nvim/fold.c | 16 ++++++++-------- src/nvim/getchar.c | 12 ++++++------ src/nvim/hashtab.c | 2 +- src/nvim/indent.c | 6 +++--- src/nvim/indent_c.c | 14 +++++++------- src/nvim/input.c | 4 ++-- src/nvim/insexpand.c | 4 ++-- src/nvim/keycodes.c | 12 ++++++------ src/nvim/lua/executor.c | 2 +- src/nvim/lua/spell.c | 6 +++--- src/nvim/lua/stdlib.c | 4 ++-- src/nvim/lua/treesitter.c | 2 +- src/nvim/lua/xdiff.c | 8 ++++---- src/nvim/mapping.c | 14 +++++++------- src/nvim/mark.c | 2 +- src/nvim/marktree.c | 2 +- src/nvim/marktree.h | 2 +- src/nvim/match.c | 6 +++--- src/nvim/mbyte.c | 20 ++++++++++---------- src/nvim/memfile.c | 2 +- src/nvim/memline.c | 12 ++++++------ src/nvim/memory.c | 2 +- src/nvim/menu.c | 2 +- src/nvim/message.c | 8 ++++---- src/nvim/mouse.c | 6 +++--- src/nvim/move.c | 2 +- src/nvim/normal.c | 8 ++++---- src/nvim/ops.c | 10 +++++----- src/nvim/option.c | 4 ++-- src/nvim/option_defs.h | 6 +++--- src/nvim/optionstr.c | 12 ++++++------ src/nvim/os/env.c | 2 +- src/nvim/os/fs.c | 2 +- src/nvim/os/input.c | 4 ++-- src/nvim/os/process.c | 2 +- src/nvim/os/shell.c | 2 +- src/nvim/plines.c | 12 ++++++------ src/nvim/popupmenu.c | 2 +- src/nvim/quickfix.c | 8 ++++---- src/nvim/regexp.c | 6 +++--- src/nvim/regexp_bt.c | 12 ++++++------ src/nvim/regexp_nfa.c | 8 ++++---- src/nvim/runtime.c | 2 +- src/nvim/search.c | 22 +++++++++++----------- src/nvim/shada.c | 4 ++-- src/nvim/sign.c | 2 +- src/nvim/spell.c | 12 ++++++------ src/nvim/spellfile.c | 16 ++++++++-------- src/nvim/spellsuggest.c | 10 +++++----- src/nvim/state.c | 4 ++-- src/nvim/statusline.c | 2 +- src/nvim/strings.c | 14 +++++++------- src/nvim/syntax.c | 12 ++++++------ src/nvim/tag.c | 14 +++++++------- src/nvim/terminal.c | 4 ++-- src/nvim/textformat.c | 2 +- src/nvim/textobject.c | 12 ++++++------ src/nvim/tui/tui.c | 4 ++-- src/nvim/ui_compositor.c | 8 ++++---- src/nvim/undo.c | 6 +++--- src/nvim/usercmd.c | 10 +++++----- src/nvim/window.c | 18 +++++++++--------- src/uncrustify.cfg | 22 +++++++++++----------- 94 files changed, 324 insertions(+), 324 deletions(-) (limited to 'src') diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index eb49587d03..b781da1dc3 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -1168,7 +1168,7 @@ static bool extmark_get_index_from_obj(buf_T *buf, Integer ns_id, Object obj, in Integer pos_row = pos.items[0].data.integer; Integer pos_col = pos.items[1].data.integer; - *row = (int)(pos_row >= 0 ? pos_row : MAXLNUM); + *row = (int)(pos_row >= 0 ? pos_row : MAXLNUM); *col = (colnr_T)(pos_col >= 0 ? pos_col : MAXCOL); return true; } else { diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index 467a4720a6..2d1b170d2d 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -546,7 +546,7 @@ void set_option_to(uint64_t channel_id, void *to, int type, String name, Object // For global-win-local options -> setlocal // For win-local options -> setglobal and setlocal (opt_flags == 0) const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) ? 0 : - (type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL; + (type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL; WITH_SCRIPT_CONTEXT(channel_id, { access_option_value_for(name.data, &numval, &stringval, opt_flags, type, to, false, err); diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index 7d04d883f5..a62f975cfd 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -51,7 +51,7 @@ typedef struct { const size_t len_ = (size_t)(len); \ const char *const str_ = (str); \ assert(len_ == 0 || str_ != NULL); \ - kvi_push(edata->stack, STRING_OBJ(cbuf_to_string((len_?str_:""), len_))); \ + kvi_push(edata->stack, STRING_OBJ(cbuf_to_string((len_ ? str_ : ""), len_))); \ } while (0) #define TYPVAL_ENCODE_CONV_STR_STRING TYPVAL_ENCODE_CONV_STRING @@ -275,7 +275,7 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) case kObjectTypeBoolean: tv->v_type = VAR_BOOL; - tv->vval.v_bool = obj.data.boolean? kBoolVarTrue: kBoolVarFalse; + tv->vval.v_bool = obj.data.boolean ? kBoolVarTrue : kBoolVarFalse; break; case kObjectTypeBuffer: diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 6e3fc62c5b..284c94a712 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -852,7 +852,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall) if (aall->had_tab > 0) { goto_tabpage_tp(first_tabpage, true, true); } - for (;;) { + while (true) { win_T *wpnext = NULL; tabpage_T *tpnext = curtab->tp_next; for (win_T *wp = firstwin; wp != NULL; wp = wpnext) { @@ -1148,7 +1148,7 @@ char *arg_all(void) // Do this loop two times: // first time: compute the total length // second time: concatenate the names - for (;;) { + while (true) { int len = 0; for (int idx = 0; idx < ARGCOUNT; idx++) { char *p = alist_name(&ARGLIST[idx]); diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 726344a42b..1d09e8f6c3 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -2185,7 +2185,7 @@ char *getnextac(int c, void *cookie, int indent, bool do_concat) } // repeat until we find an autocommand to execute - for (;;) { + while (true) { // skip removed commands while (acp->nextcmd != NULL && aucmd_exec_is_deleted(acp->nextcmd->exec)) { diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index d1c93733c0..c63ab804af 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1403,7 +1403,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit) if (buf == NULL) { // No previous buffer, Try 2'nd approach forward = true; buf = curbuf->b_next; - for (;;) { + while (true) { if (buf == NULL) { if (!forward) { // tried both directions break; @@ -2241,7 +2241,7 @@ int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted, // First try finding a listed buffer. If not found and "unlisted" // is true, try finding an unlisted buffer. find_listed = true; - for (;;) { + while (true) { for (attempt = 0; attempt <= 3; attempt++) { // may add '^' and '$' if (toggledollar) { @@ -3180,7 +3180,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) bool dontwrite = bt_dontwrite(curbuf); vim_snprintf_add(buffer, IOSIZE, "\"%s%s%s%s%s%s", curbufIsChanged() - ? (shortmess(SHM_MOD) ? " [+]" : _(" [Modified]")) : " ", + ? (shortmess(SHM_MOD) ? " [+]" : _(" [Modified]")) : " ", (curbuf->b_flags & BF_NOTEDITED) && !dontwrite ? _("[Not edited]") : "", (curbuf->b_flags & BF_NEW) && !dontwrite @@ -3609,7 +3609,7 @@ void ex_buffer_all(exarg_T *eap) if (had_tab > 0) { goto_tabpage_tp(first_tabpage, true, true); } - for (;;) { + while (true) { tpnext = curtab->tp_next; for (wp = firstwin; wp != NULL; wp = wpnext) { wpnext = wp->w_next; diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index c808909942..02226f3cc4 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -607,7 +607,7 @@ struct file_buffer { int b_p_ai; ///< 'autoindent' int b_p_ai_nopaste; ///< b_p_ai saved for paste mode char *b_p_bkc; ///< 'backupco - unsigned int b_bkc_flags; ///< flags for 'backupco + unsigned b_bkc_flags; ///< flags for 'backupco int b_p_ci; ///< 'copyindent' int b_p_bin; ///< 'binary' int b_p_bomb; ///< 'bomb' diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 89d63a39d5..de56c5c717 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -714,7 +714,7 @@ static int get_fileinfo(buf_T *buf, char *fname, bool overwriting, bool forceit, } static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_old, vim_acl_T acl, - long perm, unsigned int bkc, bool file_readonly, bool forceit, + long perm, unsigned bkc, bool file_readonly, bool forceit, int *backup_copyp, char **backupp, Error_T *err) { FileInfo file_info; @@ -1056,7 +1056,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en int whole = (start == 1 && end == buf->b_ml.ml_line_count); int write_undo_file = false; context_sha256_T sha_ctx; - unsigned int bkc = get_bkc_value(buf); + unsigned bkc = get_bkc_value(buf); if (fname == NULL || *fname == NUL) { // safety check return FAIL; diff --git a/src/nvim/change.c b/src/nvim/change.c index 6fd32d9113..1d6869990e 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -950,7 +950,7 @@ int copy_indent(int size, char *src) // Add tabs required for indent. if (!curbuf->b_p_et) { - for (;;) { + while (true) { tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts, curbuf->b_p_vts_array); diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 545002a197..3d4e0abda9 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -990,7 +990,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en && *get_showbreak_value(wp) == NUL && !wp->w_p_bri && !cts.cts_has_virt_text) { - for (;;) { + while (true) { head = 0; int c = (uint8_t)(*ptr); @@ -1034,7 +1034,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en MB_PTR_ADV(ptr); } } else { - for (;;) { + while (true) { // A tab gets expanded, depending on the current column // Other things also take up space. head = 0; diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index ceeaa65206..6d90b32545 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -351,7 +351,7 @@ void check_cursor_col_win(win_T *win) { colnr_T oldcol = win->w_cursor.col; colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd; - unsigned int cur_ve_flags = get_ve_flags(); + unsigned cur_ve_flags = get_ve_flags(); colnr_T len = (colnr_T)strlen(ml_get_buf(win->w_buffer, win->w_cursor.lnum, false)); if (len == 0) { diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 90723372a9..1b1dea0d62 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -126,7 +126,7 @@ void do_debug(char *cmd) } // Repeat getting a command and executing it. - for (;;) { + while (true) { msg_scroll = true; need_wait_return = false; diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index ea54554c46..980be0282d 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -86,7 +86,7 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor) } if (decor && kv_size(decor->virt_lines)) { - redraw_buf_line_later(buf, row1 + 1 + (decor->virt_lines_above?0:1), true); + redraw_buf_line_later(buf, row1 + 1 + (decor->virt_lines_above ? 0 : 1), true); changed_line_display_buf(buf); } } diff --git a/src/nvim/diff.c b/src/nvim/diff.c index b2efcbac58..f1a3a679be 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -328,7 +328,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T diff_T *dp = tp->tp_first_diff; linenr_T lnum_deleted = line1; // lnum of remaining deletion - for (;;) { + while (true) { // If the change is after the previous diff block and before the next // diff block, thus not touching an existing change, create a new diff // block. Don't do this when ex_diffgetput() is busy. @@ -588,7 +588,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) linenr_T off_org = 0; linenr_T off_new = 0; int dir = FORWARD; - for (;;) { + while (true) { // Repeat until a line is found which is different or the number of // lines has become zero. while (dp->df_count[i_org] > 0) { @@ -1012,7 +1012,7 @@ static int check_external_diff(diffio_T *diffio) // May try twice, first with "-a" and then without. int io_error = false; TriState ok = kFalse; - for (;;) { + while (true) { ok = kFalse; FILE *fd = os_fopen(diffio->dio_orig.din_fname, "w"); @@ -1042,7 +1042,7 @@ static int check_external_diff(diffio_T *diffio) } else { char linebuf[LBUFLEN]; - for (;;) { + while (true) { // For normal diff there must be a line that contains // "1c1". For unified diff "@@ -1 +1 @@". if (vim_fgets(linebuf, LBUFLEN, fd)) { @@ -1560,7 +1560,7 @@ static bool extract_hunk_internal(diffout_T *dout, diffhunk_T *hunk, int *line_i // Extract hunk by parsing the diff output from file and calculate the diffstyle. static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle) { - for (;;) { + while (true) { char line[LBUFLEN]; // only need to hold the diff line if (vim_fgets(line, LBUFLEN, fd)) { return true; // end of file @@ -1747,7 +1747,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) } } - for (;;) { + while (true) { diffhunk_T hunk = { 0 }; bool eof = dio->dio_internal ? extract_hunk_internal(dout, &hunk, &line_idx) @@ -2952,7 +2952,7 @@ void ex_diffgetput(exarg_T *eap) } const int idx_from = eap->cmdidx == CMD_diffget ? idx_other : idx_cur; - const int idx_to = eap->cmdidx == CMD_diffget ? idx_cur : idx_other; + const int idx_to = eap->cmdidx == CMD_diffget ? idx_cur : idx_other; // May give the warning for a changed buffer here, which can trigger the // FileChangedRO autocommand, which may do nasty things and mess diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index de3808e4f5..7a690d889f 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -2098,7 +2098,7 @@ void ex_loadkeymap(exarg_T *eap) p_cpo = "C"; // Get each line of the sourced file, break at the end. - for (;;) { + while (true) { char *line = eap->getline(0, eap->cookie, 0, true); if (line == NULL) { diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 93549d1fb0..9bdf6a8255 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1516,7 +1516,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, int virt_line_index; int virt_line_offset = -1; // Repeat for the whole displayed line. - for (;;) { + while (true) { int has_match_conc = 0; ///< match wants to conceal int decor_conceal = 0; diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index aa819c01a3..b5e516005b 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1715,7 +1715,7 @@ static void win_update(win_T *wp, DecorProviders *providers) // bot_start to the first row that needs redrawing. bot_start = 0; int idx = 0; - for (;;) { + while (true) { wp->w_lines[idx] = wp->w_lines[j]; // stop at line that didn't fit, unless it is still // valid (no lines deleted) @@ -1828,7 +1828,7 @@ static void win_update(win_T *wp, DecorProviders *providers) // First compute the actual start and end column. if (VIsual_mode == Ctrl_V) { colnr_T fromc, toc; - unsigned int save_ve_flags = curwin->w_ve_flags; + unsigned save_ve_flags = curwin->w_ve_flags; if (curwin->w_p_lbr) { curwin->w_ve_flags = VE_ALL; @@ -1979,7 +1979,7 @@ static void win_update(win_T *wp, DecorProviders *providers) bool eof = false; // if true, we hit the end of the file bool didline = false; // if true, we finished the last line - for (;;) { + while (true) { // stop updating when reached the end of the window (check for _past_ // the end of the window is at the end of the loop) if (row == wp->w_grid.rows) { @@ -2129,7 +2129,7 @@ static void win_update(win_T *wp, DecorProviders *providers) int x = row + new_rows; // move entries in w_lines[] upwards - for (;;) { + while (true) { // stop at last valid entry in w_lines[] if (i >= wp->w_lines_valid) { wp->w_lines_valid = (int)j; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 9e4457f793..0fb1102f4f 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1858,7 +1858,7 @@ int get_literal(bool no_simplify) no_mapping++; // don't map the next key hits cc = 0; i = 0; - for (;;) { + while (true) { nc = plain_vgetc(); if (!no_simplify) { nc = merge_modifiers(nc, &mod_mask); @@ -2356,7 +2356,7 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove) curwin->w_cursor = *end_insert_pos; check_cursor_col(); // make sure it is not past the line - for (;;) { + while (true) { if (gchar_cursor() == NUL && curwin->w_cursor.col > 0) { curwin->w_cursor.col--; } @@ -2505,7 +2505,7 @@ int oneleft(void) // We might get stuck on 'showbreak', skip over it. width = 1; - for (;;) { + while (true) { coladvance(v - width); // getviscol() is slow, skip it when 'showbreak' is empty, // 'breakindent' is not set and there are no multi-byte @@ -2886,7 +2886,7 @@ static void mb_replace_pop_ins(int cc) } // Handle composing chars. - for (;;) { + while (true) { int c = replace_pop(); if (c == -1) { // stack empty break; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b3618c1811..1dfa853fd3 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2082,7 +2082,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx) || cmdidx == CMD_echon || cmdidx == CMD_echomsg) && xp->xp_context == EXPAND_EXPRESSION) { - for (;;) { + while (true) { char *const n = skiptowhite(arg); if (n == arg || ascii_iswhite_or_nul(*skipwhite(n))) { @@ -2780,7 +2780,7 @@ static int eval5(char **arg, typval_T *rettv, evalarg_T *const evalarg) } // Repeat computing, until no '+', '-' or '.' is following. - for (;;) { + while (true) { int op = (uint8_t)(**arg); bool concat = op == '.'; if (op != '+' && op != '-' && !concat) { @@ -2924,7 +2924,7 @@ static int eval6(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan } // Repeat computing, until no '*', '/' or '%' is following. - for (;;) { + while (true) { int op = (uint8_t)(**arg); if (op != '*' && op != '/' && op != '%') { break; @@ -3920,7 +3920,7 @@ static int eval_string(char **arg, typval_T *rettv, bool evaluate, bool interpol { char *p; const char *const arg_end = *arg + strlen(*arg); - unsigned int extra = interpolate ? 1 : 0; + unsigned extra = interpolate ? 1 : 0; const int off = interpolate ? 0 : 1; // Find the end of the string, skipping backslashed characters. @@ -4175,7 +4175,7 @@ int eval_interp_string(char **arg, typval_T *rettv, bool evaluate) const int quote = (uint8_t)(**arg); (*arg)++; - for (;;) { + while (true) { typval_T tv; // Get the string up to the matching quote or to a single '{'. // "arg" is advanced to either the quote or the '{'. @@ -4686,7 +4686,7 @@ bool set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack) ht_stack_T *ht_stack = NULL; hashtab_T *cur_ht = ht; - for (;;) { + while (true) { if (!abort) { // Mark each item in the hashtab. If the item contains a hashtab // it is added to ht_stack, if it contains a list it is added to @@ -4724,7 +4724,7 @@ bool set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack) list_stack_T *list_stack = NULL; list_T *cur_l = l; - for (;;) { + while (true) { // Mark each item in the list. If the item contains a hashtab // it is added to ht_stack, if it contains a list it is added to // list_stack. @@ -6514,7 +6514,7 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret } pos = fm->mark; // Vimscript behavior, only provide fnum if mark is global. - *ret_fnum = ASCII_ISUPPER(mname) || ascii_isdigit(mname) ? fm->fnum: *ret_fnum; + *ret_fnum = ASCII_ISUPPER(mname) || ascii_isdigit(mname) ? fm->fnum : *ret_fnum; } if (pos.lnum != 0) { if (charcol) { @@ -7162,7 +7162,7 @@ char *set_cmdarg(exarg_T *eap, char *oldarg) rc = snprintf(newval + xlen, newval_len - xlen, " ++ff=%s", - eap->force_ff == 'u' ? "unix" + eap->force_ff == 'u' ? "unix" : eap->force_ff == 'd' ? "dos" : "mac"); if (rc < 0) { goto error; diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c index d9cc18a402..aad88619b7 100644 --- a/src/nvim/eval/buffer.c +++ b/src/nvim/eval/buffer.c @@ -172,7 +172,7 @@ static void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, typval_ } // Default result is zero == OK. - for (;;) { + while (true) { if (lines->v_type == VAR_LIST) { // List argument, get next string. if (li == NULL) { diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index b056a1784c..be0cf79e85 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -418,7 +418,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s ga_concat(gap, "v:null") #define TYPVAL_ENCODE_CONV_BOOL(tv, num) \ - ga_concat(gap, ((num)? "v:true": "v:false")) + ga_concat(gap, ((num) ? "v:true" : "v:false")) #define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, num) @@ -544,7 +544,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s #undef TYPVAL_ENCODE_CONV_BOOL #define TYPVAL_ENCODE_CONV_BOOL(tv, num) \ - ga_concat(gap, ((num)? "true": "false")) + ga_concat(gap, ((num) ? "true" : "false")) #undef TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER #define TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, num) \ diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 5c9d39b91f..91f78b8ed6 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -643,7 +643,7 @@ static void f_chansend(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) bool crlf = false; #else Channel *chan = find_channel(id); - bool crlf = (chan != NULL && chan->term) ? true: false; + bool crlf = (chan != NULL && chan->term) ? true : false; #endif if (argvars[1].v_type == VAR_BLOB) { @@ -4593,7 +4593,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; - for (;;) { + while (true) { if (l != NULL) { if (li == NULL) { match = false; @@ -4960,7 +4960,7 @@ static void msgpackparse_unpack_list(const list_T *const list, list_T *const ret } msgpack_unpacked unpacked; msgpack_unpacked_init(&unpacked); - do { + while (true) { if (!msgpack_unpacker_reserve_buffer(unpacker, IOSIZE)) { emsg(_(e_outofmem)); goto end; @@ -4990,7 +4990,7 @@ static void msgpackparse_unpack_list(const list_T *const list, list_T *const ret if (rlret == OK) { break; } - } while (true); + } end: msgpack_unpacker_free(unpacker); @@ -6026,8 +6026,8 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) char *const buf = xmallocz(MAXPATHL); char *cpy; - for (;;) { - for (;;) { + while (true) { + while (true) { len = readlink(p, buf, MAXPATHL); if (len <= 0) { break; @@ -6409,7 +6409,7 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp) int subpatnum; // Repeat until {skip} returns false. - for (;;) { + while (true) { subpatnum = searchit(curwin, curbuf, &pos, NULL, dir, (char *)pat, 1, options, RE_SEARCH, &sia); // finding the first match again means there is no match where {skip} @@ -6989,7 +6989,7 @@ long do_searchpair(const char *spat, const char *mpat, const char *epat, int dir pos_T foundpos; clearpos(&foundpos); char *pat = pat3; - for (;;) { + while (true) { searchit_arg_T sia = { .sa_stop_lnum = lnum_stop, .sa_tm = &tm, diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 6556e274ab..cf355a22fa 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1042,7 +1042,7 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero) if (sortinfo->item_compare_lc) { res = strcoll(p1, p2); } else { - res = sortinfo->item_compare_ic ? STRICMP(p1, p2): strcmp(p1, p2); + res = sortinfo->item_compare_ic ? STRICMP(p1, p2) : strcmp(p1, p2); } } else { double n1, n2; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 854a0732ab..0e22cf54cf 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2343,7 +2343,7 @@ void ex_function(exarg_T *eap) } // find extra arguments "range", "dict", "abort" and "closure" - for (;;) { + while (true) { p = skipwhite(p); if (strncmp(p, "range", 5) == 0) { flags |= FC_RANGE; @@ -2403,7 +2403,7 @@ void ex_function(exarg_T *eap) indent = 2; nesting = 0; - for (;;) { + while (true) { if (KeyTyped) { msg_scroll = true; saved_wait_return = false; diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index d3ca2624eb..593ba9f6c3 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -220,7 +220,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd) char *theline = NULL; list_T *l = tv_list_alloc(0); - for (;;) { + while (true) { int mi = 0; int ti = 0; @@ -502,7 +502,7 @@ const char *skip_var_list(const char *arg, int *var_count, int *semicolon) const char *s; // "[var, var]": find the matching ']'. const char *p = arg; - for (;;) { + while (true) { p = skipwhite(p + 1); // skip whites after '[', ';' or ',' s = skip_var_one(p); if (s == p) { @@ -1012,7 +1012,7 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_ // Delete a range of List items. listitem_T *const first_li = lp->ll_li; listitem_T *last_li = first_li; - for (;;) { + while (true) { listitem_T *const li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); if (value_check_lock(TV_LIST_ITEM_TV(lp->ll_li)->v_lock, lp->ll_name, diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 3c7e230ad3..7a77ffb4da 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1402,7 +1402,7 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp) : 0; if (itmp != NULL) { - len += is_pwsh ? strlen(itmp) + sizeof("& { Get-Content " " | & " " }") - 1 + 6 // +6: #20530 + len += is_pwsh ? strlen(itmp) + sizeof("& { Get-Content " " | & " " }") - 1 + 6 // +6: #20530 : strlen(itmp) + sizeof(" { " " < " " } ") - 1; } if (otmp != NULL) { @@ -1427,7 +1427,7 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp) // redirecting input and/or output. if (itmp != NULL || otmp != NULL) { char *fmt = is_fish_shell ? "begin; %s; end" - : "(%s)"; + : "(%s)"; vim_snprintf(buf, len, fmt, cmd); } else { xstrlcpy(buf, cmd, len); @@ -2782,7 +2782,7 @@ void ex_append(exarg_T *eap) State |= MODE_LANGMAP; } - for (;;) { + while (true) { msg_scroll = true; need_wait_return = false; if (curbuf->b_p_ai) { @@ -3581,7 +3581,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T // 3. substitute the string. // 4. if subflags.do_all is set, find next match // 5. break if there isn't another match in this line - for (;;) { + while (true) { SubResult current_match = { .start = { 0, 0 }, .end = { 0, 0 }, diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b65fa086f4..8a2dabaf30 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2371,7 +2371,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, bool CLEAR_POINTER(cmod); // Repeat until no more command modifiers are found. - for (;;) { + while (true) { while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':') { @@ -2700,7 +2700,7 @@ int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent) int ret = FAIL; // Repeat for all ',' or ';' separated addresses. - for (;;) { + while (true) { eap->line1 = eap->line2; eap->line2 = get_cmd_default_range(eap); eap->cmd = skipwhite(eap->cmd); @@ -3464,7 +3464,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int } } - for (;;) { + while (true) { cmd = skipwhite(cmd); if (*cmd != '-' && *cmd != '+' && !ascii_isdigit(*cmd)) { break; @@ -6577,7 +6577,7 @@ static void ex_findpat(exarg_T *eap) } if (!eap->skip) { find_pattern_in_path(eap->arg, 0, strlen(eap->arg), whole, !eap->forceit, - *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, + *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, n, action, eap->line1, eap->line2); } } @@ -7110,7 +7110,7 @@ static void ex_filetype(exarg_T *eap) bool indent = false; // Accept "plugin" and "indent" in any order. - for (;;) { + while (true) { if (strncmp(arg, "plugin", 6) == 0) { plugin = true; arg = skipwhite(arg + 6); diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 12d1f3d9bd..375bf37664 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1484,8 +1484,8 @@ void ex_finally(exarg_T *eap) } else { pending |= (did_throw ? CSTP_THROW : 0); } - pending |= did_emsg ? CSTP_ERROR : 0; - pending |= got_int ? CSTP_INTERRUPT : 0; + pending |= did_emsg ? CSTP_ERROR : 0; + pending |= got_int ? CSTP_INTERRUPT : 0; assert(pending >= CHAR_MIN && pending <= CHAR_MAX); cstack->cs_pending[cstack->cs_idx] = (char)pending; @@ -1973,7 +1973,7 @@ void ex_endfunction(exarg_T *eap) int has_loop_cmd(char *p) { // skip modifiers, white space and ':' - for (;;) { + while (true) { while (*p == ' ' || *p == '\t' || *p == ':') { p++; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a8ac6ab439..33a8dcafc2 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1651,7 +1651,7 @@ static void command_line_left_right_mouse(CommandLineState *s) static void command_line_next_histidx(CommandLineState *s, bool next_match) { int j = (int)strlen(s->lookfor); - for (;;) { + while (true) { // one step backwards if (!next_match) { if (s->hiscnt == get_hislen()) { @@ -4574,7 +4574,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp) } const char *const end_pattern = (cmd[2] != NUL ? skipwhite(cmd + 2) : "."); - for (;;) { + while (true) { char *const theline = eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, eap->cookie, 0, true); diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 4f6c3b1918..9c112f2344 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -576,9 +576,9 @@ char *vim_findfile(void *search_ctx_arg) } // upward search loop - for (;;) { + while (true) { // downward search loop - for (;;) { + while (true) { // check if user wants to stop the search os_breakcheck(); if (got_int) { @@ -780,7 +780,7 @@ char *vim_findfile(void *search_ctx_arg) } else { suf = curbuf->b_p_sua; } - for (;;) { + while (true) { // if file exists and we didn't already find it if ((path_with_url(file_path) || (os_path_exists(file_path) @@ -1419,7 +1419,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch // When the file doesn't exist, try adding parts of 'suffixesadd'. buf = suffixes; - for (;;) { + while (true) { if ((os_path_exists(NameBuff) && (find_what == FINDFILE_BOTH || ((find_what == FINDFILE_DIR) @@ -1446,7 +1446,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch did_findfile_init = false; } - for (;;) { + while (true) { if (did_findfile_init) { file_name = vim_findfile(*search_ctx); if (file_name != NULL) { diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index bb17382f98..d659987686 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -943,7 +943,7 @@ retry: } else { int ni; long tlen = 0; - for (;;) { + while (true) { p = (uint8_t *)ml_get(read_buf_lnum) + read_buf_col; int n = (int)strlen((char *)p); if ((int)tlen + n + 1 > size) { @@ -1141,7 +1141,7 @@ retry: } if (fio_flags != 0) { - unsigned int u8c; + unsigned u8c; char *dest; char *tail = NULL; @@ -3360,7 +3360,7 @@ int readdir_core(garray_T *gap, const char *path, void *context, CheckItem check return FAIL; } - for (;;) { + while (true) { const char *p = os_scandir_next(&dir); if (p == NULL) { break; @@ -3820,8 +3820,8 @@ long read_eintr(int fd, void *buf, size_t bufsize) { long ret; - for (;;) { - ret = read(fd, buf, (unsigned int)bufsize); + while (true) { + ret = read(fd, buf, (unsigned)bufsize); if (ret >= 0 || errno != EINTR) { break; } @@ -3838,7 +3838,7 @@ long write_eintr(int fd, void *buf, size_t bufsize) // Repeat the write() so long it didn't fail, other than being interrupted // by a signal. while (ret < (long)bufsize) { - long wlen = write(fd, (char *)buf + ret, (unsigned int)(bufsize - (size_t)ret)); + long wlen = write(fd, (char *)buf + ret, (unsigned)(bufsize - (size_t)ret)); if (wlen < 0) { if (errno != EINTR) { break; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 2066da280a..13329040e1 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -201,7 +201,7 @@ bool hasFoldingWin(win_T *const win, const linenr_T lnum, linenr_T *const firstp if (first == 0) { // Recursively search for a fold that contains "lnum". garray_T *gap = &win->w_folds; - for (;;) { + while (true) { if (!foldFind(gap, lnum_rel, &fp)) { break; } @@ -430,7 +430,7 @@ void foldOpenCursor(void) { checkupdate(curwin); if (hasAnyFolding(curwin)) { - for (;;) { + while (true) { int done = DONE_NOTHING; (void)setManualFold(curwin->w_cursor, true, false, &done); if (!(done & DONE_ACTION)) { @@ -562,7 +562,7 @@ void foldCreate(win_T *wp, pos_T start, pos_T end) i = 0; } else { fold_T *fp; - for (;;) { + while (true) { if (!foldFind(gap, start_rel.lnum, &fp)) { break; } @@ -683,7 +683,7 @@ void deleteFold(win_T *const wp, const linenr_T start, const linenr_T end, const garray_T *found_ga = NULL; linenr_T lnum_off = 0; bool use_level = false; - for (;;) { + while (true) { fold_T *fp; if (!foldFind(gap, lnum - lnum_off, &fp)) { break; @@ -865,7 +865,7 @@ int foldMoveTo(const bool updown, const int dir, const long count) linenr_T lnum_found = curwin->w_cursor.lnum; int level = 0; bool last = false; - for (;;) { + while (true) { if (!foldFind(gap, curwin->w_cursor.lnum - lnum_off, &fp)) { if (!updown || gap->ga_len == 0) { break; @@ -1104,7 +1104,7 @@ static int foldLevelWin(win_T *wp, linenr_T lnum) // Recursively search for a fold that contains "lnum". garray_T *gap = &wp->w_folds; - for (;;) { + while (true) { if (!foldFind(gap, lnum_rel, &fp)) { break; } @@ -1201,7 +1201,7 @@ static linenr_T setManualFoldWin(win_T *wp, linenr_T lnum, int opening, int recu // Find the fold, open or close it. garray_T *gap = &wp->w_folds; - for (;;) { + while (true) { if (!foldFind(gap, lnum, &fp)) { // If there is a following fold, continue there next time. if (fp != NULL && fp < (fold_T *)gap->ga_data + gap->ga_len) { @@ -2509,7 +2509,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level, } // delete following folds that end before the current line - for (;;) { + while (true) { fp2 = fp + 1; if (fp2 >= (fold_T *)gap->ga_data + gap->ga_len || fp2->fd_top > flp->lnum) { diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 15f2e6d06f..057043b225 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -973,7 +973,7 @@ int ins_typebuf(char *str, int noremap, int offset, bool nottyped, bool silent) int ins_char_typebuf(int c, int modifiers) { char buf[MB_MAXBYTES * 3 + 4]; - unsigned int len = special_to_buf(c, modifiers, true, buf); + unsigned len = special_to_buf(c, modifiers, true, buf); assert(len < sizeof(buf)); buf[len] = NUL; (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); @@ -1432,7 +1432,7 @@ int vgetc(void) // if peeking records more last_recorded_len -= last_vgetc_recorded_len; - for (;;) { // this is done twice if there are modifiers + while (true) { // this is done twice if there are modifiers bool did_inc = false; if (mod_mask) { // no mapping after modifier has been read no_mapping++; @@ -1670,7 +1670,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv) no_mapping++; allow_keys++; - for (;;) { + while (true) { if (msg_col > 0) { // Position the cursor. Needed after a message that ends in a space. ui_cursor_goto(msg_row, msg_col); @@ -2363,7 +2363,7 @@ static int vgetorpeek(bool advance) // are sure that it is not a mapped key. // If a mapped key sequence is found we go back to the start to // try re-mapping. - for (;;) { + while (true) { check_end_reg_executing(advance); // os_breakcheck() is slow, don't use it too often when // inside a mapping. But call it each time for typed @@ -2694,7 +2694,7 @@ static int vgetorpeek(bool advance) typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len++] = RM_YES; } } - } // for (;;) + } // while (true) } // if (!character from stuffbuf) // if advance is false don't loop on NULs @@ -2813,7 +2813,7 @@ int inchar(uint8_t *buf, int maxlen, long wait_time) #define DUM_LEN (MAXMAPLEN * 3 + 3) uint8_t dum[DUM_LEN + 1]; - for (;;) { + while (true) { len = os_inchar(dum, DUM_LEN, 0L, 0, NULL); if (len == 0 || (len == 1 && dum[0] == Ctrl_C)) { break; diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 04ecdd46a8..5b987e7c34 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -65,7 +65,7 @@ void hash_clear(hashtab_T *ht) /// Free the array of a hash table and all contained values. /// /// @param off the offset from start of value to start of key (@see hashitem_T). -void hash_clear_all(hashtab_T *ht, unsigned int off) +void hash_clear_all(hashtab_T *ht, unsigned off) { size_t todo = ht->ht_used; for (hashitem_T *hi = ht->ht_array; todo > 0; hi++) { diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 1d8bceae4e..7e12637c6d 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -527,7 +527,7 @@ int set_indent(int size, int flags) } // Count tabs required for indent. - for (;;) { + while (true) { tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts, curbuf->b_p_vts_array); if (todo < tab_pad) { break; @@ -650,7 +650,7 @@ int set_indent(int size, int flags) p = skipwhite(p); } - for (;;) { + while (true) { tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); @@ -980,7 +980,7 @@ void ex_retab(exarg_T *eap) long col = 0; long vcol = 0; bool did_undo = false; // called u_save for current line - for (;;) { + while (true) { if (ascii_iswhite(ptr[col])) { if (!got_tab && num_spaces == 0) { // First consecutive white-space diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index f7bf9c46a4..37a76542d4 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -47,7 +47,7 @@ pos_T *find_start_comment(int ind_maxcomment) // XXX pos_T *pos; int64_t cur_maxcomment = ind_maxcomment; - for (;;) { + while (true) { pos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment); if (pos == NULL) { break; @@ -108,7 +108,7 @@ static pos_T *find_start_rawstring(int ind_maxcomment) // XXX pos_T *pos; long cur_maxcomment = ind_maxcomment; - for (;;) { + while (true) { pos = findmatchlimit(NULL, 'R', FM_BACKWARD, cur_maxcomment); if (pos == NULL) { break; @@ -412,7 +412,7 @@ static int cin_isinit(void) s = cin_skipcomment(s + 7); } - for (;;) { + while (true) { int i, l; for (i = 0; i < (int)ARRAY_SIZE(skip); i++) { @@ -756,7 +756,7 @@ static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount) candidate_amount = get_indent_lnum(lnum); } - for (;;) { + while (true) { if (cin_ispreproc(line)) { retval = true; *lnump = lnum; @@ -929,7 +929,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu // At the end: check for ',' in the next line, for this style: // func(arg1 // , arg2) - for (;;) { + while (true) { if (lnum >= curbuf->b_ml.ml_line_count) { break; } @@ -1186,7 +1186,7 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) pos->lnum = lnum; line = ml_get(lnum); s = line; - for (;;) { + while (true) { if (*s == NUL) { if (lnum == curwin->w_cursor.lnum) { break; @@ -2501,7 +2501,7 @@ int get_c_indent(void) // the usual amount relative to the conditional // that opens the block. curwin->w_cursor = cur_curpos; - for (;;) { + while (true) { curwin->w_cursor.lnum--; curwin->w_cursor.col = 0; diff --git a/src/nvim/input.c b/src/nvim/input.c index fa55c02a24..4fd6297019 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -93,7 +93,7 @@ int get_keystroke(MultiQueue *events) int save_mapped_ctrl_c = mapped_ctrl_c; mapped_ctrl_c = 0; // mappings are not used here - for (;;) { + while (true) { // flush output before waiting ui_flush(); // Leave some room for check_termcode() to insert a key code into (max @@ -179,7 +179,7 @@ int get_number(int colon, int *mouse_used) no_mapping++; allow_keys++; // no mapping here, but recognize keys - for (;;) { + while (true) { ui_cursor_goto(msg_row, msg_col); int c = safe_vgetc(); if (ascii_isdigit(c)) { diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 5baf090f14..6624b39d0c 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -3147,7 +3147,7 @@ static int get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_ } bool looped_around = false; int found_new_match = FAIL; - for (;;) { + while (true) { bool cont_s_ipos = false; msg_silent++; // Don't want messages for wrapscan. @@ -3311,7 +3311,7 @@ static int ins_compl_get_exp(pos_T *ini) st.cur_match_pos = compl_dir_forward() ? &st.last_match_pos : &st.first_match_pos; // For ^N/^P loop over all the flags/windows/buffers in 'complete' - for (;;) { + while (true) { found_new_match = FAIL; st.set_match_pos = false; diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index abf31ae344..34442ae5c4 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -572,8 +572,8 @@ char *get_special_key_name(int c, int modifiers) /// @param[out] did_simplify found , etc. /// /// @return Number of characters added to dst, zero for no match. -unsigned int trans_special(const char **const srcp, const size_t src_len, char *const dst, - const int flags, const bool escape_ks, bool *const did_simplify) +unsigned trans_special(const char **const srcp, const size_t src_len, char *const dst, + const int flags, const bool escape_ks, bool *const did_simplify) FUNC_ATTR_NONNULL_ARG(1, 3) FUNC_ATTR_WARN_UNUSED_RESULT { int modifiers = 0; @@ -590,9 +590,9 @@ unsigned int trans_special(const char **const srcp, const size_t src_len, char * /// When "escape_ks" is true escape K_SPECIAL bytes in the character. /// The sequence is not NUL terminated. /// This is how characters in a string are encoded. -unsigned int special_to_buf(int key, int modifiers, bool escape_ks, char *dst) +unsigned special_to_buf(int key, int modifiers, bool escape_ks, char *dst) { - unsigned int dlen = 0; + unsigned dlen = 0; // Put the appropriate modifier in a string. if (modifiers != 0) { @@ -608,9 +608,9 @@ unsigned int special_to_buf(int key, int modifiers, bool escape_ks, char *dst) } else if (escape_ks) { char *after = add_char2buf(key, dst + dlen); assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX); - dlen = (unsigned int)(after - dst); + dlen = (unsigned)(after - dst); } else { - dlen += (unsigned int)utf_char2bytes(key, dst + dlen); + dlen += (unsigned)utf_char2bytes(key, dst + dlen); } return dlen; diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 13a0c4b0cd..1c1f68b68d 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1094,7 +1094,7 @@ static int nlua_debug(lua_State *lstate) .v_type = VAR_UNKNOWN, }, }; - for (;;) { + while (true) { lua_settop(lstate, 0); typval_T input; get_user_input(input_args, &input, false, false); diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 78e023c26d..742e8720f9 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -69,10 +69,10 @@ int nlua_spell_check(lua_State *lstate) lua_pushlstring(lstate, str, len); lua_rawseti(lstate, -2, 1); - result = attr == HLF_SPB ? "bad" : - attr == HLF_SPR ? "rare" : + result = attr == HLF_SPB ? "bad" : + attr == HLF_SPR ? "rare" : attr == HLF_SPL ? "local" : - attr == HLF_SPC ? "caps" : + attr == HLF_SPC ? "caps" : NULL; assert(result != NULL); diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 20a99b2836..f53493e088 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -455,7 +455,7 @@ static int nlua_stricmp(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL int ret = 0; assert(s1[s1_len] == NUL); assert(s2[s2_len] == NUL); - do { + while (true) { nul1 = memchr(s1, NUL, s1_len); nul2 = memchr(s2, NUL, s2_len); ret = STRICMP(s1, s2); @@ -479,7 +479,7 @@ static int nlua_stricmp(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL } else { break; } - } while (true); + } lua_pop(lstate, 2); lua_pushnumber(lstate, (lua_Number)((ret > 0) - (ret < 0))); return 1; diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index ae3a7b6d75..da64685a40 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -454,7 +454,7 @@ static int parser_parse(lua_State *L) // the lua GC. // Old tree is still owned by the lua GC. uint32_t n_ranges = 0; - TSRange *changed = old_tree ? ts_tree_get_changed_ranges(old_tree, new_tree, &n_ranges) : NULL; + TSRange *changed = old_tree ? ts_tree_get_changed_ranges(old_tree, new_tree, &n_ranges) : NULL; push_tree(L, new_tree, false); // [tree] diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index e0bbdb8942..b5575fe202 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -193,10 +193,10 @@ static bool check_xdiff_opt(ObjectType actType, ObjectType expType, const char * { if (actType != expType) { const char *type_str = - expType == kObjectTypeString ? "string" : - expType == kObjectTypeInteger ? "integer" : - expType == kObjectTypeBoolean ? "boolean" : - expType == kObjectTypeLuaRef ? "function" : + expType == kObjectTypeString ? "string" : + expType == kObjectTypeInteger ? "integer" : + expType == kObjectTypeBoolean ? "boolean" : + expType == kObjectTypeLuaRef ? "function" : "NA"; api_set_error(err, kErrorTypeValidation, "%s is not a %s", name, diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index f88c0deb87..9a835e0eb8 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -706,7 +706,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, hash_end = 256; } for (int hash = hash_start; hash < hash_end && !got_int; hash++) { - mpp = is_abbrev ? abbr_table : &(map_table[hash]); + mpp = is_abbrev ? abbr_table : &(map_table[hash]); for (mp = *mpp; mp != NULL && !got_int; mp = *mpp) { if ((mp->m_mode & mode) == 0) { // skip entries with wrong mode @@ -1112,7 +1112,7 @@ int map_to_exists_mode(const char *const rhs, const int mode, const bool abbr) bool exp_buffer = false; // Do it twice: once for global maps and once for local maps. - for (;;) { + while (true) { for (hash = 0; hash < 256; hash++) { if (abbr) { if (hash > 0) { // There is only one abbr list. @@ -1229,7 +1229,7 @@ char *set_context_in_map_cmd(expand_T *xp, char *cmd, char *arg, bool forceit, b expand_isabbrev = isabbrev; xp->xp_context = EXPAND_MAPPINGS; expand_buffer = false; - for (;;) { + while (true) { if (strncmp(arg, "", 8) == 0) { expand_buffer = true; arg = skipwhite(arg + 8); @@ -2322,13 +2322,13 @@ static garray_T langmap_mapga = GA_EMPTY_INIT_VALUE; static void langmap_set_entry(int from, int to) { langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); - unsigned int a = 0; + unsigned a = 0; assert(langmap_mapga.ga_len >= 0); - unsigned int b = (unsigned int)langmap_mapga.ga_len; + unsigned b = (unsigned)langmap_mapga.ga_len; // Do a binary search for an existing entry. while (a != b) { - unsigned int i = (a + b) / 2; + unsigned i = (a + b) / 2; int d = entries[i].from - from; if (d == 0) { @@ -2347,7 +2347,7 @@ static void langmap_set_entry(int from, int to) // insert new entry at position "a" entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a; memmove(entries + 1, entries, - ((unsigned int)langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); + ((unsigned)langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); langmap_mapga.ga_len++; entries[0].from = from; entries[0].to = to; diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 7b79081dd9..b3f94a42fc 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -239,7 +239,7 @@ fmark_T *get_jumplist(win_T *win, int count) return NULL; } - for (;;) { + while (true) { if (win->w_jumplistidx + count < 0 || win->w_jumplistidx + count >= win->w_jumplistlen) { return NULL; diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index f1285b39e7..757906d42f 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -127,7 +127,7 @@ static inline int marktree_getp_aux(const mtnode_t *x, mtkey_t k, int *r) if (x->n == 0) { return -1; } - rr = r? r : &tr; + rr = r ? r : &tr; while (begin < end) { int mid = (begin + end) >> 1; if (key_cmp(x->key[mid], k) < 0) { diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h index 046946bc95..29d2abcd46 100644 --- a/src/nvim/marktree.h +++ b/src/nvim/marktree.h @@ -77,7 +77,7 @@ typedef struct { #define MARKTREE_END_FLAG (((uint64_t)1) << 63) static inline uint64_t mt_lookup_id(uint32_t ns, uint32_t id, bool enda) { - return (uint64_t)ns << 32 | id | (enda?MARKTREE_END_FLAG:0); + return (uint64_t)ns << 32 | id | (enda ? MARKTREE_END_FLAG : 0); } #undef MARKTREE_END_FLAG diff --git a/src/nvim/match.c b/src/nvim/match.c index 31a628bbff..6903c0a851 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -111,7 +111,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in } m->mit_id = id; m->mit_priority = prio; - m->mit_pattern = pat == NULL ? NULL: xstrdup(pat); + m->mit_pattern = pat == NULL ? NULL : xstrdup(pat); m->mit_hlg_id = hlg_id; m->mit_match.regprog = regprog; m->mit_match.rmm_ic = false; @@ -388,7 +388,7 @@ static int next_search_hl_pos(match_T *shl, linenr_T lnum, matchitem_T *match, c match->mit_pos_cur = 0; if (found >= 0) { colnr_T start = match->mit_pos_array[found].col == 0 - ? 0: match->mit_pos_array[found].col - 1; + ? 0 : match->mit_pos_array[found].col - 1; colnr_T end = match->mit_pos_array[found].col == 0 ? MAXCOL : start + match->mit_pos_array[found].len; @@ -444,7 +444,7 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_ // Repeat searching for a match until one is found that includes "mincol" // or none is found in this line. - for (;;) { + while (true) { // Stop searching after passing the time limit. if (profile_passed_limit(shl->tm)) { shl->lnum = 0; // no match found in time diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 78204b22a8..7d61b918d2 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -749,7 +749,7 @@ int utfc_ptr2char(const char *p, int *pcc) && (uint8_t)p[len] >= 0x80 && utf_composinglike(p, p + len)) { int cc = utf_ptr2char(p + len); - for (;;) { + while (true) { pcc[i++] = cc; if (i == MAX_MCO) { break; @@ -889,7 +889,7 @@ int utfc_ptr2len(const char *const p) // Check for composing characters. We can handle only the first six, but // skip all of them (otherwise the cursor would get stuck). int prevlen = 0; - for (;;) { + while (true) { if ((uint8_t)p[len] < 0x80 || !utf_composinglike(p + prevlen, p + len)) { return len; } @@ -1051,9 +1051,9 @@ int utf_class_tab(const int c, const uint64_t *const chartab) { // sorted list of non-overlapping intervals static struct clinterval { - unsigned int first; - unsigned int last; - unsigned int cls; + unsigned first; + unsigned last; + unsigned cls; } classes[] = { { 0x037e, 0x037e, 1 }, // Greek question mark { 0x0387, 0x0387, 1 }, // Greek ano teleia @@ -1149,9 +1149,9 @@ int utf_class_tab(const int c, const uint64_t *const chartab) // binary search in table while (top >= bot) { int mid = (bot + top) / 2; - if (classes[mid].last < (unsigned int)c) { + if (classes[mid].last < (unsigned)c) { bot = mid + 1; - } else if (classes[mid].first > (unsigned int)c) { + } else if (classes[mid].first > (unsigned)c) { top = mid - 1; } else { return (int)classes[mid].cls; @@ -1276,7 +1276,7 @@ static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) int c1, c2, cdiff; char buffer[6]; - for (;;) { + while (true) { c1 = utf_safe_read_char_adv(&s1, &n1); c2 = utf_safe_read_char_adv(&s2, &n2); @@ -1881,7 +1881,7 @@ void utf_find_illegal(void) } curwin->w_cursor.coladd = 0; - for (;;) { + while (true) { p = get_cursor_pos_ptr(); if (vimconv.vc_type != CONV_NONE) { xfree(tofree); @@ -2299,7 +2299,7 @@ static char *iconv_string(const vimconv_T *const vcp, const char *str, size_t sl from = str; fromlen = slen; - for (;;) { + while (true) { if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) { // Allocate enough room for most conversions. When re-allocating // increase the buffer size. diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 3eac44b40b..968fa455bf 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -628,7 +628,7 @@ static int mf_write(memfile_T *mfp, bhdr_T *hp) /// to extend the file. /// If block 'mf_infile_count' is not in the hash list, it has been /// freed. Fill the space in the file with data from the current block. - for (;;) { + while (true) { blocknr_T nr = hp->bh_bnum; // block nr which is being written if (nr > mfp->mf_infile_count) { // beyond end of file nr = mfp->mf_infile_count; diff --git a/src/nvim/memline.c b/src/nvim/memline.c index b91a0a9169..0400949eae 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -392,7 +392,7 @@ void ml_setname(buf_T *buf) // Try all directories in the 'directory' option. char *dirp = p_dir; bool found_existing_dir = false; - for (;;) { + while (true) { if (*dirp == NUL) { // tried all directories, fail break; } @@ -479,7 +479,7 @@ void ml_open_file(buf_T *buf) // Try all directories in 'directory' option. char *dirp = p_dir; bool found_existing_dir = false; - for (;;) { + while (true) { if (*dirp == NUL) { break; } @@ -2262,7 +2262,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, boo // allocate a new pointer block // move some of the pointer into the new block // prepare for updating the parent block - for (;;) { // do this twice when splitting block 1 + while (true) { // do this twice when splitting block 1 hp_new = ml_new_ptr(mfp); if (hp_new == NULL) { // TODO(vim): try to fix tree return FAIL; @@ -2857,7 +2857,7 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action) buf->b_ml.ml_stack_top = 0; // start at the root } // search downwards in the tree until a data block is found - for (;;) { + while (true) { if ((hp = mf_get(mfp, bnum, (unsigned)page_count)) == NULL) { goto error_noblock; } @@ -3021,7 +3021,7 @@ int resolve_symlink(const char *fname, char *buf) // Put the result so far in tmp[], starting with the original name. xstrlcpy(tmp, fname, MAXPATHL); - for (;;) { + while (true) { // Limit symlink depth to 100, catch recursive loops. if (++depth == 100) { semsg(_("E773: Symlink loop for \"%s\""), fname); @@ -3273,7 +3273,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // we try different names until we find one that does not exist yet char *fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name); - for (;;) { + while (true) { size_t n; if (fname == NULL) { // must be out of memory break; diff --git a/src/nvim/memory.c b/src/nvim/memory.c index ffeafbdf2c..b9a26e1ac6 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -782,7 +782,7 @@ void free_all_mem(void) first_tabpage = NULL; // message history - for (;;) { + while (true) { if (delete_first_msg() == FAIL) { break; } diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 65b6363f4b..16fea2ccf1 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -88,7 +88,7 @@ void ex_menu(exarg_T *eap) modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu); arg = eap->arg; - for (;;) { + while (true) { if (strncmp(arg, "