patch 8.1.2392: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
diff --git a/src/ops.c b/src/ops.c
index f269f35..d3e1e47 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -72,13 +72,13 @@
{
int i;
- if (char1 == 'r') /* ignore second character */
+ if (char1 == 'r') // ignore second character
return OP_REPLACE;
- if (char1 == '~') /* when tilde is an operator */
+ if (char1 == '~') // when tilde is an operator
return OP_TILDE;
- if (char1 == 'g' && char2 == Ctrl_A) /* add */
+ if (char1 == 'g' && char2 == Ctrl_A) // add
return OP_NR_ADD;
- if (char1 == 'g' && char2 == Ctrl_X) /* subtract */
+ if (char1 == 'g' && char2 == Ctrl_X) // subtract
return OP_NR_SUB;
for (i = 0; ; ++i)
{
@@ -152,13 +152,13 @@
for (i = oap->line_count; --i >= 0; )
{
first_char = *ml_get_curline();
- if (first_char == NUL) /* empty line */
+ if (first_char == NUL) // empty line
curwin->w_cursor.col = 0;
else if (oap->block_mode)
shift_block(oap, amount);
else
- /* Move the line right if it doesn't start with '#', 'smartindent'
- * isn't set or 'cindent' isn't set or '#' isn't in 'cino'. */
+ // Move the line right if it doesn't start with '#', 'smartindent'
+ // isn't set or 'cindent' isn't set or '#' isn't in 'cino'.
#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
if (first_char != '#' || !preprocs_left())
#endif
@@ -172,16 +172,16 @@
curwin->w_cursor.lnum = oap->start.lnum;
curwin->w_cursor.col = block_col;
}
- else if (curs_top) /* put cursor on first line, for ">>" */
+ else if (curs_top) // put cursor on first line, for ">>"
{
curwin->w_cursor.lnum = oap->start.lnum;
- beginline(BL_SOL | BL_FIX); /* shift_line() may have set cursor.col */
+ beginline(BL_SOL | BL_FIX); // shift_line() may have set cursor.col
}
else
- --curwin->w_cursor.lnum; /* put cursor on last line, for ":>" */
+ --curwin->w_cursor.lnum; // put cursor on last line, for ":>"
#ifdef FEAT_FOLDING
- /* The cursor line is not in a closed fold */
+ // The cursor line is not in a closed fold
foldOpenCursor();
#endif
@@ -291,18 +291,18 @@
#ifdef FEAT_RIGHTLEFT
int old_p_ri = p_ri;
- p_ri = 0; /* don't want revins in indent */
+ p_ri = 0; // don't want revins in indent
#endif
- State = INSERT; /* don't want REPLACE for State */
+ State = INSERT; // don't want REPLACE for State
block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE);
if (bd.is_short)
return;
- /* total is number of screen columns to be inserted/removed */
+ // total is number of screen columns to be inserted/removed
total = (int)((unsigned)amount * (unsigned)sw_val);
if ((total / sw_val) != amount)
- return; /* multiplication overflow */
+ return; // multiplication overflow
oldp = ml_get_curline();
@@ -314,7 +314,7 @@
* 3. Divvy into TABs & spp
* 4. Construct new string
*/
- total += bd.pre_whitesp; /* all virtual WS upto & incl a split TAB */
+ total += bd.pre_whitesp; // all virtual WS upto & incl a split TAB
ws_vcol = bd.start_vcol - bd.pre_whitesp;
if (bd.startspaces)
{
@@ -333,14 +333,14 @@
}
for ( ; VIM_ISWHITE(*bd.textstart); )
{
- /* TODO: is passing bd.textstart for start of the line OK? */
+ // TODO: is passing bd.textstart for start of the line OK?
incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart,
(colnr_T)(bd.start_vcol));
total += incr;
bd.start_vcol += incr;
}
- /* OK, now total=all the VWS reqd, and textstart points at the 1st
- * non-ws char in the block. */
+ // OK, now total=all the VWS reqd, and textstart points at the 1st
+ // non-ws char in the block.
#ifdef FEAT_VARTABS
if (!curbuf->b_p_et)
tabstop_fromto(ws_vcol, ws_vcol + total,
@@ -349,13 +349,13 @@
j = total;
#else
if (!curbuf->b_p_et)
- i = ((ws_vcol % ts_val) + total) / ts_val; /* number of tabs */
+ i = ((ws_vcol % ts_val) + total) / ts_val; // number of tabs
if (i)
- j = ((ws_vcol % ts_val) + total) % ts_val; /* number of spp */
+ j = ((ws_vcol % ts_val) + total) % ts_val; // number of spp
else
j = total;
#endif
- /* if we're splitting a TAB, allow for it */
+ // if we're splitting a TAB, allow for it
bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0);
len = (int)STRLEN(bd.textstart) + 1;
newp = alloc(bd.textcol + i + j + len);
@@ -365,20 +365,20 @@
mch_memmove(newp, oldp, (size_t)bd.textcol);
vim_memset(newp + bd.textcol, TAB, (size_t)i);
vim_memset(newp + bd.textcol + i, ' ', (size_t)j);
- /* the end */
+ // the end
mch_memmove(newp + bd.textcol + i + j, bd.textstart, (size_t)len);
}
- else /* left */
+ else // left
{
- colnr_T destination_col; /* column to which text in block will
- be shifted */
- char_u *verbatim_copy_end; /* end of the part of the line which is
- copied verbatim */
- colnr_T verbatim_copy_width;/* the (displayed) width of this part
- of line */
- unsigned fill; /* nr of spaces that replace a TAB */
- unsigned new_line_len; /* the length of the line after the
- block shift */
+ colnr_T destination_col; // column to which text in block will
+ // be shifted
+ char_u *verbatim_copy_end; // end of the part of the line which is
+ // copied verbatim
+ colnr_T verbatim_copy_width;// the (displayed) width of this part
+ // of line
+ unsigned fill; // nr of spaces that replace a TAB
+ unsigned new_line_len; // the length of the line after the
+ // block shift
size_t block_space_width;
size_t shift_amount;
char_u *non_white = bd.textstart;
@@ -392,13 +392,13 @@
* 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);
- /* The character's column is in "bd.start_vcol". */
+ // The character's column is in "bd.start_vcol".
non_white_col = bd.start_vcol;
while (VIM_ISWHITE(*non_white))
@@ -408,29 +408,28 @@
}
block_space_width = non_white_col - oap->start_vcol;
- /* We will shift by "total" or "block_space_width", whichever is less.
- */
+ // We will shift by "total" or "block_space_width", whichever is less.
shift_amount = (block_space_width < (size_t)total
? block_space_width : (size_t)total);
- /* The column to which we will shift the text. */
+ // The column to which we will shift the text.
destination_col = (colnr_T)(non_white_col - shift_amount);
- /* Now let's find out how much of the beginning of the line we can
- * reuse without modification. */
+ // Now let's find out how much of the beginning of the line we can
+ // reuse without modification.
verbatim_copy_end = bd.textstart;
verbatim_copy_width = bd.start_vcol;
- /* If "bd.startspaces" is set, "bd.textstart" points to the character
- * preceding the block. We have to subtract its width to obtain its
- * column number. */
+ // If "bd.startspaces" is set, "bd.textstart" points to the character
+ // preceding the block. We have to subtract its width to obtain its
+ // column number.
if (bd.startspaces)
verbatim_copy_width -= bd.start_char_vcols;
while (verbatim_copy_width < destination_col)
{
char_u *line = verbatim_copy_end;
- /* TODO: is passing verbatim_copy_end for start of the line OK? */
+ // TODO: is passing verbatim_copy_end for start of the line OK?
incr = lbr_chartabsize(line, verbatim_copy_end,
verbatim_copy_width);
if (verbatim_copy_width + incr > destination_col)
@@ -439,15 +438,15 @@
MB_PTR_ADV(verbatim_copy_end);
}
- /* If "destination_col" is different from the width of the initial
- * part of the line that will be copied, it means we encountered a tab
- * character, which we will have to partly replace with spaces. */
+ // If "destination_col" is different from the width of the initial
+ // part of the line that will be copied, it means we encountered a tab
+ // character, which we will have to partly replace with spaces.
fill = destination_col - verbatim_copy_width;
- /* The replacement line will consist of:
- * - the beginning of the original line up to "verbatim_copy_end",
- * - "fill" number of spaces,
- * - the rest of the line, pointed to by non_white. */
+ // The replacement line will consist of:
+ // - the beginning of the original line up to "verbatim_copy_end",
+ // - "fill" number of spaces,
+ // - the rest of the line, pointed to by non_white.
new_line_len = (unsigned)(verbatim_copy_end - oldp)
+ fill
+ (unsigned)STRLEN(non_white) + 1;
@@ -459,7 +458,7 @@
vim_memset(newp + (verbatim_copy_end - oldp), ' ', (size_t)fill);
STRMOVE(newp + (verbatim_copy_end - oldp) + fill, non_white);
}
- /* replace the line */
+ // replace the line
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol);
State = oldstate;
@@ -481,22 +480,22 @@
struct block_def *bdp)
{
int ts_val;
- int count = 0; /* extra spaces to replace a cut TAB */
- int spaces = 0; /* non-zero if cutting a TAB */
- colnr_T offset; /* pointer along new line */
- unsigned s_len; /* STRLEN(s) */
- char_u *newp, *oldp; /* new, old lines */
- linenr_T lnum; /* loop var */
+ int count = 0; // extra spaces to replace a cut TAB
+ int spaces = 0; // non-zero if cutting a TAB
+ colnr_T offset; // pointer along new line
+ unsigned s_len; // STRLEN(s)
+ char_u *newp, *oldp; // new, old lines
+ linenr_T lnum; // loop var
int oldstate = State;
- State = INSERT; /* don't want REPLACE for State */
+ State = INSERT; // don't want REPLACE for State
s_len = (unsigned)STRLEN(s);
for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
- continue; /* OP_INSERT, line ends before block start */
+ continue; // OP_INSERT, line ends before block start
oldp = ml_get(lnum);
@@ -505,22 +504,22 @@
ts_val = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
- count = ts_val - 1; /* we're cutting a TAB */
+ count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol;
}
- else /* append */
+ else // append
{
ts_val = bdp->end_char_vcols;
- if (!bdp->is_short) /* spaces = padding after block */
+ if (!bdp->is_short) // spaces = padding after block
{
spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);
if (spaces != 0)
- count = ts_val - 1; /* we're cutting a TAB */
+ count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol + bdp->textlen - (spaces != 0);
}
- else /* spaces = padding to block edge */
+ else // spaces = padding to block edge
{
- /* if $ used, just append to EOL (ie spaces==0) */
+ // if $ used, just append to EOL (ie spaces==0)
if (!bdp->is_MAX)
spaces = (oap->end_vcol - bdp->end_vcol) + 1;
count = spaces;
@@ -532,7 +531,7 @@
{
int off;
- /* Avoid starting halfway a multi-byte character. */
+ // Avoid starting halfway a multi-byte character.
if (b_insert)
{
off = (*mb_head_off)(oldp, oldp + offset + spaces);
@@ -550,24 +549,24 @@
if (newp == NULL)
continue;
- /* copy up to shifted part */
+ // copy up to shifted part
mch_memmove(newp, oldp, (size_t)(offset));
oldp += offset;
- /* insert pre-padding */
+ // insert pre-padding
vim_memset(newp + offset, ' ', (size_t)spaces);
- /* copy the new text */
+ // copy the new text
mch_memmove(newp + offset + spaces, s, (size_t)s_len);
offset += s_len;
if (spaces && !bdp->is_short)
{
- /* insert post-padding */
+ // insert post-padding
vim_memset(newp + offset + spaces, ' ', (size_t)(ts_val - spaces));
- /* We're splitting a TAB, don't copy it. */
+ // We're splitting a TAB, don't copy it.
oldp++;
- /* We allowed for that TAB, remember this now */
+ // We allowed for that TAB, remember this now
count++;
}
@@ -579,12 +578,12 @@
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;
}
- } /* for all lnum */
+ } // for all lnum
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
@@ -603,13 +602,13 @@
while (*arg != NUL)
{
- /* Stuff a sequence of normal ASCII characters, that's fast. Also
- * stuff K_SPECIAL to get the effect of a special key when "literally"
- * is TRUE. */
+ // Stuff a sequence of normal ASCII characters, that's fast. Also
+ // stuff K_SPECIAL to get the effect of a special key when "literally"
+ // is TRUE.
start = arg;
while ((*arg >= ' '
#ifndef EBCDIC
- && *arg < DEL /* EBCDIC: chars above space are normal */
+ && *arg < DEL // EBCDIC: chars above space are normal
#endif
)
|| (*arg == K_SPECIAL && !literally))
@@ -617,7 +616,7 @@
if (arg > start)
stuffReadbuffLen(start, (long)(arg - start));
- /* stuff a single special character */
+ // stuff a single special character
if (*arg != NUL)
{
if (has_mbyte)
@@ -647,10 +646,10 @@
linenr_T old_lcount = curbuf->b_ml.ml_line_count;
int did_yank = FALSE;
- if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to do */
+ if (curbuf->b_ml.ml_flags & ML_EMPTY) // nothing to do
return OK;
- /* Nothing to delete, return here. Do prepare undo, for op_change(). */
+ // Nothing to delete, return here. Do prepare undo, for op_change().
if (oap->empty)
return u_save_cursor();
@@ -701,8 +700,8 @@
* 'cpoptions' (Vi compatible).
*/
if (virtual_op)
- /* Virtual editing: Nothing gets deleted, but we set the '[ and ']
- * marks as if it happened. */
+ // Virtual editing: Nothing gets deleted, but we set the '[ and ']
+ // marks as if it happened.
goto setmarks;
if (vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL)
beep_flush();
@@ -718,14 +717,14 @@
{
if (oap->regname != 0)
{
- /* check for read-only register */
+ // check for read-only register
if (!valid_yank_reg(oap->regname, TRUE))
{
beep_flush();
return OK;
}
- get_yank_register(oap->regname, TRUE); /* yank into specif'd reg. */
- if (op_yank(oap, TRUE, FALSE) == OK) /* yank without message */
+ get_yank_register(oap->regname, TRUE); // yank into specif'd reg.
+ if (op_yank(oap, TRUE, FALSE) == OK) // yank without message
did_yank = TRUE;
}
@@ -744,8 +743,8 @@
did_yank = TRUE;
}
- /* Yank into small delete register when no named register specified
- * and the delete is within one line. */
+ // Yank into small delete register when no named register specified
+ // and the delete is within one line.
if ((
#ifdef FEAT_CLIPBOARD
((clip_unnamed & CLIP_UNNAMED) && oap->regname == '*') ||
@@ -771,7 +770,7 @@
{
int msg_silent_save = msg_silent;
- msg_silent = 0; /* must display the prompt */
+ msg_silent = 0; // must display the prompt
n = ask_yesno((char_u *)_("cannot yank; delete anyway"), TRUE);
msg_silent = msg_silent_save;
if (n != 'y')
@@ -799,10 +798,10 @@
for (lnum = curwin->w_cursor.lnum; lnum <= oap->end.lnum; ++lnum)
{
block_prep(oap, &bd, lnum, TRUE);
- if (bd.textlen == 0) /* nothing to delete */
+ if (bd.textlen == 0) // nothing to delete
continue;
- /* Adjust cursor position for tab replaced by spaces and 'lbr'. */
+ // Adjust cursor position for tab replaced by spaces and 'lbr'.
if (lnum == curwin->w_cursor.lnum)
{
curwin->w_cursor.col = bd.textcol + bd.startspaces;
@@ -817,15 +816,15 @@
newp = alloc(STRLEN(oldp) + 1 - n);
if (newp == NULL)
continue;
- /* copy up to deleted part */
+ // copy up to deleted part
mch_memmove(newp, oldp, (size_t)bd.textcol);
- /* insert spaces */
+ // insert spaces
vim_memset(newp + bd.textcol, ' ',
(size_t)(bd.startspaces + bd.endspaces));
- /* copy the part after the deleted part */
+ // copy the part after the deleted part
oldp += bd.textcol + bd.textlen;
STRMOVE(newp + bd.textcol + bd.startspaces + bd.endspaces, oldp);
- /* replace the line */
+ // replace the line
ml_replace(lnum, newp, FALSE);
#ifdef FEAT_PROP_POPUP
@@ -837,16 +836,15 @@
check_cursor_col();
changed_lines(curwin->w_cursor.lnum, curwin->w_cursor.col,
oap->end.lnum + 1, 0L);
- oap->line_count = 0; /* no lines deleted */
+ oap->line_count = 0; // no lines deleted
}
else if (oap->motion_type == MLINE)
{
if (oap->op_type == OP_CHANGE)
{
- /* Delete the lines except the first one. Temporarily move the
- * cursor to the next line. Save the current line number, if the
- * last line is deleted it may be changed.
- */
+ // Delete the lines except the first one. Temporarily move the
+ // cursor to the next line. Save the current line number, if the
+ // last line is deleted it may be changed.
if (oap->line_count > 1)
{
lnum = curwin->w_cursor.lnum;
@@ -856,24 +854,24 @@
}
if (u_save_cursor() == FAIL)
return FAIL;
- if (curbuf->b_p_ai) /* don't delete indent */
+ if (curbuf->b_p_ai) // don't delete indent
{
- beginline(BL_WHITE); /* cursor on first non-white */
- did_ai = TRUE; /* delete the indent when ESC hit */
+ beginline(BL_WHITE); // cursor on first non-white
+ did_ai = TRUE; // delete the indent when ESC hit
ai_col = curwin->w_cursor.col;
}
else
- beginline(0); /* cursor in column 0 */
- truncate_line(FALSE); /* delete the rest of the line */
- /* leave cursor past last char in line */
+ beginline(0); // cursor in column 0
+ truncate_line(FALSE); // delete the rest of the line
+ // leave cursor past last char in line
if (oap->line_count > 1)
- u_clearline(); /* "U" command not possible after "2cc" */
+ u_clearline(); // "U" command not possible after "2cc"
}
else
{
del_lines(oap->line_count, TRUE);
beginline(BL_WHITE | BL_FIX);
- u_clearline(); /* "U" command not possible after "dd" */
+ u_clearline(); // "U" command not possible after "dd"
}
}
else
@@ -882,10 +880,10 @@
{
int endcol = 0;
- /* For virtualedit: break the tabs that are partly included. */
+ // For virtualedit: break the tabs that are partly included.
if (gchar_pos(&oap->start) == '\t')
{
- if (u_save_cursor() == FAIL) /* save first line for undo */
+ if (u_save_cursor() == FAIL) // save first line for undo
return FAIL;
if (oap->line_count == 1)
endcol = getviscol2(oap->end.col, oap->end.coladd);
@@ -900,11 +898,11 @@
}
}
- /* Break a tab only when it's included in the area. */
+ // Break a tab only when it's included in the area.
if (gchar_pos(&oap->end) == '\t'
&& (int)oap->end.coladd < oap->inclusive)
{
- /* save last line for undo */
+ // save last line for undo
if (u_save((linenr_T)(oap->end.lnum - 1),
(linenr_T)(oap->end.lnum + 1)) == FAIL)
return FAIL;
@@ -917,12 +915,12 @@
mb_adjust_opend(oap);
}
- if (oap->line_count == 1) /* delete characters within one line */
+ if (oap->line_count == 1) // delete characters within one line
{
- if (u_save_cursor() == FAIL) /* save line for undo */
+ if (u_save_cursor() == FAIL) // save line for undo
return FAIL;
- /* if 'cpoptions' contains '$', display '$' at end of change */
+ // if 'cpoptions' contains '$', display '$' at end of change
if ( vim_strchr(p_cpo, CPO_DOLLAR) != NULL
&& oap->op_type == OP_CHANGE
&& oap->end.lnum == curwin->w_cursor.lnum
@@ -933,9 +931,8 @@
if (virtual_op)
{
- /* fix up things for virtualedit-delete:
- * break the tabs which are going to get in our way
- */
+ // fix up things for virtualedit-delete:
+ // break the tabs which are going to get in our way
char_u *curline = ml_get_curline();
int len = (int)STRLEN(curline);
@@ -943,38 +940,38 @@
&& (int)oap->end.col >= len - 1
&& !(oap->start.coladd && (int)oap->end.col >= len - 1))
n++;
- /* Delete at least one char (e.g, when on a control char). */
+ // Delete at least one char (e.g, when on a control char).
if (n == 0 && oap->start.coladd != oap->end.coladd)
n = 1;
- /* When deleted a char in the line, reset coladd. */
+ // When deleted a char in the line, reset coladd.
if (gchar_cursor() != NUL)
curwin->w_cursor.coladd = 0;
}
(void)del_bytes((long)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
}
- else /* delete characters between lines */
+ else // delete characters between lines
{
pos_T curpos;
- /* save deleted and changed lines for undo */
+ // save deleted and changed lines for undo
if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
(linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
return FAIL;
- truncate_line(TRUE); /* delete from cursor to end of line */
+ truncate_line(TRUE); // delete from cursor to end of line
- curpos = curwin->w_cursor; /* remember curwin->w_cursor */
+ curpos = curwin->w_cursor; // remember curwin->w_cursor
++curwin->w_cursor.lnum;
del_lines((long)(oap->line_count - 2), FALSE);
- /* delete from start of line until op_end */
+ // delete from start of line until op_end
n = (oap->end.col + 1 - !oap->inclusive);
curwin->w_cursor.col = 0;
(void)del_bytes((long)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
- curwin->w_cursor = curpos; /* restore curwin->w_cursor */
+ curwin->w_cursor = curpos; // restore curwin->w_cursor
(void)do_join(2, FALSE, FALSE, FALSE, FALSE);
}
}
@@ -1025,7 +1022,7 @@
State = REPLACE;
ins_char(c);
State = n;
- /* Backup to the replaced character. */
+ // Backup to the replaced character.
dec_cursor();
}
@@ -1044,7 +1041,7 @@
int had_ctrl_v_cr = FALSE;
if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty)
- return OK; /* nothing to do */
+ return OK; // nothing to do
if (c == REPLACE_CR_NCHAR)
{
@@ -1072,17 +1069,16 @@
bd.is_MAX = (curwin->w_curswant == MAXCOL);
for ( ; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum)
{
- curwin->w_cursor.col = 0; /* make sure cursor position is valid */
+ curwin->w_cursor.col = 0; // make sure cursor position is valid
block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE);
if (bd.textlen == 0 && (!virtual_op || bd.is_MAX))
- continue; /* nothing to replace */
+ continue; // nothing to replace
- /* n == number of extra chars required
- * If we split a TAB, it may be replaced by several characters.
- * Thus the number of characters may increase!
- */
- /* If the range starts in virtual space, count the initial
- * coladd offset as part of "startspaces" */
+ // n == number of extra chars required
+ // If we split a TAB, it may be replaced by several characters.
+ // Thus the number of characters may increase!
+ // If the range starts in virtual space, count the initial
+ // coladd offset as part of "startspaces"
if (virtual_op && bd.is_short && *bd.textstart == NUL)
{
pos_T vpos;
@@ -1093,20 +1089,20 @@
n = bd.startspaces;
}
else
- /* allow for pre spaces */
+ // allow for pre spaces
n = (bd.startspaces ? bd.start_char_vcols - 1 : 0);
- /* allow for post spp */
+ // allow for post spp
n += (bd.endspaces
&& !bd.is_oneChar
&& bd.end_char_vcols > 0) ? bd.end_char_vcols - 1 : 0;
- /* Figure out how many characters to replace. */
+ // Figure out how many characters to replace.
numc = oap->end_vcol - oap->start_vcol + 1;
if (bd.is_short && (!virtual_op || bd.is_MAX))
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)
@@ -1117,10 +1113,10 @@
numc = numc / 2;
}
- /* Compute bytes needed, move character count to num_chars. */
+ // Compute bytes needed, move character count to num_chars.
num_chars = numc;
numc *= (*mb_char2len)(c);
- /* oldlen includes textlen, so don't double count */
+ // oldlen includes textlen, so don't double count
n += numc - bd.textlen;
oldp = ml_get_curline();
@@ -1129,14 +1125,14 @@
if (newp == NULL)
continue;
vim_memset(newp, NUL, (size_t)(oldlen + 1 + n));
- /* copy up to deleted part */
+ // copy up to deleted part
mch_memmove(newp, oldp, (size_t)bd.textcol);
oldp += bd.textcol + bd.textlen;
- /* insert pre-spaces */
+ // insert pre-spaces
vim_memset(newp + bd.textcol, ' ', (size_t)bd.startspaces);
- /* insert replacement chars CHECK FOR ALLOCATED SPACE */
- /* REPLACE_CR_NCHAR/REPLACE_NL_NCHAR is used for entering CR
- * literally. */
+ // insert replacement chars CHECK FOR ALLOCATED SPACE
+ // REPLACE_CR_NCHAR/REPLACE_NL_NCHAR is used for entering CR
+ // literally.
if (had_ctrl_v_cr || (c != '\r' && c != '\n'))
{
if (has_mbyte)
@@ -1149,20 +1145,20 @@
vim_memset(newp + STRLEN(newp), c, (size_t)numc);
if (!bd.is_short)
{
- /* insert post-spaces */
+ // insert post-spaces
vim_memset(newp + STRLEN(newp), ' ', (size_t)bd.endspaces);
- /* copy the part after the changed part */
+ // copy the part after the changed part
STRMOVE(newp + STRLEN(newp), oldp);
}
}
else
{
- /* Replacing with \r or \n means splitting the line. */
+ // Replacing with \r or \n means splitting the line.
after_p = alloc(oldlen + 1 + n - STRLEN(newp));
if (after_p != NULL)
STRMOVE(after_p, oldp);
}
- /* replace the line */
+ // replace the line
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
if (after_p != NULL)
{
@@ -1196,8 +1192,8 @@
{
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);
replace_character(c);
@@ -1210,8 +1206,8 @@
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);
}
@@ -1230,9 +1226,9 @@
&& oap->start.col == oap->end.col && oap->start.coladd)
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--)
@@ -1246,7 +1242,7 @@
}
}
- /* Advance to next character, stop at the end of the file. */
+ // Advance to next character, stop at the end of the file.
if (inc_cursor() == -1)
break;
}
@@ -1258,7 +1254,7 @@
if (!cmdmod.lockmarks)
{
- /* Set "'[" and "']" marks. */
+ // Set "'[" and "']" marks.
curbuf->b_op_start = oap->start;
curbuf->b_op_end = oap->end;
}
@@ -1283,7 +1279,7 @@
return;
pos = oap->start;
- if (oap->block_mode) /* Visual block mode */
+ if (oap->block_mode) // Visual block mode
{
for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
{
@@ -1309,7 +1305,7 @@
if (did_change)
changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
}
- else /* not block mode */
+ else // not block mode
{
if (oap->motion_type == MLINE)
{
@@ -1366,7 +1362,7 @@
}
if (!did_change && oap->is_VIsual)
- /* No change: need to remove the Visual selection */
+ // No change: need to remove the Visual selection
redraw_curbuf_later(INVERTED);
if (!cmdmod.lockmarks)
@@ -1400,12 +1396,12 @@
{
int len = (*mb_ptr2len)(ml_get_pos(pos));
- /* we're counting bytes, not characters */
+ // we're counting bytes, not characters
if (len > 0)
todo -= len - 1;
}
did_change |= swapchar(op_type, pos);
- if (inc(pos) == -1) /* at end of file */
+ if (inc(pos) == -1) // at end of file
break;
}
return did_change;
@@ -1426,7 +1422,7 @@
c = gchar_pos(pos);
- /* Only do rot13 encoding for ASCII characters. */
+ // Only do rot13 encoding for ASCII characters.
if (c >= 0x80 && op_type == OP_ROT13)
return FALSE;
@@ -1435,7 +1431,7 @@
{
pos_T sp = curwin->w_cursor;
- /* Special handling of German sharp s: change to "SS". */
+ // Special handling of German sharp s: change to "SS".
curwin->w_cursor = *pos;
del_char(FALSE);
ins_char('S');
@@ -1444,7 +1440,7 @@
inc(pos);
}
- if (enc_dbcs != 0 && c >= 0x100) /* No lower/uppercase letter */
+ if (enc_dbcs != 0 && c >= 0x100) // No lower/uppercase letter
return FALSE;
nc = c;
if (MB_ISLOWER(c))
@@ -1468,7 +1464,7 @@
pos_T sp = curwin->w_cursor;
curwin->w_cursor = *pos;
- /* don't use del_char(), it also removes composing chars */
+ // don't use del_char(), it also removes composing chars
del_bytes(utf_ptr2len(ml_get_cursor()), FALSE, FALSE);
ins_char(nc);
curwin->w_cursor = sp;
@@ -1493,19 +1489,19 @@
int i;
pos_T t1;
- /* edit() changes this - record it for OP_APPEND */
+ // edit() changes this - record it for OP_APPEND
bd.is_MAX = (curwin->w_curswant == MAXCOL);
- /* vis block is still marked. Get rid of it now. */
+ // vis block is still marked. Get rid of it now.
curwin->w_cursor.lnum = oap->start.lnum;
update_screen(INVERTED);
if (oap->block_mode)
{
- /* When 'virtualedit' is used, need to insert the extra spaces before
- * doing block_prep(). When only "block" is used, virtual edit is
- * already disabled, but still need it when calling
- * coladvance_force(). */
+ // When 'virtualedit' is used, need to insert the extra spaces before
+ // doing block_prep(). When only "block" is used, virtual edit is
+ // already disabled, but still need it when calling
+ // coladvance_force().
if (curwin->w_cursor.coladd > 0)
{
int old_ve_flags = ve_flags;
@@ -1519,9 +1515,9 @@
--curwin->w_cursor.col;
ve_flags = old_ve_flags;
}
- /* Get the info about the block before entering the text */
+ // Get the info about the block before entering the text
block_prep(oap, &bd, oap->start.lnum, TRUE);
- /* Get indent information */
+ // Get indent information
ind_pre = (colnr_T)getwhitecols_curline();
firstline = ml_get(oap->start.lnum) + bd.textcol;
@@ -1534,15 +1530,15 @@
{
if (oap->block_mode && curwin->w_cursor.coladd == 0)
{
- /* Move the cursor to the character right of the block. */
+ // Move the cursor to the character right of the block.
curwin->w_set_curswant = TRUE;
while (*ml_get_cursor() != NUL
&& (curwin->w_cursor.col < bd.textcol + bd.textlen))
++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;
for (i = 0; i < bd.endspaces; ++i)
@@ -1555,7 +1551,7 @@
curwin->w_cursor = oap->end;
check_cursor_col();
- /* Works just like an 'i'nsert on the next character. */
+ // Works just like an 'i'nsert on the next character.
if (!LINEEMPTY(curwin->w_cursor.lnum)
&& oap->start_vcol != oap->end_vcol)
inc_cursor();
@@ -1565,16 +1561,16 @@
t1 = oap->start;
(void)edit(NUL, FALSE, (linenr_T)count1);
- /* When a tab was inserted, and the characters in front of the tab
- * have been converted to a tab as well, the column of the cursor
- * might have actually been reduced, so need to adjust here. */
+ // When a tab was inserted, and the characters in front of the tab
+ // have been converted to a tab as well, the column of the cursor
+ // might have actually been reduced, so need to adjust here.
if (t1.lnum == curbuf->b_op_start_orig.lnum
&& LT_POS(curbuf->b_op_start_orig, t1))
oap->start = curbuf->b_op_start_orig;
- /* If user has moved off this line, we don't know what to do, so do
- * nothing.
- * Also don't repeat the insert when Insert mode ended with CTRL-C. */
+ // If user has moved off this line, we don't know what to do, so do
+ // nothing.
+ // Also don't repeat the insert when Insert mode ended with CTRL-C.
if (curwin->w_cursor.lnum != oap->start.lnum || got_int)
return;
@@ -1585,8 +1581,8 @@
size_t len;
int add;
- /* If indent kicked in, the firstline might have changed
- * but only do that, if the indent actually increased. */
+ // If indent kicked in, the firstline might have changed
+ // but only do that, if the indent actually increased.
ind_post = (colnr_T)getwhitecols_curline();
if (curbuf->b_op_start.col > ind_pre && ind_post > ind_pre)
{
@@ -1595,9 +1591,9 @@
did_indent = TRUE;
}
- /* The user may have moved the cursor before inserting something, try
- * to adjust the block for that. But only do it, if the difference
- * does not come from indent kicking in. */
+ // The user may have moved the cursor before inserting something, try
+ // to adjust the block for that. But only do it, if the difference
+ // does not come from indent kicking in.
if (oap->start.lnum == curbuf->b_op_start_orig.lnum
&& !bd.is_MAX && !did_indent)
{
@@ -1620,7 +1616,7 @@
int t = getviscol2(curbuf->b_op_start_orig.col,
curbuf->b_op_start_orig.coladd);
oap->start.col = curbuf->b_op_start_orig.col;
- /* reset pre_textlen to the value of OP_INSERT */
+ // reset pre_textlen to the value of OP_INSERT
pre_textlen += bd.textlen;
pre_textlen -= t - oap->start_vcol;
oap->start_vcol = t;
@@ -1665,7 +1661,7 @@
ins_text = vim_strnsave(firstline, (int)ins_len);
if (ins_text != NULL)
{
- /* block handled here */
+ // block handled here
if (u_save(oap->start.lnum,
(linenr_T)(oap->end.lnum + 1)) == OK)
block_insert(oap, ins_text, (oap->op_type == OP_INSERT),
@@ -1708,12 +1704,12 @@
&& !curbuf->b_p_cin
# endif
)
- can_si = TRUE; /* It's like opening a new line, do si */
+ can_si = TRUE; // It's like opening a new line, do si
#endif
}
- /* 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)
@@ -1726,11 +1722,11 @@
&& !virtual_op)
inc_cursor();
- /* check for still on same line (<CR> in inserted text meaningless) */
- /* skip blank lines too */
+ // check for still on same line (<CR> in inserted text meaningless)
+ // skip blank lines too
if (oap->block_mode)
{
- /* Add spaces before getting the current line length. */
+ // Add spaces before getting the current line length.
if (virtual_op && (curwin->w_cursor.coladd > 0
|| gchar_cursor() == NUL))
coladvance_force(getviscol());
@@ -1754,8 +1750,8 @@
*/
if (oap->block_mode && oap->start.lnum != oap->end.lnum && !got_int)
{
- /* Auto-indenting may have changed the indent. If the cursor was past
- * the indent, exclude that indent change from the inserted text. */
+ // Auto-indenting may have changed the indent. If the cursor was past
+ // the indent, exclude that indent change from the inserted text.
firstline = ml_get(oap->start.lnum);
if (bd.textcol > (colnr_T)pre_indent)
{
@@ -1768,8 +1764,8 @@
ins_len = (long)STRLEN(firstline) - pre_textlen;
if (ins_len > 0)
{
- /* Subsequent calls to ml_get() flush the firstline data - take a
- * copy of the inserted text. */
+ // Subsequent calls to ml_get() flush the firstline data - take a
+ // copy of the inserted text.
if ((ins_text = alloc(ins_len + 1)) != NULL)
{
vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
@@ -1781,8 +1777,8 @@
{
pos_T vpos;
- /* If the block starts in virtual space, count the
- * initial coladd offset as part of "startspaces" */
+ // If the block starts in virtual space, count the
+ // initial coladd offset as part of "startspaces"
if (bd.is_short)
{
vpos.lnum = linenr;
@@ -1794,7 +1790,7 @@
newp = alloc(STRLEN(oldp) + vpos.coladd + ins_len + 1);
if (newp == NULL)
continue;
- /* copy up to block start */
+ // copy up to block start
mch_memmove(newp, oldp, (size_t)bd.textcol);
offset = bd.textcol;
vim_memset(newp + offset, ' ', (size_t)vpos.coladd);
@@ -1829,14 +1825,14 @@
&& (ve_flags & VE_ONEMORE) == 0
&& !(restart_edit || (State & INSERT)))
{
- /* Put the cursor on the last character in the line. */
+ // Put the cursor on the last character in the line.
dec_cursor();
if (ve_flags == VE_ALL)
{
colnr_T scol, ecol;
- /* Coladd is set to the width of the last character. */
+ // Coladd is set to the width of the last character.
getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
curwin->w_cursor.coladd = ecol - scol + 1;
}
@@ -1869,9 +1865,8 @@
*is_comment = FALSE;
if (leader_offset != -1)
{
- /* Let's check whether the line ends with an unclosed comment.
- * If the last comment leader has COM_END in flags, there's no comment.
- */
+ // Let's check whether the line ends with an unclosed comment.
+ // If the last comment leader has COM_END in flags, there's no comment.
while (*comment_flags)
{
if (*comment_flags == COM_END
@@ -1891,11 +1886,10 @@
if (lead_len == 0)
return line;
- /* Find:
- * - COM_END,
- * - colon,
- * whichever comes first.
- */
+ // Find:
+ // - COM_END,
+ // - colon,
+ // whichever comes first.
while (*comment_flags)
{
if (*comment_flags == COM_END
@@ -1904,10 +1898,9 @@
++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;
@@ -1936,11 +1929,11 @@
char_u *curr_start = NULL;
char_u *cend;
char_u *newp;
- char_u *spaces; /* number of spaces inserted before a line */
+ char_u *spaces; // number of spaces inserted before a line
int endcurr1 = NUL;
int endcurr2 = NUL;
- int currsize = 0; /* size of the current line */
- int sumsize = 0; /* size of the long new line */
+ int currsize = 0; // size of the current line
+ int sumsize = 0; // size of the long new line
linenr_T t;
colnr_T col = 0;
int ret = OK;
@@ -1957,9 +1950,9 @@
(linenr_T)(curwin->w_cursor.lnum + count)) == FAIL)
return FAIL;
- /* Allocate an array to store the number of spaces inserted before each
- * line. We will use it to pre-compute the length of the new line and the
- * proper placement of each original line in the new one. */
+ // Allocate an array to store the number of spaces inserted before each
+ // line. We will use it to pre-compute the length of the new line and the
+ // proper placement of each original line in the new one.
spaces = lalloc_clear(count, TRUE);
if (spaces == NULL)
return FAIL;
@@ -1983,14 +1976,14 @@
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
if (t == 0 && setmark && !cmdmod.lockmarks)
{
- /* Set the '[ mark. */
+ // Set the '[ mark.
curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr);
}
if (remove_comments)
{
- /* We don't want to remove the comment leader if the
- * previous line is not a comment. */
+ // We don't want to remove the comment leader if the
+ // previous line is not a comment.
if (t > 0 && prev_was_comment)
{
@@ -2015,12 +2008,12 @@
|| mb_ptr2char(curr) < 0x100 || endcurr1 < 0x100)
)
{
- /* don't add a space if the line is ending in a space */
+ // don't add a space if the line is ending in a space
if (endcurr1 == ' ')
endcurr1 = endcurr2;
else
++spaces[t];
- /* extra space when 'joinspaces' set and line ends in '.' */
+ // extra space when 'joinspaces' set and line ends in '.'
if ( p_js
&& (endcurr1 == '.'
|| (vim_strchr(p_cpo, CPO_JOINSP) == NULL
@@ -2059,10 +2052,10 @@
}
}
- /* store the column position before last line */
+ // store the column position before last line
col = sumsize - currsize - spaces[count - 1];
- /* allocate the space for the new line */
+ // allocate the space for the new line
newp = alloc(sumsize + 1);
if (newp == NULL)
{
@@ -2139,13 +2132,13 @@
if (setmark && !cmdmod.lockmarks)
{
- /* Set the '] mark. */
+ // Set the '] mark.
curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum;
curwin->w_buffer->b_op_end.col = (colnr_T)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);
/*
@@ -2259,12 +2252,12 @@
static void
op_format(
oparg_T *oap,
- int keep_cursor) /* keep cursor on same text char */
+ int keep_cursor) // keep cursor on same text char
{
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),
@@ -2273,15 +2266,15 @@
curwin->w_cursor = oap->start;
if (oap->is_VIsual)
- /* When there is no change: need to remove the Visual selection */
+ // When there is no change: need to remove the Visual selection
redraw_curbuf_later(INVERTED);
if (!cmdmod.lockmarks)
- /* Set '[ mark at the start of the formatted area */
+ // 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;
@@ -2299,7 +2292,7 @@
msgmore(old_line_count);
if (!cmdmod.lockmarks)
- /* put '] mark on the end of the formatted area */
+ // put '] mark on the end of the formatted area
curbuf->b_op_end = curwin->w_cursor;
if (keep_cursor)
@@ -2316,8 +2309,8 @@
{
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
@@ -2335,12 +2328,12 @@
op_formatexpr(oparg_T *oap)
{
if (oap->is_VIsual)
- /* When there is no change: need to remove the Visual selection */
+ // When there is no change: need to remove the Visual selection
redraw_curbuf_later(INVERTED);
if (fex_format(oap->start.lnum, oap->line_count, NUL) != 0)
- /* As documented: when 'formatexpr' returns non-zero fall back to
- * internal formatting. */
+ // As documented: when 'formatexpr' returns non-zero fall back to
+ // internal formatting.
op_format(oap, FALSE);
}
@@ -2348,7 +2341,7 @@
fex_format(
linenr_T lnum,
long count,
- int c) /* character to be inserted */
+ int c) // character to be inserted
{
int use_sandbox = was_set_insecurely((char_u *)"formatexpr",
OPT_LOCAL);
@@ -2363,7 +2356,7 @@
set_vim_var_nr(VV_COUNT, count);
set_vim_var_char(c);
- /* Make a copy, the option could be changed while calling it. */
+ // Make a copy, the option could be changed while calling it.
fex = vim_strsave(curbuf->b_p_fex);
if (fex == NULL)
return 0;
@@ -2393,37 +2386,37 @@
void
format_lines(
linenr_T line_count,
- int avoid_fex) /* don't use 'formatexpr' */
+ int avoid_fex) // don't use 'formatexpr'
{
int max_len;
- int is_not_par; /* current line not part of parag. */
- int next_is_not_par; /* next line not part of paragraph */
- int is_end_par; /* at end of paragraph */
- int prev_is_end_par = FALSE;/* prev. line not part of parag. */
+ int is_not_par; // current line not part of parag.
+ int next_is_not_par; // next line not part of paragraph
+ int is_end_par; // at end of paragraph
+ int prev_is_end_par = FALSE;// prev. line not part of parag.
int next_is_start_par = FALSE;
- int leader_len = 0; /* leader len of current line */
- int next_leader_len; /* leader len of next line */
- char_u *leader_flags = NULL; /* flags for leader of current line */
- char_u *next_leader_flags; /* flags for leader of next line */
- int do_comments; /* format comments */
- int do_comments_list = 0; /* format comments with 'n' or '2' */
+ int leader_len = 0; // leader len of current line
+ int next_leader_len; // leader len of next line
+ char_u *leader_flags = NULL; // flags for leader of current line
+ char_u *next_leader_flags; // flags for leader of next line
+ int do_comments; // format comments
+ int do_comments_list = 0; // format comments with 'n' or '2'
int advance = TRUE;
- int second_indent = -1; /* indent for second line (comment
- * aware) */
+ int second_indent = -1; // indent for second line (comment
+ // aware)
int do_second_indent;
int do_number_indent;
int do_trail_white;
int first_par_line = TRUE;
int smd_save;
long count;
- int need_set_indent = TRUE; /* set indent of next paragraph */
+ int need_set_indent = TRUE; // set indent of next paragraph
int force_format = FALSE;
int old_State = State;
- /* length of a line to force formatting: 3 * 'tw' */
+ // length of a line to force formatting: 3 * 'tw'
max_len = comp_textwidth(TRUE) * 3;
- /* check for 'q', '2' and '1' in 'formatoptions' */
+ // check for 'q', '2' and '1' in 'formatoptions'
do_comments = has_format_option(FO_Q_COMS);
do_second_indent = has_format_option(FO_Q_SECOND);
do_number_indent = has_format_option(FO_Q_NUMBER);
@@ -2503,7 +2496,7 @@
{
if (leader_len == 0 && next_leader_len == 0)
{
- /* no comment found */
+ // no comment found
second_indent =
get_indent_lnum(curwin->w_cursor.lnum + 1);
}
@@ -2517,13 +2510,13 @@
{
if (leader_len == 0 && next_leader_len == 0)
{
- /* no comment found */
+ // no comment found
second_indent =
get_number_indent(curwin->w_cursor.lnum);
}
else
{
- /* get_number_indent() is now "comment aware"... */
+ // get_number_indent() is now "comment aware"...
second_indent =
get_number_indent(curwin->w_cursor.lnum);
do_comments_list = 1;
@@ -2547,18 +2540,18 @@
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);
- /* put cursor on last non-space */
- State = NORMAL; /* don't go past end-of-line */
+ // put cursor on last non-space
+ State = NORMAL; // don't go past end-of-line
coladvance((colnr_T)MAXCOL);
while (curwin->w_cursor.col && vim_isspace(gchar_cursor()))
dec_cursor();
- /* do the formatting, without 'showmode' */
- State = INSERT; /* for open_line() */
+ // do the formatting, without 'showmode'
+ State = INSERT; // for open_line()
smd_save = p_smd;
p_smd = FALSE;
insertchar(NUL, INSCHAR_FORMAT
@@ -2569,12 +2562,12 @@
State = old_State;
p_smd = smd_save;
second_indent = -1;
- /* at end of par.: need to set indent of next par. */
+ // 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;
first_par_line = TRUE;
@@ -2617,7 +2610,7 @@
break;
}
first_par_line = FALSE;
- /* If the line is getting long, format it next time */
+ // If the line is getting long, format it next time
if (STRLEN(ml_get_curline()) > (size_t)max_len)
force_format = TRUE;
else
@@ -2639,8 +2632,8 @@
if (*s == NUL)
return FALSE;
- /* Don't use STRLEN() inside VIM_ISWHITE(), SAS/C complains: "macro
- * invocation may call function multiple times". */
+ // Don't use STRLEN() inside VIM_ISWHITE(), SAS/C complains: "macro
+ // invocation may call function multiple times".
l = STRLEN(s) - 1;
return VIM_ISWHITE(s[l]);
}
@@ -2660,7 +2653,7 @@
char_u **leader_flags,
int do_comments)
{
- char_u *flags = NULL; /* init for GCC */
+ char_u *flags = NULL; // init for GCC
char_u *ptr;
ptr = ml_get(lnum);
@@ -2692,35 +2685,35 @@
paragraph_start(linenr_T lnum)
{
char_u *p;
- int leader_len = 0; /* leader len of current line */
- char_u *leader_flags = NULL; /* flags for leader of current line */
- int next_leader_len; /* leader len of next line */
- char_u *next_leader_flags; /* flags for leader of next line */
- int do_comments; /* format comments */
+ int leader_len = 0; // leader len of current line
+ char_u *leader_flags = NULL; // flags for leader of current line
+ int next_leader_len; // leader len of next line
+ char_u *next_leader_flags; // flags for leader of next line
+ int do_comments; // format comments
if (lnum <= 1)
- return TRUE; /* start of the file */
+ return TRUE; // start of the file
p = ml_get(lnum - 1);
if (*p == NUL)
- return TRUE; /* after empty line */
+ return TRUE; // after empty line
do_comments = has_format_option(FO_Q_COMS);
if (fmt_check_par(lnum - 1, &leader_len, &leader_flags, do_comments))
- return TRUE; /* after non-paragraph line */
+ return TRUE; // after non-paragraph line
if (fmt_check_par(lnum, &next_leader_len, &next_leader_flags, do_comments))
- return TRUE; /* "lnum" is not a paragraph line */
+ return TRUE; // "lnum" is not a paragraph line
if (has_format_option(FO_WHITE_PAR) && !ends_in_white(lnum - 1))
- return TRUE; /* missing trailing space in previous line. */
+ return TRUE; // missing trailing space in previous line.
if (has_format_option(FO_Q_NUMBER) && (get_number_indent(lnum) > 0))
- return TRUE; /* numbered item starts in "lnum". */
+ return TRUE; // numbered item starts in "lnum".
if (!same_leader(lnum - 1, leader_len, leader_flags,
next_leader_len, next_leader_flags))
- return TRUE; /* change of comment leader. */
+ return TRUE; // change of comment leader.
return FALSE;
}
@@ -2769,7 +2762,7 @@
prev_pstart = line;
while (bdp->start_vcol < oap->start_vcol && *pstart)
{
- /* Count a tab for what it's worth (if list mode not on) */
+ // Count a tab for what it's worth (if list mode not on)
incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol);
bdp->start_vcol += incr;
if (VIM_ISWHITE(*pstart))
@@ -2786,7 +2779,7 @@
MB_PTR_ADV(pstart);
}
bdp->start_char_vcols = incr;
- if (bdp->start_vcol < oap->start_vcol) /* line too short */
+ if (bdp->start_vcol < oap->start_vcol) // line too short
{
bdp->end_vcol = bdp->start_vcol;
bdp->is_short = TRUE;
@@ -2795,14 +2788,14 @@
}
else
{
- /* notice: this converts partly selected Multibyte characters to
- * spaces, too. */
+ // notice: this converts partly selected Multibyte characters to
+ // spaces, too.
bdp->startspaces = bdp->start_vcol - oap->start_vcol;
if (is_del && bdp->startspaces)
bdp->startspaces = bdp->start_char_vcols - bdp->startspaces;
pend = pstart;
bdp->end_vcol = bdp->start_vcol;
- if (bdp->end_vcol > oap->end_vcol) /* it's all in one character */
+ if (bdp->end_vcol > oap->end_vcol) // it's all in one character
{
bdp->is_oneChar = TRUE;
if (oap->op_type == OP_INSERT)
@@ -2817,9 +2810,9 @@
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;
@@ -2831,7 +2824,7 @@
prev_pend = pend;
while (bdp->end_vcol <= oap->end_vcol && *pend != NUL)
{
- /* Count a tab for what it's worth (if list mode not on) */
+ // Count a tab for what it's worth (if list mode not on)
prev_pend = pend;
incr = lbr_chartabsize_adv(line, &pend, (colnr_T)bdp->end_vcol);
bdp->end_vcol += incr;
@@ -2839,18 +2832,18 @@
if (bdp->end_vcol <= oap->end_vcol
&& (!is_del
|| oap->op_type == OP_APPEND
- || oap->op_type == OP_REPLACE)) /* line too short */
+ || oap->op_type == OP_REPLACE)) // line too short
{
bdp->is_short = TRUE;
- /* Alternative: include spaces to fill up the block.
- * Disadvantage: can lead to trailing spaces when the line is
- * short where the text is put */
- /* if (!is_del || oap->op_type == OP_APPEND) */
+ // Alternative: include spaces to fill up the block.
+ // Disadvantage: can lead to trailing spaces when the line is
+ // short where the text is put
+ // if (!is_del || oap->op_type == OP_APPEND)
if (oap->op_type == OP_APPEND || virtual_op)
bdp->endspaces = oap->end_vcol - bdp->end_vcol
+ oap->inclusive;
else
- bdp->endspaces = 0; /* replace doesn't add characters */
+ bdp->endspaces = 0; // replace doesn't add characters
}
else if (bdp->end_vcol > oap->end_vcol)
{
@@ -2878,8 +2871,8 @@
void
op_addsub(
oparg_T *oap,
- linenr_T Prenum1, /* Amount of add/subtract */
- int g_cmd) /* was g<c-a>/g<c-x> */
+ linenr_T Prenum1, // Amount of add/subtract
+ int g_cmd) // was g<c-a>/g<c-x>
{
pos_T pos;
struct block_def bd;
@@ -2928,7 +2921,7 @@
pos = oap->start;
for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
{
- if (oap->block_mode) /* Visual block mode */
+ if (oap->block_mode) // Visual block mode
{
block_prep(oap, &bd, pos.lnum, FALSE);
pos.col = bd.textcol;
@@ -2940,7 +2933,7 @@
pos.col = 0;
length = (colnr_T)STRLEN(ml_get(pos.lnum));
}
- else /* oap->motion_type == MCHAR */
+ else // oap->motion_type == MCHAR
{
if (pos.lnum == oap->start.lnum && !oap->inclusive)
dec(&(oap->end));
@@ -2962,7 +2955,7 @@
one_change = do_addsub(oap->op_type, &pos, length, amount);
if (one_change)
{
- /* Remember the start position of the first change. */
+ // Remember the start position of the first change.
if (change_cnt == 0)
startpos = curbuf->b_op_start;
++change_cnt;
@@ -2989,11 +2982,11 @@
changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
if (!change_cnt && oap->is_VIsual)
- /* No change: need to remove the Visual selection */
+ // No change: need to remove the Visual selection
redraw_curbuf_later(INVERTED);
- /* Set '[ mark if something changed. Keep the last end
- * position from do_addsub(). */
+ // Set '[ mark if something changed. Keep the last end
+ // position from do_addsub().
if (change_cnt > 0 && !cmdmod.lockmarks)
curbuf->b_op_start = startpos;
@@ -3019,8 +3012,8 @@
int col;
char_u *buf1;
char_u buf2[NUMBUFLEN];
- int pre; /* 'X'/'x': hex; '0': octal; 'B'/'b': bin */
- static int hexupper = FALSE; /* 0xABC */
+ int pre; // 'X'/'x': hex; '0': octal; 'B'/'b': bin
+ static int hexupper = FALSE; // 0xABC
uvarnumber_T n;
uvarnumber_T oldn;
char_u *ptr;
@@ -3085,7 +3078,7 @@
&& vim_isxdigit(ptr[col + 1]))))
{
- /* In case of binary/hexadecimal pattern overlap match, rescan */
+ // In case of binary/hexadecimal pattern overlap match, rescan
col = pos->col;
@@ -3114,7 +3107,7 @@
!(*mb_head_off)(ptr, ptr + col - 1))
&& vim_isbdigit(ptr[col + 1])))
{
- /* Found hexadecimal or binary number, move to its start. */
+ // Found hexadecimal or binary number, move to its start.
--col;
if (has_mbyte)
col -= (*mb_head_off)(ptr, ptr + col);
@@ -3177,7 +3170,7 @@
if (doalp && ASCII_ISALPHA(firstdigit))
{
- /* decrement or increment alphabetic character */
+ // decrement or increment alphabetic character
if (op_type == OP_NR_SUB)
{
if (CharOrd(firstdigit) < Prenum1)
@@ -3226,11 +3219,11 @@
!(*mb_head_off)(ptr, ptr + col - 1))
&& !visual)
{
- /* negative number */
+ // negative number
--col;
negative = TRUE;
}
- /* get the number value (unsigned) */
+ // get the number value (unsigned)
if (visual && VIsual_mode != 'V')
maxlen = (curbuf->b_visual.vi_curswant == MAXCOL
? (int)STRLEN(ptr) - col
@@ -3242,14 +3235,14 @@
+ (dohex ? STR2NR_HEX : 0),
NULL, &n, maxlen, FALSE);
- /* ignore leading '-' for hex and octal and bin numbers */
+ // ignore leading '-' for hex and octal and bin numbers
if (pre && negative)
{
++col;
--length;
negative = FALSE;
}
- /* add or subtract */
+ // add or subtract
subtract = FALSE;
if (op_type == OP_NR_SUB)
subtract ^= TRUE;
@@ -3261,7 +3254,7 @@
n -= (uvarnumber_T)Prenum1;
else
n += (uvarnumber_T)Prenum1;
- /* handle wraparound for decimal numbers */
+ // handle wraparound for decimal numbers
if (!pre)
{
if (subtract)
@@ -3274,7 +3267,7 @@
}
else
{
- /* add */
+ // add
if (n < oldn)
{
n = (n ^ (uvarnumber_T)-1);
@@ -3287,7 +3280,7 @@
if (visual && !was_positive && !negative && col > 0)
{
- /* need to remove the '-' */
+ // need to remove the '-'
col--;
length++;
}
@@ -3316,7 +3309,7 @@
else
hexupper = FALSE;
}
- /* del_char() will mark line needing displaying */
+ // del_char() will mark line needing displaying
(void)del_char(FALSE);
c = gchar_cursor();
}
@@ -3353,7 +3346,7 @@
int bit = 0;
int bits = sizeof(uvarnumber_T) * 8;
- /* leading zeros */
+ // leading zeros
for (bit = bits; bit > 0; bit--)
if ((n >> (bit - 1)) & 0x1) break;
@@ -3387,7 +3380,7 @@
*ptr++ = '0';
*ptr = NUL;
STRCAT(buf1, buf2);
- ins_str(buf1); /* insert the new number */
+ ins_str(buf1); // insert the new number
vim_free(buf1);
endpos = curwin->w_cursor;
if (did_change && curwin->w_cursor.col)
@@ -3396,7 +3389,7 @@
if (did_change && !cmdmod.lockmarks)
{
- /* set the '[ and '] marks */
+ // set the '[ and '] marks
curbuf->b_op_start = startpos;
curbuf->b_op_end = endpos;
if (curbuf->b_op_end.col > 0)
@@ -3460,22 +3453,21 @@
return;
# endif
- /* Get selection to export */
+ // Get selection to export
if (clip_plus.owned)
motion_type = clip_convert_selection(&str, &len, &clip_plus);
else if (clip_star.owned)
motion_type = clip_convert_selection(&str, &len, &clip_star);
- /* Check it's OK */
+ // Check it's OK
if (dpy != NULL && str != NULL && motion_type >= 0
&& len < 1024*1024 && len > 0)
{
int ok = TRUE;
- /* The CUT_BUFFER0 is supposed to always contain latin1. Convert from
- * 'enc' when it is a multi-byte encoding. When 'enc' is an 8-bit
- * encoding conversion usually doesn't work, so keep the text as-is.
- */
+ // The CUT_BUFFER0 is supposed to always contain latin1. Convert from
+ // 'enc' when it is a multi-byte encoding. When 'enc' is an 8-bit
+ // encoding conversion usually doesn't work, so keep the text as-is.
if (has_mbyte)
{
vimconv_T vc;
@@ -3506,8 +3498,8 @@
}
}
- /* Do not store the string if conversion failed. Better to use any
- * other selection than garbled text. */
+ // Do not store the string if conversion failed. Better to use any
+ // other selection than garbled text.
if (ok)
{
XStoreBuffer(dpy, (char *)str, (int)len, 0);
@@ -3518,7 +3510,7 @@
vim_free(str);
}
#endif
-#endif /* FEAT_CLIPBOARD || PROTO */
+#endif // FEAT_CLIPBOARD || PROTO
void
clear_oparg(oparg_T *oap)
@@ -3573,7 +3565,7 @@
words++;
*wc += words;
- /* Add eol_size if the end of line was reached before hitting limit. */
+ // Add eol_size if the end of line was reached before hitting limit.
if (i < limit && line[i] == NUL)
{
i += eol_size;
@@ -3649,7 +3641,7 @@
char_u * saved_sbr = p_sbr;
char_u * saved_w_sbr = curwin->w_p_sbr;
- /* Make 'sbr' empty for a moment to get the correct size. */
+ // Make 'sbr' empty for a moment to get the correct size.
p_sbr = empty_option;
curwin->w_p_sbr = empty_option;
#endif
@@ -3664,7 +3656,7 @@
#endif
if (curwin->w_curswant == MAXCOL)
oparg.end_vcol = MAXCOL;
- /* Swap the start, end vcol if needed */
+ // Swap the start, end vcol if needed
if (oparg.end_vcol < oparg.start_vcol)
{
oparg.end_vcol += oparg.start_vcol;
@@ -3677,7 +3669,7 @@
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
{
- /* Check for a CTRL-C every 100000 characters. */
+ // Check for a CTRL-C every 100000 characters.
if (byte_count > last_check)
{
ui_breakcheck();
@@ -3686,7 +3678,7 @@
last_check = byte_count + 100000L;
}
- /* Do extra processing for VIsual mode. */
+ // Do extra processing for VIsual mode.
if (VIsual_active
&& lnum >= min_pos.lnum && lnum <= max_pos.lnum)
{
@@ -3731,7 +3723,7 @@
}
else
{
- /* In non-visual mode, check for the line the cursor is on */
+ // In non-visual mode, check for the line the cursor is on
if (lnum == curwin->w_cursor.lnum)
{
word_count_cursor += word_count;
@@ -3743,13 +3735,13 @@
eol_size);
}
}
- /* Add to the running totals */
+ // Add to the running totals
byte_count += line_count_info(ml_get(lnum), &word_count,
&char_count, (varnumber_T)MAXCOL,
eol_size);
}
- /* Correction for when last line doesn't have an EOL. */
+ // Correction for when last line doesn't have an EOL.
if (!curbuf->b_p_eol && (curbuf->b_p_bin || !curbuf->b_p_fixeol))
byte_count -= eol_size;
@@ -4328,7 +4320,8 @@
if (cap->cmdchar == 'g' && (cap->nchar == 'n'
|| cap->nchar == 'N'))
prep_redo(oap->regname, cap->count0,
- get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
+ get_op_char(oap->op_type),
+ get_extra_op_char(oap->op_type),
oap->motion_force, cap->cmdchar, cap->nchar);
else if (cap->cmdchar != ':')
{