diff options
author | Dundar Göc <gocdundar@gmail.com> | 2021-10-06 10:53:17 +0200 |
---|---|---|
committer | Dundar Göc <gocdundar@gmail.com> | 2021-10-06 11:50:10 +0200 |
commit | b4acae2c4a4d52ec79e7a04d9c55c2345e2a57cc (patch) | |
tree | 08e8096ebe61240e41d2c87e0bc472da787310e0 | |
parent | 41d3b98debb3c90306f301dad185a6b487fa4002 (diff) | |
download | rneovim-b4acae2c4a4d52ec79e7a04d9c55c2345e2a57cc.tar.gz rneovim-b4acae2c4a4d52ec79e7a04d9c55c2345e2a57cc.tar.bz2 rneovim-b4acae2c4a4d52ec79e7a04d9c55c2345e2a57cc.zip |
vim-patch:8.1.2392: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
https://github.com/vim/vim/commit/6e0ce171e19d0118ecd7c2b16e2a1bd50aa76013
-rw-r--r-- | src/nvim/normal.c | 91 | ||||
-rw-r--r-- | src/nvim/ops.c | 79 | ||||
-rw-r--r-- | src/nvim/option.c | 42 |
3 files changed, 103 insertions, 109 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 493c704f42..732e5ffc1f 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -349,8 +349,8 @@ static const struct nv_cmd { // Sorted index of commands in nv_cmds[]. static short nv_cmd_idx[NV_CMDS_SIZE]; -/* The highest index for which - * nv_cmds[idx].cmd_char == nv_cmd_idx[nv_cmds[idx].cmd_char] */ +// The highest index for which +// nv_cmds[idx].cmd_char == nv_cmd_idx[nv_cmds[idx].cmd_char] static int nv_max_linear; /* @@ -3623,8 +3623,8 @@ void do_check_scrollbind(bool check) static colnr_T old_leftcol = 0; if (check && curwin->w_p_scb) { - /* If a ":syncbind" command was just used, don't scroll, only reset - * the values. */ + // If a ":syncbind" command was just used, don't scroll, only reset + // the values. if (did_syncbind) { did_syncbind = false; } else if (curwin == old_curwin) { @@ -4264,8 +4264,8 @@ void scroll_redraw(int up, long count) break; } } - /* Mark w_topline as valid, otherwise the screen jumps back at the - * end of the file. */ + // Mark w_topline as valid, otherwise the screen jumps back at the + // end of the file. check_cursor_moved(curwin); curwin->w_valid |= VALID_TOPLINE; } @@ -4712,9 +4712,9 @@ dozet: if (ptr == NULL) { pos_T pos = curwin->w_cursor; - /* Find bad word under the cursor. When 'spell' is - * off this fails and find_ident_under_cursor() is - * used below. */ + // Find bad word under the cursor. When 'spell' is + // off this fails and find_ident_under_cursor() is + // used below. emsg_off++; len = spell_move_to(curwin, FORWARD, true, true, NULL); emsg_off--; @@ -4833,10 +4833,8 @@ static void nv_colon(cmdarg_T *cap) && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count || cap->oap->start.col > (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) - || did_emsg - )) { - /* The start of the operator has become invalid by the Ex command. - */ + || did_emsg)) { + // The start of the operator has become invalid by the Ex command. clearopbeep(cap->oap); } } @@ -5667,8 +5665,8 @@ static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrap } } - /* "/$" will put the cursor after the end of the line, may need to - * correct that here */ + // "/$" will put the cursor after the end of the line, may need to + // correct that here check_cursor(); return i; } @@ -5848,16 +5846,15 @@ static void nv_brackets(cmdarg_T *cap) } c = gchar_cursor(); if (c == '{' || c == '}') { - /* Must have found end/start of class: use it. - * Or found the place to be at. */ + // Must have found end/start of class: use it. + // Or found the place to be at. if ((c == findc && norm) || (n == 1 && !norm)) { new_pos = curwin->w_cursor; pos = &new_pos; n = 0; - } - /* if no match found at all, we started outside of the - * class and we're inside now. Just go on. */ - else if (new_pos.lnum == 0) { + } else if (new_pos.lnum == 0) { + // if no match found at all, we started outside of the + // class and we're inside now. Just go on. new_pos = curwin->w_cursor; pos = &new_pos; } @@ -6306,8 +6303,8 @@ static void v_swap_corners(int cmdchar) curwin->w_cursor.lnum = old_cursor.lnum; curwin->w_curswant = right; - /* 'selection "exclusive" and cursor at right-bottom corner: move it - * right one column */ + // 'selection "exclusive" and cursor at right-bottom corner: move it + // right one column if (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e') { ++curwin->w_curswant; } @@ -6479,8 +6476,8 @@ static void v_visop(cmdarg_T *cap) { static char_u trans[] = "YyDdCcxdXdAAIIrr"; - /* Uppercase means linewise, except in block mode, then "D" deletes till - * the end of the line, and "C" replaces till EOL */ + // Uppercase means linewise, except in block mode, then "D" deletes till + // the end of the line, and "C" replaces till EOL if (isupper(cap->cmdchar)) { if (VIsual_mode != Ctrl_V) { VIsual_mode_orig = VIsual_mode; @@ -6912,8 +6909,8 @@ static void nv_g_cmd(cmdarg_T *cap) VIsual_active = true; VIsual_reselect = true; - /* Set Visual to the start and w_cursor to the end of the Visual - * area. Make sure they are on an existing character. */ + // Set Visual to the start and w_cursor to the end of the Visual + // area. Make sure they are on an existing character. check_cursor(); VIsual = curwin->w_cursor; curwin->w_cursor = tpos; @@ -6956,10 +6953,9 @@ static void nv_g_cmd(cmdarg_T *cap) nv_visual(cap); break; - /* "gn", "gN" visually select next/previous search match - * "gn" selects next match - * "gN" selects previous match - */ + // "gn", "gN" visually select next/previous search match + // "gn" selects next match + // "gN" selects previous match case 'N': case 'n': if (!current_search(cap->count1, cap->nchar == 'n')) { @@ -7033,9 +7029,9 @@ static void nv_g_cmd(cmdarg_T *cap) } else { i = curwin->w_leftcol; } - /* Go to the middle of the screen line. When 'number' or - * 'relativenumber' is on and lines are wrapping the middle can be more - * to the left. */ + // Go to the middle of the screen line. When 'number' or + // 'relativenumber' is on and lines are wrapping the middle can be more + // to the left. if (cap->nchar == 'm') { i += (curwin->w_width_inner - curwin_col_off() + ((curwin->w_p_wrap && i > 0) @@ -7683,11 +7679,10 @@ static void nv_wordcmd(cmdarg_T *cap) */ static void adjust_cursor(oparg_T *oap) { - /* The cursor cannot remain on the NUL when: - * - the column is > 0 - * - not in Visual mode or 'selection' is "o" - * - 'virtualedit' is not "all" and not "onemore". - */ + // The cursor cannot remain on the NUL when: + // - the column is > 0 + // - not in Visual mode or 'selection' is "o" + // - 'virtualedit' is not "all" and not "onemore". if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL && (!VIsual_active || *p_sel == 'o') && !virtual_active() && @@ -7956,8 +7951,8 @@ static void nv_edit(cmdarg_T *cap) if (curwin->w_cursor.coladd && cap->cmdchar != 'A') { int save_State = State; - /* Pretend Insert mode here to allow the cursor on the - * character past the end of the line */ + // Pretend Insert mode here to allow the cursor on the + // character past the end of the line State = INSERT; coladvance(getviscol()); State = save_State; @@ -7974,9 +7969,9 @@ static void invoke_edit(cmdarg_T *cap, int repl, int cmd, int startln) { int restart_edit_save = 0; - /* Complicated: When the user types "a<C-O>a" we don't want to do Insert - * mode recursively. But when doing "a<C-O>." or "a<C-O>rx" we do allow - * it. */ + // Complicated: When the user types "a<C-O>a" we don't want to do Insert + // mode recursively. But when doing "a<C-O>." or "a<C-O>rx" we do allow + // it. if (repl || !stuff_empty()) { restart_edit_save = restart_edit; } else { @@ -8260,8 +8255,8 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) && curwin->w_cursor.col < curbuf->b_op_start.col) || (VIsual_mode == 'V' && curwin->w_cursor.lnum < curbuf->b_op_start.lnum)) { - /* cursor is at the end of the line or end of file, put - * forward. */ + // cursor is at the end of the line or end of file, put + // forward. dir = FORWARD; } // May have been reset in do_put(). @@ -8275,8 +8270,8 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) xfree(savereg); } - /* What to reselect with "gv"? Selecting the just put text seems to - * be the most useful, since the original text was removed. */ + // What to reselect with "gv"? Selecting the just put text seems to + // be the most useful, since the original text was removed. if (was_visual) { curbuf->b_visual.vi_start = curbuf->b_op_start; curbuf->b_visual.vi_end = curbuf->b_op_end; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 1d737ee9fc..8d36bc9aa4 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -435,9 +435,9 @@ static void shift_block(oparg_T *oap, int amount) * non-whitespace character. */ - /* If "bd.startspaces" is set, "bd.textstart" points to the character, - * the part of which is displayed at the block's beginning. Let's start - * searching from the next character. */ + // If "bd.startspaces" is set, "bd.textstart" points to the character, + // the part of which is displayed at the block's beginning. Let's start + // searching from the next character. if (bd.startspaces) { MB_PTR_ADV(non_white); } @@ -614,8 +614,8 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def skipped, offset-startcol, kExtmarkUndo); if (lnum == oap->end.lnum) { - /* Set "']" mark to the end of the block instead of the end of - * the insert in the first line. */ + // Set "']" mark to the end of the block instead of the end of + // the insert in the first line. curbuf->b_op_end.lnum = oap->end.lnum; curbuf->b_op_end.col = offset; } @@ -1846,8 +1846,8 @@ int op_replace(oparg_T *oap, int c) numc -= (oap->end_vcol - bd.end_vcol) + 1; } - /* A double-wide character can be replaced only up to half the - * times. */ + // A double-wide character can be replaced only up to half the + // times. if ((*mb_char2cells)(c) > 1) { if ((numc & 1) && !bd.is_short) { ++bd.endspaces; @@ -1938,8 +1938,8 @@ int op_replace(oparg_T *oap, int c) n = gchar_cursor(); if (n != NUL) { if ((*mb_char2len)(c) > 1 || (*mb_char2len)(n) > 1) { - /* This is slow, but it handles replacing a single-byte - * with a multi-byte and the other way around. */ + // This is slow, but it handles replacing a single-byte + // with a multi-byte and the other way around. if (curwin->w_cursor.lnum == oap->end.lnum) { oap->end.col += (*mb_char2len)(c) - (*mb_char2len)(n); } @@ -1949,8 +1949,8 @@ int op_replace(oparg_T *oap, int c) int end_vcol = 0; if (curwin->w_cursor.lnum == oap->end.lnum) { - /* oap->end has to be recalculated when - * the tab breaks */ + // oap->end has to be recalculated when + // the tab breaks end_vcol = getviscol2(oap->end.col, oap->end.coladd); } @@ -1969,9 +1969,9 @@ int op_replace(oparg_T *oap, int c) virtcols -= oap->start.coladd; } - /* oap->end has been trimmed so it's effectively inclusive; - * as a result an extra +1 must be counted so we don't - * trample the NUL byte. */ + // oap->end has been trimmed so it's effectively inclusive; + // as a result an extra +1 must be counted so we don't + // trample the NUL byte. coladvance_force(getviscol2(oap->end.col, oap->end.coladd) + 1); curwin->w_cursor.col -= (virtcols + 1); for (; virtcols >= 0; virtcols--) { @@ -2228,8 +2228,8 @@ void op_insert(oparg_T *oap, long count1) ++curwin->w_cursor.col; } if (bd.is_short && !bd.is_MAX) { - /* First line was too short, make it longer and adjust the - * values in "bd". */ + // First line was too short, make it longer and adjust the + // values in "bd". if (u_save_cursor() == FAIL) { return; } @@ -2386,8 +2386,8 @@ int op_change(oparg_T *oap) } } - /* First delete the text in the region. In an empty buffer only need to - * save for undo */ + // First delete the text in the region. In an empty buffer only need to + // save for undo if (curbuf->b_ml.ml_flags & ML_EMPTY) { if (u_save_cursor() == FAIL) { return FALSE; @@ -3872,10 +3872,9 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co ++comment_flags; } - /* If we found a colon, it means that we are not processing a line - * starting with a closing part of a three-part comment. That's good, - * because we don't want to remove those as this would be annoying. - */ + // If we found a colon, it means that we are not processing a line + // starting with a closing part of a three-part comment. That's good, + // because we don't want to remove those as this would be annoying. if (*comment_flags == ':' || *comment_flags == NUL) { line += lead_len; } @@ -4054,8 +4053,8 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions curwin->w_buffer->b_op_end.col = sumsize; } - /* Only report the change in the first line here, del_lines() will report - * the deleted line. */ + // Only report the change in the first line here, del_lines() will report + // the deleted line. changed_lines(curwin->w_cursor.lnum, currsize, curwin->w_cursor.lnum + 1, 0L, true); @@ -4172,8 +4171,8 @@ void op_format(oparg_T *oap, int keep_cursor) { long old_line_count = curbuf->b_ml.ml_line_count; - /* Place the cursor where the "gq" or "gw" command was given, so that "u" - * can put it back there. */ + // Place the cursor where the "gq" or "gw" command was given, so that "u" + // can put it back there. curwin->w_cursor = oap->cursor_start; if (u_save((linenr_T)(oap->start.lnum - 1), @@ -4190,8 +4189,8 @@ void op_format(oparg_T *oap, int keep_cursor) // Set '[ mark at the start of the formatted area curbuf->b_op_start = oap->start; - /* For "gw" remember the cursor position and put it back below (adjusted - * for joined and split lines). */ + // For "gw" remember the cursor position and put it back below (adjusted + // for joined and split lines). if (keep_cursor) { saved_cursor = oap->cursor_start; } @@ -4221,8 +4220,8 @@ void op_format(oparg_T *oap, int keep_cursor) if (oap->is_VIsual) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp->w_old_cursor_lnum != 0) { - /* When lines have been inserted or deleted, adjust the end of - * the Visual area to be redrawn. */ + // When lines have been inserted or deleted, adjust the end of + // the Visual area to be redrawn. if (wp->w_old_cursor_lnum > wp->w_old_visual_lnum) { wp->w_old_cursor_lnum += old_line_count; } else { @@ -4244,9 +4243,9 @@ void op_formatexpr(oparg_T *oap) } if (fex_format(oap->start.lnum, oap->line_count, NUL) != 0) { - /* As documented: when 'formatexpr' returns non-zero fall back to - * internal formatting. */ - op_format(oap, FALSE); + // As documented: when 'formatexpr' returns non-zero fall back to + // internal formatting. + op_format(oap, false); } } @@ -4424,8 +4423,8 @@ void format_lines(linenr_T line_count, int avoid_fex) */ if (is_end_par || force_format) { if (need_set_indent) { - /* replace indent in first line with minimal number of - * tabs and spaces, according to current options */ + // replace indent in first line with minimal number of + // tabs and spaces, according to current options (void)set_indent(get_indent(), SIN_CHANGED); } @@ -4451,8 +4450,8 @@ void format_lines(linenr_T line_count, int avoid_fex) // at end of par.: need to set indent of next par. need_set_indent = is_end_par; if (is_end_par) { - /* When called with a negative line count, break at the - * end of the paragraph. */ + // When called with a negative line count, break at the + // end of the paragraph. if (line_count < 0) { break; } @@ -4674,9 +4673,9 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool } else { bdp->startspaces = oap->end_vcol - oap->start_vcol + 1; if (is_del && oap->op_type != OP_LSHIFT) { - /* just putting the sum of those two into - * bdp->startspaces doesn't work for Visual replace, - * so we have to split the tab in two */ + // just putting the sum of those two into + // bdp->startspaces doesn't work for Visual replace, + // so we have to split the tab in two bdp->startspaces = bdp->start_char_vcols - (bdp->start_vcol - oap->start_vcol); bdp->endspaces = bdp->end_vcol - oap->end_vcol - 1; diff --git a/src/nvim/option.c b/src/nvim/option.c index 5646a62cd4..e6c7e416fb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -615,8 +615,8 @@ static void set_option_default(int opt_idx, int opt_flags) uint32_t flags = options[opt_idx].flags; if (varp != NULL) { // skip hidden option, nothing to do for it if (flags & P_STRING) { - /* Use set_string_option_direct() for local options to handle - * freeing and allocating the value. */ + // Use set_string_option_direct() for local options to handle + // freeing and allocating the value. if (options[opt_idx].indir != PV_NONE) { set_string_option_direct(NULL, opt_idx, options[opt_idx].def_val, opt_flags, 0); @@ -1094,8 +1094,8 @@ int do_set(char_u *arg, int opt_flags) flags = P_STRING; } - /* Skip all options that are not window-local (used when showing - * an already loaded buffer in a window). */ + // Skip all options that are not window-local (used when showing + // an already loaded buffer in a window). if ((opt_flags & OPT_WINONLY) && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) { goto skip; @@ -1514,8 +1514,8 @@ int do_set(char_u *arg, int opt_flags) } } - /* concatenate the two strings; add a ',' if - * needed */ + // concatenate the two strings; add a ',' if + // needed if (adding || prepending) { comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL); @@ -1540,8 +1540,8 @@ int do_set(char_u *arg, int opt_flags) } } - /* Remove newval[] from origval[]. (Note: "i" has - * been set above and is used here). */ + // Remove newval[] from origval[]. (Note: "i" has + // been set above and is used here). if (removing) { STRCPY(newval, origval); if (*s) { @@ -4044,8 +4044,8 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va } } - /* Arabic requires a utf-8 encoding, inform the user if its not - * set. */ + // Arabic requires a utf-8 encoding, inform the user if its not + // set. if (STRCMP(p_enc, "utf-8") != 0) { static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); @@ -4070,12 +4070,12 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va changed_window_setting(); } - /* 'arabicshape' isn't reset, it is a global option and - * another window may still need it "on". */ + // 'arabicshape' isn't reset, it is a global option and + // another window may still need it "on". } - /* 'delcombine' isn't reset, it is a global option and another - * window may still want it "on". */ + // 'delcombine' isn't reset, it is a global option and another + // window may still want it "on". // Revert to the default keymap curbuf->b_p_iminsert = B_IMODE_NONE; @@ -5218,8 +5218,8 @@ int makeset(FILE *fd, int opt_flags, int local_only) continue; } - /* Do not store options like 'bufhidden' and 'syntax' in a vimrc - * file, they are always buffer-specific. */ + // Do not store options like 'bufhidden' and 'syntax' in a vimrc + // file, they are always buffer-specific. if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) { continue; } @@ -5339,9 +5339,9 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint6 return FAIL; } if (*valuep != NULL) { - /* Output 'pastetoggle' as key names. For other - * options some characters have to be escaped with - * CTRL-V or backslash */ + // Output 'pastetoggle' as key names. For other + // options some characters have to be escaped with + // CTRL-V or backslash if (valuep == &p_pt) { s = *valuep; while (*s != NUL) { @@ -6607,8 +6607,8 @@ void ExpandOldSetting(int *num_file, char_u ***file) char_u *buf = vim_strsave_escaped(var, escape_chars); #ifdef BACKSLASH_IN_FILENAME - /* For MS-Windows et al. we don't double backslashes at the start and - * before a file name character. */ + // For MS-Windows et al. we don't double backslashes at the start and + // before a file name character. for (var = buf; *var != NUL; MB_PTR_ADV(var)) { if (var[0] == '\\' && var[1] == '\\' && expand_option_idx >= 0 |