diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-03-13 15:11:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-13 22:11:17 +0800 |
commit | 4ba12b3dda34472c193c9fa8ffd7d3bd5b6c04d6 (patch) | |
tree | c281f75c93feb5d0789ee602484c22e3b6a83116 | |
parent | 4ede2ea4b2e9cd61fb7e634fa35e6a500816be19 (diff) | |
download | rneovim-4ba12b3dda34472c193c9fa8ffd7d3bd5b6c04d6.tar.gz rneovim-4ba12b3dda34472c193c9fa8ffd7d3bd5b6c04d6.tar.bz2 rneovim-4ba12b3dda34472c193c9fa8ffd7d3bd5b6c04d6.zip |
refactor: fix clint warnings (#17682)
-rw-r--r-- | src/nvim/api/private/helpers.c | 5 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 6 | ||||
-rw-r--r-- | src/nvim/charset.c | 14 | ||||
-rw-r--r-- | src/nvim/cursor.c | 146 | ||||
-rw-r--r-- | src/nvim/cursor_shape.c | 11 | ||||
-rw-r--r-- | src/nvim/diff.c | 68 | ||||
-rw-r--r-- | src/nvim/digraph.c | 16 | ||||
-rw-r--r-- | src/nvim/event/socket.c | 13 | ||||
-rw-r--r-- | src/nvim/indent.c | 13 | ||||
-rw-r--r-- | src/nvim/lua/converter.c | 25 | ||||
-rw-r--r-- | src/nvim/os/env.c | 4 | ||||
-rw-r--r-- | src/nvim/os/pty_process_win.c | 3 | ||||
-rw-r--r-- | src/nvim/os/shell.c | 2 | ||||
-rw-r--r-- | src/nvim/rbuffer.h | 14 | ||||
-rw-r--r-- | src/nvim/screen.h | 10 | ||||
-rw-r--r-- | src/nvim/syntax_defs.h | 16 | ||||
-rw-r--r-- | src/nvim/tag.h | 10 | ||||
-rw-r--r-- | src/nvim/undo_defs.h | 6 | ||||
-rw-r--r-- | src/nvim/viml/parser/parser.h | 6 | ||||
-rw-r--r-- | src/nvim/window.h | 12 |
20 files changed, 160 insertions, 240 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 8056950e26..9f41393c6b 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -111,7 +111,7 @@ bool try_leave(const TryState *const tstate, Error *const err) /// try_enter()/try_leave() pair should be used instead. void try_start(void) { - ++trylevel; + trylevel++; } /// End try block, set the error message if any and return true if an error @@ -1037,8 +1037,7 @@ static void set_option_value_for(char *key, int numval, char *stringval, int opt aco_save_T aco; try_start(); - switch (opt_type) - { + switch (opt_type) { case SREQ_WIN: if (switch_win_noblock(&switchwin, (win_T *)from, win_find_tabpage((win_T *)from), true) == FAIL) { diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 80fa677485..3292ee2ef8 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -219,7 +219,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks) bool execute = false; bool dangerous = false; - for (size_t i = 0; i < mode.size; ++i) { + for (size_t i = 0; i < mode.size; i++) { switch (mode.data[i]) { case 'n': remap = false; break; @@ -1880,7 +1880,7 @@ static void write_msg(String message, bool to_err) } \ line_buf[pos++] = message.data[i]; - ++no_wait_return; + no_wait_return++; for (uint32_t i = 0; i < message.size; i++) { if (got_int) { break; @@ -1891,7 +1891,7 @@ static void write_msg(String message, bool to_err) PUSH_CHAR(i, out_pos, out_line_buf, msg); } } - --no_wait_return; + no_wait_return--; msg_end(); } diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 3383dd2a76..6a3ff6f433 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -159,7 +159,7 @@ int buf_init_chartab(buf_T *buf, int global) if ((*p == '^') && (p[1] != NUL)) { tilde = true; - ++p; + p++; } if (ascii_isdigit(*p)) { @@ -170,7 +170,7 @@ int buf_init_chartab(buf_T *buf, int global) c2 = -1; if ((*p == '-') && (p[1] != NUL)) { - ++p; + p++; if (ascii_isdigit(*p)) { c2 = getdigits_int((char_u **)&p, true, 0); @@ -243,7 +243,7 @@ int buf_init_chartab(buf_T *buf, int global) } } } - ++c; + c++; } c = *p; @@ -292,7 +292,7 @@ void trans_characters(char_u *buf, int bufsize) memmove(buf + trs_len, buf + 1, (size_t)len); } memmove(buf, trs, (size_t)trs_len); - --len; + len--; } buf += trs_len; } @@ -1314,9 +1314,9 @@ char_u *skiptowhite_esc(char_u *p) { while (*p != ' ' && *p != '\t' && *p != NUL) { if (((*p == '\\') || (*p == Ctrl_V)) && (*(p + 1) != NUL)) { - ++p; + p++; } - ++p; + p++; } return p; } @@ -1686,7 +1686,7 @@ bool rem_backslash(const char_u *str) /// @param p void backslash_halve(char_u *p) { - for (; *p; ++p) { + for (; *p; p++) { if (rem_backslash(p)) { STRMOVE(p, p + 1); } diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 55f55a46b2..1c0fd29d5b 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -25,9 +25,7 @@ # include "cursor.c.generated.h" #endif -/* - * Get the screen position of the cursor. - */ +/// @return the screen position of the cursor. int getviscol(void) { colnr_T x; @@ -36,9 +34,7 @@ int getviscol(void) return (int)x; } -/* - * Get the screen position of character col with a coladd in the cursor line. - */ +/// @return the screen position of character col with a coladd in the cursor line. int getviscol2(colnr_T col, colnr_T coladd) { colnr_T x; @@ -51,11 +47,9 @@ int getviscol2(colnr_T col, colnr_T coladd) return (int)x; } -/* - * Go to column "wcol", and add/insert white space as necessary to get the - * cursor in that column. - * The caller must have saved the cursor line for undo! - */ +/// Go to column "wcol", and add/insert white space as necessary to get the +/// cursor in that column. +/// The caller must have saved the cursor line for undo! int coladvance_force(colnr_T wcol) { int rc = coladvance2(&curwin->w_cursor, true, false, wcol); @@ -70,15 +64,13 @@ int coladvance_force(colnr_T wcol) return rc; } -/* - * Try to advance the Cursor to the specified screen column. - * If virtual editing: fine tune the cursor position. - * Note that all virtual positions off the end of a line should share - * a curwin->w_cursor.col value (n.b. this is equal to STRLEN(line)), - * beginning at coladd 0. - * - * return OK if desired column is reached, FAIL if not - */ +/// Try to advance the Cursor to the specified screen column. +/// If virtual editing: fine tune the cursor position. +/// Note that all virtual positions off the end of a line should share +/// a curwin->w_cursor.col value (n.b. this is equal to STRLEN(line)), +/// beginning at coladd 0. +/// +/// @return OK if desired column is reached, FAIL if not int coladvance(colnr_T wcol) { int rc = getvpos(&curwin->w_cursor, wcol); @@ -121,7 +113,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a if ((addspaces || finetune) && !VIsual_active) { curwin->w_curswant = linetabsize(line) + one_more; if (curwin->w_curswant > 0) { - --curwin->w_curswant; + curwin->w_curswant--; } } } else { @@ -139,10 +131,10 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a if (wcol / width > (colnr_T)csize / width && ((State & INSERT) == 0 || (int)wcol > csize + 1)) { - /* In case of line wrapping don't move the cursor beyond the - * right screen edge. In Insert mode allow going just beyond - * the last character (like what happens when typing and - * reaching the right window edge). */ + // In case of line wrapping don't move the cursor beyond the + // right screen edge. In Insert mode allow going just beyond + // the last character (like what happens when typing and + // reaching the right window edge). wcol = (csize / width + 1) * width - 1; } } @@ -155,12 +147,10 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a col += csize; } idx = (int)(ptr - line); - /* - * Handle all the special cases. The virtual_active() check - * is needed to ensure that a virtual position off the end of - * a line has the correct indexing. The one_more comparison - * replaces an explicit add of one_more later on. - */ + // Handle all the special cases. The virtual_active() check + // is needed to ensure that a virtual position off the end of + // a line has the correct indexing. The one_more comparison + // replaces an explicit add of one_more later on. if (col > wcol || (!virtual_active() && one_more == 0)) { idx -= 1; // Don't count the chars from 'showbreak'. @@ -172,8 +162,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a && addspaces && wcol >= 0 && ((col != wcol && col != wcol + 1) || csize > 1)) { - /* 'virtualedit' is set: The difference between wcol and col is - * filled with spaces. */ + // 'virtualedit' is set: The difference between wcol and col is filled with spaces. if (line[idx] == NUL) { // Append spaces @@ -256,29 +245,23 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a return OK; } -/* - * Return in "pos" the position of the cursor advanced to screen column "wcol". - * return OK if desired column is reached, FAIL if not - */ +/// Return in "pos" the position of the cursor advanced to screen column "wcol". +/// +/// @return OK if desired column is reached, FAIL if not int getvpos(pos_T *pos, colnr_T wcol) { return coladvance2(pos, false, virtual_active(), wcol); } -/* - * Increment the cursor position. See inc() for return values. - */ +/// Increment the cursor position. See inc() for return values. int inc_cursor(void) { return inc(&curwin->w_cursor); } -/* - * dec(p) - * - * Decrement the line pointer 'p' crossing line boundaries as necessary. - * Return 1 when crossing a line, -1 when at start of file, 0 otherwise. - */ +/// Decrement the line pointer 'p' crossing line boundaries as necessary. +/// +/// @return 1 when crossing a line, -1 when at start of file, 0 otherwise. int dec_cursor(void) { return dec(&curwin->w_cursor); @@ -314,8 +297,8 @@ linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum) return (lnum < cursor) ? -retval : retval; } -// Make sure "pos.lnum" and "pos.col" are valid in "buf". -// This allows for the col to be on the NUL byte. +/// Make sure "pos.lnum" and "pos.col" are valid in "buf". +/// This allows for the col to be on the NUL byte. void check_pos(buf_T *buf, pos_T *pos) { char_u *line; @@ -334,14 +317,12 @@ void check_pos(buf_T *buf, pos_T *pos) } } -/* - * Make sure curwin->w_cursor.lnum is valid. - */ +/// Make sure curwin->w_cursor.lnum is valid. void check_cursor_lnum(void) { if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { - /* If there is a closed fold at the end of the file, put the cursor in - * its first line. Otherwise in the last line. */ + // If there is a closed fold at the end of the file, put the cursor in + // its first line. Otherwise in the last line. if (!hasFolding(curbuf->b_ml.ml_line_count, &curwin->w_cursor.lnum, NULL)) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; @@ -352,9 +333,7 @@ void check_cursor_lnum(void) } } -/* - * Make sure curwin->w_cursor.col is valid. - */ +/// Make sure curwin->w_cursor.col is valid. void check_cursor_col(void) { check_cursor_col_win(curwin); @@ -373,10 +352,10 @@ void check_cursor_col_win(win_T *win) if (len == 0) { win->w_cursor.col = 0; } else if (win->w_cursor.col >= len) { - /* Allow cursor past end-of-line when: - * - in Insert mode or restarting Insert mode - * - in Visual mode and 'selection' isn't "old" - * - 'virtualedit' is set */ + // Allow cursor past end-of-line when: + // - in Insert mode or restarting Insert mode + // - in Visual mode and 'selection' isn't "old" + // - 'virtualedit' is set */ if ((State & INSERT) || restart_edit || (VIsual_active && *p_sel != 'o') || (cur_ve_flags & VE_ONEMORE) @@ -419,32 +398,27 @@ void check_cursor_col_win(win_T *win) } } -/* - * make sure curwin->w_cursor in on a valid character - */ +/// Make sure curwin->w_cursor in on a valid character void check_cursor(void) { check_cursor_lnum(); check_cursor_col(); } -/* - * Make sure curwin->w_cursor is not on the NUL at the end of the line. - * Allow it when in Visual mode and 'selection' is not "old". - */ +/// Make sure curwin->w_cursor is not on the NUL at the end of the line. +/// Allow it when in Visual mode and 'selection' is not "old". void adjust_cursor_col(void) { if (curwin->w_cursor.col > 0 && (!VIsual_active || *p_sel == 'o') && gchar_cursor() == NUL) { - --curwin->w_cursor.col; + curwin->w_cursor.col--; } } -/* - * When curwin->w_leftcol has changed, adjust the cursor position. - * Return true if the cursor was moved. - */ +/// When curwin->w_leftcol has changed, adjust the cursor position. +/// +/// @return true if the cursor was moved. bool leftcol_changed(void) { // TODO(hinidu): I think it should be colnr_T or int, but p_siso is long. @@ -457,10 +431,8 @@ bool leftcol_changed(void) lastcol = curwin->w_leftcol + curwin->w_width_inner - curwin_col_off() - 1; validate_virtcol(); - /* - * If the cursor is right or left of the screen, move it to last or first - * character. - */ + // If the cursor is right or left of the screen, move it to last or first + // character. if (curwin->w_virtcol > (colnr_T)(lastcol - p_siso)) { retval = true; coladvance((colnr_T)(lastcol - p_siso)); @@ -469,11 +441,9 @@ bool leftcol_changed(void) coladvance((colnr_T)(curwin->w_leftcol + p_siso)); } - /* - * If the start of the character under the cursor is not on the screen, - * advance the cursor one more char. If this fails (last char of the - * line) adjust the scrolling. - */ + // If the start of the character under the cursor is not on the screen, + // advance the cursor one more char. If this fails (last char of the + // line) adjust the scrolling. getvvcol(curwin, &curwin->w_cursor, &s, NULL, &e); if (e > (colnr_T)lastcol) { retval = true; @@ -498,27 +468,21 @@ int gchar_cursor(void) return utf_ptr2char(get_cursor_pos_ptr()); } -/* - * Write a character at the current cursor position. - * It is directly written into the block. - */ +/// Write a character at the current cursor position. +/// It is directly written into the block. void pchar_cursor(char_u c) { *(ml_get_buf(curbuf, curwin->w_cursor.lnum, true) + curwin->w_cursor.col) = c; } -/* - * Return pointer to cursor line. - */ +/// @return pointer to cursor line. char_u *get_cursor_line_ptr(void) { return ml_get_buf(curbuf, curwin->w_cursor.lnum, false); } -/* - * Return pointer to cursor position. - */ +/// @return pointer to cursor position. char_u *get_cursor_pos_ptr(void) { return ml_get_buf(curbuf, curwin->w_cursor.lnum, false) + diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 6b0a5dfe12..f19da94512 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -74,8 +74,7 @@ Array mode_style_array(void) PUT(dic, "hl_id", INTEGER_OBJ(cur->id)); PUT(dic, "id_lm", INTEGER_OBJ(cur->id_lm)); PUT(dic, "attr_id", INTEGER_OBJ(cur->id ? syn_id2attr(cur->id) : 0)); - PUT(dic, "attr_id_lm", INTEGER_OBJ(cur->id_lm ? syn_id2attr(cur->id_lm) - : 0)); + PUT(dic, "attr_id_lm", INTEGER_OBJ(cur->id_lm ? syn_id2attr(cur->id_lm) : 0)); } PUT(dic, "name", STRING_OBJ(cstr_to_string(cur->full_name))); PUT(dic, "short_name", STRING_OBJ(cstr_to_string(cur->name))); @@ -147,7 +146,7 @@ char *parse_shape_opt(int what) if (len == 1 && TOLOWER_ASC(modep[0]) == 'a') { all_idx = SHAPE_IDX_COUNT - 1; } else { - for (idx = 0; idx < SHAPE_IDX_COUNT; ++idx) { + for (idx = 0; idx < SHAPE_IDX_COUNT; idx++) { if (STRNICMP(modep, shape_table[idx].name, len) == 0) { break; } @@ -170,9 +169,7 @@ char *parse_shape_opt(int what) // Parse the part after the colon for (p = colonp + 1; *p && *p != ',';) { { - /* - * First handle the ones with a number argument. - */ + // First handle the ones with a number argument. i = *p; len = 0; if (STRNICMP(p, "ver", 3) == 0) { @@ -245,7 +242,7 @@ char *parse_shape_opt(int what) } // if (what != SHAPE_MOUSE) if (*p == '-') { - ++p; + p++; } } } diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 80bd3229c6..a3e45b8784 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -167,7 +167,7 @@ void diff_buf_add(buf_T *buf) } int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (curtab->tp_diffbuf[i] == NULL) { curtab->tp_diffbuf[i] = buf; curtab->tp_diff_invalid = true; @@ -201,7 +201,7 @@ static void diff_buf_clear(void) static int diff_buf_idx(buf_T *buf) { int idx; - for (idx = 0; idx < DB_COUNT; ++idx) { + for (idx = 0; idx < DB_COUNT; idx++) { if (curtab->tp_diffbuf[idx] == buf) { break; } @@ -218,7 +218,7 @@ static int diff_buf_idx(buf_T *buf) static int diff_buf_idx_tp(buf_T *buf, tabpage_T *tp) { int idx; - for (idx = 0; idx < DB_COUNT; ++idx) { + for (idx = 0; idx < DB_COUNT; idx++) { if (tp->tp_diffbuf[idx] == buf) { break; } @@ -323,7 +323,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T dnext->df_lnum[idx] = line1; dnext->df_count[idx] = inserted; int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((tp->tp_diffbuf[i] != NULL) && (i != idx)) { if (dprev == NULL) { dnext->df_lnum[i] = line1; @@ -421,7 +421,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T } int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((tp->tp_diffbuf[i] != NULL) && (i != idx)) { dp->df_lnum[i] -= off; dp->df_count[i] += n; @@ -442,7 +442,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T // Check if inserted lines are equal, may reduce the size of the // diff. // - // TODO: also check for equal lines in the middle and perhaps split + // TODO(unknown): also check for equal lines in the middle and perhaps split // the block. diff_check_unchanged(tp, dp); } @@ -453,7 +453,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T if ((dprev != NULL) && (dprev->df_lnum[idx] + dprev->df_count[idx] == dp->df_lnum[idx])) { int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (tp->tp_diffbuf[i] != NULL) { dprev->df_count[i] += dp->df_count[i]; } @@ -474,7 +474,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T while (dp != NULL) { // All counts are zero, remove this entry. int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((tp->tp_diffbuf[i] != NULL) && (dp->df_count[i] != 0)) { break; } @@ -542,7 +542,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) // Find the first buffers, use it as the original, compare the other // buffer lines against this one. int i_org; - for (i_org = 0; i_org < DB_COUNT; ++i_org) { + for (i_org = 0; i_org < DB_COUNT; i_org++) { if (tp->tp_diffbuf[i_org] != NULL) { break; } @@ -574,7 +574,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) false)); int i_new; - for (i_new = i_org + 1; i_new < DB_COUNT; ++i_new) { + for (i_new = i_org + 1; i_new < DB_COUNT; i_new++) { if (tp->tp_diffbuf[i_new] == NULL) { continue; } @@ -602,7 +602,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) } // Line matched in all buffers, remove it from the diff. - for (i_new = i_org; i_new < DB_COUNT; ++i_new) { + for (i_new = i_org; i_new < DB_COUNT; i_new++) { if (tp->tp_diffbuf[i_new] != NULL) { if (dir == FORWARD) { dp->df_lnum[i_new]++; @@ -629,7 +629,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) static int diff_check_sanity(tabpage_T *tp, diff_T *dp) { int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (tp->tp_diffbuf[i] != NULL) { if (dp->df_lnum[i] + dp->df_count[i] - 1 > tp->tp_diffbuf[i]->b_ml.ml_line_count) { @@ -927,7 +927,7 @@ void ex_diffupdate(exarg_T *eap) // Use the first buffer as the original text. int idx_orig; - for (idx_orig = 0; idx_orig < DB_COUNT; ++idx_orig) { + for (idx_orig = 0; idx_orig < DB_COUNT; idx_orig++) { if (curtab->tp_diffbuf[idx_orig] != NULL) { break; } @@ -939,7 +939,7 @@ void ex_diffupdate(exarg_T *eap) // Only need to do something when there is another buffer. int idx_new; - for (idx_new = idx_orig + 1; idx_new < DB_COUNT; ++idx_new) { + for (idx_new = idx_orig + 1; idx_new < DB_COUNT; idx_new++) { if (curtab->tp_diffbuf[idx_new] != NULL) { break; } @@ -1659,7 +1659,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) off = dp->df_lnum[idx_orig] - hunk->lnum_orig; if (off > 0) { - for (i = idx_orig; i < idx_new; ++i) { + for (i = idx_orig; i < idx_new; i++) { if (curtab->tp_diffbuf[i] != NULL) { dp->df_lnum[i] -= off; } @@ -1693,7 +1693,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) off = 0; } - for (i = idx_orig; i < idx_new; ++i) { + for (i = idx_orig; i < idx_new; i++) { if (curtab->tp_diffbuf[i] != NULL) { dp->df_count[i] = dpl->df_lnum[i] + dpl->df_count[i] - dp->df_lnum[i] + off; @@ -1721,7 +1721,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) // Set values for other buffers, these must be equal to the // original buffer, otherwise there would have been a change // already. - for (i = idx_orig + 1; i < idx_new; ++i) { + for (i = idx_orig + 1; i < idx_new; i++) { if (curtab->tp_diffbuf[i] != NULL) { diff_copy_entry(dprev, dp, idx_orig, i); } @@ -1852,7 +1852,7 @@ int diff_check(win_T *wp, linenr_T lnum) // count, check if the lines are identical. cmp = false; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL)) { if (dp->df_count[i] == 0) { zero = true; @@ -1869,7 +1869,7 @@ int diff_check(win_T *wp, linenr_T lnum) if (cmp) { // Compare all lines. If they are equal the lines were inserted // in some buffers, deleted in others, but not changed. - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] != 0)) { @@ -1899,7 +1899,7 @@ int diff_check(win_T *wp, linenr_T lnum) // Insert filler lines above the line just below the change. Will return // 0 when this buf had the max count. maxcount = 0; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] > maxcount)) { maxcount = dp->df_count[i]; } @@ -2073,7 +2073,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) // buffers we need to know the largest count. max_count = 0; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (max_count < dp->df_count[i])) { max_count = dp->df_count[i]; } @@ -2219,7 +2219,7 @@ int diffopt_changed(void) } if (*p == ',') { - ++p; + p++; } } @@ -2322,7 +2322,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) int off = lnum - dp->df_lnum[idx]; int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (i != idx)) { // Skip lines that are not in the other change (filler lines). if (off >= dp->df_count[i]) { @@ -2430,7 +2430,7 @@ bool diff_infold(win_T *wp, linenr_T lnum) int idx = -1; int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (curtab->tp_diffbuf[i] == wp->w_buffer) { idx = i; } else if (curtab->tp_diffbuf[i] != NULL) { @@ -2480,7 +2480,7 @@ void nv_diffgetput(bool put, size_t count) if (count == 0) { ea.arg = (char_u *)""; } else { - vim_snprintf(buf, 30, "%zu", count); + vim_snprintf(buf, sizeof(buf), "%zu", count); ea.arg = (char_u *)buf; } @@ -2529,7 +2529,7 @@ void ex_diffgetput(exarg_T *eap) if (*eap->arg == NUL) { // No argument: Find the other buffer in the list of diff buffers. - for (idx_other = 0; idx_other < DB_COUNT; ++idx_other) { + for (idx_other = 0; idx_other < DB_COUNT; idx_other++) { if ((curtab->tp_diffbuf[idx_other] != curbuf) && (curtab->tp_diffbuf[idx_other] != NULL)) { if ((eap->cmdidx != CMD_diffput) @@ -2550,7 +2550,7 @@ void ex_diffgetput(exarg_T *eap) } // Check that there isn't a third buffer in the list - for (i = idx_other + 1; i < DB_COUNT; ++i) { + for (i = idx_other + 1; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != curbuf) && (curtab->tp_diffbuf[i] != NULL) && ((eap->cmdidx != CMD_diffput) @@ -2567,7 +2567,7 @@ void ex_diffgetput(exarg_T *eap) p--; } - for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; ++i) { + for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) { } if (eap->arg + i == p) { @@ -2610,9 +2610,9 @@ void ex_diffgetput(exarg_T *eap) && (eap->line1 == curbuf->b_ml.ml_line_count) && (diff_check(curwin, eap->line1) == 0) && ((eap->line1 == 1) || (diff_check(curwin, eap->line1 - 1) == 0))) { - ++eap->line2; + eap->line2++; } else if (eap->line1 > 0) { - --eap->line1; + eap->line1--; } } @@ -2703,14 +2703,14 @@ void ex_diffgetput(exarg_T *eap) buf_empty = buf_is_empty(curbuf); added = 0; - for (i = 0; i < count; ++i) { + for (i = 0; i < count; i++) { // remember deleting the last line of the buffer buf_empty = curbuf->b_ml.ml_line_count == 1; ml_delete(lnum, false); added--; } - for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i) { + for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; i++) { linenr_T nr = dp->df_lnum[idx_from] + start_skip + i; if (nr > curtab->tp_diffbuf[idx_from]->b_ml.ml_line_count) { break; @@ -2732,7 +2732,7 @@ void ex_diffgetput(exarg_T *eap) if ((start_skip == 0) && (end_skip == 0)) { // Check if there are any other buffers and if the diff is // equal in them. - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (i != idx_from) && (i != idx_to) @@ -2835,7 +2835,7 @@ theend: static void diff_fold_update(diff_T *dp, int skip_idx) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - for (int i = 0; i < DB_COUNT; ++i) { + for (int i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] == wp->w_buffer) && (i != skip_idx)) { foldUpdate(wp, dp->df_lnum[i], dp->df_lnum[i] + dp->df_count[i]); } diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 8eda173cac..c1fbc9a0f9 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1555,24 +1555,24 @@ static int getexactdigraph(int char1, int char2, bool meta_char) // Search user digraphs first. digr_T *dp = (digr_T *)user_digraphs.ga_data; - for (int i = 0; i < user_digraphs.ga_len; ++i) { + for (int i = 0; i < user_digraphs.ga_len; i++) { if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) { retval = dp->result; break; } - ++dp; + dp++; } // Search default digraphs. if (retval == 0) { dp = digraphdefault; - for (int i = 0; dp->char1 != 0; ++i) { + for (int i = 0; dp->char1 != 0; i++) { if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) { retval = dp->result; break; } - ++dp; + dp++; } } @@ -1647,12 +1647,12 @@ void putdigraph(char_u *str) dp = (digr_T *)user_digraphs.ga_data; int i; - for (i = 0; i < user_digraphs.ga_len; ++i) { + for (i = 0; i < user_digraphs.ga_len; i++) { if (((int)dp->char1 == char1) && ((int)dp->char2 == char2)) { dp->result = n; break; } - ++dp; + dp++; } // Add a new digraph to the table. @@ -1684,7 +1684,7 @@ void listdigraphs(bool use_headers) dp = digraphdefault; - for (int i = 0; dp->char1 != NUL && !got_int; ++i) { + for (int i = 0; dp->char1 != NUL && !got_int; i++) { digr_T tmp; // May need to convert the result to 'encoding'. @@ -1911,7 +1911,7 @@ void ex_loadkeymap(exarg_T *eap) } xfree(kp->from); xfree(kp->to); - --curbuf->b_kmap_ga.ga_len; + curbuf->b_kmap_ga.ga_len--; } } xfree(line); diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index 7948a7be83..c20716496f 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -53,10 +53,8 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher, const char *endpoint uv_getaddrinfo_t request; int retval = uv_getaddrinfo(&loop->uv, &request, NULL, addr, port, - &(struct addrinfo){ - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM, - }); + &(struct addrinfo){ .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM, }); if (retval != 0) { ELOG("Host lookup failed: %s", endpoint); return retval; @@ -103,10 +101,9 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb) // contain 0 in this case, unless uv_tcp_getsockname() is used first. uv_tcp_getsockname(&watcher->uv.tcp.handle, (struct sockaddr *)&sas, &(int){ sizeof(sas) }); - uint16_t port = (uint16_t)( - (sas.ss_family == AF_INET) - ? (STRUCT_CAST(struct sockaddr_in, &sas))->sin_port - : (STRUCT_CAST(struct sockaddr_in6, &sas))->sin6_port); + uint16_t port = (uint16_t)((sas.ss_family == AF_INET) + ? (STRUCT_CAST(struct sockaddr_in, &sas))->sin_port + : (STRUCT_CAST(struct sockaddr_in6, &sas))->sin6_port); // v:servername uses the string from watcher->addr size_t len = strlen(watcher->addr); snprintf(watcher->addr+len, sizeof(watcher->addr)-len, ":%" PRIu16, diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 8cc5bc2436..59ba2c92f7 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -70,7 +70,7 @@ int get_indent_str(const char_u *ptr, int ts, bool list) { int count = 0; - for (; *ptr; ++ptr) { + for (; *ptr; ptr++) { // Count a tab for what it is worth. if (*ptr == TAB) { if (!list || curwin->w_p_lcs_chars.tab1) { @@ -442,10 +442,9 @@ int get_breakindent_win(win_T *wp, char_u *line) static long *prev_vts = NULL; // Cached vartabs values. int bri = 0; // window width minus window margin space, i.e. what rests for text - const int eff_wwidth = wp->w_width_inner - - ((wp->w_p_nu || wp->w_p_rnu) - && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) - ? number_width(wp) + 1 : 0); + const int eff_wwidth = wp->w_width_inner - + ((wp->w_p_nu || wp->w_p_rnu) + && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) ? number_width(wp) + 1 : 0); // used cached indent, unless pointer or 'tabstop' changed if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts @@ -512,7 +511,7 @@ int inindent(int extra) char_u *ptr; colnr_T col; - for (col = 0, ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr); ++col) { + for (col = 0, ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr); col++) { ptr++; } @@ -630,7 +629,7 @@ int get_lisp_indent(void) continue; } - for (that = get_cursor_line_ptr(); *that != NUL; ++that) { + for (that = get_cursor_line_ptr(); *that != NUL; that++) { if (*that == ';') { while (*(that + 1) != NUL) { that++; diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 2b54e56df1..beea1959e1 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -286,9 +286,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) break; case LUA_TBOOLEAN: cur.tv->v_type = VAR_BOOL; - cur.tv->vval.v_bool = (lua_toboolean(lstate, -1) - ? kBoolVarTrue - : kBoolVarFalse); + cur.tv->vval.v_bool = (lua_toboolean(lstate, -1) ? kBoolVarTrue : kBoolVarFalse); break; case LUA_TSTRING: { size_t len; @@ -551,8 +549,8 @@ static bool typval_conv_special = false; const MPConvStackVal mpval = kv_A(*mpstack, backref - 1); \ if (mpval.type == conv_type) { \ if (conv_type == kMPConvDict \ - ? (void *)mpval.data.d.dict == (void *)(val) \ - : (void *)mpval.data.l.list == (void *)(val)) { \ + ? (void *)mpval.data.d.dict == (void *)(val) \ + : (void *)mpval.data.l.list == (void *)(val)) { \ lua_pushvalue(lstate, \ -((int)((kv_size(*mpstack) - backref + 1) * 2))); \ break; \ @@ -1133,10 +1131,7 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Error *const err) case LUA_TSTRING: { size_t len; const char *s = lua_tolstring(lstate, -1, &len); - *cur.obj = STRING_OBJ(((String) { - .data = xmemdupz(s, len), - .size = len, - })); + *cur.obj = STRING_OBJ(((String) { .data = xmemdupz(s, len), .size = len })); break; } case LUA_TNUMBER: { @@ -1154,11 +1149,7 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Error *const err) switch (table_props.type) { case kObjectTypeArray: - *cur.obj = ARRAY_OBJ(((Array) { - .items = NULL, - .size = 0, - .capacity = 0, - })); + *cur.obj = ARRAY_OBJ(((Array) { .items = NULL, .size = 0, .capacity = 0 })); if (table_props.maxidx != 0) { cur.obj->data.array.items = xcalloc(table_props.maxidx, @@ -1169,11 +1160,7 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Error *const err) } break; case kObjectTypeDictionary: - *cur.obj = DICTIONARY_OBJ(((Dictionary) { - .items = NULL, - .size = 0, - .capacity = 0, - })); + *cur.obj = DICTIONARY_OBJ(((Dictionary) { .items = NULL, .size = 0, .capacity = 0 })); if (table_props.string_keys_num != 0) { cur.obj->data.dictionary.items = xcalloc(table_props.string_keys_num, diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index e9868d6b61..b738d36234 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -720,7 +720,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo && dst[-1] != ':' #endif && vim_ispathsep(*tail)) { - ++tail; + tail++; } dst += c; src = tail; @@ -738,7 +738,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo at_start = false; if (src[0] == '\\' && src[1] != NUL) { *dst++ = *src++; - --dstlen; + dstlen--; } else if ((src[0] == ' ' || src[0] == ',') && !one) { at_start = true; } diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 99231968a2..ed9f4636e3 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -58,8 +58,7 @@ int pty_process_spawn(PtyProcess *ptyproc) if (os_has_conpty_working()) { if ((conpty_object = - os_conpty_init(&in_name, &out_name, - ptyproc->width, ptyproc->height)) != NULL) { + os_conpty_init(&in_name, &out_name, ptyproc->width, ptyproc->height)) != NULL) { ptyproc->type = kConpty; } } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 656e059303..5680cdbe42 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1229,7 +1229,7 @@ static void read_input(DynamicBuffer *buf) dynamic_buffer_ensure(buf, buf->len + 1); buf->data[buf->len++] = NL; } - ++lnum; + lnum++; if (lnum > curbuf->b_op_end.lnum) { break; } diff --git a/src/nvim/rbuffer.h b/src/nvim/rbuffer.h index cc690050ab..e86765a4ad 100644 --- a/src/nvim/rbuffer.h +++ b/src/nvim/rbuffer.h @@ -38,17 +38,15 @@ // create infinite loops #define RBUFFER_UNTIL_EMPTY(buf, rptr, rcnt) \ for (size_t rcnt = 0, _r = 1; _r; _r = 0) /* NOLINT(readability/braces) */ \ - for ( /* NOLINT(readability/braces) */ \ - char *rptr = rbuffer_read_ptr(buf, &rcnt); \ - buf->size; \ - rptr = rbuffer_read_ptr(buf, &rcnt)) + for (char *rptr = rbuffer_read_ptr(buf, &rcnt); /* NOLINT(readability/braces) */ \ + buf->size; \ + rptr = rbuffer_read_ptr(buf, &rcnt)) #define RBUFFER_UNTIL_FULL(buf, wptr, wcnt) \ for (size_t wcnt = 0, _r = 1; _r; _r = 0) /* NOLINT(readability/braces) */ \ - for ( /* NOLINT(readability/braces) */ \ - char *wptr = rbuffer_write_ptr(buf, &wcnt); \ - rbuffer_space(buf); \ - wptr = rbuffer_write_ptr(buf, &wcnt)) + for (char *wptr = rbuffer_write_ptr(buf, &wcnt); /* NOLINT(readability/braces) */ \ + rbuffer_space(buf); \ + wptr = rbuffer_write_ptr(buf, &wcnt)) // Iteration diff --git a/src/nvim/screen.h b/src/nvim/screen.h index d704a6eb8a..9e8a034d93 100644 --- a/src/nvim/screen.h +++ b/src/nvim/screen.h @@ -8,12 +8,10 @@ #include "nvim/pos.h" #include "nvim/types.h" -/* - * flags for update_screen() - * The higher the value, the higher the priority - */ -#define VALID 10 /* buffer not changed, or changes marked - with b_mod_* */ +// flags for update_screen() +// The higher the value, the higher the priority +#define VALID 10 // buffer not changed, or changes marked + // with b_mod_* #define INVERTED 20 // redisplay inverted part that changed #define INVERTED_ALL 25 // redisplay whole inverted part #define REDRAW_TOP 30 // display first w_upd_rows screen lines diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h index 526be905e9..a005f67209 100644 --- a/src/nvim/syntax_defs.h +++ b/src/nvim/syntax_defs.h @@ -21,9 +21,7 @@ struct sp_syn { int16_t *cont_in_list; // cont.in group IDs, if non-zero }; -/* - * Each keyword has one keyentry, which is linked in a hash list. - */ +// Each keyword has one keyentry, which is linked in a hash list. typedef struct keyentry keyentry_T; struct keyentry { @@ -35,9 +33,7 @@ struct keyentry { char_u keyword[1]; // actually longer }; -/* - * Struct used to store one state of the state stack. - */ +// Struct used to store one state of the state stack. typedef struct buf_state { int bs_idx; // index of pattern int bs_flags; // flags for pattern @@ -46,10 +42,8 @@ typedef struct buf_state { reg_extmatch_T *bs_extmatch; // external matches from start pattern } bufstate_T; -/* - * syn_state contains the syntax state stack for the start of one line. - * Used by b_sst_array[]. - */ +// syn_state contains the syntax state stack for the start of one line. +// Used by b_sst_array[]. struct syn_state { synstate_T *sst_next; // next entry in used or free list linenr_T sst_lnum; // line number for this state @@ -66,4 +60,4 @@ struct syn_state { // may have made the state invalid }; -#endif // NVIM_SYNTAX_DEFS_H +#endif // NVIM_SYNTAX_DEFS_H diff --git a/src/nvim/tag.h b/src/nvim/tag.h index 64bacceb1b..902fe0c7ba 100644 --- a/src/nvim/tag.h +++ b/src/nvim/tag.h @@ -4,9 +4,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/types.h" -/* - * Values for do_tag(). - */ +// Values for do_tag(). #define DT_TAG 1 // jump to newer position or same tag again #define DT_POP 2 // jump to older position #define DT_NEXT 3 // jump to next match of same tag @@ -20,9 +18,7 @@ #define DT_LTAG 11 // tag using location list #define DT_FREE 99 // free cached matches -// // flags for find_tags(). -// #define TAG_HELP 1 // only search for help tags #define TAG_NAMES 2 // only return name of tag #define TAG_REGEXP 4 // use tag pattern as regexp @@ -36,9 +32,7 @@ #define TAG_MANY 300 // When finding many tags (for completion), // find up to this many tags -/* - * Structure used for get_tagfname(). - */ +// Structure used for get_tagfname(). typedef struct { char_u *tn_tags; // value of 'tags' when starting char_u *tn_np; // current position in tn_tags diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index 3267b2f71e..d8470b07b1 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -33,8 +33,8 @@ struct u_entry { }; struct u_header { - /* The following have a pointer and a number. The number is used when - * reading the undo file in u_read_undo() */ + // The following have a pointer and a number. The number is used when reading + // the undo file in u_read_undo() union { u_header_T *ptr; // pointer to next undo header in list long seq; @@ -80,4 +80,4 @@ typedef struct { FILE *bi_fp; } bufinfo_T; -#endif // NVIM_UNDO_DEFS_H +#endif // NVIM_UNDO_DEFS_H diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index b2933c3781..b8835127e7 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -81,10 +81,8 @@ typedef struct { bool can_continuate; } ParserState; -static inline void viml_parser_init( - ParserState *const ret_pstate, - const ParserLineGetter get_line, void *const cookie, - ParserHighlight *const colors) +static inline void viml_parser_init(ParserState *const ret_pstate, const ParserLineGetter get_line, + void *const cookie, ParserHighlight *const colors) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2); /// Initialize a new parser state instance diff --git a/src/nvim/window.h b/src/nvim/window.h index 42701f72b4..b75b8abd9b 100644 --- a/src/nvim/window.h +++ b/src/nvim/window.h @@ -12,13 +12,11 @@ #define FNAME_EXP 2 // expand to path #define FNAME_HYP 4 // check for hypertext link #define FNAME_INCL 8 // apply 'includeexpr' -#define FNAME_REL 16 /* ".." and "./" are relative to the (current) - file instead of the current directory */ +#define FNAME_REL 16 // ".." and "./" are relative to the (current) + // file instead of the current directory #define FNAME_UNESC 32 // remove backslashes used for escaping -/* - * arguments for win_split() - */ +// arguments for win_split() #define WSP_ROOM 1 // require enough room #define WSP_VERT 2 // split vertically #define WSP_TOP 4 // window at top-left of shell @@ -28,9 +26,7 @@ #define WSP_ABOVE 64 // put new window above/left #define WSP_NEWLOC 128 // don't copy location list -/* - * Minimum screen size - */ +// Minimum screen size #define MIN_COLUMNS 12 // minimal columns for screen #define MIN_LINES 2 // minimal lines for screen |