summaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c1205
1 files changed, 600 insertions, 605 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index a1eecc505..45c733bba 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -57,10 +57,10 @@ do_ascii(exarg_T *eap UNUSED)
IObuff[0] = NUL;
if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80)
{
- if (c == NL) /* NUL is stored as NL */
+ if (c == NL) // NUL is stored as NL
c = NUL;
if (c == CAR && get_fileformat(curbuf) == EOL_MAC)
- cval = NL; /* NL is stored as CR */
+ cval = NL; // NL is stored as CR
else
cval = c;
if (vim_isprintc_strict(c) && (c < ' '
@@ -98,11 +98,11 @@ do_ascii(exarg_T *eap UNUSED)
c = 0;
}
- /* Repeat for combining characters. */
+ // Repeat for combining characters.
while (has_mbyte && (c >= 0x100 || (enc_utf8 && c >= 0x80)))
{
len = (int)STRLEN(IObuff);
- /* This assumes every multi-byte char is printable... */
+ // This assumes every multi-byte char is printable...
if (len > 0)
IObuff[len++] = ' ';
IObuff[len++] = '<';
@@ -111,7 +111,7 @@ do_ascii(exarg_T *eap UNUSED)
&& !gui.in_use
# endif
)
- IObuff[len++] = ' '; /* draw composing char on top of a space */
+ IObuff[len++] = ' '; // draw composing char on top of a space
len += (*mb_char2bytes)(c, IObuff + len);
#ifdef FEAT_DIGRAPHS
dig = get_digraph_for_char(c);
@@ -153,7 +153,7 @@ ex_align(exarg_T *eap)
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl)
{
- /* switch left and right aligning */
+ // switch left and right aligning
if (eap->cmdidx == CMD_right)
eap->cmdidx = CMD_left;
else if (eap->cmdidx == CMD_left)
@@ -163,7 +163,7 @@ ex_align(exarg_T *eap)
width = atoi((char *)eap->arg);
save_curpos = curwin->w_cursor;
- if (eap->cmdidx == CMD_left) /* width is used for new indent */
+ if (eap->cmdidx == CMD_left) // width is used for new indent
{
if (width >= 0)
indent = width;
@@ -189,22 +189,22 @@ ex_align(exarg_T *eap)
for (curwin->w_cursor.lnum = eap->line1;
curwin->w_cursor.lnum <= eap->line2; ++curwin->w_cursor.lnum)
{
- if (eap->cmdidx == CMD_left) /* left align */
+ if (eap->cmdidx == CMD_left) // left align
new_indent = indent;
else
{
- has_tab = FALSE; /* avoid uninit warnings */
+ has_tab = FALSE; // avoid uninit warnings
len = linelen(eap->cmdidx == CMD_right ? &has_tab
: NULL) - get_indent();
- if (len <= 0) /* skip blank lines */
+ if (len <= 0) // skip blank lines
continue;
if (eap->cmdidx == CMD_center)
new_indent = (width - len) / 2;
else
{
- new_indent = width - len; /* right align */
+ new_indent = width - len; // right align
/*
* Make sure that embedded TABs don't make the text go too far
@@ -232,7 +232,7 @@ ex_align(exarg_T *eap)
}
if (new_indent < 0)
new_indent = 0;
- (void)set_indent(new_indent, 0); /* set indent */
+ (void)set_indent(new_indent, 0); // set indent
}
changed_lines(eap->line1, 0, eap->line2 + 1, 0L);
curwin->w_cursor = save_curpos;
@@ -274,21 +274,21 @@ linelen(int *has_tab)
return len;
}
-/* Buffer for two lines used during sorting. They are allocated to
- * contain the longest line being sorted. */
+// Buffer for two lines used during sorting. They are allocated to
+// contain the longest line being sorted.
static char_u *sortbuf1;
static char_u *sortbuf2;
-static int sort_ic; /* ignore case */
-static int sort_nr; /* sort on number */
-static int sort_rx; /* sort on regex instead of skipping it */
+static int sort_ic; // ignore case
+static int sort_nr; // sort on number
+static int sort_rx; // sort on regex instead of skipping it
#ifdef FEAT_FLOAT
-static int sort_flt; /* sort on floating number */
+static int sort_flt; // sort on floating number
#endif
-static int sort_abort; /* flag to indicate if sorting has been interrupted */
+static int sort_abort; // flag to indicate if sorting has been interrupted
-/* Struct to store info to be sorted. */
+// Struct to store info to be sorted.
typedef struct
{
linenr_T lnum; // line number
@@ -318,9 +318,9 @@ sort_compare(const void *s1, const void *s2)
sorti_T l2 = *(sorti_T *)s2;
int result = 0;
- /* If the user interrupts, there's no way to stop qsort() immediately, but
- * if we return 0 every time, qsort will assume it's done sorting and
- * exit. */
+ // If the user interrupts, there's no way to stop qsort() immediately, but
+ // if we return 0 every time, qsort will assume it's done sorting and
+ // exit.
if (sort_abort)
return 0;
fast_breakcheck();
@@ -342,9 +342,9 @@ sort_compare(const void *s1, const void *s2)
#endif
else
{
- /* We need to copy one line into "sortbuf1", because there is no
- * guarantee that the first pointer becomes invalid when obtaining the
- * second one. */
+ // We need to copy one line into "sortbuf1", because there is no
+ // guarantee that the first pointer becomes invalid when obtaining the
+ // second one.
STRNCPY(sortbuf1, ml_get(l1.lnum) + l1.st_u.line.start_col_nr,
l1.st_u.line.end_col_nr - l1.st_u.line.start_col_nr + 1);
sortbuf1[l1.st_u.line.end_col_nr - l1.st_u.line.start_col_nr] = 0;
@@ -356,7 +356,7 @@ sort_compare(const void *s1, const void *s2)
: STRCMP(sortbuf1, sortbuf2);
}
- /* If two lines have the same value, preserve the original line order. */
+ // If two lines have the same value, preserve the original line order.
if (result == 0)
return (int)(l1.lnum - l2.lnum);
return result;
@@ -378,7 +378,7 @@ ex_sort(exarg_T *eap)
char_u *p;
char_u *s;
char_u *s2;
- char_u c; /* temporary character storage */
+ char_u c; // temporary character storage
int unique = FALSE;
long deleted;
colnr_T start_col;
@@ -387,7 +387,7 @@ ex_sort(exarg_T *eap)
int format_found = 0;
int change_occurred = FALSE; // Buffer contents changed.
- /* Sorting one line is really quick! */
+ // Sorting one line is really quick!
if (count <= 1)
return;
@@ -442,7 +442,7 @@ ex_sort(exarg_T *eap)
}
else if (*p == 'u')
unique = TRUE;
- else if (*p == '"') /* comment start */
+ else if (*p == '"') // comment start
break;
else if (check_nextcmd(p) != NULL)
{
@@ -458,7 +458,7 @@ ex_sort(exarg_T *eap)
goto sortend;
}
*s = NUL;
- /* Use last search pattern if sort pattern is empty. */
+ // Use last search pattern if sort pattern is empty.
if (s == p + 1)
{
if (last_search_pat() == NULL)
@@ -472,7 +472,7 @@ ex_sort(exarg_T *eap)
regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
if (regmatch.regprog == NULL)
goto sortend;
- p = s; /* continue after the regexp */
+ p = s; // continue after the regexp
regmatch.rm_ic = p_ic;
}
else
@@ -482,15 +482,15 @@ ex_sort(exarg_T *eap)
}
}
- /* Can only have one of 'n', 'b', 'o' and 'x'. */
+ // Can only have one of 'n', 'b', 'o' and 'x'.
if (format_found > 1)
{
emsg(_(e_invarg));
goto sortend;
}
- /* From here on "sort_nr" is used as a flag for any integer number
- * sorting. */
+ // From here on "sort_nr" is used as a flag for any integer number
+ // sorting.
sort_nr += sort_what;
/*
@@ -530,12 +530,12 @@ ex_sort(exarg_T *eap)
#endif
)
{
- /* Make sure vim_str2nr doesn't read any digits past the end
- * of the match, by temporarily terminating the string there */
+ // Make sure vim_str2nr doesn't read any digits past the end
+ // of the match, by temporarily terminating the string there
s2 = s + end_col;
c = *s2;
*s2 = NUL;
- /* Sorting on number: Store the number itself. */
+ // Sorting on number: Store the number itself.
p = s + start_col;
if (sort_nr)
{
@@ -546,10 +546,10 @@ ex_sort(exarg_T *eap)
else
s = skiptodigit(p);
if (s > p && s[-1] == '-')
- --s; /* include preceding negative sign */
+ --s; // include preceding negative sign
if (*s == NUL)
{
- /* line without number should sort before any number */
+ // line without number should sort before any number
nrs[lnum - eap->line1].st_u.num.is_number = FALSE;
nrs[lnum - eap->line1].st_u.num.value = 0;
}
@@ -569,7 +569,7 @@ ex_sort(exarg_T *eap)
s = skipwhite(s + 1);
if (*s == NUL)
- /* empty line should sort before any number */
+ // empty line should sort before any number
nrs[lnum - eap->line1].st_u.value_flt = -DBL_MAX;
else
nrs[lnum - eap->line1].st_u.value_flt =
@@ -580,7 +580,7 @@ ex_sort(exarg_T *eap)
}
else
{
- /* Store the column to sort at. */
+ // Store the column to sort at.
nrs[lnum - eap->line1].st_u.line.start_col_nr = start_col;
nrs[lnum - eap->line1].st_u.line.end_col_nr = end_col;
}
@@ -593,7 +593,7 @@ ex_sort(exarg_T *eap)
goto sortend;
}
- /* Allocate a buffer that can hold the longest line. */
+ // Allocate a buffer that can hold the longest line.
sortbuf1 = alloc(maxlen + 1);
if (sortbuf1 == NULL)
goto sortend;
@@ -601,13 +601,13 @@ ex_sort(exarg_T *eap)
if (sortbuf2 == NULL)
goto sortend;
- /* Sort the array of line numbers. Note: can't be interrupted! */
+ // Sort the array of line numbers. Note: can't be interrupted!
qsort((void *)nrs, count, sizeof(sorti_T), sort_compare);
if (sort_abort)
goto sortend;
- /* Insert the lines in the sorted order below the last one. */
+ // Insert the lines in the sorted order below the last one.
lnum = eap->line2;
for (i = 0; i < count; ++i)
{
@@ -633,14 +633,14 @@ ex_sort(exarg_T *eap)
goto sortend;
}
- /* delete the original lines if appending worked */
+ // delete the original lines if appending worked
if (i == count)
for (i = 0; i < count; ++i)
ml_delete(eap->line1, FALSE);
else
count = 0;
- /* Adjust marks for deleted (or added) lines and prepare for displaying. */
+ // Adjust marks for deleted (or added) lines and prepare for displaying.
deleted = (long)(count - (lnum - eap->line2));
if (deleted > 0)
{
@@ -844,15 +844,15 @@ ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
curwin->w_cursor.lnum = n;
while (line1 <= line2)
{
- /* need to use vim_strsave() because the line will be unlocked within
- * ml_append() */
+ // need to use vim_strsave() because the line will be unlocked within
+ // ml_append()
p = vim_strsave(ml_get(line1));
if (p != NULL)
{
ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE);
vim_free(p);
}
- /* situation 2: skip already copied lines */
+ // situation 2: skip already copied lines
if (line1 == n)
line1 = curwin->w_cursor.lnum;
++line1;
@@ -868,7 +868,7 @@ ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
msgmore((long)count);
}
-static char_u *prevcmd = NULL; /* the previous command */
+static char_u *prevcmd = NULL; // the previous command
#if defined(EXITFREE) || defined(PROTO)
void
@@ -891,11 +891,11 @@ do_bang(
int do_in,
int do_out)
{
- char_u *arg = eap->arg; /* command */
- linenr_T line1 = eap->line1; /* start of range */
- linenr_T line2 = eap->line2; /* end of range */
- char_u *newcmd = NULL; /* the new command */
- int free_newcmd = FALSE; /* need to free() newcmd */
+ char_u *arg = eap->arg; // command
+ linenr_T line1 = eap->line1; // start of range
+ linenr_T line2 = eap->line2; // end of range
+ char_u *newcmd = NULL; // the new command
+ int free_newcmd = FALSE; // need to free() newcmd
int ins_prevcmd;
char_u *t;
char_u *p;
@@ -911,9 +911,9 @@ do_bang(
if (check_restricted() || check_secure())
return;
- if (addr_count == 0) /* :! */
+ if (addr_count == 0) // :!
{
- msg_scroll = FALSE; /* don't scroll here */
+ msg_scroll = FALSE; // don't scroll here
autowrite_all();
msg_scroll = scroll_save;
}
@@ -980,11 +980,11 @@ do_bang(
vim_free(prevcmd);
prevcmd = newcmd;
- if (bangredo) /* put cmd in redo buffer for ! command */
+ if (bangredo) // put cmd in redo buffer for ! command
{
- /* If % or # appears in the command, it must have been escaped.
- * Reescape them, so that redoing them does not substitute them by the
- * buffername. */
+ // If % or # appears in the command, it must have been escaped.
+ // Reescape them, so that redoing them does not substitute them by the
+ // buffername.
char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#");
if (cmd != NULL)
@@ -1010,9 +1010,9 @@ do_bang(
STRCAT(newcmd, p_shq);
free_newcmd = TRUE;
}
- if (addr_count == 0) /* :! */
+ if (addr_count == 0) // :!
{
- /* echo the command */
+ // echo the command
msg_start();
msg_putchar(':');
msg_putchar('!');
@@ -1022,10 +1022,10 @@ do_bang(
do_shell(newcmd, 0);
}
- else /* :range! */
+ else // :range!
{
- /* Careful: This may recursively call do_bang() again! (because of
- * autocommands) */
+ // Careful: This may recursively call do_bang() again! (because of
+ // autocommands)
do_filter(line1, line2, eap, newcmd, do_in, do_out);
apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, FALSE, curbuf);
}
@@ -1052,7 +1052,7 @@ do_bang(
do_filter(
linenr_T line1,
linenr_T line2,
- exarg_T *eap, /* for forced 'ff' and 'fenc' */
+ exarg_T *eap, // for forced 'ff' and 'fenc'
char_u *cmd,
int do_in,
int do_out)
@@ -1072,7 +1072,7 @@ do_filter(
int stmp = p_stmp;
#endif
- if (*cmd == NUL) /* no filter command */
+ if (*cmd == NUL) // no filter command
return;
// Temporarily disable lockmarks since that's needed to propagate changed
@@ -1110,21 +1110,21 @@ do_filter(
if (!do_in && do_out && !stmp)
{
- /* Use a pipe to fetch stdout of the command, do not use a temp file. */
+ // Use a pipe to fetch stdout of the command, do not use a temp file.
shell_flags |= SHELL_READ;
curwin->w_cursor.lnum = line2;
}
else if (do_in && !do_out && !stmp)
{
- /* Use a pipe to write stdin of the command, do not use a temp file. */
+ // Use a pipe to write stdin of the command, do not use a temp file.
shell_flags |= SHELL_WRITE;
curbuf->b_op_start.lnum = line1;
curbuf->b_op_end.lnum = line2;
}
else if (do_in && do_out && !stmp)
{
- /* Use a pipe to write stdin and fetch stdout of the command, do not
- * use a temp file. */
+ // Use a pipe to write stdin and fetch stdout of the command, do not
+ // use a temp file.
shell_flags |= SHELL_READ|SHELL_WRITE;
curbuf->b_op_start.lnum = line1;
curbuf->b_op_end.lnum = line2;
@@ -1143,16 +1143,16 @@ do_filter(
* The writing and reading of temp files will not be shown.
* Vi also doesn't do this and the messages are not very informative.
*/
- ++no_wait_return; /* don't call wait_return() while busy */
+ ++no_wait_return; // don't call wait_return() while busy
if (itmp != NULL && buf_write(curbuf, itmp, NULL, line1, line2, eap,
FALSE, FALSE, FALSE, TRUE) == FAIL)
{
- msg_putchar('\n'); /* keep message from buf_write() */
+ msg_putchar('\n'); // keep message from buf_write()
--no_wait_return;
#if defined(FEAT_EVAL)
if (!aborting())
#endif
- (void)semsg(_(e_notcreate), itmp); /* will call wait_return */
+ (void)semsg(_(e_notcreate), itmp); // will call wait_return
goto filterend;
}
if (curbuf != old_curbuf)
@@ -1161,7 +1161,7 @@ do_filter(
if (!do_out)
msg_putchar('\n');
- /* Create the shell command in allocated memory. */
+ // Create the shell command in allocated memory.
cmd_buf = make_filter_cmd(cmd, itmp, otmp);
if (cmd_buf == NULL)
goto filterend;
@@ -1209,9 +1209,9 @@ do_filter(
did_check_timestamps = FALSE;
need_check_timestamps = TRUE;
- /* When interrupting the shell command, it may still have produced some
- * useful output. Reset got_int here, so that readfile() won't cancel
- * reading. */
+ // When interrupting the shell command, it may still have produced some
+ // useful output. Reset got_int here, so that readfile() won't cancel
+ // reading.
ui_breakcheck();
got_int = FALSE;
@@ -1249,12 +1249,12 @@ do_filter(
if (cmdmod.keepmarks || vim_strchr(p_cpo, CPO_REMMARK) == NULL)
{
if (read_linecount >= linecount)
- /* move all marks from old lines to new lines */
+ // move all marks from old lines to new lines
mark_adjust(line1, line2, linecount, 0L);
else
{
- /* move marks from old lines to new lines, delete marks
- * that are in deleted lines */
+ // move marks from old lines to new lines, delete marks
+ // that are in deleted lines
mark_adjust(line1, line1 + read_linecount - 1,
linecount, 0L);
mark_adjust(line1 + read_linecount, line2, MAXLNUM, 0L);
@@ -1267,10 +1267,10 @@ do_filter(
*/
curwin->w_cursor.lnum = line1;
del_lines(linecount, TRUE);
- curbuf->b_op_start.lnum -= linecount; /* adjust '[ */
- curbuf->b_op_end.lnum -= linecount; /* adjust '] */
- write_lnum_adjust(-linecount); /* adjust last line
- for next write */
+ curbuf->b_op_start.lnum -= linecount; // adjust '[
+ curbuf->b_op_end.lnum -= linecount; // adjust ']
+ write_lnum_adjust(-linecount); // adjust last line
+ // for next write
#ifdef FEAT_FOLDING
foldUpdate(curwin, curbuf->b_op_start.lnum, curbuf->b_op_end.lnum);
#endif
@@ -1284,7 +1284,7 @@ do_filter(
curwin->w_cursor.lnum = curbuf->b_op_end.lnum;
}
- beginline(BL_WHITE | BL_FIX); /* cursor on first non-blank */
+ beginline(BL_WHITE | BL_FIX); // cursor on first non-blank
--no_wait_return;
if (linecount > p_report)
@@ -1294,7 +1294,7 @@ do_filter(
vim_snprintf(msg_buf, sizeof(msg_buf),
_("%ld lines filtered"), (long)linecount);
if (msg(msg_buf) && !msg_scroll)
- /* save message to display it after redraw */
+ // save message to display it after redraw
set_keep_msg((char_u *)msg_buf, 0);
}
else
@@ -1304,7 +1304,7 @@ do_filter(
else
{
error:
- /* put cursor back in same position for ":w !cmd" */
+ // put cursor back in same position for ":w !cmd"
curwin->w_cursor = cursor_save;
--no_wait_return;
wait_return(FALSE);
@@ -1339,7 +1339,7 @@ filterend:
void
do_shell(
char_u *cmd,
- int flags) /* may be SHELL_DOOUT when output is redirected */
+ int flags) // may be SHELL_DOOUT when output is redirected
{
buf_T *buf;
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
@@ -1473,7 +1473,7 @@ do_shell(
no_wait_return = save_nwr;
}
}
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
#ifdef MSWIN
if (!keep_termcap) // if keep_termcap is TRUE didn't stop termcap
@@ -1488,23 +1488,23 @@ do_shell(
* but it saves an extra redraw.
*/
#ifdef AMIGA
- if (skip_redraw) /* ':' hit in wait_return() */
+ if (skip_redraw) // ':' hit in wait_return()
{
if (msg_silent == 0)
redraw_later_clear();
}
else if (term_console)
{
- OUT_STR(IF_EB("\033[0 q", ESC_STR "[0 q")); /* get window size */
+ OUT_STR(IF_EB("\033[0 q", ESC_STR "[0 q")); // get window size
if (got_int && msg_silent == 0)
- redraw_later_clear(); /* if got_int is TRUE, redraw needed */
+ redraw_later_clear(); // if got_int is TRUE, redraw needed
else
- must_redraw = 0; /* no extra redraw needed */
+ must_redraw = 0; // no extra redraw needed
}
#endif
}
- /* display any error messages now */
+ // display any error messages now
display_errors();
apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf);
@@ -1537,9 +1537,9 @@ find_pipe(char_u *cmd)
*/
char_u *
make_filter_cmd(
- char_u *cmd, /* command */
- char_u *itmp, /* NULL or name of input file */
- char_u *otmp) /* NULL or name of output file */
+ char_u *cmd, // command
+ char_u *itmp, // NULL or name of input file
+ char_u *otmp) // NULL or name of output file
{
char_u *buf;
long_u len;
@@ -1548,18 +1548,18 @@ make_filter_cmd(
int is_fish_shell;
char_u *shell_name = get_isolated_shell_name();
- /* Account for fish's different syntax for subshells */
+ // Account for fish's different syntax for subshells
is_fish_shell = (fnamecmp(shell_name, "fish") == 0);
vim_free(shell_name);
if (is_fish_shell)
- len = (long_u)STRLEN(cmd) + 13; /* "begin; " + "; end" + NUL */
+ len = (long_u)STRLEN(cmd) + 13; // "begin; " + "; end" + NUL
else
#endif
- len = (long_u)STRLEN(cmd) + 3; /* "()" + NUL */
+ len = (long_u)STRLEN(cmd) + 3; // "()" + NUL
if (itmp != NULL)
- len += (long_u)STRLEN(itmp) + 9; /* " { < " + " } " */
+ len += (long_u)STRLEN(itmp) + 9; // " { < " + " } "
if (otmp != NULL)
- len += (long_u)STRLEN(otmp) + (long_u)STRLEN(p_srr) + 2; /* " " */
+ len += (long_u)STRLEN(otmp) + (long_u)STRLEN(p_srr) + 2; // " "
buf = alloc(len);
if (buf == NULL)
return NULL;
@@ -1720,7 +1720,7 @@ print_line_no_prefix(
{
vim_snprintf(numbuf, sizeof(numbuf),
"%*ld ", number_width(curwin), (long)lnum);
- msg_puts_attr(numbuf, HL_ATTR(HLF_N)); /* Highlight line nrs */
+ msg_puts_attr(numbuf, HL_ATTR(HLF_N)); // Highlight line nrs
}
msg_prt_line(ml_get(lnum), list);
}
@@ -1733,18 +1733,18 @@ print_line(linenr_T lnum, int use_number, int list)
{
int save_silent = silent_mode;
- /* apply :filter /pat/ */
+ // apply :filter /pat/
if (message_filtered(ml_get(lnum)))
return;
msg_start();
silent_mode = FALSE;
- info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
+ info_message = TRUE; // use mch_msg(), not mch_errmsg()
print_line_no_prefix(lnum, use_number, list);
if (save_silent)
{
msg_putchar('\n');
- cursor_on(); /* msg_start() switches it off */
+ cursor_on(); // msg_start() switches it off
out_flush();
silent_mode = save_silent;
}
@@ -1759,11 +1759,11 @@ rename_buffer(char_u *new_fname)
buf = curbuf;
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
- /* buffer changed, don't change name now */
+ // buffer changed, don't change name now
if (buf != curbuf)
return FAIL;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
/*
@@ -1795,7 +1795,7 @@ rename_buffer(char_u *new_fname)
vim_free(sfname);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
- /* Change directories when the 'acd' option is set. */
+ // Change directories when the 'acd' option is set.
DO_AUTOCHDIR;
return OK;
}
@@ -1806,8 +1806,8 @@ rename_buffer(char_u *new_fname)
void
ex_file(exarg_T *eap)
{
- /* ":0file" removes the file name. Check for illegal uses ":3file",
- * "0file name", etc. */
+ // ":0file" removes the file name. Check for illegal uses ":3file",
+ // "0file name", etc.
if (eap->addr_count > 0
&& (*eap->arg != NUL
|| eap->line2 > 0
@@ -1852,7 +1852,7 @@ ex_write(exarg_T *eap)
eap->line2 = curbuf->b_ml.ml_line_count;
}
- if (eap->usefilter) /* input lines to shell command */
+ if (eap->usefilter) // input lines to shell command
do_bang(1, eap, FALSE, TRUE, FALSE);
else
(void)do_write(eap);
@@ -1870,7 +1870,7 @@ ex_write(exarg_T *eap)
do_write(exarg_T *eap)
{
int other;
- char_u *fname = NULL; /* init to shut up gcc */
+ char_u *fname = NULL; // init to shut up gcc
char_u *ffname;
int retval = FAIL;
char_u *free_fname = NULL;
@@ -1880,7 +1880,7 @@ do_write(exarg_T *eap)
buf_T *alt_buf = NULL;
int name_was_missing;
- if (not_writing()) /* check 'write' option */
+ if (not_writing()) // check 'write' option
return FAIL;
ffname = eap->arg;
@@ -1928,8 +1928,8 @@ do_write(exarg_T *eap)
alt_buf = buflist_findname(ffname);
if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL)
{
- /* Overwriting a file that is loaded in another buffer is not a
- * good idea. */
+ // Overwriting a file that is loaded in another buffer is not a
+ // good idea.
emsg(_(e_bufloaded));
goto theend;
}
@@ -1991,15 +1991,15 @@ do_write(exarg_T *eap)
if (curbuf != was_curbuf)
#endif
{
- /* buffer changed, don't change name now */
+ // buffer changed, don't change name now
retval = FAIL;
goto theend;
}
- /* Exchange the file names for the current and the alternate
- * buffer. This makes it look like we are now editing the buffer
- * under the new name. Must be done before buf_write(), because
- * if there is no file name and 'cpo' contains 'F', it will set
- * the file name. */
+ // Exchange the file names for the current and the alternate
+ // buffer. This makes it look like we are now editing the buffer
+ // under the new name. Must be done before buf_write(), because
+ // if there is no file name and 'cpo' contains 'F', it will set
+ // the file name.
fname = alt_buf->b_fname;
alt_buf->b_fname = curbuf->b_fname;
curbuf->b_fname = fname;
@@ -2024,12 +2024,12 @@ do_write(exarg_T *eap)
if (curbuf != was_curbuf)
#endif
{
- /* buffer changed, don't write the file */
+ // buffer changed, don't write the file
retval = FAIL;
goto theend;
}
- /* If 'filetype' was empty try detecting it now. */
+ // If 'filetype' was empty try detecting it now.
if (*curbuf->b_p_ft == NUL)
{
if (au_has_group((char_u *)"filetypedetect"))
@@ -2038,8 +2038,8 @@ do_write(exarg_T *eap)
do_modelines(0);
}
- /* Autocommands may have changed buffer names, esp. when
- * 'autochdir' is set. */
+ // Autocommands may have changed buffer names, esp. when
+ // 'autochdir' is set.
fname = curbuf->b_sfname;
}
@@ -2048,7 +2048,7 @@ do_write(exarg_T *eap)
retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
eap, eap->append, eap->forceit, TRUE, FALSE);
- /* After ":saveas fname" reset 'readonly'. */
+ // After ":saveas fname" reset 'readonly'.
if (eap->cmdidx == CMD_saveas)
{
if (retval == OK)
@@ -2058,8 +2058,8 @@ do_write(exarg_T *eap)
}
}
- /* Change directories when the 'acd' option is set and the file name
- * got changed or set. */
+ // Change directories when the 'acd' option is set and the file name
+ // got changed or set.
if (eap->cmdidx == CMD_saveas || name_was_missing)
DO_AUTOCHDIR;
}
@@ -2082,10 +2082,10 @@ theend:
check_overwrite(
exarg_T *eap,
buf_T *buf,
- char_u *fname, /* file name to be used (can differ from
- buf->ffname) */
- char_u *ffname, /* full path version of fname */
- int other) /* writing under other name */
+ char_u *fname, // file name to be used (can differ from
+ // buf->ffname)
+ char_u *ffname, // full path version of fname
+ int other) // writing under other name
{
/*
* write to other file or b_flags set or not writing the whole file:
@@ -2105,7 +2105,7 @@ check_overwrite(
if (!eap->forceit && !eap->append)
{
#ifdef UNIX
- /* with UNIX it is possible to open a directory */
+ // with UNIX it is possible to open a directory
if (mch_isdir(ffname))
{
semsg(_(e_isadir2), ffname);
@@ -2130,7 +2130,7 @@ check_overwrite(
}
}
- /* For ":w! filename" check that no swap file exists for "filename". */
+ // For ":w! filename" check that no swap file exists for "filename".
if (other && !emsg_silent)
{
char_u *dir;
@@ -2138,11 +2138,11 @@ check_overwrite(
int r;
char_u *swapname;
- /* We only try the first entry in 'directory', without checking if
- * it's writable. If the "." directory is not writable the write
- * will probably fail anyway.
- * Use 'shortname' of the current buffer, since there is no buffer
- * for the written file. */
+ // We only try the first entry in 'directory', without checking if
+ // it's writable. If the "." directory is not writable the write
+ // will probably fail anyway.
+ // Use 'shortname' of the current buffer, since there is no buffer
+ // for the written file.
if (*p_dir == NUL)
{
dir = alloc(5);
@@ -2250,7 +2250,7 @@ do_wqall(exarg_T *eap)
break;
}
#ifdef FEAT_BROWSE
- /* ":browse wall": ask for file name if there isn't one */
+ // ":browse wall": ask for file name if there isn't one
if (buf->b_ffname == NULL && cmdmod.browse)
browse_save_fname(buf);
#endif
@@ -2272,17 +2272,17 @@ do_wqall(exarg_T *eap)
set_bufref(&bufref, buf);
if (buf_write_all(buf, eap->forceit) == FAIL)
++error;
- /* an autocommand may have deleted the buffer */
+ // an autocommand may have deleted the buffer
if (!bufref_valid(&bufref))
buf = firstbuf;
}
- eap->forceit = save_forceit; /* check_overwrite() may set it */
+ eap->forceit = save_forceit; // check_overwrite() may set it
}
}
if (exiting)
{
if (!error)
- getout(0); /* exit Vim */
+ getout(0); // exit Vim
not_exiting();
}
}
@@ -2310,10 +2310,10 @@ check_readonly(int *forceit, buf_T *buf)
{
stat_T st;
- /* Handle a file being readonly when the 'readonly' option is set or when
- * the file exists and permissions are read-only.
- * We will send 0777 to check_file_readonly(), as the "perm" variable is
- * important for device checks but not here. */
+ // Handle a file being readonly when the 'readonly' option is set or when
+ // the file exists and permissions are read-only.
+ // We will send 0777 to check_file_readonly(), as the "perm" variable is
+ // important for device checks but not here.
if (!*forceit && (buf->b_p_ro
|| (mch_stat((char *)buf->b_ffname, &st) >= 0
&& check_file_readonly(buf->b_ffname, 0777))))
@@ -2332,7 +2332,7 @@ check_readonly(int *forceit, buf_T *buf)
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES)
{
- /* Set forceit, to force the writing of a readonly file */
+ // Set forceit, to force the writing of a readonly file
*forceit = TRUE;
return FALSE;
}
@@ -2385,16 +2385,16 @@ getfile(
if (fnum == 0)
{
- /* make ffname full path, set sfname */
+ // make ffname full path, set sfname
fname_expand(curbuf, &ffname, &sfname);
other = otherfile(ffname);
- free_me = ffname; /* has been allocated, free() later */
+ free_me = ffname; // has been allocated, free() later
}
else
other = (fnum != curbuf->b_fnum);
if (other)
- ++no_wait_return; /* don't wait for autowrite message */
+ ++no_wait_return; // don't wait for autowrite message
if (other && !forceit && curbuf->b_nwindows == 1 && !buf_hide(curbuf)
&& curbufIsChanged() && autowrite(curbuf, forceit) == FAIL)
{
@@ -2407,7 +2407,7 @@ getfile(
if (other)
--no_wait_return;
no_write_message();
- retval = GETFILE_NOT_WRITTEN; /* file has been changed */
+ retval = GETFILE_NOT_WRITTEN; // file has been changed
goto theend;
}
}
@@ -2421,14 +2421,14 @@ getfile(
curwin->w_cursor.lnum = lnum;
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
- retval = GETFILE_SAME_FILE; /* it's in the same file */
+ retval = GETFILE_SAME_FILE; // it's in the same file
}
else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
(buf_hide(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
curwin) == OK)
- retval = GETFILE_OPEN_OTHER; /* opened another file */
+ retval = GETFILE_OPEN_OTHER; // opened another file
else
- retval = GETFILE_ERROR; /* error encountered */
+ retval = GETFILE_ERROR; // error encountered
theend:
vim_free(free_me);
@@ -2469,15 +2469,15 @@ do_ecmd(
int fnum,
char_u *ffname,
char_u *sfname,
- exarg_T *eap, /* can be NULL! */
+ exarg_T *eap, // can be NULL!
linenr_T newlnum,
int flags,
win_T *oldwin)
{
- int other_file; /* TRUE if editing another file */
- int oldbuf; /* TRUE if using existing buffer */
- int auto_buf = FALSE; /* TRUE if autocommands brought us
- into the buffer unexpectedly */
+ int other_file; // TRUE if editing another file
+ int oldbuf; // TRUE if using existing buffer
+ int auto_buf = FALSE; // TRUE if autocommands brought us
+ // into the buffer unexpectedly
char_u *new_name = NULL;
#if defined(FEAT_EVAL)
int did_set_swapcommand = FALSE;
@@ -2510,8 +2510,8 @@ do_ecmd(
if (fnum != 0)
{
- if (fnum == curbuf->b_fnum) /* file is already being edited */
- return OK; /* nothing to do */
+ if (fnum == curbuf->b_fnum) // file is already being edited
+ return OK; // nothing to do
other_file = TRUE;
}
else
@@ -2525,8 +2525,8 @@ do_ecmd(
# endif
au_has_group((char_u *)"FileExplorer"))
{
- /* No browsing supported but we do have the file explorer:
- * Edit the directory. */
+ // No browsing supported but we do have the file explorer:
+ // Edit the directory.
if (ffname == NULL || !mch_isdir(ffname))
ffname = (char_u *)".";
}
@@ -2540,12 +2540,12 @@ do_ecmd(
}
}
#endif
- /* if no short name given, use ffname for short name */
+ // if no short name given, use ffname for short name
if (sfname == NULL)
sfname = ffname;
#ifdef USE_FNAME_CASE
if (sfname != NULL)
- fname_case(sfname, 0); /* set correct case for sfname */
+ fname_case(sfname, 0); // set correct case for sfname
#endif
if ((flags & ECMD_ADDBUF) && (ffname == NULL || *ffname == NUL))
@@ -2553,17 +2553,17 @@ do_ecmd(
if (ffname == NULL)
other_file = TRUE;
- /* there is no file name */
+ // there is no file name
else if (*ffname == NUL && curbuf->b_ffname == NULL)
other_file = FALSE;
else
{
- if (*ffname == NUL) /* re-edit with same file name */
+ if (*ffname == NUL) // re-edit with same file name
{
ffname = curbuf->b_ffname;
sfname = curbuf->b_fname;
}
- free_fname = fix_fname(ffname); /* may expand to full path name */
+ free_fname = fix_fname(ffname); // may expand to full path name
if (free_fname != NULL)
ffname = free_fname;
other_file = otherfile(ffname);
@@ -2601,7 +2601,7 @@ do_ecmd(
int len;
char_u *p;
- /* Set v:swapcommand for the SwapExists autocommands. */
+ // Set v:swapcommand for the SwapExists autocommands.
if (command != NULL)
len = (int)STRLEN(command) + 3;
else
@@ -2654,34 +2654,34 @@ do_ecmd(
buf = buflist_new(ffname, sfname, 0L,
BLN_CURBUF | ((flags & ECMD_SET_HELP) ? 0 : BLN_LISTED));
- /* autocommands may change curwin and curbuf */
+ // autocommands may change curwin and curbuf
if (oldwin != NULL)
oldwin = curwin;
set_bufref(&old_curbuf, curbuf);
}
if (buf == NULL)
goto theend;
- if (buf->b_ml.ml_mfp == NULL) /* no memfile yet */
+ if (buf->b_ml.ml_mfp == NULL) // no memfile yet
{
oldbuf = FALSE;
}
- else /* existing memfile */
+ else // existing memfile
{
oldbuf = TRUE;
set_bufref(&bufref, buf);
(void)buf_check_timestamp(buf, FALSE);
- /* Check if autocommands made the buffer invalid or changed the
- * current buffer. */
+ // Check if autocommands made the buffer invalid or changed the
+ // current buffer.
if (!bufref_valid(&bufref) || curbuf != old_curbuf.br_buf)
goto theend;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
goto theend;
#endif
}
- /* May jump to last used line number for a loaded buffer or when asked
- * for explicitly */
+ // May jump to last used line number for a loaded buffer or when asked
+ // for explicitly
if ((oldbuf && newlnum == ECMD_LASTL) || newlnum == ECMD_LAST)
{
pos = buflist_findfpos(buf);
@@ -2713,33 +2713,33 @@ do_ecmd(
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
if (!bufref_valid(&au_new_curbuf))
{
- /* new buffer has been deleted */
- delbuf_msg(new_name); /* frees new_name */
+ // new buffer has been deleted
+ delbuf_msg(new_name); // frees new_name
goto theend;
}
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
{
vim_free(new_name);
goto theend;
}
#endif
- if (buf == curbuf) /* already in new buffer */
+ if (buf == curbuf) // already in new buffer
auto_buf = TRUE;
else
{
win_T *the_curwin = curwin;
- /* Set the w_closing flag to avoid that autocommands close the
- * window. And set b_locked for the same reason. */
+ // Set the w_closing flag to avoid that autocommands close the
+ // window. And set b_locked for the same reason.
the_curwin->w_closing = TRUE;
++buf->b_locked;
if (curbuf == old_curbuf.br_buf)
buf_copy_options(buf, BCO_ENTER);
- /* Close the link to the current buffer. This will set
- * oldwin->w_buffer to NULL. */
+ // Close the link to the current buffer. This will set
+ // oldwin->w_buffer to NULL.
u_sync(FALSE);
close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE);
@@ -2748,21 +2748,21 @@ do_ecmd(
--buf->b_locked;
#ifdef FEAT_EVAL
- /* autocmds may abort script processing */
+ // autocmds may abort script processing
if (aborting() && curwin->w_buffer != NULL)
{
vim_free(new_name);
goto theend;
}
#endif
- /* Be careful again, like above. */
+ // Be careful again, like above.
if (!bufref_valid(&au_new_curbuf))
{
- /* new buffer has been deleted */
- delbuf_msg(new_name); /* frees new_name */
+ // new buffer has been deleted
+ delbuf_msg(new_name); // frees new_name
goto theend;
}
- if (buf == curbuf) /* already in new buffer */
+ if (buf == curbuf) // already in new buffer
auto_buf = TRUE;
else
{
@@ -2779,7 +2779,7 @@ do_ecmd(
curbuf = buf;
++curbuf->b_nwindows;
- /* Set 'fileformat', 'binary' and 'fenc' when forced. */
+ // Set 'fileformat', 'binary' and 'fenc' when forced.
if (!oldbuf && eap != NULL)
{
set_file_options(TRUE, eap);
@@ -2787,10 +2787,10 @@ do_ecmd(
}
}
- /* May get the window options from the last time this buffer
- * was in this window (or another window). If not used
- * before, reset the local window options to the global
- * values. Also restores old folding stuff. */
+ // May get the window options from the last time this buffer
+ // was in this window (or another window). If not used
+ // before, reset the local window options to the global
+ // values. Also restores old folding stuff.
get_winopts(curbuf);
#ifdef FEAT_SPELL
did_get_winopts = TRUE;
@@ -2804,7 +2804,7 @@ do_ecmd(
curwin->w_pcmark.lnum = 1;
curwin->w_pcmark.col = 0;
}
- else /* !other_file */
+ else // !other_file
{
if ((flags & ECMD_ADDBUF) || check_fname() == FAIL)
goto theend;
@@ -2812,8 +2812,8 @@ do_ecmd(
oldbuf = (flags & ECMD_OLDBUF);
}
- /* Don't redraw until the cursor is in the right line, otherwise
- * autocommands may cause ml_get errors. */
+ // Don't redraw until the cursor is in the right line, otherwise
+ // autocommands may cause ml_get errors.
++RedrawingDisabled;
did_inc_redrawing_disabled = TRUE;
@@ -2824,24 +2824,24 @@ do_ecmd(
}
else
{
- /* Don't make a buffer listed if it's a help buffer. Useful when
- * using CTRL-O to go back to a help file. */
+ // Don't make a buffer listed if it's a help buffer. Useful when
+ // using CTRL-O to go back to a help file.
if (!curbuf->b_help)
set_buflisted(TRUE);
}
- /* If autocommands change buffers under our fingers, forget about
- * editing the file. */
+ // If autocommands change buffers under our fingers, forget about
+ // editing the file.
if (buf != curbuf)
goto theend;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
goto theend;
#endif
- /* Since we are starting to edit a file, consider the filetype to be
- * unset. Helps for when an autocommand changes files and expects syntax
- * highlighting to work in the other file. */
+ // Since we are starting to edit a file, consider the filetype to be
+ // unset. Helps for when an autocommand changes files and expects syntax
+ // highlighting to work in the other file.
did_filetype = FALSE;
/*
@@ -2851,9 +2851,9 @@ do_ecmd(
* TRUE FALSE start editing new file, new buffer
* TRUE TRUE start editing in existing buffer (nothing to do)
*/
- if (!other_file && !oldbuf) /* re-use the buffer */
+ if (!other_file && !oldbuf) // re-use the buffer
{
- set_last_cursor(curwin); /* may set b_last_cursor */
+ set_last_cursor(curwin); // may set b_last_cursor
if (newlnum == ECMD_LAST || newlnum == ECMD_LASTL)
{
newlnum = curwin->w_cursor.lnum;
@@ -2868,8 +2868,8 @@ do_ecmd(
if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur)
{
- /* Save all the text, so that the reload can be undone.
- * Sync first so that this is a separate undo-able action. */
+ // Save all the text, so that the reload can be undone.
+ // Sync first so that this is a separate undo-able action.
u_sync(FALSE);
if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE)
== FAIL)
@@ -2880,39 +2880,39 @@ do_ecmd(
u_unchanged(curbuf);
buf_freeall(curbuf, BFA_KEEP_UNDO);
- /* tell readfile() not to clear or reload undo info */
+ // tell readfile() not to clear or reload undo info
readfile_flags = READ_KEEP_UNDO;
}
else
- buf_freeall(curbuf, 0); /* free all things for buffer */
+ buf_freeall(curbuf, 0); // free all things for buffer
- /* If autocommands deleted the buffer we were going to re-edit, give
- * up and jump to the end. */
+ // If autocommands deleted the buffer we were going to re-edit, give
+ // up and jump to the end.
if (!bufref_valid(&bufref))
{
- delbuf_msg(new_name); /* frees new_name */
+ delbuf_msg(new_name); // frees new_name
goto theend;
}
vim_free(new_name);
- /* If autocommands change buffers under our fingers, forget about
- * re-editing the file. Should do the buf_clear_file(), but perhaps
- * the autocommands changed the buffer... */
+ // If autocommands change buffers under our fingers, forget about
+ // re-editing the file. Should do the buf_clear_file(), but perhaps
+ // the autocommands changed the buffer...
if (buf != curbuf)
goto theend;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
goto theend;
#endif
buf_clear_file(curbuf);
- curbuf->b_op_start.lnum = 0; /* clear '[ and '] marks */
+ curbuf->b_op_start.lnum = 0; // clear '[ and '] marks
curbuf->b_op_end.lnum = 0;
}
/*
* If we get here we are sure to start editing
*/
- /* Assume success now */
+ // Assume success now
retval = OK;
/*
@@ -2930,8 +2930,8 @@ do_ecmd(
curwin_init();
#ifdef FEAT_FOLDING
- /* It's possible that all lines in the buffer changed. Need to update
- * automatic folding for all windows where it's used. */
+ // It's possible that all lines in the buffer changed. Need to update
+ // automatic folding for all windows where it's used.
{
win_T *win;
tabpage_T *tp;
@@ -2942,7 +2942,7 @@ do_ecmd(
}
#endif
- /* Change directories when the 'acd' option is set. */
+ // Change directories when the 'acd' option is set.
DO_AUTOCHDIR;
/*
@@ -2951,7 +2951,7 @@ do_ecmd(
*/
orig_pos = curwin->w_cursor;
topline = curwin->w_topline;
- if (!oldbuf) /* need to read the file */
+ if (!oldbuf) // need to read the file
{
#ifdef FEAT_PROP_POPUP
// Don't use the swap-exists dialog for a popup window, can't edit
@@ -2960,7 +2960,7 @@ do_ecmd(
curbuf->b_flags |= BF_NO_SEA;
#endif
swap_exists_action = SEA_DIALOG;
- curbuf->b_flags |= BF_CHECK_RO; /* set/reset 'ro' flag */
+ curbuf->b_flags |= BF_CHECK_RO; // set/reset 'ro' flag
/*
* Open the buffer and read the file.
@@ -2981,9 +2981,9 @@ do_ecmd(
}
else
{
- /* Read the modelines, but only to set window-local options. Any
- * buffer-local options have already been set and may have been
- * changed by the user. */
+ // Read the modelines, but only to set window-local options. Any
+ // buffer-local options have already been set and may have been
+ // changed by the user.
do_modelines(OPT_WINONLY);
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf,
@@ -2993,9 +2993,9 @@ do_ecmd(
}
check_arg_idx(curwin);
- /* If autocommands change the cursor position or topline, we should
- * keep it. Also when it moves within a line. But not when it moves
- * to the first non-blank. */
+ // If autocommands change the cursor position or topline, we should
+ // keep it. Also when it moves within a line. But not when it moves
+ // to the first non-blank.
if (!EQUAL_POS(curwin->w_cursor, orig_pos))
{
char_u *text = ml_get_curline();
@@ -3010,7 +3010,7 @@ do_ecmd(
if (curwin->w_topline == topline)
topline = 0;
- /* Even when cursor didn't move we need to recompute topline. */
+ // Even when cursor didn't move we need to recompute topline.
changed_line_abv_curs();
#ifdef FEAT_TITLE
@@ -3023,9 +3023,9 @@ do_ecmd(
}
#ifdef FEAT_DIFF
- /* Tell the diff stuff that this buffer is new and/or needs updating.
- * Also needed when re-editing the same buffer, because unloading will
- * have removed it as a diff buffer. */
+ // Tell the diff stuff that this buffer is new and/or needs updating.
+ // Also needed when re-editing the same buffer, because unloading will
+ // have removed it as a diff buffer.
if (curwin->w_p_diff)
{
diff_buf_add(curbuf);
@@ -3034,27 +3034,27 @@ do_ecmd(
#endif
#ifdef FEAT_SPELL
- /* If the window options were changed may need to set the spell language.
- * Can only do this after the buffer has been properly setup. */
+ // If the window options were changed may need to set the spell language.
+ // Can only do this after the buffer has been properly setup.
if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
(void)did_set_spelllang(curwin);
#endif
if (command == NULL)
{
- if (newcol >= 0) /* position set by autocommands */
+ if (newcol >= 0) // position set by autocommands
{
curwin->w_cursor.lnum = newlnum;
curwin->w_cursor.col = newcol;
check_cursor();
}
- else if (newlnum > 0) /* line number from caller or old position */
+ else if (newlnum > 0) // line number from caller or old position
{
curwin->w_cursor.lnum = newlnum;
check_cursor_lnum();
if (solcol >= 0 && !p_sol)
{
- /* 'sol' is off: Use last known column. */
+ // 'sol' is off: Use last known column.
curwin->w_cursor.col = solcol;
check_cursor_col();
curwin->w_cursor.coladd = 0;
@@ -3063,7 +3063,7 @@ do_ecmd(
else
beginline(BL_SOL | BL_FIX);
}
- else /* no line number, go to last line in Ex mode */
+ else // no line number, go to last line in Ex mode
{
if (exmode_active)
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
@@ -3071,7 +3071,7 @@ do_ecmd(
}
}
- /* Check if cursors in other windows on the same buffer are still valid */
+ // Check if cursors in other windows on the same buffer are still valid
check_lnums(FALSE);
/*
@@ -3082,11 +3082,11 @@ do_ecmd(
{
int msg_scroll_save = msg_scroll;
- /* Obey the 'O' flag in 'cpoptions': overwrite any previous file
- * message. */
+ // Obey the 'O' flag in 'cpoptions': overwrite any previous file
+ // message.
if (shortmess(SHM_OVERALL) && !exiting && p_verbose == 0)
msg_scroll = FALSE;
- if (!msg_scroll) /* wait a bit when overwriting an error msg */
+ if (!msg_scroll) // wait a bit when overwriting an error msg
check_for_delay(FALSE);
msg_start();
msg_scroll = msg_scroll_save;
@@ -3120,16 +3120,16 @@ do_ecmd(
update_topline();
curwin->w_scbind_pos = curwin->w_topline;
*so_ptr = n;
- redraw_curbuf_later(NOT_VALID); /* redraw this buffer later */
+ redraw_curbuf_later(NOT_VALID); // redraw this buffer later
}
if (p_im)
need_start_insertmode = TRUE;
#ifdef FEAT_AUTOCHDIR
- /* Change directories when the 'acd' option is set and we aren't already in
- * that directory (should already be done above). Expect getcwd() to be
- * faster than calling shorten_fnames() unnecessarily. */
+ // Change directories when the 'acd' option is set and we aren't already in
+ // that directory (should already be done above). Expect getcwd() to be
+ // faster than calling shorten_fnames() unnecessarily.
if (p_acd && curbuf->b_ffname != NULL)
{
char_u curdir[MAXPATHL];
@@ -3177,7 +3177,7 @@ delbuf_msg(char_u *name)
au_new_curbuf.br_buf_free_count = 0;
}
-static int append_indent = 0; /* autoindent for first line */
+static int append_indent = 0; // autoindent for first line
/*
* ":insert" and ":append", also used by ":change"
@@ -3193,22 +3193,22 @@ ex_append(exarg_T *eap)
int vcol;
int empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
- /* the ! flag toggles autoindent */
+ // the ! flag toggles autoindent
if (eap->forceit)
curbuf->b_p_ai = !curbuf->b_p_ai;
- /* First autoindent comes from the line we start on */
+ // First autoindent comes from the line we start on
if (eap->cmdidx != CMD_change && curbuf->b_p_ai && lnum > 0)
append_indent = get_indent_lnum(lnum);
if (eap->cmdidx != CMD_append)
--lnum;
- /* when the buffer is empty need to delete the dummy line */
+ // when the buffer is empty need to delete the dummy line
if (empty && lnum == 1)
lnum = 0;
- State = INSERT; /* behave like in Insert mode */
+ State = INSERT; // behave like in Insert mode
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
State |= LANGMAP;
@@ -3229,8 +3229,8 @@ ex_append(exarg_T *eap)
ex_keep_indent = FALSE;
if (eap->getline == NULL)
{
- /* No getline() function, use the lines that follow. This ends
- * when there is no more. */
+ // No getline() function, use the lines that follow. This ends
+ // when there is no more.
if (eap->nextcmd == NULL || *eap->nextcmd == NUL)
break;
p = vim_strchr(eap->nextcmd, NL);
@@ -3245,8 +3245,8 @@ ex_append(exarg_T *eap)
{
int save_State = State;
- /* Set State to avoid the cursor shape to be set to INSERT mode
- * when getline() returns. */
+ // Set State to avoid the cursor shape to be set to INSERT mode
+ // when getline() returns.
State = CMDLINE;
theline = eap->getline(
#ifdef FEAT_EVAL
@@ -3259,11 +3259,11 @@ ex_append(exarg_T *eap)
if (theline == NULL)
break;
- /* Using ^ CTRL-D in getexmodeline() makes us repeat the indent. */
+ // Using ^ CTRL-D in getexmodeline() makes us repeat the indent.
if (ex_keep_indent)
append_indent = indent;
- /* Look for the "." after automatic indent. */
+ // Look for the "." after automatic indent.
vcol = 0;
for (p = theline; indent > vcol; ++p)
{
@@ -3282,7 +3282,7 @@ ex_append(exarg_T *eap)
break;
}
- /* don't use autoindent if nothing was typed. */
+ // don't use autoindent if nothing was typed.
if (p[0] == NUL)
theline[0] = NUL;
@@ -3304,10 +3304,10 @@ ex_append(exarg_T *eap)
if (eap->forceit)
curbuf->b_p_ai = !curbuf->b_p_ai;
- /* "start" is set to eap->line2+1 unless that position is invalid (when
- * eap->line2 pointed to the end of the buffer and nothing was appended)
- * "end" is set to lnum when something has been appended, otherwise
- * it is the same than "start" -- Acevedo */
+ // "start" is set to eap->line2+1 unless that position is invalid (when
+ // eap->line2 pointed to the end of the buffer and nothing was appended)
+ // "end" is set to lnum when something has been appended, otherwise
+ // it is the same than "start" -- Acevedo
if (!cmdmod.lockmarks)
{
curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ?
@@ -3322,7 +3322,7 @@ ex_append(exarg_T *eap)
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
- need_wait_return = FALSE; /* don't use wait_return() now */
+ need_wait_return = FALSE; // don't use wait_return() now
ex_no_reprint = TRUE;
}
@@ -3338,22 +3338,22 @@ ex_change(exarg_T *eap)
&& u_save(eap->line1 - 1, eap->line2 + 1) == FAIL)
return;
- /* the ! flag toggles autoindent */
+ // the ! flag toggles autoindent
if (eap->forceit ? !curbuf->b_p_ai : curbuf->b_p_ai)
append_indent = get_indent_lnum(eap->line1);
for (lnum = eap->line2; lnum >= eap->line1; --lnum)
{
- if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
+ if (curbuf->b_ml.ml_flags & ML_EMPTY) // nothing to delete
break;
ml_delete(eap->line1, FALSE);
}
- /* make sure the cursor is not beyond the end of the file now */
+ // make sure the cursor is not beyond the end of the file now
check_cursor_lnum();
deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum));
- /* ":append" on the line above the deleted lines. */
+ // ":append" on the line above the deleted lines.
eap->line2 = eap->line1;
ex_append(eap);
}
@@ -3369,8 +3369,8 @@ ex_z(exarg_T *eap)
int j;
linenr_T lnum = eap->line2;
- /* Vi compatible: ":z!" uses display height, without a count uses
- * 'scroll' */
+ // Vi compatible: ":z!" uses display height, without a count uses
+ // 'scroll'
if (eap->forceit)
bigness = curwin->w_height;
else if (!ONE_WINDOW)
@@ -3399,7 +3399,7 @@ ex_z(exarg_T *eap)
{
bigness = atol((char *)x);
- /* bigness could be < 0 if atol(x) overflows. */
+ // bigness could be < 0 if atol(x) overflows.
if (bigness > 2 * curbuf->b_ml.ml_line_count || bigness < 0)
bigness = 2 * curbuf->b_ml.ml_line_count;
@@ -3409,7 +3409,7 @@ ex_z(exarg_T *eap)
}
}
- /* the number of '-' and '+' multiplies the distance */
+ // the number of '-' and '+' multiplies the distance
if (*kind == '-' || *kind == '+')
for (x = kind + 1; *x == *kind; ++x)
;
@@ -3441,7 +3441,7 @@ ex_z(exarg_T *eap)
curs = end;
break;
- default: /* '+' */
+ default: // '+'
start = lnum;
if (*kind == '+')
start += bigness * (linenr_T)(x - kind - 1) + 1;
@@ -3536,25 +3536,24 @@ check_secure(void)
return FALSE;
}
-static char_u *old_sub = NULL; /* previous substitute pattern */
-static int global_need_beginline; /* call beginline() after ":g" */
+static char_u *old_sub = NULL; // previous substitute pattern
+static int global_need_beginline; // call beginline() after ":g"
/*
* Flags that are kept between calls to :substitute.
*/
typedef struct {
- int do_all; /* do multiple substitutions per line */
- int do_ask; /* ask for confirmation */
- int do_count; /* count only */
- int do_error; /* if false, ignore errors */
- int do_print; /* print last line with subs. */
- int do_list; /* list last line with subs. */
- int do_number; /* list last line with line nr*/
- int do_ic; /* ignore case flag */
+ int do_all; // do multiple substitutions per line
+ int do_ask; // ask for confirmation
+ int do_count; // count only
+ int do_error; // if false, ignore errors
+ int do_print; // print last line with subs.
+ int do_list; // list last line with subs.
+ int do_number; // list last line with line nr
+ int do_ic; // ignore case flag
} subflags_T;
-/* do_sub()
- *
+/*
* Perform a substitution from line eap->line1 to line eap->line2 using the
* command pointed to by eap->arg which should be of the form:
*
@@ -3573,9 +3572,9 @@ do_sub(exarg_T *eap)
#ifdef FEAT_EVAL
subflags_T subflags_save;
#endif
- int save_do_all; /* remember user specified 'g' flag */
- int save_do_ask; /* remember user specified 'c' flag */
- char_u *pat = NULL, *sub = NULL; /* init for GCC */
+ int save_do_all; // remember user specified 'g' flag
+ int save_do_ask; // remember user specified 'c' flag
+ char_u *pat = NULL, *sub = NULL; // init for GCC
int delimiter;
int sublen;
int got_quit = FALSE;
@@ -3584,14 +3583,14 @@ do_sub(exarg_T *eap)
int which_pat;
char_u *cmd;
int save_State;
- linenr_T first_line = 0; /* first changed line */
- linenr_T last_line= 0; /* below last changed line AFTER the
- * change */
+ linenr_T first_line = 0; // first changed line
+ linenr_T last_line= 0; // below last changed line AFTER the
+ // change
linenr_T old_line_count = curbuf->b_ml.ml_line_count;
linenr_T line2;
- long nmatch; /* number of lines in match */
- char_u *sub_firstline; /* allocated copy of first sub line */
- int endcolumn = FALSE; /* cursor in last column when done */
+ long nmatch; // number of lines in match
+ char_u *sub_firstline; // allocated copy of first sub line
+ int endcolumn = FALSE; // cursor in last column when done
pos_T old_cursor = curwin->w_cursor;
int start_nsubs;
#ifdef FEAT_EVAL
@@ -3607,15 +3606,15 @@ do_sub(exarg_T *eap)
start_nsubs = sub_nsubs;
if (eap->cmdidx == CMD_tilde)
- which_pat = RE_LAST; /* use last used regexp */
+ which_pat = RE_LAST; // use last used regexp
else
- which_pat = RE_SUBST; /* use last substitute regexp */
+ which_pat = RE_SUBST; // use last substitute regexp
- /* new pattern and substitution */
+ // new pattern and substitution
if (eap->cmd[0] == 's' && *cmd != NUL && !VIM_ISWHITE(*cmd)
&& vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL)
{
- /* don't accept alphanumeric for separator */
+ // don't accept alphanumeric for separator
if (isalpha(*cmd))
{
emsg(_("E146: Regular expressions can't be delimited by letters"));
@@ -3635,45 +3634,45 @@ do_sub(exarg_T *eap)
return;
}
if (*cmd != '&')
- which_pat = RE_SEARCH; /* use last '/' pattern */
- pat = (char_u *)""; /* empty search pattern */
- delimiter = *cmd++; /* remember delimiter character */
+ which_pat = RE_SEARCH; // use last '/' pattern
+ pat = (char_u *)""; // empty search pattern
+ delimiter = *cmd++; // remember delimiter character
}
- else /* find the end of the regexp */
+ else // find the end of the regexp
{
- which_pat = RE_LAST; /* use last used regexp */
- delimiter = *cmd++; /* remember delimiter character */
- pat = cmd; /* remember start of search pat */
+ which_pat = RE_LAST; // use last used regexp
+ delimiter = *cmd++; // remember delimiter character
+ pat = cmd; // remember start of search pat
cmd = skip_regexp(cmd, delimiter, p_magic, &eap->arg);
- if (cmd[0] == delimiter) /* end delimiter found */
- *cmd++ = NUL; /* replace it with a NUL */
+ if (cmd[0] == delimiter) // end delimiter found
+ *cmd++ = NUL; // replace it with a NUL
}
/*
* Small incompatibility: vi sees '\n' as end of the command, but in
* Vim we want to use '\n' to find/substitute a NUL.
*/
- sub = cmd; /* remember the start of the substitution */
+ sub = cmd; // remember the start of the substitution
while (cmd[0])
{
- if (cmd[0] == delimiter) /* end delimiter found */
+ if (cmd[0] == delimiter) // end delimiter found
{
- *cmd++ = NUL; /* replace it with a NUL */
+ *cmd++ = NUL; // replace it with a NUL
break;
}
- if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */
+ if (cmd[0] == '\\' && cmd[1] != 0) // skip escaped characters
++cmd;
MB_PTR_ADV(cmd);
}
if (!eap->skip)
{
- /* In POSIX vi ":s/pat/%/" uses the previous subst. string. */
+ // In POSIX vi ":s/pat/%/" uses the previous subst. string.
if (STRCMP(sub, "%") == 0
&& vim_strchr(p_cpo, CPO_SUBPERCENT) != NULL)
{
- if (old_sub == NULL) /* there is no previous command */
+ if (old_sub == NULL) // there is no previous command
{
emsg(_(e_nopresub));
return;
@@ -3687,26 +3686,25 @@ do_sub(exarg_T *eap)
}
}
}
- else if (!eap->skip) /* use previous pattern and substitution */
+ else if (!eap->skip) // use previous pattern and substitution
{
- if (old_sub == NULL) /* there is no previous command */
+ if (old_sub == NULL) // there is no previous command
{
emsg(_(e_nopresub));
return;
}
- pat = NULL; /* search_regcomp() will use previous pattern */
+ pat = NULL; // search_regcomp() will use previous pattern
sub = old_sub;
- /* Vi compatibility quirk: repeating with ":s" keeps the cursor in the
- * last column after using "$". */
+ // Vi compatibility quirk: repeating with ":s" keeps the cursor in the
+ // last column after using "$".
endcolumn = (curwin->w_curswant == MAXCOL);
}
- /* Recognize ":%s/\n//" and turn it into a join command, which is much
- * more efficient.
- * TODO: find a generic solution to make line-joining operations more
- * efficient, avoid allocating a string that grows in size.
- */
+ // Recognize ":%s/\n//" and turn it into a join command, which is much
+ // more efficient.
+ // TODO: find a generic solution to make line-joining operations more
+ // efficient, avoid allocating a string that grows in size.
if (pat != NULL && STRCMP(pat, "\\n") == 0
&& *sub == NUL
&& (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
@@ -3722,8 +3720,8 @@ do_sub(exarg_T *eap)
else if (*cmd == 'p')
eap->flags = EXFLAG_PRINT;
- /* The number of lines joined is the number of lines in the range plus
- * one. One less when the last line is included. */
+ // The number of lines joined is the number of lines in the range plus
+ // one. One less when the last line is included.
joined_lines_count = eap->line2 - eap->line1 + 1;
if (eap->line2 < curbuf->b_ml.ml_line_count)
++joined_lines_count;
@@ -3753,7 +3751,7 @@ do_sub(exarg_T *eap)
{
if (!p_ed)
{
- if (p_gd) /* default is global on */
+ if (p_gd) // default is global on
subflags.do_all = TRUE;
else
subflags.do_all = FALSE;
@@ -3780,7 +3778,7 @@ do_sub(exarg_T *eap)
subflags.do_count = TRUE;
else if (*cmd == 'e')
subflags.do_error = !subflags.do_error;
- else if (*cmd == 'r') /* use last used regexp */
+ else if (*cmd == 'r') // use last used regexp
which_pat = RE_LAST;
else if (*cmd == 'p')
subflags.do_print = TRUE;
@@ -3794,9 +3792,9 @@ do_sub(exarg_T *eap)
subflags.do_print = TRUE;
subflags.do_list = TRUE;
}
- else if (*cmd == 'i') /* ignore case */
+ else if (*cmd == 'i') // ignore case
subflags.do_ic = 'i';
- else if (*cmd == 'I') /* don't ignore case */
+ else if (*cmd == 'I') // don't ignore case
subflags.do_ic = 'I';
else
break;
@@ -3830,7 +3828,7 @@ do_sub(exarg_T *eap)
* check for trailing command or garbage
*/
cmd = skipwhite(cmd);
- if (*cmd && *cmd != '"') /* if not end-of-line or comment */
+ if (*cmd && *cmd != '"') // if not end-of-line or comment
{
eap->nextcmd = check_nextcmd(cmd);
if (eap->nextcmd == NULL)
@@ -3840,12 +3838,12 @@ do_sub(exarg_T *eap)
}
}
- if (eap->skip) /* not executing commands, only parsing */
+ if (eap->skip) // not executing commands, only parsing
return;
if (!subflags.do_count && !curbuf->b_p_ma)
{
- /* Substitution is not allowed in non-'modifiable' buffer */
+ // Substitution is not allowed in non-'modifiable' buffer
emsg(_(e_modifiable));
return;
}
@@ -3857,7 +3855,7 @@ do_sub(exarg_T *eap)
return;
}
- /* the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase' */
+ // the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase'
if (subflags.do_ic == 'i')
regmatch.rmm_ic = TRUE;
else if (subflags.do_ic == 'I')
@@ -3896,10 +3894,10 @@ do_sub(exarg_T *eap)
int did_sub = FALSE;
int lastone;
int len, copy_len, needed_len;
- long nmatch_tl = 0; /* nr of lines matched below lnum */
- int do_again; /* do it again after joining lines */
+ long nmatch_tl = 0; // nr of lines matched below lnum
+ int do_again; // do it again after joining lines
int skip_match = FALSE;
- linenr_T sub_firstlnum; /* nr of first sub line */
+ linenr_T sub_firstlnum; // nr of first sub line
#ifdef FEAT_PROP_POPUP
int apc_flags = APC_SAVE_FOR_UNDO | APC_SUBSTITUTE;
colnr_T total_added = 0;
@@ -3954,7 +3952,7 @@ do_sub(exarg_T *eap)
copycol = 0;
matchcol = 0;
- /* At first match, remember current cursor position. */
+ // At first match, remember current cursor position.
if (!got_match)
{
setpcmark();
@@ -3971,9 +3969,9 @@ do_sub(exarg_T *eap)
*/
for (;;)
{
- /* Advance "lnum" to the line where the match starts. The
- * match does not start in the first line when there is a line
- * break before \zs. */
+ // Advance "lnum" to the line where the match starts. The
+ // match does not start in the first line when there is a line
+ // break before \zs.
if (regmatch.startpos[0].lnum > 0)
{
lnum += regmatch.startpos[0].lnum;
@@ -3997,8 +3995,8 @@ do_sub(exarg_T *eap)
}
}
- /* Save the line number of the last change for the final
- * cursor position (just like Vi). */
+ // Save the line number of the last change for the final
+ // cursor position (just like Vi).
curwin->w_cursor.lnum = lnum;
do_again = FALSE;
@@ -4012,12 +4010,12 @@ do_sub(exarg_T *eap)
&& matchcol == regmatch.endpos[0].col)
{
if (sub_firstline[matchcol] == NUL)
- /* We already were at the end of the line. Don't look
- * for a match in this line again. */
+ // We already were at the end of the line. Don't look
+ // for a match in this line again.
skip_match = TRUE;
else
{
- /* search for a match at next column */
+ // search for a match at next column
if (has_mbyte)
matchcol += mb_ptr2len(sub_firstline + matchcol);
else
@@ -4026,8 +4024,8 @@ do_sub(exarg_T *eap)
goto skip;
}
- /* Normally we continue searching for a match just after the
- * previous match. */
+ // Normally we continue searching for a match just after the
+ // previous match.
matchcol = regmatch.endpos[0].col;
prev_matchcol = matchcol;
@@ -4037,10 +4035,10 @@ do_sub(exarg_T *eap)
*/
if (subflags.do_count)
{
- /* For a multi-line match, put matchcol at the NUL at
- * the end of the line and set nmatch to one, so that
- * we continue looking for a match on the next line.
- * Avoids that ":s/\nB\@=//gc" get stuck. */
+ // For a multi-line match, put matchcol at the NUL at
+ // the end of the line and set nmatch to one, so that
+ // we continue looking for a match on the next line.
+ // Avoids that ":s/\nB\@=//gc" get stuck.
if (nmatch > 1)
{
matchcol = (colnr_T)STRLEN(sub_firstline);
@@ -4050,8 +4048,8 @@ do_sub(exarg_T *eap)
sub_nsubs++;
did_sub = TRUE;
#ifdef FEAT_EVAL
- /* Skip the substitution, unless an expression is used,
- * then it is evaluated in the sandbox. */
+ // Skip the substitution, unless an expression is used,
+ // then it is evaluated in the sandbox.
if (!(sub[0] == '\\' && sub[1] == '='))
#endif
goto skip;
@@ -4061,8 +4059,8 @@ do_sub(exarg_T *eap)
{
int typed = 0;
- /* change State to CONFIRM, so that the mouse works
- * properly */
+ // change State to CONFIRM, so that the mouse works
+ // properly
save_State = State;
State = CONFIRM;
setmouse(); // disable mouse in xterm
@@ -4070,8 +4068,8 @@ do_sub(exarg_T *eap)
if (curwin->w_p_crb)
do_check_cursorbind();
- /* When 'cpoptions' contains "u" don't sync undo when
- * asking for confirmation. */
+ // When 'cpoptions' contains "u" don't sync undo when
+ // asking for confirmation.
if (vim_strchr(p_cpo, CPO_UNDO) != NULL)
++no_u_sync;
@@ -4121,18 +4119,18 @@ do_sub(exarg_T *eap)
curwin->w_p_fen = FALSE;
#endif
- /* Invert the matched string.
- * Remove the inversion afterwards. */
+ // Invert the matched string.
+ // Remove the inversion afterwards.
temp = RedrawingDisabled;
RedrawingDisabled = 0;
if (new_start != NULL)
{
- /* There already was a substitution, we would
- * like to show this to the user. We cannot
- * really update the line, it would change
- * what matches. Temporarily replace the line
- * and change it back afterwards. */
+ // There already was a substitution, we would
+ // like to show this to the user. We cannot
+ // really update the line, it would change
+ // what matches. Temporarily replace the line
+ // and change it back afterwards.
orig_line = vim_strsave(ml_get(lnum));
if (orig_line != NULL)
{
@@ -4143,11 +4141,11 @@ do_sub(exarg_T *eap)
VIM_CLEAR(orig_line);
else
{
- /* Position the cursor relative to the
- * end of the line, the previous
- * substitute may have inserted or
- * deleted characters before the
- * cursor. */
+ // Position the cursor relative to the
+ // end of the line, the previous
+ // substitute may have inserted or
+ // deleted characters before the
+ // cursor.
len_change = (int)STRLEN(new_line)
- (int)STRLEN(orig_line);
curwin->w_cursor.col += len_change;
@@ -4172,14 +4170,14 @@ do_sub(exarg_T *eap)
curwin->w_p_fen = save_p_fen;
#endif
if (msg_row == Rows - 1)
- msg_didout = FALSE; /* avoid a scroll-up */
+ msg_didout = FALSE; // avoid a scroll-up
msg_starthere();
i = msg_scroll;
- msg_scroll = 0; /* truncate msg when
- needed */
+ msg_scroll = 0; // truncate msg when
+ // needed
msg_no_more = TRUE;
- /* write message same highlighting as for
- * wait_return */
+ // write message same highlighting as for
+ // wait_return
smsg_attr(HL_ATTR(HLF_R),
_("replace with %s (y/n/a/q/l/^E/^Y)?"), sub);
msg_no_more = FALSE;
@@ -4189,25 +4187,25 @@ do_sub(exarg_T *eap)
RedrawingDisabled = temp;
#ifdef USE_ON_FLY_SCROLL
- dont_scroll = FALSE; /* allow scrolling here */
+ dont_scroll = FALSE; // allow scrolling here
#endif
- ++no_mapping; /* don't map this key */
- ++allow_keys; /* allow special keys */
+ ++no_mapping; // don't map this key
+ ++allow_keys; // allow special keys
typed = plain_vgetc();
--allow_keys;
--no_mapping;
- /* clear the question */
- msg_didout = FALSE; /* don't scroll up */
+ // clear the question
+ msg_didout = FALSE; // don't scroll up
msg_col = 0;
gotocmdline(TRUE);
- /* restore the line */
+ // restore the line
if (orig_line != NULL)
ml_replace(lnum, orig_line, FALSE);
}
- need_wait_return = FALSE; /* no hit-return prompt */
+ need_wait_return = FALSE; // no hit-return prompt
if (typed == 'q' || typed == ESC || typed == Ctrl_C
#ifdef UNIX
|| typed == intr_char
@@ -4223,7 +4221,7 @@ do_sub(exarg_T *eap)
break;
if (typed == 'l')
{
- /* last: replace and then stop */
+ // last: replace and then stop
subflags.do_all = FALSE;
line2 = lnum;
break;
@@ -4245,11 +4243,11 @@ do_sub(exarg_T *eap)
if (typed == 'n')
{
- /* For a multi-line match, put matchcol at the NUL at
- * the end of the line and set nmatch to one, so that
- * we continue looking for a match on the next line.
- * Avoids that ":%s/\nB\@=//gc" and ":%s/\n/,\r/gc"
- * get stuck when pressing 'n'. */
+ // For a multi-line match, put matchcol at the NUL at
+ // the end of the line and set nmatch to one, so that
+ // we continue looking for a match on the next line.
+ // Avoids that ":%s/\nB\@=//gc" and ":%s/\n/,\r/gc"
+ // get stuck when pressing 'n'.
if (nmatch > 1)
{
matchcol = (colnr_T)STRLEN(sub_firstline);
@@ -4261,8 +4259,8 @@ do_sub(exarg_T *eap)
goto skip;
}
- /* Move the cursor to the start of the match, so that we can
- * use "\=col("."). */
+ // Move the cursor to the start of the match, so that we can
+ // use "\=col(".").
curwin->w_cursor.col = regmatch.startpos[0].col;
/*
@@ -4298,22 +4296,21 @@ do_sub(exarg_T *eap)
}
#endif
- /* When the match included the "$" of the last line it may
- * go beyond the last line of the buffer. */
+ // When the match included the "$" of the last line it may
+ // go beyond the last line of the buffer.
if (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1)
{
nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1;
skip_match = TRUE;
}
- /* Need room for:
- * - result so far in new_start (not for first sub in line)
- * - original text up to match
- * - length of substituted part
- * - original text after match
- * Adjust text properties here, since we have all information
- * needed.
- */
+ // Need room for:
+ // - result so far in new_start (not for first sub in line)
+ // - original text up to match
+ // - length of substituted part
+ // - original text after match
+ // Adjust text properties here, since we have all information
+ // needed.
if (nmatch == 1)
{
p1 = sub_firstline;
@@ -4392,31 +4389,31 @@ do_sub(exarg_T *eap)
sub_nsubs++;
did_sub = TRUE;
- /* Move the cursor to the start of the line, to avoid that it
- * is beyond the end of the line after the substitution. */
+ // Move the cursor to the start of the line, to avoid that it
+ // is beyond the end of the line after the substitution.
curwin->w_cursor.col = 0;
- /* For a multi-line match, make a copy of the last matched
- * line and continue in that one. */
+ // For a multi-line match, make a copy of the last matched
+ // line and continue in that one.
if (nmatch > 1)
{
sub_firstlnum += nmatch - 1;
vim_free(sub_firstline);
sub_firstline = vim_strsave(ml_get(sub_firstlnum));
- /* When going beyond the last line, stop substituting. */
+ // When going beyond the last line, stop substituting.
if (sub_firstlnum <= line2)
do_again = TRUE;
else
subflags.do_all = FALSE;
}
- /* Remember next character to be copied. */
+ // Remember next character to be copied.
copycol = regmatch.endpos[0].col;
if (skip_match)
{
- /* Already hit end of the buffer, sub_firstlnum is one
- * less than what it ought to be. */
+ // Already hit end of the buffer, sub_firstlnum is one
+ // less than what it ought to be.
vim_free(sub_firstline);
sub_firstline = vim_strsave((char_u *)"");
copycol = 0;
@@ -4432,7 +4429,7 @@ do_sub(exarg_T *eap)
*/
for (p1 = new_end; *p1; ++p1)
{
- if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */
+ if (p1[0] == '\\' && p1[1] != NUL) // remove backslash
{
STRMOVE(p1, p1 + 1);
#ifdef FEAT_PROP_POPUP
@@ -4489,11 +4486,11 @@ do_sub(exarg_T *eap)
* But ":s/\n/#/" is OK.
*/
skip:
- /* We already know that we did the last subst when we are at
- * the end of the line, except that a pattern like
- * "bar\|\nfoo" may match at the NUL. "lnum" can be below
- * "line2" when there is a \zs in the pattern after a line
- * break. */
+ // We already know that we did the last subst when we are at
+ // the end of the line, except that a pattern like
+ // "bar\|\nfoo" may match at the NUL. "lnum" can be below
+ // "line2" when there is a \zs in the pattern after a line
+ // break.
lastone = (skip_match
|| got_int
|| got_quit
@@ -4555,12 +4552,12 @@ skip:
if (subflags.do_ask)
deleted_lines(lnum, nmatch_tl);
--lnum;
- line2 -= nmatch_tl; /* nr of lines decreases */
+ line2 -= nmatch_tl; // nr of lines decreases
nmatch_tl = 0;
}
- /* When asking, undo is saved each time, must also set
- * changed flag each time. */
+ // When asking, undo is saved each time, must also set
+ // changed flag each time.
if (subflags.do_ask)
changed_bytes(lnum, 0);
else
@@ -4571,7 +4568,7 @@ skip:
}
sub_firstlnum = lnum;
- vim_free(sub_firstline); /* free the temp buffer */
+ vim_free(sub_firstline); // free the temp buffer
sub_firstline = new_start;
new_start = NULL;
matchcol = (colnr_T)STRLEN(sub_firstline) - matchcol;
@@ -4588,9 +4585,9 @@ skip:
*/
if (nmatch <= 0)
{
- /* If the match found didn't start where we were
- * searching, do the next search in the line where we
- * found the match. */
+ // If the match found didn't start where we were
+ // searching, do the next search in the line where we
+ // found the match.
if (nmatch == -1)
lnum -= regmatch.startpos[0].lnum;
break;
@@ -4602,8 +4599,8 @@ skip:
if (did_sub)
++sub_nlines;
- vim_free(new_start); /* for when substitute was cancelled */
- VIM_CLEAR(sub_firstline); /* free the copy of the original line */
+ vim_free(new_start); // for when substitute was cancelled
+ VIM_CLEAR(sub_firstline); // free the copy of the original line
}
line_breakcheck();
@@ -4611,17 +4608,17 @@ skip:
if (first_line != 0)
{
- /* Need to subtract the number of added lines from "last_line" to get
- * the line number before the change (same as adding the number of
- * deleted lines). */
+ // Need to subtract the number of added lines from "last_line" to get
+ // the line number before the change (same as adding the number of
+ // deleted lines).
i = curbuf->b_ml.ml_line_count - old_line_count;
changed_lines(first_line, 0, last_line - i, i);
}
outofmem:
- vim_free(sub_firstline); /* may have to free allocated copy of the line */
+ vim_free(sub_firstline); // may have to free allocated copy of the line
- /* ":s/pat//n" doesn't move the cursor */
+ // ":s/pat//n" doesn't move the cursor
if (subflags.do_count)
curwin->w_cursor = old_cursor;
@@ -4637,7 +4634,7 @@ outofmem:
if (!global_busy)
{
- /* when interactive leave cursor on the match */
+ // when interactive leave cursor on the match
if (!subflags.do_ask)
{
if (endcolumn)
@@ -4656,23 +4653,23 @@ outofmem:
}
else if (!global_busy)
{
- if (got_int) /* interrupted */
+ if (got_int) // interrupted
emsg(_(e_interr));
- else if (got_match) /* did find something but nothing substituted */
+ else if (got_match) // did find something but nothing substituted
msg("");
- else if (subflags.do_error) /* nothing found */
+ else if (subflags.do_error) // nothing found
semsg(_(e_patnotf2), get_search_pat());
}
#ifdef FEAT_FOLDING
if (subflags.do_ask && hasAnyFolding(curwin))
- /* Cursor position may require updating */
+ // Cursor position may require updating
changed_window_setting();
#endif
vim_regfree(regmatch.regprog);
- /* Restore the flag values, they can be used for ":&&". */
+ // Restore the flag values, they can be used for ":&&".
subflags.do_all = save_do_all;
subflags.do_ask = save_do_ask;
}
@@ -4684,7 +4681,7 @@ outofmem:
*/
int
do_sub_msg(
- int count_only) /* used 'n' flag for ":s" */
+ int count_only) // used 'n' flag for ":s"
{
/*
* Only report substitutions when:
@@ -4720,7 +4717,7 @@ do_sub_msg(
sub_nsubs, (long)sub_nlines);
if (msg(msg_buf))
- /* save message to display it after redraw */
+ // save message to display it after redraw
set_keep_msg((char_u *)msg_buf, 0);
return TRUE;
}
@@ -4762,33 +4759,33 @@ global_exe_one(char_u *cmd, linenr_T lnum)
void
ex_global(exarg_T *eap)
{
- linenr_T lnum; /* line number according to old situation */
+ linenr_T lnum; // line number according to old situation
int ndone = 0;
- int type; /* first char of cmd: 'v' or 'g' */
- char_u *cmd; /* command argument */
+ int type; // first char of cmd: 'v' or 'g'
+ char_u *cmd; // command argument
- char_u delim; /* delimiter, normally '/' */
+ char_u delim; // delimiter, normally '/'
char_u *pat;
regmmatch_T regmatch;
int match;
int which_pat;
- /* When nesting the command works on one line. This allows for
- * ":g/found/v/notfound/command". */
+ // When nesting the command works on one line. This allows for
+ // ":g/found/v/notfound/command".
if (global_busy && (eap->line1 != 1
|| eap->line2 != curbuf->b_ml.ml_line_count))
{
- /* will increment global_busy to break out of the loop */
+ // will increment global_busy to break out of the loop
emsg(_("E147: Cannot do :global recursive with a range"));
return;
}
- if (eap->forceit) /* ":global!" is like ":vglobal" */
+ if (eap->forceit) // ":global!" is like ":vglobal"
type = 'v';
else
type = *eap->cmd;
cmd = eap->arg;
- which_pat = RE_LAST; /* default: use last used regexp */
+ which_pat = RE_LAST; // default: use last used regexp
/*
* undocumented vi feature:
@@ -4804,9 +4801,9 @@ ex_global(exarg_T *eap)
return;
}
if (*cmd == '&')
- which_pat = RE_SUBST; /* use previous substitute pattern */
+ which_pat = RE_SUBST; // use previous substitute pattern
else
- which_pat = RE_SEARCH; /* use previous search pattern */
+ which_pat = RE_SEARCH; // use previous search pattern
++cmd;
pat = (char_u *)"";
}
@@ -4817,13 +4814,13 @@ ex_global(exarg_T *eap)
}
else
{
- delim = *cmd; /* get the delimiter */
+ delim = *cmd; // get the delimiter
if (delim)
- ++cmd; /* skip delimiter if there is one */
- pat = cmd; /* remember start of pattern */
+ ++cmd; // skip delimiter if there is one
+ pat = cmd; // remember start of pattern
cmd = skip_regexp(cmd, delim, p_magic, &eap->arg);
- if (cmd[0] == delim) /* end delimiter found */
- *cmd++ = NUL; /* replace it with a NUL */
+ if (cmd[0] == delim) // end delimiter found
+ *cmd++ = NUL; // replace it with a NUL
}
if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, &regmatch) == FAIL)
@@ -4847,7 +4844,7 @@ ex_global(exarg_T *eap)
*/
for (lnum = eap->line1; lnum <= eap->line2 && !got_int; ++lnum)
{
- /* a match on this line? */
+ // a match on this line?
match = vim_regexec_multi(&regmatch, curwin, curbuf, lnum,
(colnr_T)0, NULL, NULL);
if ((type == 'g' && match) || (type == 'v' && !match))
@@ -4881,7 +4878,7 @@ ex_global(exarg_T *eap)
#endif
}
- ml_clearmarked(); /* clear rest of the marks */
+ ml_clearmarked(); // clear rest of the marks
}
vim_regfree(regmatch.regprog);
@@ -4893,9 +4890,9 @@ ex_global(exarg_T *eap)
void
global_exe(char_u *cmd)
{
- linenr_T old_lcount; /* b_ml.ml_line_count before the command */
- buf_T *old_buf = curbuf; /* remember what buffer we started in */
- linenr_T lnum; /* line number according to old situation */
+ linenr_T old_lcount; // b_ml.ml_line_count before the command
+ buf_T *old_buf = curbuf; // remember what buffer we started in
+ linenr_T lnum; // line number according to old situation
/*
* Set current position only once for a global command.
@@ -4904,7 +4901,7 @@ global_exe(char_u *cmd)
*/
setpcmark();
- /* When the command writes a message, don't overwrite the command. */
+ // When the command writes a message, don't overwrite the command.
msg_didout = TRUE;
sub_nsubs = 0;
@@ -4922,21 +4919,21 @@ global_exe(char_u *cmd)
if (global_need_beginline)
beginline(BL_WHITE | BL_FIX);
else
- check_cursor(); /* cursor may be beyond the end of the line */
+ check_cursor(); // cursor may be beyond the end of the line
- /* the cursor may not have moved in the text but a change in a previous
- * line may move it on the screen */
+ // the cursor may not have moved in the text but a change in a previous
+ // line may move it on the screen
changed_line_abv_curs();
- /* If it looks like no message was written, allow overwriting the
- * command with the report for number of changes. */
+ // If it looks like no message was written, allow overwriting the
+ // command with the report for number of changes.
if (msg_col == 0 && msg_scrolled == 0)
msg_didout = FALSE;
- /* If substitutes done, report number of substitutes, otherwise report
- * number of extra or deleted lines.
- * Don't report extra or deleted lines in the edge case where the buffer
- * we are in after execution is different from the buffer we started in. */
+ // If substitutes done, report number of substitutes, otherwise report
+ // number of extra or deleted lines.
+ // Don't report extra or deleted lines in the edge case where the buffer
+ // we are in after execution is different from the buffer we started in.
if (!do_sub_msg(FALSE) && curbuf == old_buf)
msgmore(curbuf->b_ml.ml_line_count - old_lcount);
}
@@ -5062,7 +5059,7 @@ ex_help(exarg_T *eap)
{
char_u *arg;
char_u *tag;
- FILE *helpfd; /* file descriptor of help file */
+ FILE *helpfd; // file descriptor of help file
int n;
int i;
win_T *wp;
@@ -5104,23 +5101,23 @@ ex_help(exarg_T *eap)
return;
}
- if (eap->skip) /* not executing commands */
+ if (eap->skip) // not executing commands
return;
}
else
arg = (char_u *)"";
- /* remove trailing blanks */
+ // remove trailing blanks
p = arg + STRLEN(arg) - 1;
while (p > arg && VIM_ISWHITE(*p) && p[-1] != '\\')
*p-- = NUL;
#ifdef FEAT_MULTI_LANG
- /* Check for a specified language */
+ // Check for a specified language
lang = check_help_lang(arg);
#endif
- /* When no argument given go to the index. */
+ // When no argument given go to the index.
if (*arg == NUL)
arg = (char_u *)"help.txt";
@@ -5133,7 +5130,7 @@ ex_help(exarg_T *eap)
i = 0;
#ifdef FEAT_MULTI_LANG
if (n != FAIL && lang != NULL)
- /* Find first item with the requested language. */
+ // Find first item with the requested language.
for (i = 0; i < num_matches; ++i)
{
len = (int)STRLEN(matches[i]);
@@ -5155,7 +5152,7 @@ ex_help(exarg_T *eap)
return;
}
- /* The first match (in the requested language) is the best match. */
+ // The first match (in the requested language) is the best match.
tag = vim_strsave(matches[i]);
FreeWild(num_matches, matches);
@@ -5190,9 +5187,9 @@ ex_help(exarg_T *eap)
}
fclose(helpfd);
- /* Split off help window; put it at far top if no position
- * specified, the current window is vertically split and
- * narrow. */
+ // Split off help window; put it at far top if no position
+ // specified, the current window is vertically split and
+ // narrow.
n = WSP_HELP;
if (cmdmod.split == 0 && curwin->w_width != Columns
&& curwin->w_width < 80)
@@ -5211,7 +5208,7 @@ ex_help(exarg_T *eap)
alt_fnum = curbuf->b_fnum;
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
ECMD_HIDE + ECMD_SET_HELP,
- NULL); /* buffer is still open, don't store info */
+ NULL); // buffer is still open, don't store info
if (!cmdmod.keepalt)
curwin->w_alt_fnum = alt_fnum;
empty_fnum = curbuf->b_fnum;
@@ -5219,20 +5216,20 @@ ex_help(exarg_T *eap)
}
if (!p_im)
- restart_edit = 0; /* don't want insert mode in help file */
+ restart_edit = 0; // don't want insert mode in help file
#ifdef FEAT_FOLDING
- /* Restore KeyTyped, setting 'filetype=help' may reset it.
- * It is needed for do_tag top open folds under the cursor. */
+ // Restore KeyTyped, setting 'filetype=help' may reset it.
+ // It is needed for do_tag top open folds under the cursor.
KeyTyped = old_KeyTyped;
#endif
if (tag != NULL)
do_tag(tag, DT_HELP, 1, FALSE, TRUE);
- /* Delete the empty buffer if we're not using it. Careful: autocommands
- * may have jumped to another window, check that the buffer is not in a
- * window. */
+ // Delete the empty buffer if we're not using it. Careful: autocommands
+ // may have jumped to another window, check that the buffer is not in a
+ // window.
if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum)
{
buf = buflist_findnr(empty_fnum);
@@ -5240,7 +5237,7 @@ ex_help(exarg_T *eap)
wipe_buffer(buf, TRUE);
}
- /* keep the previous alternate file */
+ // keep the previous alternate file
if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum && !cmdmod.keepalt)
curwin->w_alt_fnum = alt_fnum;
@@ -5280,7 +5277,7 @@ check_help_lang(char_u *arg)
if (len >= 3 && arg[len - 3] == '@' && ASCII_ISALPHA(arg[len - 2])
&& ASCII_ISALPHA(arg[len - 1]))
{
- arg[len - 3] = NUL; /* remove the '@' */
+ arg[len - 3] = NUL; // remove the '@'
return arg + len - 2;
}
return NULL;
@@ -5301,8 +5298,8 @@ check_help_lang(char_u *arg)
int
help_heuristic(
char_u *matched_string,
- int offset, /* offset for match */
- int wrong_case) /* no matching case */
+ int offset, // offset for match
+ int wrong_case) // no matching case
{
int num_letters;
char_u *p;
@@ -5328,8 +5325,8 @@ help_heuristic(
offset *= 200;
if (wrong_case)
offset += 5000;
- /* Features are less interesting than the subjects themselves, but "+"
- * alone is not a feature. */
+ // Features are less interesting than the subjects themselves, but "+"
+ // alone is not a feature.
if (matched_string[0] == '+' && matched_string[1] != NUL)
offset += 100;
return (int)(100 * num_letters + STRLEN(matched_string) + offset);
@@ -5391,7 +5388,7 @@ find_help_tags(
">=?", ">?", "is?", "isnot?"};
int flags;
- d = IObuff; /* assume IObuff is long enough! */
+ d = IObuff; // assume IObuff is long enough!
if (STRNICMP(arg, "expr-", 5) == 0)
{
@@ -5427,13 +5424,13 @@ find_help_tags(
}
}
- if (i < 0) /* no match in table */
+ if (i < 0) // no match in table
{
- /* Replace "\S" with "/\\S", etc. Otherwise every tag is matched.
- * Also replace "\%^" and "\%(", they match every tag too.
- * Also "\zs", "\z1", etc.
- * Also "\@<", "\@=", "\@<=", etc.
- * And also "\_$" and "\_^". */
+ // Replace "\S" with "/\\S", etc. Otherwise every tag is matched.
+ // Also replace "\%^" and "\%(", they match every tag too.
+ // Also "\zs", "\z1", etc.
+ // Also "\@<", "\@=", "\@<=", etc.
+ // And also "\_$" and "\_^".
if (arg[0] == '\\'
&& ((arg[1] != NUL && arg[2] == NUL)
|| (vim_strchr((char_u *)"%_z@", arg[1]) != NULL
@@ -5441,17 +5438,16 @@ find_help_tags(
{
STRCPY(d, "/\\\\");
STRCPY(d + 3, arg + 1);
- /* Check for "/\\_$", should be "/\\_\$" */
+ // Check for "/\\_$", should be "/\\_\$"
if (d[3] == '_' && d[4] == '$')
STRCPY(d + 4, "\\$");
}
else
{
- /* Replace:
- * "[:...:]" with "\[:...:]"
- * "[++...]" with "\[++...]"
- * "\{" with "\\{" -- matching "} \}"
- */
+ // Replace:
+ // "[:...:]" with "\[:...:]"
+ // "[++...]" with "\[++...]"
+ // "\{" with "\\{" -- matching "} \}"
if ((arg[0] == '[' && (arg[1] == ':'
|| (arg[1] == '+' && arg[2] == '+')))
|| (arg[0] == '\\' && arg[1] == '{'))
@@ -5472,7 +5468,7 @@ find_help_tags(
* Insert a backslash before '~', '$' and '.' to avoid their
* special meaning.
*/
- if (d - IObuff > IOSIZE - 10) /* getting too long!? */
+ if (d - IObuff > IOSIZE - 10) // getting too long!?
break;
switch (*s)
{
@@ -5501,7 +5497,7 @@ find_help_tags(
|| vim_strchr((char_u *)"?@[\\]^", s[1]) != NULL)))
{
if (d > IObuff && d[-1] != '_' && d[-1] != '\\')
- *d++ = '_'; /* prepend a '_' to make x_CTRL-x */
+ *d++ = '_'; // prepend a '_' to make x_CTRL-x
STRCPY(d, "CTRL-");
d += 5;
if (*s < ' ')
@@ -5512,15 +5508,15 @@ find_help_tags(
*d++ = *s + '@';
#endif
if (d[-1] == '\\')
- *d++ = '\\'; /* double a backslash */
+ *d++ = '\\'; // double a backslash
}
else
*d++ = *++s;
if (s[1] != NUL && s[1] != '_')
- *d++ = '_'; /* append a '_' */
+ *d++ = '_'; // append a '_'
continue;
}
- else if (*s == '^') /* "^" or "CTRL-^" or "^_" */
+ else if (*s == '^') // "^" or "CTRL-^" or "^_"
*d++ = '\\';
/*
@@ -5531,8 +5527,8 @@ find_help_tags(
&& *arg == '/' && s == arg + 1)
*d++ = '\\';
- /* "CTRL-\_" -> "CTRL-\\_" to avoid the special meaning of "\_" in
- * "CTRL-\_CTRL-N" */
+ // "CTRL-\_" -> "CTRL-\\_" to avoid the special meaning of "\_" in
+ // "CTRL-\_CTRL-N"
if (STRNICMP(s, "CTRL-\\_", 7) == 0)
{
STRCPY(d, "CTRL-\\\\");
@@ -5555,7 +5551,7 @@ find_help_tags(
*/
if (*s == '\'' && s > arg && *arg == '\'')
break;
- /* Also '{' and '}'. */
+ // Also '{' and '}'.
if (*s == '}' && s > arg && *arg == '{')
break;
}
@@ -5565,20 +5561,20 @@ find_help_tags(
{
if (d > IObuff + 2 && d[-1] == '`')
{
- /* remove the backticks from `command` */
+ // remove the backticks from `command`
mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
d[-2] = NUL;
}
else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',')
{
- /* remove the backticks and comma from `command`, */
+ // remove the backticks and comma from `command`,
mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
d[-3] = NUL;
}
else if (d > IObuff + 4 && d[-3] == '`'
&& d[-2] == '\\' && d[-1] == '.')
{
- /* remove the backticks and dot from `command`\. */
+ // remove the backticks and dot from `command`\.
mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
d[-4] = NUL;
}
@@ -5594,11 +5590,11 @@ find_help_tags(
if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK
&& *num_matches > 0)
{
- /* Sort the matches found on the heuristic number that is after the
- * tag name. */
+ // Sort the matches found on the heuristic number that is after the
+ // tag name.
qsort((void *)*matches, (size_t)*num_matches,
sizeof(char_u *), help_compare);
- /* Delete more than TAG_MANY to reduce the size of the listing. */
+ // Delete more than TAG_MANY to reduce the size of the listing.
while (*num_matches > TAG_MANY)
vim_free((*matches)[--*num_matches]);
}
@@ -5640,33 +5636,33 @@ prepare_help_buffer(void)
}
#ifdef FEAT_FOLDING
- /* Don't use the global foldmethod.*/
+ // Don't use the global foldmethod.
set_string_option_direct((char_u *)"fdm", -1, (char_u *)"manual",
OPT_FREE|OPT_LOCAL, 0);
#endif
- curbuf->b_p_ts = 8; /* 'tabstop' is 8 */
- curwin->w_p_list = FALSE; /* no list mode */
+ curbuf->b_p_ts = 8; // 'tabstop' is 8
+ curwin->w_p_list = FALSE; // no list mode
- curbuf->b_p_ma = FALSE; /* not modifiable */
- curbuf->b_p_bin = FALSE; /* reset 'bin' before reading file */
- curwin->w_p_nu = 0; /* no line numbers */
- curwin->w_p_rnu = 0; /* no relative line numbers */
- RESET_BINDING(curwin); /* no scroll or cursor binding */
+ curbuf->b_p_ma = FALSE; // not modifiable
+ curbuf->b_p_bin = FALSE; // reset 'bin' before reading file
+ curwin->w_p_nu = 0; // no line numbers
+ curwin->w_p_rnu = 0; // no relative line numbers
+ RESET_BINDING(curwin); // no scroll or cursor binding
#ifdef FEAT_ARABIC
- curwin->w_p_arab = FALSE; /* no arabic mode */
+ curwin->w_p_arab = FALSE; // no arabic mode
#endif
#ifdef FEAT_RIGHTLEFT
- curwin->w_p_rl = FALSE; /* help window is left-to-right */
+ curwin->w_p_rl = FALSE; // help window is left-to-right
#endif
#ifdef FEAT_FOLDING
- curwin->w_p_fen = FALSE; /* No folding in the help window */
+ curwin->w_p_fen = FALSE; // No folding in the help window
#endif
#ifdef FEAT_DIFF
- curwin->w_p_diff = FALSE; /* No 'diff' */
+ curwin->w_p_diff = FALSE; // No 'diff'
#endif
#ifdef FEAT_SPELL
- curwin->w_p_spell = FALSE; /* No spell checking */
+ curwin->w_p_spell = FALSE; // No spell checking
#endif
set_buflisted(FALSE);
@@ -5688,7 +5684,7 @@ fix_help_buffer(void)
char_u *rt;
int mustfree;
- /* Set filetype to "help" if still needed. */
+ // Set filetype to "help" if still needed.
if (STRCMP(curbuf->b_p_ft, "help") != 0)
{
++curbuf_lock;
@@ -5706,10 +5702,10 @@ fix_help_buffer(void)
len = (int)STRLEN(line);
if (in_example && len > 0 && !VIM_ISWHITE(line[0]))
{
- /* End of example: non-white or '<' in first column. */
+ // End of example: non-white or '<' in first column.
if (line[0] == '<')
{
- /* blank-out a '<' in the first column */
+ // blank-out a '<' in the first column
line = ml_get_buf(curbuf, lnum, TRUE);
line[0] = ' ';
}
@@ -5719,14 +5715,14 @@ fix_help_buffer(void)
{
if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' '))
{
- /* blank-out a '>' in the last column (start of example) */
+ // blank-out a '>' in the last column (start of example)
line = ml_get_buf(curbuf, lnum, TRUE);
line[len - 1] = ' ';
in_example = TRUE;
}
else if (line[len - 1] == '~')
{
- /* blank-out a '~' at the end of line (header marker) */
+ // blank-out a '~' at the end of line (header marker)
line = ml_get_buf(curbuf, lnum, TRUE);
line[len - 1] = ' ';
}
@@ -5755,8 +5751,8 @@ fix_help_buffer(void)
if (strstr((char *)line, "*local-additions*") == NULL)
continue;
- /* Go through all directories in 'runtimepath', skipping
- * $VIMRUNTIME. */
+ // Go through all directories in 'runtimepath', skipping
+ // $VIMRUNTIME.
p = p_rtp;
while (*p != NUL)
{
@@ -5774,7 +5770,7 @@ fix_help_buffer(void)
vimconv_T vc;
char_u *cp;
- /* Find all "doc/ *.txt" files in this directory. */
+ // Find all "doc/ *.txt" files in this directory.
add_pathsep(NameBuff);
#ifdef FEAT_MULTI_LANG
STRCAT(NameBuff, "doc/*.??[tx]");
@@ -5791,8 +5787,8 @@ fix_help_buffer(void)
char_u *t1, *t2;
char_u *e1, *e2;
- /* If foo.abx is found use it instead of foo.txt in
- * the same directory. */
+ // If foo.abx is found use it instead of foo.txt in
+ // the same directory.
for (i1 = 0; i1 < fcount; ++i1)
{
for (i2 = 0; i2 < fcount; ++i2)
@@ -5812,7 +5808,7 @@ fix_help_buffer(void)
if (fnamecmp(e1, ".txt") != 0
&& fnamecmp(e1, fname + 4) != 0)
{
- /* Not .txt and not .abx, remove it. */
+ // Not .txt and not .abx, remove it.
VIM_CLEAR(fnames[i1]);
continue;
}
@@ -5821,7 +5817,7 @@ fix_help_buffer(void)
continue;
if (fnamecmp(e1, ".txt") == 0
&& fnamecmp(e2, fname + 4) == 0)
- /* use .abx instead of .txt */
+ // use .abx instead of .txt
VIM_CLEAR(fnames[i1]);
}
}
@@ -5840,18 +5836,17 @@ fix_help_buffer(void)
{
int this_utf = MAYBE;
- /* Change tag definition to a
- * reference and remove <CR>/<NL>. */
+ // Change tag definition to a
+ // reference and remove <CR>/<NL>.
IObuff[0] = '|';
*s = '|';
while (*s != NUL)
{
if (*s == '\r' || *s == '\n')
*s = NUL;
- /* The text is utf-8 when a byte
- * above 127 is found and no
- * illegal byte sequence is found.
- */
+ // The text is utf-8 when a byte
+ // above 127 is found and no
+ // illegal byte sequence is found.
if (*s >= 0x80 && this_utf != FALSE)
{
int l;
@@ -5865,20 +5860,20 @@ fix_help_buffer(void)
++s;
}
- /* The help file is latin1 or utf-8;
- * conversion to the current
- * 'encoding' may be required. */
+ // The help file is latin1 or utf-8;
+ // conversion to the current
+ // 'encoding' may be required.
vc.vc_type = CONV_NONE;
convert_setup(&vc, (char_u *)(
this_utf == TRUE ? "utf-8"
: "latin1"), p_enc);
if (vc.vc_type == CONV_NONE)
- /* No conversion needed. */
+ // No conversion needed.
cp = IObuff;
else
{
- /* Do the conversion. If it fails
- * use the unconverted text. */
+ // Do the conversion. If it fails
+ // use the unconverted text.
cp = string_convert(&vc, IObuff,
NULL);
if (cp == NULL)
@@ -5928,10 +5923,10 @@ ex_viusage(exarg_T *eap UNUSED)
*/
static void
helptags_one(
- char_u *dir, /* doc directory */
- char_u *ext, /* suffix, ".txt", ".itx", ".frx", etc. */
- char_u *tagfname, /* "tags" for English, "tags-fr" for French. */
- int add_help_tags) /* add "help-tags" tag */
+ char_u *dir, // doc directory
+ char_u *ext, // suffix, ".txt", ".itx", ".frx", etc.
+ char_u *tagfname, // "tags" for English, "tags-fr" for French.
+ int add_help_tags) // add "help-tags" tag
{
FILE *fd_tags;
FILE *fd;
@@ -5947,7 +5942,7 @@ helptags_one(
int utf8 = MAYBE;
int this_utf8;
int firstline;
- int mix = FALSE; /* detected mixed encodings */
+ int mix = FALSE; // detected mixed encodings
/*
* Find all *.txt files.
@@ -6022,7 +6017,7 @@ helptags_one(
{
if (firstline)
{
- /* Detect utf-8 file by a non-ASCII char in the first line. */
+ // Detect utf-8 file by a non-ASCII char in the first line.
this_utf8 = MAYBE;
for (s = IObuff; *s != NUL; ++s)
if (*s >= 0x80)
@@ -6033,15 +6028,15 @@ helptags_one(
l = utf_ptr2len(s);
if (l == 1)
{
- /* Illegal UTF-8 byte sequence. */
+ // Illegal UTF-8 byte sequence.
this_utf8 = FALSE;
break;
}
s += l - 1;
}
- if (this_utf8 == MAYBE) /* only ASCII characters found */
+ if (this_utf8 == MAYBE) // only ASCII characters found
this_utf8 = FALSE;
- if (utf8 == MAYBE) /* first file */
+ if (utf8 == MAYBE) // first file
utf8 = this_utf8;
else if (utf8 != this_utf8)
{
@@ -6051,14 +6046,14 @@ helptags_one(
}
firstline = FALSE;
}
- p1 = vim_strchr(IObuff, '*'); /* find first '*' */
+ p1 = vim_strchr(IObuff, '*'); // find first '*'
while (p1 != NULL)
{
- /* Use vim_strbyte() instead of vim_strchr() so that when
- * 'encoding' is dbcs it still works, don't find '*' in the
- * second byte. */
- p2 = vim_strbyte(p1 + 1, '*'); /* find second '*' */
- if (p2 != NULL && p2 > p1 + 1) /* skip "*" and "**" */
+ // Use vim_strbyte() instead of vim_strchr() so that when
+ // 'encoding' is dbcs it still works, don't find '*' in the
+ // second byte.
+ p2 = vim_strbyte(p1 + 1, '*'); // find second '*'
+ if (p2 != NULL && p2 > p1 + 1) // skip "*" and "**"
{
for (s = p1 + 1; s < p2; ++s)
if (*s == ' ' || *s == '\t' || *s == '|')
@@ -6091,7 +6086,7 @@ helptags_one(
++ga.ga_len;
sprintf((char *)s, "%s\t%s", p1, fname);
- /* find next '*' */
+ // find next '*'
p2 = vim_strchr(p2 + 1, '*');
}
}
@@ -6147,14 +6142,14 @@ helptags_one(
{
s = ((char_u **)ga.ga_data)[i];
if (STRNCMP(s, "help-tags\t", 10) == 0)
- /* help-tags entry was added in formatted form */
+ // help-tags entry was added in formatted form
fputs((char *)s, fd_tags);
else
{
fprintf(fd_tags, "%s\t/*", s);
for (p1 = s; *p1 != '\t'; ++p1)
{
- /* insert backslash before '\\' and '/' */
+ // insert backslash before '\\' and '/'
if (*p1 == '\\' || *p1 == '/')
putc('\\', fd_tags);
putc(*p1, fd_tags);
@@ -6164,12 +6159,12 @@ helptags_one(
}
}
if (mix)
- got_int = FALSE; /* continue with other languages */
+ got_int = FALSE; // continue with other languages
for (i = 0; i < ga.ga_len; ++i)
vim_free(((char_u **)ga.ga_data)[i]);
ga_clear(&ga);
- fclose(fd_tags); /* there is no check for an error... */
+ fclose(fd_tags); // there is no check for an error...
}
/*
@@ -6188,7 +6183,7 @@ do_helptags(char_u *dirname, int add_help_tags)
int filecount;
char_u **files;
- /* Get a list of all files in the help directory and in subdirectories. */
+ // Get a list of all files in the help directory and in subdirectories.
STRCPY(NameBuff, dirname);
add_pathsep(NameBuff);
STRCAT(NameBuff, "**");
@@ -6200,8 +6195,8 @@ do_helptags(char_u *dirname, int add_help_tags)
return;
}
- /* Go over all files in the directory to find out what languages are
- * present. */
+ // Go over all files in the directory to find out what languages are
+ // present.
ga_init2(&ga, 1, 10);
for (i = 0; i < filecount; ++i)
{
@@ -6210,7 +6205,7 @@ do_helptags(char_u *dirname, int add_help_tags)
{
if (STRICMP(files[i] + len - 4, ".txt") == 0)
{
- /* ".txt" -> language "en" */
+ // ".txt" -> language "en"
lang[0] = 'e';
lang[1] = 'n';
}
@@ -6219,20 +6214,20 @@ do_helptags(char_u *dirname, int add_help_tags)
&& ASCII_ISALPHA(files[i][len - 2])
&& TOLOWER_ASC(files[i][len - 1]) == 'x')
{
- /* ".abx" -> language "ab" */
+ // ".abx" -> language "ab"
lang[0] = TOLOWER_ASC(files[i][len - 3]);
lang[1] = TOLOWER_ASC(files[i][len - 2]);
}
else
continue;
- /* Did we find this language already? */
+ // Did we find this language already?
for (j = 0; j < ga.ga_len; j += 2)
if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0)
break;
if (j == ga.ga_len)
{
- /* New language, add it. */
+ // New language, add it.
if (ga_grow(&ga, 2) == FAIL)
break;
((char_u *)ga.ga_data)[ga.ga_len++] = lang[0];
@@ -6251,13 +6246,13 @@ do_helptags(char_u *dirname, int add_help_tags)
fname[6] = ((char_u *)ga.ga_data)[j + 1];
if (fname[5] == 'e' && fname[6] == 'n')
{
- /* English is an exception: use ".txt" and "tags". */
+ // English is an exception: use ".txt" and "tags".
fname[4] = NUL;
STRCPY(ext, ".txt");
}
else
{
- /* Language "ab" uses ".abx" and "tags-ab". */
+ // Language "ab" uses ".abx" and "tags-ab".
STRCPY(ext, ".xxx");
ext[1] = fname[5];
ext[2] = fname[6];
@@ -6269,7 +6264,7 @@ do_helptags(char_u *dirname, int add_help_tags)
FreeWild(filecount, files);
#else
- /* No language support, just use "*.txt" and "tags". */
+ // No language support, just use "*.txt" and "tags".
helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags);
#endif
}
@@ -6290,7 +6285,7 @@ ex_helptags(exarg_T *eap)
char_u *dirname;
int add_help_tags = FALSE;
- /* Check for ":helptags ++t {dir}". */
+ // Check for ":helptags ++t {dir}".
if (STRNCMP(eap->arg, "++t", 3) == 0 && VIM_ISWHITE(eap->arg[3]))
{
add_help_tags = TRUE;
@@ -6378,16 +6373,16 @@ ex_drop(exarg_T *eap)
if (cmdmod.tab)
{
- /* ":tab drop file ...": open a tab for each argument that isn't
- * edited in a window yet. It's like ":tab all" but without closing
- * windows or tabs. */
+ // ":tab drop file ...": open a tab for each argument that isn't
+ // edited in a window yet. It's like ":tab all" but without closing
+ // windows or tabs.
ex_all(eap);
}
else
{
- /* ":drop file ...": Edit the first argument. Jump to an existing
- * window if possible, edit in current window if the current buffer
- * can be abandoned, otherwise open a new window. */
+ // ":drop file ...": Edit the first argument. Jump to an existing
+ // window if possible, edit in current window if the current buffer
+ // can be abandoned, otherwise open a new window.
buf = buflist_findnr(ARGLIST[0].ae_fnum);
FOR_ALL_TAB_WINDOWS(tp, wp)
@@ -6413,7 +6408,7 @@ ex_drop(exarg_T *eap)
--emsg_off;
}
- /* Fake a ":sfirst" or ":first" command edit the first argument. */
+ // Fake a ":sfirst" or ":first" command edit the first argument.
if (split)
{
eap->cmdidx = CMD_sfirst;
@@ -6439,7 +6434,7 @@ skip_vimgrep_pat(char_u *p, char_u **s, int *flags)
if (vim_isIDc(*p))
{
- /* ":vimgrep pattern fname" */
+ // ":vimgrep pattern fname"
if (s != NULL)
*s = p;
p = skiptowhite(p);
@@ -6448,7 +6443,7 @@ skip_vimgrep_pat(char_u *p, char_u **s, int *flags)
}
else
{
- /* ":vimgrep /pattern/[g][j] fname" */
+ // ":vimgrep /pattern/[g][j] fname"
if (s != NULL)
*s = p + 1;
c = *p;
@@ -6456,12 +6451,12 @@ skip_vimgrep_pat(char_u *p, char_u **s, int *flags)
if (*p != c)
return NULL;
- /* Truncate the pattern. */
+ // Truncate the pattern.
if (s != NULL)
*p = NUL;
++p;
- /* Find the flags */
+ // Find the flags
while (*p == 'g' || *p == 'j')
{
if (flags != NULL)
@@ -6506,12 +6501,12 @@ ex_oldfiles(exarg_T *eap UNUSED)
msg_outtrans(fname);
msg_clr_eos();
msg_putchar('\n');
- out_flush(); /* output one line at a time */
+ out_flush(); // output one line at a time
ui_breakcheck();
}
}
- /* Assume "got_int" was set to truncate the listing. */
+ // Assume "got_int" was set to truncate the listing.
got_int = FALSE;
# ifdef FEAT_BROWSE_CMD