diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-04-26 23:23:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-26 23:23:44 +0200 |
commit | 3b0df1780e2c8526bda5dead18ee7cc45925caba (patch) | |
tree | c8415dc986f1cd3ddf6044b4ec0318a089db3ed7 /src | |
parent | 7d0479c55810af9bf9f115ba69d1419ea81ec41e (diff) | |
download | rneovim-3b0df1780e2c8526bda5dead18ee7cc45925caba.tar.gz rneovim-3b0df1780e2c8526bda5dead18ee7cc45925caba.tar.bz2 rneovim-3b0df1780e2c8526bda5dead18ee7cc45925caba.zip |
refactor: uncrustify
Notable changes: replace all infinite loops to `while(true)` and remove
`int` from `unsigned int`.
Diffstat (limited to 'src')
94 files changed, 324 insertions, 324 deletions
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 <C-H>, 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, "<buffer>", 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, "<script>", 8) == 0) { noremap = REMAP_SCRIPT; arg = skipwhite(arg + 8); diff --git a/src/nvim/message.c b/src/nvim/message.c index f78980c859..e8e2d57e41 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -438,7 +438,7 @@ void trunc_string(const char *s, char *buf, int room_in, int buflen) // Last part: End of the string. half = i = (int)strlen(s); - for (;;) { + while (true) { do { half = half - utf_head_off(s, s + half - 1) - 1; } while (half > 0 && utf_iscomposing(utf_ptr2char(s + half))); @@ -2656,7 +2656,7 @@ static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp) { msgchunk_T *mp = smp; - for (;;) { + while (true) { msg_row = row; msg_col = mp->sb_msg_col; char *p = mp->sb_text; @@ -2801,7 +2801,7 @@ static int do_more_prompt(int typed_char) if (typed_char == NUL) { msg_moremsg(false); } - for (;;) { + while (true) { // Get a typed character directly from the user. if (used_typed_char != NUL) { c = used_typed_char; // was typed at hit-enter prompt @@ -3528,7 +3528,7 @@ int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutto no_wait_return++; hotkeys = msg_show_console_dialog(message, buttons, dfltbutton); - for (;;) { + while (true) { // Get a typed character directly from the user. int c = get_keystroke(NULL); switch (c) { diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index c00ccdd51a..e03eec184f 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -310,7 +310,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent) pos_T save_cursor = curwin->w_cursor; - for (;;) { + while (true) { which_button = get_mouse_button(KEY2TERMCAP1(c), &is_click, &is_drag); if (is_drag) { // If the next character is the same mouse event then use that @@ -1474,7 +1474,7 @@ win_T *mouse_find_win(int *gridp, int *rowp, int *colp) frame_T *fp = topframe; *rowp -= firstwin->w_winrow; - for (;;) { + while (true) { if (fp->fr_layout == FR_LEAF) { break; } @@ -1580,7 +1580,7 @@ static colnr_T scroll_line_len(linenr_T lnum) colnr_T col = 0; char *line = ml_get(lnum); if (*line != NUL) { - for (;;) { + while (true) { int numchar = win_chartabsize(curwin, line, col); MB_PTR_ADV(line); if (*line == NUL) { // don't count the last character diff --git a/src/nvim/move.c b/src/nvim/move.c index e74dc32fd4..b749d07d15 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -780,7 +780,7 @@ void curs_columns(win_T *wp, int may_scroll) int off_right = endcol - wp->w_leftcol - wp->w_width_inner + (int)siso + 1; if (off_left < 0 || off_right > 0) { - int diff = (off_left < 0) ? -off_left: off_right; + int diff = (off_left < 0) ? -off_left : off_right; // When far off or not enough room on either side, put cursor in // middle of window. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 635d177ecc..da693371f3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2342,7 +2342,7 @@ bool find_decl(char *ptr, size_t len, bool locally, bool thisblock, int flags_ar // Search forward for the identifier, ignore comment lines. clearpos(&found_pos); - for (;;) { + while (true) { t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, pat, 1L, searchflags, RE_LAST, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) { @@ -2692,7 +2692,7 @@ static bool nv_z_get_count(cmdarg_T *cap, int *nchar_arg) } long n = nchar - '0'; - for (;;) { + while (true) { no_mapping++; allow_keys++; // no mapping for nchar, but allow key codes nchar = plain_vgetc(); @@ -4162,7 +4162,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos) pos = NULL; } while (n > 0) { - for (;;) { + while (true) { if ((findc == '{' ? dec_cursor() : inc_cursor()) < 0) { // if not found anything, that's an error if (pos == NULL) { @@ -4310,7 +4310,7 @@ static void nv_brackets(cmdarg_T *cap) fm = prev_fm; } MarkMove flags = kMarkContext; - flags |= cap->nchar == '\'' ? kMarkBeginLine: 0; + flags |= cap->nchar == '\'' ? kMarkBeginLine : 0; nv_mark_move_to(cap, flags, fm); } else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) { // [ or ] followed by a middle mouse click: put selected text with diff --git a/src/nvim/ops.c b/src/nvim/ops.c index b50ef72058..2919b94d41 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2090,7 +2090,7 @@ void op_tilde(oparg_T *oap) did_change = swapchars(oap->op_type, &pos, oap->end.col - pos.col + 1); } else { - for (;;) { + while (true) { did_change |= swapchars(oap->op_type, &pos, pos.lnum == oap->end.lnum ? oap->end.col + 1 : (int)strlen(ml_get_pos(&pos))); @@ -2944,7 +2944,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) long cnt; const pos_T orig_start = curbuf->b_op_start; const pos_T orig_end = curbuf->b_op_end; - unsigned int cur_ve_flags = get_ve_flags(); + unsigned cur_ve_flags = get_ve_flags(); if (flags & PUT_FIXINDENT) { orig_indent = get_indent(); @@ -3056,7 +3056,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) // For the = register we need to split the string at NL // characters. // Loop twice: count the number of lines and save them. - for (;;) { + while (true) { y_size = 0; ptr = insert_string; while (ptr != NULL) { @@ -3717,7 +3717,7 @@ end: /// there move it left. void adjust_cursor_eol(void) { - unsigned int cur_ve_flags = get_ve_flags(); + unsigned cur_ve_flags = get_ve_flags(); const bool adj_cursor = (curwin->w_cursor.col > 0 && gchar_cursor() == NUL @@ -6470,7 +6470,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) } if (cb_flags & CB_UNNAMEDPLUS) { - *name = (cb_flags & CB_UNNAMED && writing) ? '"': '+'; + *name = (cb_flags & CB_UNNAMED && writing) ? '"' : '+'; target = &y_regs[PLUS_REGISTER]; } else { *name = '*'; diff --git a/src/nvim/option.c b/src/nvim/option.c index 0ad11fb3cb..040ab1b847 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5753,7 +5753,7 @@ bool can_bs(int what) /// Get the local or global value of 'backupcopy'. /// /// @param buf The buffer. -unsigned int get_bkc_value(buf_T *buf) +unsigned get_bkc_value(buf_T *buf) { return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; } @@ -5770,7 +5770,7 @@ char *get_flp_value(buf_T *buf) } /// Get the local or global value of the 'virtualedit' flags. -unsigned int get_ve_flags(void) +unsigned get_ve_flags(void) { return (curwin->w_ve_flags ? curwin->w_ve_flags : ve_flags) & ~(VE_NONE | VE_NONEU); } diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 66d5b7280a..0715177bba 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -410,7 +410,7 @@ EXTERN char *p_bs; // 'backspace' EXTERN char *p_bg; // 'background' EXTERN int p_bk; // 'backup' EXTERN char *p_bkc; // 'backupcopy' -EXTERN unsigned int bkc_flags; ///< flags from 'backupcopy' +EXTERN unsigned bkc_flags; ///< flags from 'backupcopy' #define BKC_YES 0x001 #define BKC_AUTO 0x002 #define BKC_NO 0x004 @@ -707,7 +707,7 @@ EXTERN long p_smc; ///< 'synmaxcol' EXTERN long p_tpm; // 'tabpagemax' EXTERN char *p_tal; // 'tabline' EXTERN char *p_tpf; // 'termpastefilter' -EXTERN unsigned int tpf_flags; ///< flags from 'termpastefilter' +EXTERN unsigned tpf_flags; ///< flags from 'termpastefilter' #define TPF_BS 0x001 #define TPF_HT 0x002 #define TPF_FF 0x004 @@ -721,7 +721,7 @@ EXTERN char *p_spf; ///< 'spellfile' EXTERN char *p_spk; ///< 'splitkeep' EXTERN char *p_spl; ///< 'spelllang' EXTERN char *p_spo; // 'spelloptions' -EXTERN unsigned int spo_flags; +EXTERN unsigned spo_flags; EXTERN char *p_sps; // 'spellsuggest' EXTERN int p_spr; // 'splitright' EXTERN int p_sol; // 'startofline' diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 1f3fb942ff..ece7a90b4a 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -484,7 +484,7 @@ static const char *check_mousescroll(char *string) long vertical = -1; long horizontal = -1; - for (;;) { + while (true) { char *end = vim_strchr(string, ','); size_t length = end ? (size_t)(end - string) : strlen(string); @@ -654,7 +654,7 @@ static bool check_illegal_path_names(char *val, uint32_t flags) static void did_set_backupcopy(buf_T *buf, char *oldval, int opt_flags, const char **errmsg) { char *bkc = p_bkc; - unsigned int *flags = &bkc_flags; + unsigned *flags = &bkc_flags; if (opt_flags & OPT_LOCAL) { bkc = buf->b_p_bkc; @@ -1322,7 +1322,7 @@ static void did_set_backspace(const char **errmsg) static void did_set_tagcase(buf_T *buf, int opt_flags, const char **errmsg) { - unsigned int *flags; + unsigned *flags; char *p; if (opt_flags & OPT_LOCAL) { @@ -1391,7 +1391,7 @@ static void did_set_foldignore(win_T *win) static void did_set_virtualedit(win_T *win, int opt_flags, char *oldval, const char **errmsg) { char *ve = p_ve; - unsigned int *flags = &ve_flags; + unsigned *flags = &ve_flags; if (opt_flags & OPT_LOCAL) { ve = win->w_p_ve; @@ -1912,10 +1912,10 @@ static int check_opt_strings(char *val, char **values, int list) /// @return OK for correct value, FAIL otherwise. Empty is always OK. static int opt_strings_flags(char *val, char **values, unsigned *flagp, bool list) { - unsigned int new_flags = 0; + unsigned new_flags = 0; while (*val) { - for (unsigned int i = 0;; i++) { + for (unsigned i = 0;; i++) { if (values[i] == NULL) { // val not found in values[] return FAIL; } diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index ad98a5b97e..f931e00916 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -1084,7 +1084,7 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si // er's home directory)). char *p = homedir; size_t len = dirlen; - for (;;) { + while (true) { if (len && path_fnamencmp(src, p, len) == 0 && (vim_ispathsep(src[len]) diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index b13afba727..d270f8767e 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -339,7 +339,7 @@ static bool is_executable_in_path(const char *name, char **abspath) // is an executable file. char *p = path; bool rv = false; - for (;;) { + while (true) { char *e = xstrchrnul(p, ENV_SEPCHAR); // Combine the $PATH segment with `name`. diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index e9f23eba40..fa9ff6e9b1 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -253,7 +253,7 @@ size_t input_enqueue(String keys) // K_SPECIAL(0x80). uint8_t buf[19] = { 0 }; // Do not simplify the keys here. Simplification will be done later. - unsigned int new_size + unsigned new_size = trans_special((const char **)&ptr, (size_t)(end - ptr), (char *)buf, FSK_KEYCODE, true, NULL); @@ -346,7 +346,7 @@ static uint8_t check_multiclick(int code, int grid, int row, int col) // Mouse event handling code(Extract row/col if available and detect multiple // clicks) -static unsigned int handle_mouse_event(char **ptr, uint8_t *buf, unsigned int bufsize) +static unsigned handle_mouse_event(char **ptr, uint8_t *buf, unsigned bufsize) { int mouse_code = 0; int type = 0; diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index f4d95e141b..2a248a1e32 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -72,7 +72,7 @@ static bool os_proc_tree_kill_rec(HANDLE process, int sig) } theend: - return (bool)TerminateProcess(process, (unsigned int)sig); + return (bool)TerminateProcess(process, (unsigned)sig); } /// Kills process `pid` and its descendants recursively. bool os_proc_tree_kill(int pid, int sig) diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 52cab63989..979c6153aa 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1225,7 +1225,7 @@ static void read_input(DynamicBuffer *buf) linenr_T lnum = curbuf->b_op_start.lnum; char *lp = ml_get(lnum); - for (;;) { + while (true) { l = strlen(lp + written); if (l == 0) { len = 0; diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 64a2e0bb61..b2a4ac710d 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -100,7 +100,7 @@ int plines_win_nofill(win_T *wp, linenr_T lnum, bool winheight) int plines_win_nofold(win_T *wp, linenr_T lnum) { char *s; - unsigned int col; + unsigned col; int width; s = ml_get_buf(wp->w_buffer, lnum, false); @@ -120,10 +120,10 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) if (width <= 0 || col > 32000) { return 32000; // bigger than the number of screen columns } - if (col <= (unsigned int)width) { + if (col <= (unsigned)width) { return 1; } - col -= (unsigned int)width; + col -= (unsigned)width; width += win_col_off2(wp); assert(col <= INT_MAX && (int)col < INT_MAX - (width - 1)); return ((int)col + (width - 1)) / width + 1; @@ -272,7 +272,7 @@ int linetabsize_col(int startcol, char *s) /// @param len /// /// @return Number of characters the string will take on the screen. -unsigned int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len) +unsigned win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len) { chartabsize_T cts; init_chartabsize_arg(&cts, wp, lnum, 0, line, line); @@ -281,7 +281,7 @@ unsigned int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len) cts.cts_vcol += win_lbr_chartabsize(&cts, NULL); } clear_chartabsize_arg(&cts); - return (unsigned int)cts.cts_vcol; + return (unsigned)cts.cts_vcol; } /// Prepare the structure passed to chartabsize functions. @@ -405,7 +405,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) } } - for (;;) { + while (true) { char *ps = s; MB_PTR_ADV(s); c = (uint8_t)(*s); diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 9be005622b..a2100d9945 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -1083,7 +1083,7 @@ void pum_show_popupmenu(vimmenu_T *menu) ui_call_option_set(STATIC_CSTR_AS_STRING("mousemoveevent"), BOOLEAN_OBJ(true)); } - for (;;) { + while (true) { pum_is_visible = true; pum_is_drawn = true; pum_grid.zindex = kZIndexCmdlinePopupMenu; // show above cmdline area #23275 diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 62eb14342c..36714d816a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -800,7 +800,7 @@ retry: memcpy(state->growbuf, IObuff, IOSIZE - 1); size_t growbuflen = state->linelen; - for (;;) { + while (true) { errno = 0; if (fgets(state->growbuf + growbuflen, (int)(state->growbufsiz - growbuflen), state->fd) == NULL) { @@ -2291,7 +2291,7 @@ static char *qf_guess_filepath(qf_list_T *qfl, char *filename) } /// Returns true, if a quickfix/location list with the given identifier exists. -static bool qflist_valid(win_T *wp, unsigned int qf_id) +static bool qflist_valid(win_T *wp, unsigned qf_id) { qf_info_T *qi = &ql_info; @@ -2641,7 +2641,7 @@ static void qf_goto_win_with_qfl_file(int qf_fnum) { win_T *win = curwin; win_T *altwin = NULL; - for (;;) { + while (true) { if (win->w_buffer->b_fnum == qf_fnum) { break; } @@ -4414,7 +4414,7 @@ static char *get_mef_name(void) } // Keep trying until the name doesn't exist yet. - for (;;) { + while (true) { if (start == -1) { start = (int)os_get_pid(); } else { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index b5cffb17d0..deb183f5c0 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1159,7 +1159,7 @@ static bool reg_match_visual(void) rex.line = (uint8_t *)reg_getline(rex.lnum); rex.input = rex.line + col; - unsigned int cols_u = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, (char *)rex.line, col); + unsigned cols_u = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, (char *)rex.line, col); assert(cols_u <= MAXCOL); colnr_T cols = (colnr_T)cols_u; if (cols < start || cols > end - (*p_sel == 'e')) { @@ -1248,7 +1248,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e if (bytelen != NULL) { *bytelen = 0; } - for (;;) { + while (true) { // Since getting one line may invalidate the other, need to make copy. // Slow! if (rex.line != reg_tofree) { @@ -2003,7 +2003,7 @@ static int vim_regsub_both(char *source, typval_T *expr, char *dest, int destlen } } if (s != NULL) { - for (;;) { + while (true) { if (len == 0) { if (REG_MULTI) { if (rex.reg_mmatch->endpos[no].lnum == clnum) { diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c index a6f554d4ae..08b97b60ba 100644 --- a/src/nvim/regexp_bt.c +++ b/src/nvim/regexp_bt.c @@ -1513,7 +1513,7 @@ static void regtail(uint8_t *p, uint8_t *val) // Find last node. uint8_t *scan = p; - for (;;) { + while (true) { uint8_t *temp = regnext(scan); if (temp == NULL) { break; @@ -2427,7 +2427,7 @@ do_multibyte: int l; // Need to get composing character too. - for (;;) { + while (true) { l = utf_ptr2len((char *)regparse); if (!utf_composinglike(regparse, regparse + l)) { break; @@ -2683,7 +2683,7 @@ static uint8_t *regbranch(int *flagp) *flagp = WORST | HASNL; // Tentatively. ret = regnode(BRANCH); - for (;;) { + while (true) { latest = regconcat(&flags); if (latest == NULL) { return NULL; @@ -3536,7 +3536,7 @@ static bool regmatch(uint8_t *scan, proftime_T *tm, int *timed_out) backpos.ga_len = 0; // Repeat until "regstack" is empty. - for (;;) { + while (true) { // Some patterns may take a long time to match, e.g., "\([a-z]\+\)\+Q". // Allow interrupting them with CTRL-C. reg_breakcheck(); @@ -3550,7 +3550,7 @@ static bool regmatch(uint8_t *scan, proftime_T *tm, int *timed_out) // Repeat for items that can be matched sequentially, without using the // regstack. - for (;;) { + while (true) { if (got_int || scan == NULL) { status = RA_FAIL; break; @@ -4770,7 +4770,7 @@ static bool regmatch(uint8_t *scan, proftime_T *tm, int *timed_out) } // Repeat until we found a position where it could match. - for (;;) { + while (true) { if (status != RA_BREAK) { // Tried first position already, advance. if (rp->rs_state == RS_STAR_LONG) { diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 69d4f00ee5..08927fe83d 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -2505,7 +2505,7 @@ nfa_do_multibyte: // building the postfix form, not the NFA itself; // a composing char could be: a, b, c, NFA_COMPOSING // where 'b' and 'c' are chars with codes > 256. */ - for (;;) { + while (true) { EMIT(c); if (i > 0) { EMIT(NFA_CONCAT); @@ -5799,7 +5799,7 @@ static long find_match_text(colnr_T *startcol, int regstart, uint8_t *match_text colnr_T col = *startcol; int regstart_len = PTR2LEN((char *)rex.line + col); - for (;;) { + while (true) { bool match = true; uint8_t *s1 = match_text; uint8_t *s2 = rex.line + col + regstart_len; // skip regstart @@ -5966,7 +5966,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm } // Run for each character. - for (;;) { + while (true) { int curc = utf_ptr2char((char *)rex.input); int clen = utfc_ptr2len((char *)rex.input); if (curc == NUL) { @@ -6501,7 +6501,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm state = t->state->out; result_if_matched = (t->state->c == NFA_START_COLL); - for (;;) { + while (true) { if (state->c == NFA_END_COLL) { result = !result_if_matched; break; diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index a6ed5c7410..2d82ff1bba 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2558,7 +2558,7 @@ static char *get_one_sourceline(struct source_cookie *sp) // Loop until there is a finished line (or end-of-file). sp->sourcing_lnum++; - for (;;) { + while (true) { // make room to read at least 120 (more) characters ga_grow(&ga, 120); buf = ga.ga_data; diff --git a/src/nvim/search.c b/src/nvim/search.c index 50e72eee86..9d1e672128 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -678,9 +678,9 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, // otherwise "/$" will get stuck on end of line. while (matchpos.lnum == 0 && (((options & SEARCH_END) && first_match) - ? (nmatched == 1 - && (int)endpos.col - 1 - < (int)start_pos.col + extra_col) + ? (nmatched == 1 + && (int)endpos.col - 1 + < (int)start_pos.col + extra_col) : ((int)matchpos.col - (ptr[matchpos.col] == NUL) < (int)start_pos.col + extra_col))) { @@ -747,7 +747,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, // When putting the new cursor at the end, compare // relative to the end of the match. match_ok = false; - for (;;) { + while (true) { // Remember a position that is before the start // position, we use it if it's the last match in // the line. Always accept a position after @@ -1079,7 +1079,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, long count, i } // Repeat the search when pattern followed by ';', e.g. "/foo/;?bar". - for (;;) { + while (true) { bool show_top_bot_msg = false; searchstr = pat; @@ -1432,7 +1432,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char *pat) if (buf->b_ml.ml_line_count == 0) { return FAIL; } - for (;;) { + while (true) { pos->lnum += dir; if (pos->lnum < 1) { if (p_ws) { @@ -1544,7 +1544,7 @@ int searchc(cmdarg_T *cap, int t_cmd) int len = (int)strlen(p); while (count--) { - for (;;) { + while (true) { if (dir > 0) { col += utfc_ptr2len(p + col); if (col >= len) { @@ -1810,7 +1810,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) if (linep[pos.col] == NUL && pos.col) { pos.col--; } - for (;;) { + while (true) { initc = utf_ptr2char(linep + pos.col); if (initc == NUL) { break; @@ -3621,7 +3621,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool } line = get_line_and_copy(lnum, file_line); - for (;;) { + while (true) { if (incl_regmatch.regprog != NULL && vim_regexec(&incl_regmatch, line, (colnr_T)0)) { char *p_fname = (curr_fname == curbuf->b_fname) @@ -4090,7 +4090,7 @@ exit_matched: } already = NULL; } - // End of big for (;;) loop. + // End of big while (true) loop. // Close any files that are still open. for (i = 0; i <= depth; i++) { @@ -4143,7 +4143,7 @@ static void show_pat_in_path(char *line, int type, bool did_show, int action, FI if (got_int) { // 'q' typed at "--more--" message return; } - for (;;) { + while (true) { char *p = line + strlen(line) - 1; if (fp != NULL) { // We used fgets(), so get rid of newline at end diff --git a/src/nvim/shada.c b/src/nvim/shada.c index ae9e9463de..c405b8ca5f 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -3168,8 +3168,8 @@ int shada_read_everything(const char *const fname, const bool forceit, const boo { return shada_read_file(fname, kShaDaWantInfo|kShaDaWantMarks|kShaDaGetOldfiles - |(forceit?kShaDaForceit:0) - |(missing_ok?0:kShaDaMissingError)); + |(forceit ? kShaDaForceit : 0) + |(missing_ok ? 0 : kShaDaMissingError)); } static void shada_free_shada_entry(ShadaEntry *const entry) diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 5d3c6e9a54..5e3882f629 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -1201,7 +1201,7 @@ static void sign_define_cmd(char *sign_name, char *cmdline) int failed = false; // set values for a defined sign. - for (;;) { + while (true) { char *arg = skipwhite(p); if (*arg == NUL) { break; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index a14a02b9f7..a571131ba1 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -389,7 +389,7 @@ size_t spell_check(win_T *wp, char *ptr, hlf_T *attrp, int *capcol, bool docount if (mi.mi_lp->lp_slang->sl_fidxs != NULL) { p = mi.mi_word; char *fp = mi.mi_fword; - for (;;) { + while (true) { MB_PTR_ADV(p); MB_PTR_ADV(fp); if (p >= mi.mi_end) { @@ -482,7 +482,7 @@ static void find_word(matchinf_T *mip, int mode) // - there is a byte that doesn't match, // - we reach the end of the tree, // - or we reach the end of the line. - for (;;) { + while (true) { if (flen <= 0 && *mip->mi_fend != NUL) { flen = fold_more(mip); } @@ -549,7 +549,7 @@ static void find_word(matchinf_T *mip, int mode) // One space in the good word may stand for several spaces in the // checked word. if (c == ' ') { - for (;;) { + while (true) { if (flen <= 0 && *mip->mi_fend != NUL) { flen = fold_more(mip); } @@ -1081,7 +1081,7 @@ static void find_prefix(matchinf_T *mip, int mode) // - there is a byte that doesn't match, // - we reach the end of the tree, // - or we reach the end of the line. - for (;;) { + while (true) { if (flen == 0 && *mip->mi_fend != NUL) { flen = fold_more(mip); } @@ -2558,7 +2558,7 @@ bool check_need_cap(linenr_T lnum, colnr_T col) .rm_ic = false }; char *p = line + endcol; - for (;;) { + while (true) { MB_PTR_BACK(line, p); if (p == line || spell_iswordp_nmw(p, curwin)) { break; @@ -2796,7 +2796,7 @@ static void spell_soundfold_sofo(slang_T *slang, char *inword, char *res) if (ip == NULL) { // empty list, can't match c = NUL; } else { - for (;;) { // find "c" in the list + while (true) { // find "c" in the list if (*ip == 0) { // not found c = NUL; break; diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index d553910ece..d5d07df7b8 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -660,7 +660,7 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent) // <SECTIONS>: <section> ... <sectionend> // <section>: <sectionID> <sectionflags> <sectionlen> (section contents) - for (;;) { + while (true) { n = getc(fd); // <sectionID> or <sectionend> if (n == SN_END) { break; @@ -980,7 +980,7 @@ someerror: ga_init(&ga, 1, 100); for (wordnr = 0; wordnr < wcount; wordnr++) { ga.ga_len = 0; - for (;;) { + while (true) { c = getc(fd); // <sugline> if (c < 0) { goto someerror; @@ -2973,7 +2973,7 @@ static bool flag_in_afflist(int flagtype, char *afflist, unsigned flag) for (p = afflist; *p != NUL;) { int digits = getdigits_int(&p, true, 0); assert(digits >= 0); - n = (unsigned int)digits; + n = (unsigned)digits; if (n == 0) { n = ZERO_FLAG; } @@ -3597,7 +3597,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_ if (store_aff_word(spin, newword, ae->ae_flags, affile, &affile->af_suff, xht, use_condit & (xht == NULL - ? ~0 : ~CONDIT_SUF), + ? ~0 : ~CONDIT_SUF), use_flags, use_pfxlist, pfxlen) == FAIL) { retval = FAIL; } @@ -4442,7 +4442,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname) // round 1: SN_REP section // round 2: SN_SAL section (unless SN_SOFO is used) // round 3: SN_REPSAL section - for (unsigned int round = 1; round <= 3; round++) { + for (unsigned round = 1; round <= 3; round++) { garray_T *gap; if (round == 1) { gap = &spin->si_rep; @@ -4505,7 +4505,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname) // <rep> : <repfromlen> <repfrom> <reptolen> <repto> // <sal> : <salfromlen> <salfrom> <saltolen> <salto> fromto_T *ftp = &((fromto_T *)gap->ga_data)[i]; - for (unsigned int rr = 1; rr <= 2; rr++) { + for (unsigned rr = 1; rr <= 2; rr++) { char *p = rr == 1 ? ftp->ft_from : ftp->ft_to; l = strlen(p); assert(l < INT_MAX); @@ -4542,7 +4542,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname) // round 1: count the bytes // round 2: write the bytes - for (unsigned int round = 1; round <= 2; round++) { + for (unsigned round = 1; round <= 2; round++) { size_t todo; size_t len = 0; hashitem_T *hi; @@ -4665,7 +4665,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname) // <LWORDTREE> <KWORDTREE> <PREFIXTREE> spin->si_memtot = 0; - for (unsigned int round = 1; round <= 3; round++) { + for (unsigned round = 1; round <= 3; round++) { wordnode_T *tree; if (round == 1) { tree = spin->si_foldroot->wn_sibling; diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index e029d949fd..bde853fa20 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -1926,7 +1926,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun // skip over NUL bytes n = sp->ts_arridx; - for (;;) { + while (true) { if (sp->ts_curi > byts[n]) { // Only NUL bytes at this node, go to next state. PROF_STORE(sp->ts_state) @@ -2959,7 +2959,7 @@ static int soundfold_find(slang_T *slang, char *word) uint8_t *byts = slang->sl_sbyts; idx_T *idxs = slang->sl_sidxs; - for (;;) { + while (true) { // First byte is the number of possible bytes. int len = byts[arridx++]; @@ -3077,7 +3077,7 @@ static void add_suggestion(suginfo_T *su, garray_T *gap, const char *goodword, i // "thee the" is added next to changing the first "the" the "thee". const char *pgood = goodword + strlen(goodword); char *pbad = su->su_badptr + badlenarg; - for (;;) { + while (true) { goodlen = (int)(pgood - goodword); badlen = (int)(pbad - su->su_badptr); if (goodlen <= 0 || badlen <= 0) { @@ -3671,9 +3671,9 @@ static int spell_edit_score_limit_w(slang_T *slang, const char *badword, const c int score = 0; int minscore = limit + 1; - for (;;) { + while (true) { // Skip over an equal part, score remains the same. - for (;;) { + while (true) { bc = wbadword[bi]; gc = wgoodword[gi]; diff --git a/src/nvim/state.c b/src/nvim/state.c index 160bc3cd69..f3c2b52024 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -36,7 +36,7 @@ void state_enter(VimState *s) { - for (;;) { + while (true) { int check_result = s->check ? s->check(s) : 1; if (!check_result) { @@ -135,7 +135,7 @@ void state_handle_k_event(void) /// Return true if in the current mode we need to use virtual. bool virtual_active(void) { - unsigned int cur_ve_flags = get_ve_flags(); + unsigned cur_ve_flags = get_ve_flags(); // While an operator is being executed we return "virtual_op", because // VIsual_active has already been reset, thus we can't check for "block" diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index db99bae03c..a6fd1d677b 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -2000,7 +2000,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // string to find the last character that will fit. trunc_p = out; width = 0; - for (;;) { + while (true) { width += ptr2cells(trunc_p); if (width >= maxwidth) { break; diff --git a/src/nvim/strings.c b/src/nvim/strings.c index e8c04aa5c7..61e00f85dc 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -373,7 +373,7 @@ int vim_stricmp(const char *s1, const char *s2) { int i; - for (;;) { + while (true) { i = (int)TOLOWER_LOC((uint8_t)(*s1)) - (int)TOLOWER_LOC((uint8_t)(*s2)); if (i != 0) { return i; // this character different @@ -831,10 +831,10 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t } else if (ascii_isdigit((int)(*p))) { // size_t could be wider than unsigned int; make sure we treat // argument like common implementations do - unsigned int uj = (unsigned)(*p++ - '0'); + unsigned uj = (unsigned)(*p++ - '0'); while (ascii_isdigit((int)(*p))) { - uj = 10 * uj + (unsigned int)(*p++ - '0'); + uj = 10 * uj + (unsigned)(*p++ - '0'); } min_field_width = uj; } @@ -855,10 +855,10 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t } else if (ascii_isdigit((int)(*p))) { // size_t could be wider than unsigned int; make sure we // treat argument like common implementations do - unsigned int uj = (unsigned)(*p++ - '0'); + unsigned uj = (unsigned)(*p++ - '0'); while (ascii_isdigit((int)(*p))) { - uj = 10 * uj + (unsigned int)(*p++ - '0'); + uj = 10 * uj + (unsigned)(*p++ - '0'); } precision = uj; } @@ -1030,10 +1030,10 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t // unsigned switch (length_modifier) { case '\0': - uarg = (unsigned int)(tvs ? tv_nr(tvs, &arg_idx) : va_arg(ap, unsigned int)); + uarg = (unsigned)(tvs ? tv_nr(tvs, &arg_idx) : va_arg(ap, unsigned)); break; case 'h': - uarg = (uint16_t)(tvs ? tv_nr(tvs, &arg_idx) : va_arg(ap, unsigned int)); + uarg = (uint16_t)(tvs ? tv_nr(tvs, &arg_idx) : va_arg(ap, unsigned)); break; case 'l': uarg = (tvs ? (unsigned long)tv_nr(tvs, &arg_idx) : va_arg(ap, unsigned long)); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 5094f0cd6f..840cd60f13 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -619,7 +619,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid) for (current_lnum = lnum; current_lnum < end_lnum; current_lnum++) { syn_start_line(); - for (;;) { + while (true) { had_sync_point = syn_finish_line(true); // When a sync point has been found, remember where, and // continue to look for another one, further on in the line. @@ -2070,7 +2070,7 @@ static void check_state_ends(void) int had_extend; cur_si = &CUR_STATE(current_state.ga_len - 1); - for (;;) { + while (true) { if (cur_si->si_ends && (cur_si->si_m_endpos.lnum < current_lnum || (cur_si->si_m_endpos.lnum == current_lnum @@ -2383,7 +2383,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_ } // Find the SKIP or first END pattern after the last START pattern. - for (;;) { + while (true) { spp = &(SYN_ITEMS(syn_block)[idx]); if (spp->sp_type != SPTYPE_START) { break; @@ -2410,7 +2410,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_ // use syntax iskeyword option save_chartab(buf_chartab); - for (;;) { + while (true) { // Find end pattern that matches first after "matchcol". best_idx = -1; for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; idx++) { @@ -3838,7 +3838,7 @@ static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, i opt->flags |= HL_CONCEAL; } - for (;;) { + while (true) { // This is used very often when a large number of keywords is defined. // Need to skip quickly when no option name is found. // Also avoid tolower(), it's slow. @@ -4675,7 +4675,7 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing) } scl_id -= SYNID_CLUSTER; - for (;;) { + while (true) { if (STRNICMP(rest, "add", 3) == 0 && (ascii_iswhite(rest[3]) || rest[3] == '=')) { opt_len = 3; diff --git a/src/nvim/tag.c b/src/nvim/tag.c index cebc7d5d89..19c62e2b0e 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -538,7 +538,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) } // Repeat searching for tags, when a file has not been found. - for (;;) { + while (true) { int other_name; char *name; @@ -1260,9 +1260,9 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag vim_snprintf(flagString, sizeof(flagString), "%s%s%s", - g_tag_at_cursor ? "c": "", - flags & TAG_INS_COMP ? "i": "", - flags & TAG_REGEXP ? "r": ""); + g_tag_at_cursor ? "c" : "", + flags & TAG_INS_COMP ? "i" : "", + flags & TAG_REGEXP ? "r" : ""); save_pos = curwin->w_cursor; result = callback_call(&curbuf->b_tfu_cb, 3, args, &rettv); @@ -2094,7 +2094,7 @@ static void findtags_get_all_tags(findtags_state_T *st, findtags_match_args_T *m CLEAR_FIELD(search_info); // Read and parse the lines in the file one by one - for (;;) { + while (true) { // check for CTRL-C typed, more often when jumping around if (st->state == TS_BINARY || st->state == TS_SKIP_BACK) { line_breakcheck(); @@ -2558,7 +2558,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf) // There are two states: // tnp->tn_did_filefind_init == false: setup for next part in 'tags'. // tnp->tn_did_filefind_init == true: find next file in this part. - for (;;) { + while (true) { if (tnp->tn_did_filefind_init) { fname = vim_findfile(tnp->tn_search_ctx); if (fname != NULL) { @@ -3168,7 +3168,7 @@ static int find_extra(char **pp) char first_char = **pp; // Repeat for addresses separated with ';' - for (;;) { + while (true) { if (ascii_isdigit(*str)) { str = skipdigits(str + 1); } else if (*str == '/' || *str == '?') { diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index c774dbe384..0686305d02 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -680,7 +680,7 @@ void terminal_send(Terminal *term, char *data, size_t size) static bool is_filter_char(int c) { - unsigned int flag = 0; + unsigned flag = 0; switch (c) { case 0x08: flag = TPF_BS; @@ -839,7 +839,7 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr, int *te | (cell.attrs.italic ? HL_ITALIC : 0) | (cell.attrs.reverse ? HL_INVERSE : 0) | get_underline_hl_flag(cell.attrs) - | (cell.attrs.strike ? HL_STRIKETHROUGH: 0) + | (cell.attrs.strike ? HL_STRIKETHROUGH : 0) | ((fg_indexed && !fg_set) ? HL_FG_INDEXED : 0) | ((bg_indexed && !bg_set) ? HL_BG_INDEXED : 0); diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index dd13295c48..6d82179796 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -318,7 +318,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on if (allow_break) { // Break only when we are not at end of line. - end_foundcol = foundcol = ncc == NUL? 0 : curwin->w_cursor.col; + end_foundcol = foundcol = ncc == NUL ? 0 : curwin->w_cursor.col; break; } curwin->w_cursor.col = col; diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 6683fbe8f4..428b14a68d 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -104,7 +104,7 @@ int findsent(Direction dir, long count) const int startlnum = pos.lnum; const bool cpo_J = vim_strchr(p_cpo, CPO_ENDOFSENT) != NULL; - for (;;) { // find end of sentence + while (true) { // find end of sentence c = gchar_pos(&pos); if (c == NUL || (pos.col == 0 && startPS(pos.lnum, NUL, false))) { if (dir == BACKWARD && pos.lnum != startlnum) { @@ -540,7 +540,7 @@ static void back_in_line(void) int sclass; // starting class sclass = cls(); - for (;;) { + while (true) { if (curwin->w_cursor.col == 0) { // stop at start of line break; } @@ -1062,7 +1062,7 @@ static bool in_html_tag(bool end_tag) } // check that the matching '>' is not preceded by '/' - for (;;) { + while (true) { if (inc(&pos) < 0) { return false; } @@ -1304,7 +1304,7 @@ extend: start_lnum -= dir; break; } - for (;;) { + while (true) { if (start_lnum == (dir == BACKWARD ? 1 : curbuf->b_ml.ml_line_count)) { break; @@ -1431,7 +1431,7 @@ extend: /// @return column number of "quotechar" or -1 when not found. static int find_next_quote(char *line, int col, int quotechar, char *escape) { - for (;;) { + while (true) { int c = (uint8_t)line[col]; if (c == NUL) { return -1; @@ -1605,7 +1605,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar) // Also do this when there is a Visual area, a' may leave the cursor // in between two strings. col_start = 0; - for (;;) { + while (true) { // Find open quote character. col_start = find_next_quote(line, col_start, quotechar, NULL); if (col_start < 0 || col_start > first_col) { diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index eecaa8c55a..2f4ff13bde 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -209,7 +209,7 @@ void tui_enable_extkeys(TUIData *tui) unibi_out_ext(tui, tui->unibi_ext.enable_extended_keys); } -static size_t unibi_pre_fmt_str(TUIData *tui, unsigned int unibi_index, char *buf, size_t len) +static size_t unibi_pre_fmt_str(TUIData *tui, unsigned unibi_index, char *buf, size_t len) { const char *str = unibi_get_str(tui->ut, unibi_index); if (!str) { @@ -1617,7 +1617,7 @@ static void pad(void *ctx, size_t delay, int scale FUNC_ATTR_UNUSED, int force) } flush_buf(tui); - uv_sleep((unsigned int)(delay/10)); + uv_sleep((unsigned)(delay/10)); } static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, const char *val) diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 8d279aa998..e38c1437dc 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -580,11 +580,11 @@ void ui_comp_msg_set_pos(Integer grid, Integer row, Boolean scrolled, String sep && (msg_current_row < Rows || (scrolled && !msg_was_scrolled))) { int delta = msg_current_row - (int)row; if (msg_grid.blending) { - int first_row = MAX((int)row - (scrolled?1:0), 0); + int first_row = MAX((int)row - (scrolled ? 1 : 0), 0); compose_area(first_row, Rows - delta, 0, Columns); } else { // scroll separator together with message text - int first_row = MAX((int)row - (msg_was_scrolled?1:0), 0); + int first_row = MAX((int)row - (msg_was_scrolled ? 1 : 0), 0); ui_composed_call_grid_scroll(1, first_row, Rows, 0, Columns, delta, 0); if (scrolled && !msg_was_scrolled && row > 0) { compose_area(row - 1, row, 0, Columns); @@ -602,8 +602,8 @@ void ui_comp_msg_set_pos(Integer grid, Integer row, Boolean scrolled, String sep static bool curgrid_covered_above(int row) { bool above_msg = (kv_A(layers, kv_size(layers) - 1) == &msg_grid - && row < msg_current_row - (msg_was_scrolled?1:0)); - return kv_size(layers) - (above_msg?1:0) > curgrid->comp_index + 1; + && row < msg_current_row - (msg_was_scrolled ? 1 : 0)); + return kv_size(layers) - (above_msg ? 1 : 0) > curgrid->comp_index + 1; } void ui_comp_grid_scroll(Integer grid, Integer top, Integer bot, Integer left, Integer right, diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 7eb0d390fc..f4f97fd8ee 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -904,7 +904,7 @@ static u_header_T *unserialize_uhp(bufinfo_T *bi, const char *file_name) uhp->uh_time = undo_read_time(bi); // Unserialize optional fields. - for (;;) { + while (true) { int len = undo_read_byte(bi); if (len == EOF) { @@ -1471,7 +1471,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT // Optional header fields. long last_save_nr = 0; - for (;;) { + while (true) { int len = undo_read_byte(&bi); if (len == 0 || len == EOF) { @@ -2024,7 +2024,7 @@ void undo_time(long step, bool sec, bool file, bool absolute) while (uhp != NULL) { uhp->uh_walk = mark; - long val = dosec ? (long)(uhp->uh_time) : + long val = dosec ? (long)(uhp->uh_time) : dofile ? uhp->uh_save_nr : uhp->uh_seq; diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 0aacc73529..b18318b5ff 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -139,7 +139,7 @@ char *find_ucmd(exarg_T *eap, char *p, int *full, expand_T *xp, int *complp) // Look for buffer-local user commands first, then global ones. gap = &prevwin_curwin()->w_buffer->b_ucmds; - for (;;) { + while (true) { for (j = 0; j < gap->ga_len; j++) { uc = USER_CMD_GA(gap, j); cp = eap->cmd; @@ -445,7 +445,7 @@ static void uc_list(char *name, size_t name_len) // In cmdwin, the alternative buffer should be used. const garray_T *gap = &prevwin_curwin()->w_buffer->b_ucmds; - for (;;) { + while (true) { for (i = 0; i < gap->ga_len; i++) { cmd = USER_CMD_GA(gap, i); a = cmd->uc_argt; @@ -1066,7 +1066,7 @@ void ex_delcommand(exarg_T *eap) } gap = &curbuf->b_ucmds; - for (;;) { + while (true) { for (i = 0; i < gap->ga_len; i++) { cmd = USER_CMD_GA(gap, i); res = strcmp(arg, cmd->uc_name); @@ -1645,12 +1645,12 @@ int do_ucmd(exarg_T *eap, bool preview) // First round: "buf" is NULL, compute length, allocate "buf". // Second round: copy result into "buf". buf = NULL; - for (;;) { + while (true) { p = cmd->uc_rep; // source q = buf; // destination totlen = 0; - for (;;) { + while (true) { start = vim_strchr(p, '<'); if (start != NULL) { end = vim_strchr(start + 1, '>'); diff --git a/src/nvim/window.c b/src/nvim/window.c index 81e1fd59c1..a45ceeb611 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2886,7 +2886,7 @@ int win_close(win_T *win, bool free_buf, bool force) if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) { // If the cursor goes to the preview or the quickfix window, try // finding another window to go to. - for (;;) { + while (true) { if (wp->w_next == NULL) { wp = firstwin; } else { @@ -4639,7 +4639,7 @@ win_T *win_vert_neighbor(tabpage_T *tp, win_T *wp, bool up, long count) // First go upwards in the tree of frames until we find an upwards or // downwards neighbor. frame_T *fr = foundfr; - for (;;) { + while (true) { if (fr == tp->tp_topframe) { goto end; } @@ -4655,7 +4655,7 @@ win_T *win_vert_neighbor(tabpage_T *tp, win_T *wp, bool up, long count) } // Now go downwards to find the bottom or top frame in it. - for (;;) { + while (true) { if (nfr->fr_layout == FR_LEAF) { foundfr = nfr; break; @@ -4715,7 +4715,7 @@ win_T *win_horz_neighbor(tabpage_T *tp, win_T *wp, bool left, long count) // First go upwards in the tree of frames until we find a left or // right neighbor. frame_T *fr = foundfr; - for (;;) { + while (true) { if (fr == tp->tp_topframe) { goto end; } @@ -4731,7 +4731,7 @@ win_T *win_horz_neighbor(tabpage_T *tp, win_T *wp, bool left, long count) } // Now go downwards to find the leftmost or rightmost frame in it. - for (;;) { + while (true) { if (nfr->fr_layout == FR_LEAF) { foundfr = nfr; break; @@ -5378,7 +5378,7 @@ static dict_T *make_win_info_dict(int width, int height, int topline, int topfil d->dv_refcount = 1; // not actually looping, for breaking out on error - while (1) { + while (true) { typval_T tv = { .v_lock = VAR_UNLOCKED, .v_type = VAR_NUMBER, @@ -6759,7 +6759,7 @@ void command_height(void) static void frame_add_height(frame_T *frp, int n) { frame_new_height(frp, frp->fr_height + n, false, false); - for (;;) { + while (true) { frp = frp->fr_parent; if (frp == NULL) { break; @@ -7426,7 +7426,7 @@ const char *check_colorcolumn(win_T *wp) return NULL; // buffer was closed } - unsigned int count = 0; + unsigned count = 0; int color_cols[256]; for (char *s = wp->w_p_cc; *s != NUL && count < 255;) { int col; @@ -7479,7 +7479,7 @@ skip: qsort(color_cols, count, sizeof(int), int_cmp); int j = 0; - for (unsigned int i = 0; i < count; i++) { + for (unsigned i = 0; i < count; i++) { // skip duplicates if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) { wp->w_p_cc_cols[j++] = color_cols[i]; diff --git a/src/uncrustify.cfg b/src/uncrustify.cfg index 83b63dbdf6..5934c088df 100644 --- a/src/uncrustify.cfg +++ b/src/uncrustify.cfg @@ -928,7 +928,7 @@ sp_cond_colon_before = ignore # ignore/add/remove/force/not_defined sp_cond_colon_after = ignore # ignore/add/remove/force/not_defined # Add or remove space around the '?' in 'b ? t : f'. -sp_cond_question = ignore # ignore/add/remove/force/not_defined +sp_cond_question = force # ignore/add/remove/force/not_defined # Add or remove space before the '?' in 'b ? t : f'. # @@ -3234,31 +3234,31 @@ mod_enum_last_comma = add # ignore/add/remove/force/not_defined # Infinite loops that do not already match one of these syntaxes are ignored. # Other options that affect loop formatting will be applied after transforming # the syntax. -mod_infinite_loop = 0 # unsigned number +mod_infinite_loop = 2 # unsigned number # Add or remove the 'int' keyword in 'int short'. -mod_int_short = ignore # ignore/add/remove/force/not_defined +mod_int_short = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'short int'. -mod_short_int = ignore # ignore/add/remove/force/not_defined +mod_short_int = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'int long'. -mod_int_long = ignore # ignore/add/remove/force/not_defined +mod_int_long = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'long int'. -mod_long_int = ignore # ignore/add/remove/force/not_defined +mod_long_int = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'int signed'. -mod_int_signed = ignore # ignore/add/remove/force/not_defined +mod_int_signed = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'signed int'. -mod_signed_int = ignore # ignore/add/remove/force/not_defined +mod_signed_int = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'int unsigned'. -mod_int_unsigned = ignore # ignore/add/remove/force/not_defined +mod_int_unsigned = remove # ignore/add/remove/force/not_defined # Add or remove the 'int' keyword in 'unsigned int'. -mod_unsigned_int = ignore # ignore/add/remove/force/not_defined +mod_unsigned_int = remove # ignore/add/remove/force/not_defined # If there is a situation where mod_int_* and mod_*_int would result in # multiple int keywords, whether to keep the rightmost int (the default) or the @@ -3615,5 +3615,5 @@ set CLASS_COLON REAL_FATTR_CONST set CLASS_COLON REAL_FATTR_NONNULL_ALL set CLASS_COLON REAL_FATTR_PURE set CLASS_COLON REAL_FATTR_WARN_UNUSED_RESULT -# option(s) with 'not default' value: 117 +# option(s) with 'not default' value: 127 # |