summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-01 21:41:28 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-01 21:41:28 +0100
commit217e1b8359447f5550dcb0d1ee43380a90c253c5 (patch)
tree137e8b7d6f27848c95caa47e2fc13a4dc4c50d29
parent5d18efecfd6c45d69f55268948a22cd0465bb955 (diff)
downloadvim-git-8.1.2379.tar.gz
patch 8.1.2379: using old C style commentsv8.1.2379
Problem: Using old C style comments. Solution: Use // comments where appropriate.
-rw-r--r--src/ex_cmds.c1205
-rw-r--r--src/ex_cmds2.c226
-rw-r--r--src/ex_docmd.c985
-rw-r--r--src/ex_eval.c364
-rw-r--r--src/ex_getln.c663
-rw-r--r--src/fileio.c1065
-rw-r--r--src/filepath.c6
-rw-r--r--src/findfile.c6
-rw-r--r--src/fold.c870
-rw-r--r--src/version.c2
10 files changed, 2687 insertions, 2705 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
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 81f2c8f5b..9a31887ab 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -89,7 +89,7 @@ create_timer(long msec, int repeat)
if (timer == NULL)
return NULL;
if (++last_timer_id <= prev_id)
- /* Overflow! Might cause duplicates... */
+ // Overflow! Might cause duplicates...
last_timer_id = 0;
timer->tr_id = last_timer_id;
insert_timer(timer);
@@ -135,7 +135,7 @@ check_due_timer(void)
int need_update_screen = FALSE;
long current_id = last_timer_id;
- /* Don't run any timers while exiting or dealing with an error. */
+ // Don't run any timers while exiting or dealing with an error.
if (exiting || aborting())
return next_due;
@@ -149,8 +149,8 @@ check_due_timer(void)
this_due = proftime_time_left(&timer->tr_due, &now);
if (this_due <= 1)
{
- /* Save and restore a lot of flags, because the timer fires while
- * waiting for a character, which might be halfway a command. */
+ // Save and restore a lot of flags, because the timer fires while
+ // waiting for a character, which might be halfway a command.
int save_timer_busy = timer_busy;
int save_vgetc_busy = vgetc_busy;
int save_did_emsg = did_emsg;
@@ -163,8 +163,8 @@ check_due_timer(void)
except_T *save_current_exception = current_exception;
vimvars_save_T vvsave;
- /* Create a scope for running the timer callback, ignoring most of
- * the current scope, such as being inside a try/catch. */
+ // Create a scope for running the timer callback, ignoring most of
+ // the current scope, such as being inside a try/catch.
timer_busy = timer_busy > 0 || vgetc_busy > 0;
vgetc_busy = 0;
called_emsg = FALSE;
@@ -200,8 +200,8 @@ check_due_timer(void)
set_pressedreturn(save_ex_pressedreturn);
may_garbage_collect = save_may_garbage_collect;
- /* Only fire the timer again if it repeats and stop_timer() wasn't
- * called while inside the callback (tr_id == -1). */
+ // Only fire the timer again if it repeats and stop_timer() wasn't
+ // called while inside the callback (tr_id == -1).
if (timer->tr_repeat != 0 && timer->tr_id != -1
&& timer->tr_emsg_count < 3)
{
@@ -250,7 +250,7 @@ check_due_timer(void)
}
#endif
#ifdef FEAT_TERMINAL
- /* Some terminal windows may need their buffer updated. */
+ // Some terminal windows may need their buffer updated.
next_due = term_check_timers(next_due, &now);
#endif
@@ -282,7 +282,7 @@ find_timer(long id)
stop_timer(timer_T *timer)
{
if (timer->tr_firing)
- /* Free the timer after the callback returns. */
+ // Free the timer after the callback returns.
timer->tr_id = -1;
else
{
@@ -520,7 +520,7 @@ autowrite(buf_T *buf, int forceit)
if (!(p_aw || p_awa) || !p_write
#ifdef FEAT_QUICKFIX
- /* never autowrite a "nofile" or "nowrite" buffer */
+ // never autowrite a "nofile" or "nowrite" buffer
|| bt_dontwrite(buf)
#endif
|| (!forceit && buf->b_p_ro) || buf->b_ffname == NULL)
@@ -528,8 +528,8 @@ autowrite(buf_T *buf, int forceit)
set_bufref(&bufref, buf);
r = buf_write_all(buf, forceit);
- /* Writing may succeed but the buffer still changed, e.g., when there is a
- * conversion error. We do want to return FAIL then. */
+ // Writing may succeed but the buffer still changed, e.g., when there is a
+ // conversion error. We do want to return FAIL then.
if (bufref_valid(&bufref) && bufIsChanged(buf))
r = FAIL;
return r;
@@ -554,7 +554,7 @@ autowrite_all(void)
(void)buf_write_all(buf, FALSE);
- /* an autocommand may have deleted the buffer */
+ // an autocommand may have deleted the buffer
if (!bufref_valid(&bufref))
buf = firstbuf;
}
@@ -593,13 +593,13 @@ check_changed(buf_T *buf, int flags)
))
++count;
if (!bufref_valid(&bufref))
- /* Autocommand deleted buffer, oops! It's not changed now. */
+ // Autocommand deleted buffer, oops! It's not changed now.
return FALSE;
dialog_changed(buf, count > 1);
if (!bufref_valid(&bufref))
- /* Autocommand deleted buffer, oops! It's not changed now. */
+ // Autocommand deleted buffer, oops! It's not changed now.
return FALSE;
return bufIsChanged(buf);
}
@@ -645,7 +645,7 @@ browse_save_fname(buf_T *buf)
void
dialog_changed(
buf_T *buf,
- int checkall) /* may abandon all changed buffers */
+ int checkall) // may abandon all changed buffers
{
char_u buff[DIALOG_MSG_SIZE];
int ret;
@@ -665,12 +665,12 @@ dialog_changed(
if (ret == VIM_YES)
{
#ifdef FEAT_BROWSE
- /* May get file name, when there is none */
+ // May get file name, when there is none
browse_save_fname(buf);
#endif
if (buf->b_fname != NULL && check_overwrite(&ea, buf,
buf->b_fname, buf->b_ffname, FALSE) == OK)
- /* didn't hit Cancel */
+ // didn't hit Cancel
(void)buf_write_all(buf, FALSE);
}
else if (ret == VIM_NO)
@@ -698,15 +698,15 @@ dialog_changed(
set_bufref(&bufref, buf2);
#ifdef FEAT_BROWSE
- /* May get file name, when there is none */
+ // May get file name, when there is none
browse_save_fname(buf2);
#endif
if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
buf2->b_fname, buf2->b_ffname, FALSE) == OK)
- /* didn't hit Cancel */
+ // didn't hit Cancel
(void)buf_write_all(buf2, FALSE);
- /* an autocommand may have deleted the buffer */
+ // an autocommand may have deleted the buffer
if (!bufref_valid(&bufref))
buf2 = firstbuf;
}
@@ -760,7 +760,7 @@ add_bufnum(int *bufnrs, int *bufnump, int nr)
*/
int
check_changed_any(
- int hidden, /* Only check hidden buffers */
+ int hidden, // Only check hidden buffers
int unload)
{
int ret = FALSE;
@@ -773,7 +773,7 @@ check_changed_any(
tabpage_T *tp;
win_T *wp;
- /* Make a list of all buffers, with the most important ones first. */
+ // Make a list of all buffers, with the most important ones first.
FOR_ALL_BUFFERS(buf)
++bufcount;
@@ -784,21 +784,21 @@ check_changed_any(
if (bufnrs == NULL)
return FALSE;
- /* curbuf */
+ // curbuf
bufnrs[bufnum++] = curbuf->b_fnum;
- /* buffers in current tab */
+ // buffers in current tab
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer != curbuf)
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
- /* buffers in other tabs */
+ // buffers in other tabs
FOR_ALL_TABPAGES(tp)
if (tp != curtab)
for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
- /* any other buffer */
+ // any other buffer
FOR_ALL_BUFFERS(buf)
add_bufnum(bufnrs, &bufnum, buf->b_fnum);
@@ -820,19 +820,19 @@ check_changed_any(
}
else
#endif
- /* Try auto-writing the buffer. If this fails but the buffer no
- * longer exists it's not changed, that's OK. */
+ // Try auto-writing the buffer. If this fails but the buffer no
+ // longer exists it's not changed, that's OK.
if (check_changed(buf, (p_awa ? CCGD_AW : 0)
| CCGD_MULTWIN
| CCGD_ALLBUF) && bufref_valid(&bufref))
- break; /* didn't save - still changes */
+ break; // didn't save - still changes
}
}
if (i >= bufnum)
goto theend;
- /* Get here if "buf" cannot be abandoned. */
+ // Get here if "buf" cannot be abandoned.
ret = TRUE;
exiting = FALSE;
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
@@ -842,10 +842,10 @@ check_changed_any(
if (!(p_confirm || cmdmod.confirm))
#endif
{
- /* There must be a wait_return for this message, do_buffer()
- * may cause a redraw. But wait_return() is a no-op when vgetc()
- * is busy (Quit used from window menu), then make sure we don't
- * cause a scroll up. */
+ // There must be a wait_return for this message, do_buffer()
+ // may cause a redraw. But wait_return() is a no-op when vgetc()
+ // is busy (Quit used from window menu), then make sure we don't
+ // cause a scroll up.
if (vgetc_busy > 0)
{
msg_row = cmdline_row;
@@ -869,7 +869,7 @@ check_changed_any(
}
}
- /* Try to find a window that contains the buffer. */
+ // Try to find a window that contains the buffer.
if (buf != curbuf)
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == buf)
@@ -887,7 +887,7 @@ check_changed_any(
}
buf_found:
- /* Open the changed buffer in the current window. */
+ // Open the changed buffer in the current window.
if (buf != curbuf)
set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO);
@@ -965,8 +965,8 @@ ex_listdo(exarg_T *eap)
#if defined(FEAT_SYN_HL)
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo)
{
- /* Don't do syntax HL autocommands. Skipping the syntax file is a
- * great speed improvement. */
+ // Don't do syntax HL autocommands. Skipping the syntax file is a
+ // great speed improvement.
save_ei = au_event_disable(",Syntax");
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
@@ -986,7 +986,7 @@ ex_listdo(exarg_T *eap)
| CCGD_EXCMD))
{
i = 0;
- /* start at the eap->line1 argument/window/buffer */
+ // start at the eap->line1 argument/window/buffer
wp = firstwin;
tp = first_tabpage;
switch (eap->cmdidx)
@@ -1005,10 +1005,10 @@ ex_listdo(exarg_T *eap)
default:
break;
}
- /* set pcmark now */
+ // set pcmark now
if (eap->cmdidx == CMD_bufdo)
{
- /* Advance to the first listed buffer after "eap->line1". */
+ // Advance to the first listed buffer after "eap->line1".
for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1
|| !buf->b_p_bl); buf = buf->b_next)
if (buf->b_fnum > eap->line2)
@@ -1033,28 +1033,28 @@ ex_listdo(exarg_T *eap)
buf = curbuf;
i = eap->line1 - 1;
if (eap->addr_count <= 0)
- /* default is all the quickfix/location list entries */
+ // default is all the quickfix/location list entries
eap->line2 = qf_size;
}
}
#endif
else
setpcmark();
- listcmd_busy = TRUE; /* avoids setting pcmark below */
+ listcmd_busy = TRUE; // avoids setting pcmark below
while (!got_int && buf != NULL)
{
if (eap->cmdidx == CMD_argdo)
{
- /* go to argument "i" */
+ // go to argument "i"
if (i == ARGCOUNT)
break;
- /* Don't call do_argfile() when already there, it will try
- * reloading the file. */
+ // Don't call do_argfile() when already there, it will try
+ // reloading the file.
if (curwin->w_arg_idx != i || !editing_arg_idx(curwin))
{
- /* Clear 'shm' to avoid that the file message overwrites
- * any output from the command. */
+ // Clear 'shm' to avoid that the file message overwrites
+ // any output from the command.
p_shm_save = vim_strsave(p_shm);
set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
do_argfile(eap, i);
@@ -1066,17 +1066,17 @@ ex_listdo(exarg_T *eap)
}
else if (eap->cmdidx == CMD_windo)
{
- /* go to window "wp" */
+ // go to window "wp"
if (!win_valid(wp))
break;
win_goto(wp);
if (curwin != wp)
- break; /* something must be wrong */
+ break; // something must be wrong
wp = curwin->w_next;
}
else if (eap->cmdidx == CMD_tabdo)
{
- /* go to window "tp" */
+ // go to window "tp"
if (!valid_tabpage(tp))
break;
goto_tabpage_tp(tp, TRUE, TRUE);
@@ -1084,8 +1084,8 @@ ex_listdo(exarg_T *eap)
}
else if (eap->cmdidx == CMD_bufdo)
{
- /* Remember the number of the next listed buffer, in case
- * ":bwipe" is used or autocommands do something strange. */
+ // Remember the number of the next listed buffer, in case
+ // ":bwipe" is used or autocommands do something strange.
next_fnum = -1;
for (buf = curbuf->b_next; buf != NULL; buf = buf->b_next)
if (buf->b_p_bl)
@@ -1097,31 +1097,31 @@ ex_listdo(exarg_T *eap)
++i;
- /* execute the command */
+ // execute the command
do_cmdline(eap->arg, eap->getline, eap->cookie,
DOCMD_VERBOSE + DOCMD_NOWAIT);
if (eap->cmdidx == CMD_bufdo)
{
- /* Done? */
+ // Done?
if (next_fnum < 0 || next_fnum > eap->line2)
break;
- /* Check if the buffer still exists. */
+ // Check if the buffer still exists.
FOR_ALL_BUFFERS(buf)
if (buf->b_fnum == next_fnum)
break;
if (buf == NULL)
break;
- /* Go to the next buffer. Clear 'shm' to avoid that the file
- * message overwrites any output from the command. */
+ // Go to the next buffer. Clear 'shm' to avoid that the file
+ // message overwrites any output from the command.
p_shm_save = vim_strsave(p_shm);
set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum);
set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
vim_free(p_shm_save);
- /* If autocommands took us elsewhere, quit here. */
+ // If autocommands took us elsewhere, quit here.
if (curbuf->b_fnum != next_fnum)
break;
}
@@ -1137,7 +1137,7 @@ ex_listdo(exarg_T *eap)
ex_cnext(eap);
- /* If jumping to the next quickfix entry fails, quit here */
+ // If jumping to the next quickfix entry fails, quit here
if (qf_get_cur_idx(eap) == qf_idx)
break;
}
@@ -1145,9 +1145,9 @@ ex_listdo(exarg_T *eap)
if (eap->cmdidx == CMD_windo)
{
- validate_cursor(); /* cursor may have moved */
+ validate_cursor(); // cursor may have moved
- /* required when 'scrollbind' has been set */
+ // required when 'scrollbind' has been set
if (curwin->w_p_scb)
do_check_scrollbind(TRUE);
}
@@ -1213,9 +1213,9 @@ ex_compiler(exarg_T *eap)
if (*eap->arg == NUL)
{
- /* List all compiler scripts. */
+ // List all compiler scripts.
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
- /* ) keep the indenter happy... */
+ // ) keep the indenter happy...
}
else
{
@@ -1224,18 +1224,18 @@ ex_compiler(exarg_T *eap)
{
if (eap->forceit)
{
- /* ":compiler! {name}" sets global options */
+ // ":compiler! {name}" sets global options
do_cmdline_cmd((char_u *)
"command -nargs=* CompilerSet set <args>");
}
else
{
- /* ":compiler! {name}" sets local options.
- * To remain backwards compatible "current_compiler" is always
- * used. A user's compiler plugin may set it, the distributed
- * plugin will then skip the settings. Afterwards set
- * "b:current_compiler" and restore "current_compiler".
- * Explicitly prepend "g:" to make it work in a function. */
+ // ":compiler! {name}" sets local options.
+ // To remain backwards compatible "current_compiler" is always
+ // used. A user's compiler plugin may set it, the distributed
+ // plugin will then skip the settings. Afterwards set
+ // "b:current_compiler" and restore "current_compiler".
+ // Explicitly prepend "g:" to make it work in a function.
old_cur_comp = get_var_value((char_u *)"g:current_compiler");
if (old_cur_comp != NULL)
old_cur_comp = vim_strsave(old_cur_comp);
@@ -1252,12 +1252,12 @@ ex_compiler(exarg_T *eap)
do_cmdline_cmd((char_u *)":delcommand CompilerSet");
- /* Set "b:current_compiler" from "current_compiler". */
+ // Set "b:current_compiler" from "current_compiler".
p = get_var_value((char_u *)"g:current_compiler");
if (p != NULL)
set_internal_string_var((char_u *)"b:current_compiler", p);
- /* Restore "current_compiler" for ":compiler {name}". */
+ // Restore "current_compiler" for ":compiler {name}".
if (!eap->forceit)
{
if (old_cur_comp != NULL)
@@ -1322,7 +1322,7 @@ requires_py_version(char_u *filename)
break;
if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!')
{
- /* Check shebang. */
+ // Check shebang.
if (strstr((char *)IObuff + 2, "python2") != NULL)
{
requires_py_version = 2;
@@ -1367,7 +1367,7 @@ source_pyx_file(exarg_T *eap, char_u *fname)
if (v == 0)
{
# if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
- /* user didn't choose a preference, 'pyx' is used */
+ // user didn't choose a preference, 'pyx' is used
v = p_pyx;
# elif defined(FEAT_PYTHON)
v = 2;
@@ -1472,12 +1472,12 @@ ex_checktime(exarg_T *eap)
int save_no_check_timestamps = no_check_timestamps;
no_check_timestamps = 0;
- if (eap->addr_count == 0) /* default is all buffers */
+ if (eap->addr_count == 0) // default is all buffers
check_timestamps(FALSE);
else
{
buf = buflist_findnr((int)eap->line2);
- if (buf != NULL) /* cannot happen? */
+ if (buf != NULL) // cannot happen?
(void)buf_check_timestamp(buf, FALSE);
}
no_check_timestamps = save_no_check_timestamps;
@@ -1491,7 +1491,7 @@ get_locale_val(int what)
{
char_u *loc;
- /* Obtain the locale value from the libraries. */
+ // Obtain the locale value from the libraries.
loc = (char_u *)setlocale(what, NULL);
# ifdef MSWIN
@@ -1499,13 +1499,13 @@ get_locale_val(int what)
{
char_u *p;
- /* setocale() returns something like "LC_COLLATE=<name>;LC_..." when
- * one of the values (e.g., LC_CTYPE) differs. */
+ // setocale() returns something like "LC_COLLATE=<name>;LC_..." when
+ // one of the values (e.g., LC_CTYPE) differs.
p = vim_strchr(loc, '=');
if (p != NULL)
{
loc = ++p;
- while (*p != NUL) /* remove trailing newline */
+ while (*p != NUL) // remove trailing newline
{
if (*p < ' ' || *p == ';')
{
@@ -1585,10 +1585,10 @@ get_mess_lang(void)
# if defined(LC_MESSAGES)
p = get_locale_val(LC_MESSAGES);
# else
- /* This is necessary for Win32, where LC_MESSAGES is not defined and $LANG
- * may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME
- * and LC_MONETARY may be set differently for a Japanese working in the
- * US. */
+ // This is necessary for Win32, where LC_MESSAGES is not defined and $LANG
+ // may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME
+ // and LC_MONETARY may be set differently for a Japanese working in the
+ // US.
p = get_locale_val(LC_COLLATE);
# endif
# else
@@ -1607,7 +1607,7 @@ get_mess_lang(void)
}
#endif
-/* Complicated #if; matches with where get_mess_env() is used below. */
+// Complicated #if; matches with where get_mess_env() is used below.
#if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
&& defined(LC_MESSAGES))) \
|| ((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
@@ -1628,7 +1628,7 @@ get_mess_env(void)
{
p = mch_getenv((char_u *)"LANG");
if (p != NULL && VIM_ISDIGIT(*p))
- p = NULL; /* ignore something like "1043" */
+ p = NULL; // ignore something like "1043"
# ifdef HAVE_GET_LOCALE_VAL
if (p == NULL || *p == NUL)
p = get_locale_val(LC_CTYPE);
@@ -1653,13 +1653,13 @@ set_lang_var(void)
# ifdef HAVE_GET_LOCALE_VAL
loc = get_locale_val(LC_CTYPE);
# else
- /* setlocale() not supported: use the default value */
+ // setlocale() not supported: use the default value
loc = (char_u *)"C";
# endif
set_vim_var_string(VV_CTYPE, loc, -1);
- /* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
- * back to LC_CTYPE if it's empty. */
+ // When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
+ // back to LC_CTYPE if it's empty.
# if defined(HAVE_GET_LOCALE_VAL) && defined(LC_MESSAGES)
loc = get_locale_val(LC_MESSAGES);
# else
@@ -1694,9 +1694,9 @@ ex_language(exarg_T *eap)
name = eap->arg;
- /* Check for "messages {name}", "ctype {name}" or "time {name}" argument.
- * Allow abbreviation, but require at least 3 characters to avoid
- * confusion with a two letter language name "me" or "ct". */
+ // Check for "messages {name}", "ctype {name}" or "time {name}" argument.
+ // Allow abbreviation, but require at least 3 characters to avoid
+ // confusion with a two letter language name "me" or "ct".
p = skiptowhite(eap->arg);
if ((*p == NUL || VIM_ISWHITE(*p)) && p - eap->arg >= 3)
{
@@ -1742,7 +1742,7 @@ ex_language(exarg_T *eap)
{
loc = setlocale(what, (char *)name);
#if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
- /* Make sure strtod() uses a decimal point, not a comma. */
+ // Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
#endif
}
@@ -1751,31 +1751,31 @@ ex_language(exarg_T *eap)
else
{
#ifdef HAVE_NL_MSG_CAT_CNTR
- /* Need to do this for GNU gettext, otherwise cached translations
- * will be used again. */
+ // Need to do this for GNU gettext, otherwise cached translations
+ // will be used again.
extern int _nl_msg_cat_cntr;
++_nl_msg_cat_cntr;
#endif
- /* Reset $LC_ALL, otherwise it would overrule everything. */
+ // Reset $LC_ALL, otherwise it would overrule everything.
vim_setenv((char_u *)"LC_ALL", (char_u *)"");
if (what != LC_TIME)
{
- /* Tell gettext() what to translate to. It apparently doesn't
- * use the currently effective locale. Also do this when
- * FEAT_GETTEXT isn't defined, so that shell commands use this
- * value. */
+ // Tell gettext() what to translate to. It apparently doesn't
+ // use the currently effective locale. Also do this when
+ // FEAT_GETTEXT isn't defined, so that shell commands use this
+ // value.
if (what == LC_ALL)
{
vim_setenv((char_u *)"LANG", name);
- /* Clear $LANGUAGE because GNU gettext uses it. */
+ // Clear $LANGUAGE because GNU gettext uses it.
vim_setenv((char_u *)"LANGUAGE", (char_u *)"");
# ifdef MSWIN
- /* Apparently MS-Windows printf() may cause a crash when
- * we give it 8-bit text while it's expecting text in the
- * current locale. This call avoids that. */
+ // Apparently MS-Windows printf() may cause a crash when
+ // we give it 8-bit text while it's expecting text in the
+ // current locale. This call avoids that.
setlocale(LC_CTYPE, "C");
# endif
}
@@ -1795,7 +1795,7 @@ ex_language(exarg_T *eap)
}
# ifdef FEAT_EVAL
- /* Set v:lang, v:lc_time and v:ctype to the final result. */
+ // Set v:lang, v:lc_time and v:ctype to the final result.
set_lang_var();
# endif
# ifdef FEAT_TITLE
@@ -1805,7 +1805,7 @@ ex_language(exarg_T *eap)
}
}
-static char_u **locales = NULL; /* Array of all available locales */
+static char_u **locales = NULL; // Array of all available locales
# ifndef MSWIN
static int did_init_locales = FALSE;
@@ -1820,16 +1820,16 @@ find_locales(void)
garray_T locales_ga;
char_u *loc;
- /* Find all available locales by running command "locale -a". If this
- * doesn't work we won't have completion. */
+ // Find all available locales by running command "locale -a". If this
+ // doesn't work we won't have completion.
char_u *locale_a = get_cmd_output((char_u *)"locale -a",
NULL, SHELL_SILENT, NULL);
if (locale_a == NULL)
return NULL;
ga_init2(&locales_ga, sizeof(char_u *), 20);
- /* Transform locale_a string where each locale is separated by "\n"
- * into an array of locale strings. */
+ // Transform locale_a string where each locale is separated by "\n"
+ // into an array of locale strings.
loc = (char_u *)strtok((char *)locale_a, "\n");
while (loc != NULL)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 677387f93..b5ce9df4b 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -23,7 +23,7 @@ static int ex_pressedreturn = FALSE;
static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int, int), void *cookie);
#else
static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie);
-static int if_level = 0; /* depth in :if */
+static int if_level = 0; // depth in :if
#endif
static void free_cmdmod(void);
static void append_command(char_u *cmd);
@@ -383,11 +383,11 @@ static char_u dollar_command[2] = {'$', 0};
#ifdef FEAT_EVAL
-/* Struct for storing a line inside a while/for loop */
+// Struct for storing a line inside a while/for loop
typedef struct
{
- char_u *line; /* command line */
- linenr_T lnum; /* sourcing_lnum of the line */
+ char_u *line; // command line
+ linenr_T lnum; // sourcing_lnum of the line
} wcmd_T;
/*
@@ -397,10 +397,10 @@ typedef struct
*/
struct loop_cookie
{
- garray_T *lines_gap; /* growarray with line info */
- int current_line; /* last read line from growarray */
- int repeating; /* TRUE when looping a second time */
- /* When "repeating" is FALSE use "getline" and "cookie" to get lines */
+ garray_T *lines_gap; // growarray with line info
+ int current_line; // last read line from growarray
+ int repeating; // TRUE when looping a second time
+ // When "repeating" is FALSE use "getline" and "cookie" to get lines
char_u *(*getline)(int, void *, int, int);
void *cookie;
};
@@ -409,7 +409,7 @@ static char_u *get_loop_line(int c, void *cookie, int indent, int do_concat);
static int store_loop_line(garray_T *gap, char_u *line);
static void free_cmdlines(garray_T *gap);
-/* Struct to save a few things while debugging. Used in do_cmdline() only. */
+// Struct to save a few things while debugging. Used in do_cmdline() only.
struct dbg_stuff
{
int trylevel;
@@ -434,7 +434,7 @@ save_dbg_stuff(struct dbg_stuff *dsp)
dsp->vv_exception = v_exception(NULL);
dsp->vv_throwpoint = v_throwpoint(NULL);
- /* Necessary for debugging an inactive ":catch", ":finally", ":endtry" */
+ // Necessary for debugging an inactive ":catch", ":finally", ":endtry"
dsp->did_emsg = did_emsg; did_emsg = FALSE;
dsp->got_int = got_int; got_int = FALSE;
dsp->did_throw = did_throw; did_throw = FALSE;
@@ -467,7 +467,7 @@ restore_dbg_stuff(struct dbg_stuff *dsp)
*/
void
do_exmode(
- int improved) /* TRUE for "improved Ex" mode */
+ int improved) // TRUE for "improved Ex" mode
{
int save_msg_scroll;
int prev_msg_row;
@@ -480,23 +480,23 @@ do_exmode(
exmode_active = EXMODE_NORMAL;
State = NORMAL;
- /* When using ":global /pat/ visual" and then "Q" we return to continue
- * the :global command. */
+ // When using ":global /pat/ visual" and then "Q" we return to continue
+ // the :global command.
if (global_busy)
return;
save_msg_scroll = msg_scroll;
- ++RedrawingDisabled; /* don't redisplay the window */
- ++no_wait_return; /* don't wait for return */
+ ++RedrawingDisabled; // don't redisplay the window
+ ++no_wait_return; // don't wait for return
#ifdef FEAT_GUI
- /* Ignore scrollbar and mouse events in Ex mode */
+ // Ignore scrollbar and mouse events in Ex mode
++hold_gui_events;
#endif
msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode."));
while (exmode_active)
{
- /* Check for a ":normal" command and no more characters left. */
+ // Check for a ":normal" command and no more characters left.
if (ex_normal_busy > 0 && typebuf.tb_len == 0)
{
exmode_active = FALSE;
@@ -527,8 +527,8 @@ do_exmode(
{
if (ex_pressedreturn)
{
- /* go up one line, to overwrite the ":<CR>" line, so the
- * output doesn't contain empty lines. */
+ // go up one line, to overwrite the ":<CR>" line, so the
+ // output doesn't contain empty lines.
msg_row = prev_msg_row;
if (prev_msg_row == Rows - 1)
msg_row--;
@@ -538,7 +538,7 @@ do_exmode(
msg_clr_eos();
}
}
- else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */
+ else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF
{
if (curbuf->b_ml.ml_flags & ML_EMPTY)
emsg(_(e_emptybuf));
@@ -611,30 +611,30 @@ do_cmdline_cmd(char_u *cmd)
do_cmdline(
char_u *cmdline,
char_u *(*fgetline)(int, void *, int, int),
- void *cookie, /* argument for fgetline() */
+ void *cookie, // argument for fgetline()
int flags)
{
- char_u *next_cmdline; /* next cmd to execute */
- char_u *cmdline_copy = NULL; /* copy of cmd line */
- int used_getline = FALSE; /* used "fgetline" to obtain command */
- static int recursive = 0; /* recursive depth */
+ char_u *next_cmdline; // next cmd to execute
+ char_u *cmdline_copy = NULL; // copy of cmd line
+ int used_getline = FALSE; // used "fgetline" to obtain command
+ static int recursive = 0; // recursive depth
int msg_didout_before_start = 0;
- int count = 0; /* line number count */
- int did_inc = FALSE; /* incremented RedrawingDisabled */
+ int count = 0; // line number count
+ int did_inc = FALSE; // incremented RedrawingDisabled
int retval = OK;
#ifdef FEAT_EVAL
- struct condstack cstack; /* conditional stack */
- garray_T lines_ga; /* keep lines for ":while"/":for" */
- int current_line = 0; /* active line in lines_ga */
- char_u *fname = NULL; /* function or script name */
- linenr_T *breakpoint = NULL; /* ptr to breakpoint field in cookie */
- int *dbg_tick = NULL; /* ptr to dbg_tick field in cookie */
- struct dbg_stuff debug_saved; /* saved things for debug mode */
+ struct condstack cstack; // conditional stack
+ garray_T lines_ga; // keep lines for ":while"/":for"
+ int current_line = 0; // active line in lines_ga
+ char_u *fname = NULL; // function or script name
+ linenr_T *breakpoint = NULL; // ptr to breakpoint field in cookie
+ int *dbg_tick = NULL; // ptr to dbg_tick field in cookie
+ struct dbg_stuff debug_saved; // saved things for debug mode
int initial_trylevel;
struct msglist **saved_msg_list = NULL;
struct msglist *private_msg_list;
- /* "fgetline" and "cookie" passed to do_one_cmd() */
+ // "fgetline" and "cookie" passed to do_one_cmd()
char_u *(*cmd_getline)(int, void *, int, int);
void *cmd_cookie;
struct loop_cookie cmd_loop_cookie;
@@ -644,23 +644,23 @@ do_cmdline(
# define cmd_getline fgetline
# define cmd_cookie cookie
#endif
- static int call_depth = 0; /* recursiveness */
+ static int call_depth = 0; // recursiveness
#ifdef FEAT_EVAL
- /* For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
- * location for storing error messages to be converted to an exception.
- * This ensures that the do_errthrow() call in do_one_cmd() does not
- * combine the messages stored by an earlier invocation of do_one_cmd()
- * with the command name of the later one. This would happen when
- * BufWritePost autocommands are executed after a write error. */
+ // For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
+ // location for storing error messages to be converted to an exception.
+ // This ensures that the do_errthrow() call in do_one_cmd() does not
+ // combine the messages stored by an earlier invocation of do_one_cmd()
+ // with the command name of the later one. This would happen when
+ // BufWritePost autocommands are executed after a write error.
saved_msg_list = msg_list;
msg_list = &private_msg_list;
private_msg_list = NULL;
#endif
- /* It's possible to create an endless loop with ":execute", catch that
- * here. The value of 200 allows nested function calls, ":source", etc.
- * Allow 200 or 'maxfuncdepth', whatever is larger. */
+ // It's possible to create an endless loop with ":execute", catch that
+ // here. The value of 200 allows nested function calls, ":source", etc.
+ // Allow 200 or 'maxfuncdepth', whatever is larger.
if (call_depth >= 200
#ifdef FEAT_EVAL
&& call_depth >= p_mfd
@@ -669,8 +669,8 @@ do_cmdline(
{
emsg(_("E169: Command too recursive"));
#ifdef FEAT_EVAL
- /* When converting to an exception, we do not include the command name
- * since this is not an error of the specific command. */
+ // When converting to an exception, we do not include the command name
+ // since this is not an error of the specific command.
do_errthrow((struct condstack *)NULL, (char_u *)NULL);
msg_list = saved_msg_list;
#endif
@@ -688,13 +688,13 @@ do_cmdline(
real_cookie = getline_cookie(fgetline, cookie);
- /* Inside a function use a higher nesting level. */
+ // Inside a function use a higher nesting level.
getline_is_func = getline_equal(fgetline, cookie, get_func_line);
if (getline_is_func && ex_nesting_level == func_level(real_cookie))
++ex_nesting_level;
- /* Get the function or script name and the address where the next breakpoint
- * line and the debug tick for a function or script are stored. */
+ // Get the function or script name and the address where the next breakpoint
+ // line and the debug tick for a function or script are stored.
if (getline_is_func)
{
fname = func_name(real_cookie);
@@ -762,7 +762,7 @@ do_cmdline(
getline_is_func = getline_equal(fgetline, cookie, get_func_line);
#endif
- /* stop skipping cmds for an error msg after all endif/while/for */
+ // stop skipping cmds for an error msg after all endif/while/for
if (next_cmdline == NULL
#ifdef FEAT_EVAL
&& !force_abort
@@ -779,15 +779,15 @@ do_cmdline(
*/
#ifdef FEAT_EVAL
- /* 1. If repeating, get a previous line from lines_ga. */
+ // 1. If repeating, get a previous line from lines_ga.
if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len)
{
- /* Each '|' separated command is stored separately in lines_ga, to
- * be able to jump to it. Don't use next_cmdline now. */
+ // Each '|' separated command is stored separately in lines_ga, to
+ // be able to jump to it. Don't use next_cmdline now.
VIM_CLEAR(cmdline_copy);
- /* Check if a function has returned or, unless it has an unclosed
- * try conditional, aborted. */
+ // Check if a function has returned or, unless it has an unclosed
+ // try conditional, aborted.
if (getline_is_func)
{
# ifdef FEAT_PROFILE
@@ -806,14 +806,14 @@ do_cmdline(
script_line_end();
#endif
- /* Check if a sourced file hit a ":finish" command. */
+ // Check if a sourced file hit a ":finish" command.
if (source_finished(fgetline, cookie))
{
retval = FAIL;
break;
}
- /* If breakpoints have been added/deleted need to check for it. */
+ // If breakpoints have been added/deleted need to check for it.
if (breakpoint != NULL && dbg_tick != NULL
&& *dbg_tick != debug_tick)
{
@@ -826,12 +826,12 @@ do_cmdline(
next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line;
sourcing_lnum = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum;
- /* Did we encounter a breakpoint? */
+ // Did we encounter a breakpoint?
if (breakpoint != NULL && *breakpoint != 0
&& *breakpoint <= sourcing_lnum)
{
dbg_breakpoint(fname, sourcing_lnum);
- /* Find next breakpoint. */
+ // Find next breakpoint.
*breakpoint = dbg_find_breakpoint(
getline_equal(fgetline, cookie, getsourceline),
fname, sourcing_lnum);
@@ -850,11 +850,11 @@ do_cmdline(
if (cstack.cs_looplevel > 0)
{
- /* Inside a while/for loop we need to store the lines and use them
- * again. Pass a different "fgetline" function to do_one_cmd()
- * below, so that it stores lines in or reads them from
- * "lines_ga". Makes it possible to define a function inside a
- * while/for loop. */
+ // Inside a while/for loop we need to store the lines and use them
+ // again. Pass a different "fgetline" function to do_one_cmd()
+ // below, so that it stores lines in or reads them from
+ // "lines_ga". Makes it possible to define a function inside a
+ // while/for loop.
cmd_getline = get_loop_line;
cmd_cookie = (void *)&cmd_loop_cookie;
cmd_loop_cookie.lines_gap = &lines_ga;
@@ -870,7 +870,7 @@ do_cmdline(
}
#endif
- /* 2. If no line given, get an allocated line with fgetline(). */
+ // 2. If no line given, get an allocated line with fgetline().
if (next_cmdline == NULL)
{
/*
@@ -887,9 +887,9 @@ do_cmdline(
#endif
, TRUE)) == NULL)
{
- /* Don't call wait_return for aborted command line. The NULL
- * returned for the end of a sourced file or executed function
- * doesn't do this. */
+ // Don't call wait_return for aborted command line. The NULL
+ // returned for the end of a sourced file or executed function
+ // doesn't do this.
if (KeyTyped && !(flags & DOCMD_REPEAT))
need_wait_return = FALSE;
retval = FAIL;
@@ -910,7 +910,7 @@ do_cmdline(
}
}
- /* 3. Make a copy of the command so we can mess with it. */
+ // 3. Make a copy of the command so we can mess with it.
else if (cmdline_copy == NULL)
{
next_cmdline = vim_strsave(next_cmdline);
@@ -954,10 +954,10 @@ do_cmdline(
if (!(flags & DOCMD_NOWAIT) && !recursive)
{
msg_didout_before_start = msg_didout;
- msg_didany = FALSE; /* no output yet */
+ msg_didany = FALSE; // no output yet
msg_start();
- msg_scroll = TRUE; /* put messages below each other */
- ++no_wait_return; /* don't wait for return until finished */
+ msg_scroll = TRUE; // put messages below each other
+ ++no_wait_return; // don't wait for return until finished
++RedrawingDisabled;
did_inc = TRUE;
}
@@ -981,8 +981,8 @@ do_cmdline(
#ifdef FEAT_EVAL
if (cmd_cookie == (void *)&cmd_loop_cookie)
- /* Use "current_line" from "cmd_loop_cookie", it may have been
- * incremented when defining a function. */
+ // Use "current_line" from "cmd_loop_cookie", it may have been
+ // incremented when defining a function.
current_line = cmd_loop_cookie.current_line;
#endif
@@ -1004,15 +1004,15 @@ do_cmdline(
}
else
{
- /* need to copy the command after the '|' to cmdline_copy, for the
- * next do_one_cmd() */
+ // need to copy the command after the '|' to cmdline_copy, for the
+ // next do_one_cmd()
STRMOVE(cmdline_copy, next_cmdline);
next_cmdline = cmdline_copy;
}
#ifdef FEAT_EVAL
- /* reset did_emsg for a function that is not aborted by an error */
+ // reset did_emsg for a function that is not aborted by an error
if (did_emsg && !force_abort
&& getline_equal(fgetline, cookie, get_func_line)
&& !func_has_abort(real_cookie))
@@ -1032,10 +1032,10 @@ do_cmdline(
{
cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP);
- /* Jump back to the matching ":while" or ":for". Be careful
- * not to use a cs_line[] from an entry that isn't a ":while"
- * or ":for": It would make "current_line" invalid and can
- * cause a crash. */
+ // Jump back to the matching ":while" or ":for". Be careful
+ // not to use a cs_line[] from an entry that isn't a ":while"
+ // or ":for": It would make "current_line" invalid and can
+ // cause a crash.
if (!did_emsg && !got_int && !did_throw
&& cstack.cs_idx >= 0
&& (cstack.cs_flags[cstack.cs_idx]
@@ -1044,12 +1044,12 @@ do_cmdline(
&& (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE))
{
current_line = cstack.cs_line[cstack.cs_idx];
- /* remember we jumped there */
+ // remember we jumped there
cstack.cs_lflags |= CSL_HAD_LOOP;
- line_breakcheck(); /* check if CTRL-C typed */
+ line_breakcheck(); // check if CTRL-C typed
- /* Check for the next breakpoint at or after the ":while"
- * or ":for". */
+ // Check for the next breakpoint at or after the ":while"
+ // or ":for".
if (breakpoint != NULL)
{
*breakpoint = dbg_find_breakpoint(
@@ -1061,7 +1061,7 @@ do_cmdline(
}
else
{
- /* can only get here with ":endwhile" or ":endfor" */
+ // can only get here with ":endwhile" or ":endfor"
if (cstack.cs_idx >= 0)
rewind_conditionals(&cstack, cstack.cs_idx - 1,
CSF_WHILE | CSF_FOR, &cstack.cs_looplevel);
@@ -1078,7 +1078,7 @@ do_cmdline(
}
}
- /* Check for the next breakpoint after a watchexpression */
+ // Check for the next breakpoint after a watchexpression
if (breakpoint != NULL && has_watchexpr())
{
*breakpoint = dbg_find_breakpoint(FALSE, fname, sourcing_lnum);
@@ -1116,8 +1116,8 @@ do_cmdline(
cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY;
}
- /* Update global "trylevel" for recursive calls to do_cmdline() from
- * within this loop. */
+ // Update global "trylevel" for recursive calls to do_cmdline() from
+ // within this loop.
trylevel = initial_trylevel + cstack.cs_trylevel;
/*
@@ -1130,9 +1130,9 @@ do_cmdline(
if (trylevel == 0 && !did_emsg && !got_int && !did_throw)
force_abort = FALSE;
- /* Convert an interrupt to an exception if appropriate. */
+ // Convert an interrupt to an exception if appropriate.
(void)do_intthrow(&cstack);
-#endif /* FEAT_EVAL */
+#endif // FEAT_EVAL
}
/*
@@ -1155,9 +1155,9 @@ do_cmdline(
)
&& !(did_emsg
#ifdef FEAT_EVAL
- /* Keep going when inside try/catch, so that the error can be
- * deal with, except when it is a syntax error, it may cause
- * the :endtry to be missed. */
+ // Keep going when inside try/catch, so that the error can be
+ // deal with, except when it is a syntax error, it may cause
+ // the :endtry to be missed.
&& (cstack.cs_trylevel == 0 || did_emsg_syntax)
#endif
&& used_getline
@@ -1209,7 +1209,7 @@ do_cmdline(
int idx = cleanup_conditionals(&cstack, 0, TRUE);
if (idx >= 0)
- --idx; /* remove try block not in its finally clause */
+ --idx; // remove try block not in its finally clause
rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR,
&cstack.cs_looplevel);
}
@@ -1217,9 +1217,9 @@ do_cmdline(
trylevel = initial_trylevel;
}
- /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
- * lack was reported above and the error message is to be converted to an
- * exception, do this now after rewinding the cstack. */
+ // If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
+ // lack was reported above and the error message is to be converted to an
+ // exception, do this now after rewinding the cstack.
do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)
? (char_u *)"endfunction" : (char_u *)NULL);
@@ -1266,7 +1266,7 @@ do_cmdline(
sourcing_lnum = current_exception->throw_lnum;
current_exception->throw_name = NULL;
- discard_current_exception(); /* uses IObuff if 'verbose' */
+ discard_current_exception(); // uses IObuff if 'verbose'
suppress_errthrow = TRUE;
force_abort = TRUE;
@@ -1323,7 +1323,7 @@ do_cmdline(
}
else
{
- /* When leaving a function, reduce nesting level. */
+ // When leaving a function, reduce nesting level.
if (getline_equal(fgetline, cookie, get_func_line))
--ex_nesting_level;
/*
@@ -1346,7 +1346,7 @@ do_cmdline(
restore_dbg_stuff(&debug_saved);
msg_list = saved_msg_list;
-#endif /* FEAT_EVAL */
+#endif // FEAT_EVAL
/*
* If there was too much output to fit on the command line, ask the user to
@@ -1370,7 +1370,7 @@ do_cmdline(
)
{
need_wait_return = FALSE;
- msg_didany = FALSE; /* don't wait when restarting edit */
+ msg_didany = FALSE; // don't wait when restarting edit
}
else if (need_wait_return)
{
@@ -1385,7 +1385,7 @@ do_cmdline(
}
#ifdef FEAT_EVAL
- did_endif = FALSE; /* in case do_cmdline used recursively */
+ did_endif = FALSE; // in case do_cmdline used recursively
#else
/*
* Reset if_level, in case a sourced script file contains more ":if" than
@@ -1412,9 +1412,9 @@ get_loop_line(int c, void *cookie, int indent, int do_concat)
if (cp->current_line + 1 >= cp->lines_gap->ga_len)
{
if (cp->repeating)
- return NULL; /* trying to read past ":endwhile"/":endfor" */
+ return NULL; // trying to read past ":endwhile"/":endfor"
- /* First time inside the ":while"/":for": get line normally. */
+ // First time inside the ":while"/":for": get line normally.
if (cp->getline == NULL)
line = getcmdline(c, 0L, indent, do_concat);
else
@@ -1467,16 +1467,16 @@ free_cmdlines(garray_T *gap)
int
getline_equal(
char_u *(*fgetline)(int, void *, int, int),
- void *cookie UNUSED, /* argument for fgetline() */
+ void *cookie UNUSED, // argument for fgetline()
char_u *(*func)(int, void *, int, int))
{
#ifdef FEAT_EVAL
char_u *(*gp)(int, void *, int, int);
struct loop_cookie *cp;
- /* When "fgetline" is "get_loop_line()" use the "cookie" to find the
- * function that's originally used to obtain the lines. This may be
- * nested several levels. */
+ // When "fgetline" is "get_loop_line()" use the "cookie" to find the
+ // function that's originally used to obtain the lines. This may be
+ // nested several levels.
gp = fgetline;
cp = (struct loop_cookie *)cookie;
while (gp == get_loop_line)
@@ -1497,15 +1497,15 @@ getline_equal(
void *
getline_cookie(
char_u *(*fgetline)(int, void *, int, int) UNUSED,
- void *cookie) /* argument for fgetline() */
+ void *cookie) // argument for fgetline()
{
#ifdef FEAT_EVAL
char_u *(*gp)(int, void *, int, int);
struct loop_cookie *cp;
- /* When "fgetline" is "get_loop_line()" use the "cookie" to find the
- * cookie that's originally used to obtain the lines. This may be nested
- * several levels. */
+ // When "fgetline" is "get_loop_line()" use the "cookie" to find the
+ // cookie that's originally used to obtain the lines. This may be nested
+ // several levels.
gp = fgetline;
cp = (struct loop_cookie *)cookie;
while (gp == get_loop_line)
@@ -1543,7 +1543,7 @@ compute_buffer_local_count(int addr_type, int lnum, int offset)
break;
buf = nextbuf;
if (addr_type == ADDR_LOADED_BUFFERS)
- /* skip over unloaded buffers */
+ // skip over unloaded buffers
while (buf->b_ml.ml_mfp == NULL)
{
nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
@@ -1552,7 +1552,7 @@ compute_buffer_local_count(int addr_type, int lnum, int offset)
buf = nextbuf;
}
}
- /* we might have gone too far, last buffer is not loadedd */
+ // we might have gone too far, last buffer is not loadedd
if (addr_type == ADDR_LOADED_BUFFERS)
while (buf->b_ml.ml_mfp == NULL)
{
@@ -1634,18 +1634,18 @@ do_one_cmd(
struct condstack *cstack,
#endif
char_u *(*fgetline)(int, void *, int, int),
- void *cookie) /* argument for fgetline() */
+ void *cookie) // argument for fgetline()
{
char_u *p;
linenr_T lnum;
long n;
- char *errormsg = NULL; /* error message */
+ char *errormsg = NULL; // error message
char_u *after_modifier = NULL;
- exarg_T ea; /* Ex command arguments */
+ exarg_T ea; // Ex command arguments
int save_msg_scroll = msg_scroll;
cmdmod_T save_cmdmod;
int save_reg_executing = reg_executing;
- int ni; /* set when Not Implemented */
+ int ni; // set when Not Implemented
char_u *cmd;
vim_memset(&ea, 0, sizeof(ea));
@@ -1655,13 +1655,13 @@ do_one_cmd(
++ex_nesting_level;
#endif
- /* When the last file has not been edited :q has to be typed twice. */
+ // When the last file has not been edited :q has to be typed twice.
if (quitmore
#ifdef FEAT_EVAL
- /* avoid that a function call in 'statusline' does this */
+ // avoid that a function call in 'statusline' does this
&& !getline_equal(fgetline, cookie, get_func_line)
#endif
- /* avoid that an autocommand, e.g. QuitPre, does this */
+ // avoid that an autocommand, e.g. QuitPre, does this
&& !getline_equal(fgetline, cookie, getnextac))
--quitmore;
@@ -1671,7 +1671,7 @@ do_one_cmd(
*/
save_cmdmod = cmdmod;
- /* "#!anything" is handled like a comment. */
+ // "#!anything" is handled like a comment.
if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!')
goto doend;
@@ -1748,8 +1748,8 @@ do_one_cmd(
}
# endif
- /* May go to debug mode. If this happens and the ">quit" debug command is
- * used, throw an interrupt exception and skip the next command. */
+ // May go to debug mode. If this happens and the ">quit" debug command is
+ // used, throw an interrupt exception and skip the next command.
dbg_check_breakpoint(&ea);
if (!ea.skip && got_int)
{
@@ -1821,7 +1821,7 @@ do_one_cmd(
* ":3|..." prints line 3
* ":|" prints current line
*/
- if (ea.skip) /* skip this if inside :if */
+ if (ea.skip) // skip this if inside :if
goto doend;
if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2))
{
@@ -1837,8 +1837,8 @@ do_one_cmd(
{
if (ea.line2 > curbuf->b_ml.ml_line_count)
{
- /* With '-' in 'cpoptions' a line number past the file is an
- * error, otherwise put it at the end of the file. */
+ // With '-' in 'cpoptions' a line number past the file is an
+ // error, otherwise put it at the end of the file.
if (vim_strchr(p_cpo, CPO_MINUS) != NULL)
ea.line2 = -1;
else
@@ -1859,8 +1859,8 @@ do_one_cmd(
goto doend;
}
- /* If this looks like an undefined user command and there are CmdUndefined
- * autocommands defined, trigger the matching autocommands. */
+ // If this looks like an undefined user command and there are CmdUndefined
+ // autocommands defined, trigger the matching autocommands.
if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip
&& ASCII_ISUPPER(*ea.cmd)
&& has_cmdundefined())
@@ -1873,8 +1873,8 @@ do_one_cmd(
p = vim_strnsave(ea.cmd, (int)(p - ea.cmd));
ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
vim_free(p);
- /* If the autocommands did something and didn't cause an error, try
- * finding the command again. */
+ // If the autocommands did something and didn't cause an error, try
+ // finding the command again.
p = (ret
#ifdef FEAT_EVAL
&& !aborting()
@@ -1903,8 +1903,8 @@ do_one_cmd(
STRCPY(IObuff, _("E492: Not an editor command"));
if (!sourcing)
{
- /* If the modifier was parsed OK the error must be in the
- * following command */
+ // If the modifier was parsed OK the error must be in the
+ // following command
if (after_modifier != NULL)
append_command(after_modifier);
else
@@ -1939,7 +1939,7 @@ do_one_cmd(
#endif
- /* forced commands */
+ // forced commands
if (*p == '!' && ea.cmdidx != CMD_substitute
&& ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic)
{
@@ -1972,7 +1972,7 @@ do_one_cmd(
}
if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY))
{
- /* Command not allowed in non-'modifiable' buffer */
+ // Command not allowed in non-'modifiable' buffer
errormsg = _(e_modifiable);
goto doend;
}
@@ -1980,15 +1980,15 @@ do_one_cmd(
if (text_locked() && !(ea.argt & EX_CMDWIN)
&& !IS_USER_CMDIDX(ea.cmdidx))
{
- /* Command not allowed when editing the command line. */
+ // Command not allowed when editing the command line.
errormsg = _(get_text_locked_msg());
goto doend;
}
- /* Disallow editing another buffer when "curbuf_lock" is set.
- * Do allow ":checktime" (it is postponed).
- * Do allow ":edit" (check for an argument later).
- * Do allow ":file" with no arguments (check for an argument later). */
+ // Disallow editing another buffer when "curbuf_lock" is set.
+ // Do allow ":checktime" (it is postponed).
+ // Do allow ":edit" (check for an argument later).
+ // Do allow ":file" with no arguments (check for an argument later).
if (!(ea.argt & EX_CMDWIN)
&& ea.cmdidx != CMD_checktime
&& ea.cmdidx != CMD_edit
@@ -1999,7 +1999,7 @@ do_one_cmd(
if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0)
{
- /* no range allowed */
+ // no range allowed
errormsg = _(e_norange);
goto doend;
}
@@ -2053,8 +2053,8 @@ do_one_cmd(
if (((ea.argt & EX_WHOLEFOLD) || ea.addr_count >= 2) && !global_busy
&& ea.addr_type == ADDR_LINES)
{
- /* Put the first line at the start of a closed fold, put the last line
- * at the end of a closed fold. */
+ // Put the first line at the start of a closed fold, put the last line
+ // at the end of a closed fold.
(void)hasFolding(ea.line1, &ea.line1, NULL);
(void)hasFolding(ea.line2, NULL, &ea.line2);
}
@@ -2097,9 +2097,9 @@ do_one_cmd(
if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update)
{
- if (*ea.arg == '>') /* append */
+ if (*ea.arg == '>') // append
{
- if (*++ea.arg != '>') /* typed wrong */
+ if (*++ea.arg != '>') // typed wrong
{
errormsg = _("E494: Use w or w>>");
goto doend;
@@ -2107,7 +2107,7 @@ do_one_cmd(
ea.arg = skipwhite(ea.arg + 1);
ea.append = TRUE;
}
- else if (*ea.arg == '!' && ea.cmdidx == CMD_write) /* :w !filter */
+ else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter
{
++ea.arg;
ea.usefilter = TRUE;
@@ -2118,10 +2118,10 @@ do_one_cmd(
{
if (ea.forceit)
{
- ea.usefilter = TRUE; /* :r! filter if ea.forceit */
+ ea.usefilter = TRUE; // :r! filter if ea.forceit
ea.forceit = FALSE;
}
- else if (*ea.arg == '!') /* :r !filter */
+ else if (*ea.arg == '!') // :r !filter
{
++ea.arg;
ea.usefilter = TRUE;
@@ -2131,7 +2131,7 @@ do_one_cmd(
if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift)
{
ea.amount = 1;
- while (*ea.arg == *ea.cmd) /* count number of '>' or '<' */
+ while (*ea.arg == *ea.cmd) // count number of '>' or '<'
{
++ea.arg;
++ea.amount;
@@ -2166,12 +2166,12 @@ do_one_cmd(
{
for (p = ea.arg; *p; ++p)
{
- /* Remove one backslash before a newline, so that it's possible to
- * pass a newline to the shell and also a newline that is preceded
- * with a backslash. This makes it impossible to end a shell
- * command in a backslash, but that doesn't appear useful.
- * Halving the number of backslashes is incompatible with previous
- * versions. */
+ // Remove one backslash before a newline, so that it's possible to
+ // pass a newline to the shell and also a newline that is preceded
+ // with a backslash. This makes it impossible to end a shell
+ // command in a backslash, but that doesn't appear useful.
+ // Halving the number of backslashes is incompatible with previous
+ // versions.
if (*p == '\\' && p[1] == '\n')
STRMOVE(p, p + 1);
else if (*p == '\n')
@@ -2238,15 +2238,15 @@ do_one_cmd(
}
}
- /* accept numbered register only when no count allowed (:put) */
+ // accept numbered register only when no count allowed (:put)
if ( (ea.argt & EX_REGSTR)
&& *ea.arg != NUL
- /* Do not allow register = for user commands */
+ // Do not allow register = for user commands
&& (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')
&& !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)))
{
#ifndef FEAT_CLIPBOARD
- /* check these explicitly for a more specific error message */
+ // check these explicitly for a more specific error message
if (*ea.arg == '*' || *ea.arg == '+')
{
errormsg = _(e_invalidreg);
@@ -2258,7 +2258,7 @@ do_one_cmd(
{
ea.regname = *ea.arg++;
#ifdef FEAT_EVAL
- /* for '=' register: accept the rest of the line as an expression */
+ // for '=' register: accept the rest of the line as an expression
if (ea.arg[-1] == '=' && ea.arg[0] != NUL)
{
set_expr_line(vim_strsave(ea.arg));
@@ -2333,7 +2333,7 @@ do_one_cmd(
{
switch (ea.cmdidx)
{
- /* commands that need evaluation */
+ // commands that need evaluation
case CMD_while:
case CMD_endwhile:
case CMD_for:
@@ -2349,9 +2349,9 @@ do_one_cmd(
case CMD_function:
break;
- /* Commands that handle '|' themselves. Check: A command should
- * either have the EX_TRLBAR flag, appear in this list or appear in
- * the list at ":help :bar". */
+ // Commands that handle '|' themselves. Check: A command should
+ // either have the EX_TRLBAR flag, appear in this list or appear in
+ // the list at ":help :bar".
case CMD_aboveleft:
case CMD_and:
case CMD_belowright:
@@ -2449,14 +2449,14 @@ do_one_cmd(
}
ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
FALSE, FALSE);
- if (ea.line2 < 0) /* failed */
+ if (ea.line2 < 0) // failed
goto doend;
ea.addr_count = 1;
ea.arg = skipwhite(p);
}
- /* The :try command saves the emsg_silent flag, reset it here when
- * ":silent! try" was used, it should only apply to :try itself. */
+ // The :try command saves the emsg_silent flag, reset it here when
+ // ":silent! try" was used, it should only apply to :try itself.
if (ea.cmdidx == CMD_try && ea.did_esilent > 0)
{
emsg_silent -= ea.did_esilent;
@@ -2509,7 +2509,7 @@ do_one_cmd(
#endif
doend:
- if (curwin->w_cursor.lnum == 0) /* can happen with zero line number */
+ if (curwin->w_cursor.lnum == 0) // can happen with zero line number
{
curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
@@ -2543,19 +2543,19 @@ doend:
if (ea.save_msg_silent != -1)
{
- /* messages could be enabled for a serious error, need to check if the
- * counters don't become negative */
+ // messages could be enabled for a serious error, need to check if the
+ // counters don't become negative
if (!did_emsg || msg_silent > ea.save_msg_silent)
msg_silent = ea.save_msg_silent;
emsg_silent -= ea.did_esilent;
if (emsg_silent < 0)
emsg_silent = 0;
- /* Restore msg_scroll, it's set by file I/O commands, even when no
- * message is actually displayed. */
+ // Restore msg_scroll, it's set by file I/O commands, even when no
+ // message is actually displayed.
msg_scroll = save_msg_scroll;
- /* "silent reg" or "silent echo x" inside "redir" leaves msg_col
- * somewhere in the line. Put it back in the first column. */
+ // "silent reg" or "silent echo x" inside "redir" leaves msg_col
+ // somewhere in the line. Put it back in the first column.
if (redirecting())
msg_col = 0;
}
@@ -2565,7 +2565,7 @@ doend:
--sandbox;
#endif
- if (ea.nextcmd && *ea.nextcmd == NUL) /* not really a next command */
+ if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command
ea.nextcmd = NULL;
#ifdef FEAT_EVAL
@@ -2607,7 +2607,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':')
++eap->cmd;
- /* in ex mode, an empty line works like :+ */
+ // in ex mode, an empty line works like :+
if (*eap->cmd == NUL && exmode_active
&& (getline_equal(eap->getline, eap->cookie, getexmodeline)
|| getline_equal(eap->getline, eap->cookie, getexline))
@@ -2618,7 +2618,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
ex_pressedreturn = TRUE;
}
- /* ignore comment and empty lines */
+ // ignore comment and empty lines
if (*eap->cmd == '"')
return FAIL;
if (*eap->cmd == NUL)
@@ -2631,7 +2631,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
p = skip_range(eap->cmd, NULL);
switch (*p)
{
- /* When adding an entry, also modify cmd_exists(). */
+ // When adding an entry, also modify cmd_exists().
case 'a': if (!checkforcmd(&eap->cmd, "aboveleft", 3))
break;
cmdmod.split |= WSP_ABOVE;
@@ -2681,7 +2681,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
cmdmod.keepjumps = TRUE;
continue;
- case 'f': /* only accept ":filter {pat} cmd" */
+ case 'f': // only accept ":filter {pat} cmd"
{
char_u *reg_pat;
@@ -2713,7 +2713,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
continue;
}
- /* ":hide" and ":hide | cmd" are not modifiers */
+ // ":hide" and ":hide | cmd" are not modifiers
case 'h': if (p != eap->cmd || !checkforcmd(&p, "hide", 3)
|| *p == NUL || ends_excmd(*p))
break;
@@ -2736,8 +2736,8 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
{
if (cmdmod.save_ei == NULL && !skip_only)
{
- /* Set 'eventignore' to "all". Restore the
- * existing option value later. */
+ // Set 'eventignore' to "all". Restore the
+ // existing option value later.
cmdmod.save_ei = vim_strsave(p_ei);
set_string_option_direct((char_u *)"ei", -1,
(char_u *)"all", OPT_FREE, SID_NONE);
@@ -2776,7 +2776,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
}
if (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1]))
{
- /* ":silent!", but not "silent !cmd" */
+ // ":silent!", but not "silent !cmd"
eap->cmd = skipwhite(eap->cmd + 1);
if (!skip_only)
{
@@ -2856,7 +2856,7 @@ free_cmdmod(void)
{
if (cmdmod.save_ei != NULL)
{
- /* Restore 'eventignore' to the value before ":noautocmd". */
+ // Restore 'eventignore' to the value before ":noautocmd".
set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei,
OPT_FREE, SID_NONE);
free_string_option(cmdmod.save_ei);
@@ -3062,9 +3062,9 @@ parse_cmd_address(exarg_T *eap, char **errormsg, int silent)
*/
int
checkforcmd(
- char_u **pp, /* start of command */
- char *cmd, /* name of command */
- int len) /* required length */
+ char_u **pp, // start of command
+ char *cmd, // name of command
+ int len) // required length
{
int i;
@@ -3150,19 +3150,19 @@ find_command(exarg_T *eap, int *full UNUSED)
{
while (ASCII_ISALPHA(*p))
++p;
- /* for python 3.x support ":py3", ":python3", ":py3file", etc. */
+ // for python 3.x support ":py3", ":python3", ":py3file", etc.
if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y')
while (ASCII_ISALNUM(*p))
++p;
- /* check for non-alpha command */
+ // check for non-alpha command
if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL)
++p;
len = (int)(p - eap->cmd);
if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
{
- /* Check for ":dl", ":dell", etc. to ":deletel": that's
- * :delete with the 'l' flag. Same for 'p'. */
+ // Check for ":dl", ":dell", etc. to ":deletel": that's
+ // :delete with the 'l' flag. Same for 'p'.
for (i = 0; i < len; ++i)
if (eap->cmd[i] != ((char_u *)"delete")[i])
break;
@@ -3187,8 +3187,8 @@ find_command(exarg_T *eap, int *full UNUSED)
getout(1);
}
- /* Use a precomputed index for fast look-up in cmdnames[]
- * taking into account the first 2 letters of eap->cmd. */
+ // Use a precomputed index for fast look-up in cmdnames[]
+ // taking into account the first 2 letters of eap->cmd.
eap->cmdidx = cmdidxs1[CharOrdLow(c1)];
if (ASCII_ISLOWER(c2))
eap->cmdidx += cmdidxs2[CharOrdLow(c1)][CharOrdLow(c2)];
@@ -3231,7 +3231,7 @@ static struct cmdmod
{
char *name;
int minlen;
- int has_count; /* :123verbose :3tab */
+ int has_count; // :123verbose :3tab
} cmdmods[] = {
{"aboveleft", 3, FALSE},
{"belowright", 3, FALSE},
@@ -3296,7 +3296,7 @@ cmd_exists(char_u *name)
int j;
char_u *p;
- /* Check command modifiers. */
+ // Check command modifiers.
for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i)
{
for (j = 0; name[j] != NUL; ++j)
@@ -3306,8 +3306,8 @@ cmd_exists(char_u *name)
return (cmdmods[i].name[j] == NUL ? 2 : 1);
}
- /* Check built-in commands and user defined commands.
- * For ":2match" and ":3match" we need to skip the number. */
+ // Check built-in commands and user defined commands.
+ // For ":2match" and ":3match" we need to skip the number.
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
p = find_command(&ea, &full);
@@ -3316,7 +3316,7 @@ cmd_exists(char_u *name)
if (vim_isdigit(*name) && ea.cmdidx != CMD_match)
return 0;
if (*skipwhite(p) != NUL)
- return 0; /* trailing garbage */
+ return 0; // trailing garbage
return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1));
}
#endif
@@ -3352,7 +3352,7 @@ excmd_get_argt(cmdidx_T idx)
char_u *
skip_range(
char_u *cmd,
- int *ctx) /* pointer to xp_context or NULL */
+ int *ctx) // pointer to xp_context or NULL
{
unsigned delim;
@@ -3383,7 +3383,7 @@ skip_range(
++cmd;
}
- /* Skip ":" and white space. */
+ // Skip ":" and white space.
while (*cmd == ':')
cmd = skipwhite(cmd + 1);
@@ -3434,7 +3434,7 @@ get_address(
{
switch (*cmd)
{
- case '.': /* '.' - Cursor position */
+ case '.': // '.' - Cursor position
++cmd;
switch (addr_type)
{
@@ -3475,7 +3475,7 @@ get_address(
}
break;
- case '$': /* '$' - last line */
+ case '$': // '$' - last line
++cmd;
switch (addr_type)
{
@@ -3529,7 +3529,7 @@ get_address(
}
break;
- case '\'': /* ''' - mark */
+ case '\'': // ''' - mark
if (*++cmd == NUL)
{
cmd = NULL;
@@ -3545,12 +3545,12 @@ get_address(
++cmd;
else
{
- /* Only accept a mark in another file when it is
- * used by itself: ":'M". */
+ // Only accept a mark in another file when it is
+ // used by itself: ":'M".
fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
++cmd;
if (fp == (pos_T *)-1)
- /* Jumped to another file. */
+ // Jumped to another file.
lnum = curwin->w_cursor.lnum;
else
{
@@ -3565,7 +3565,7 @@ get_address(
break;
case '/':
- case '?': /* '/' or '?' - search */
+ case '?': // '/' or '?' - search
c = *cmd++;
if (addr_type != ADDR_LINES)
{
@@ -3573,7 +3573,7 @@ get_address(
cmd = NULL;
goto error;
}
- if (skip) /* skip "/pat/" */
+ if (skip) // skip "/pat/"
{
cmd = skip_regexp(cmd, c, (int)p_magic, NULL);
if (*cmd == c)
@@ -3610,12 +3610,12 @@ get_address(
}
lnum = curwin->w_cursor.lnum;
curwin->w_cursor = pos;
- /* adjust command string pointer */
+ // adjust command string pointer
cmd += searchcmdlen;
}
break;
- case '\\': /* "\?", "\/" or "\&", repeat search */
+ case '\\': // "\?", "\/" or "\&", repeat search
++cmd;
if (addr_type != ADDR_LINES)
{
@@ -3668,7 +3668,7 @@ get_address(
break;
default:
- if (VIM_ISDIGIT(*cmd)) /* absolute line number */
+ if (VIM_ISDIGIT(*cmd)) // absolute line number
lnum = getdigits(&cmd);
}
@@ -3721,10 +3721,10 @@ get_address(
}
if (VIM_ISDIGIT(*cmd))
- i = '+'; /* "number" is same as "+number" */
+ i = '+'; // "number" is same as "+number"
else
i = *cmd++;
- if (!VIM_ISDIGIT(*cmd)) /* '+' is '+1', but '+0' is not '+1' */
+ if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1'
n = 1;
else
n = getdigits(&cmd);
@@ -3742,8 +3742,8 @@ get_address(
else
{
#ifdef FEAT_FOLDING
- /* Relative line addressing, need to adjust for folded lines
- * now, but only do it after the first address. */
+ // Relative line addressing, need to adjust for folded lines
+ // now, but only do it after the first address.
if (addr_type == ADDR_LINES && (i == '-' || i == '+')
&& address_count >= 2)
(void)hasFolding(lnum, NULL, &lnum);
@@ -3831,7 +3831,7 @@ invalid_range(exarg_T *eap)
return _(e_invrange);
break;
case ADDR_ARGUMENTS:
- /* add 1 if ARGCOUNT is 0 */
+ // add 1 if ARGCOUNT is 0
if (eap->line2 > ARGCOUNT + (!ARGCOUNT))
return _(e_invrange);
break;
@@ -3979,14 +3979,14 @@ replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL)
{
- /* replace $* by given arguments */
+ // replace $* by given arguments
i = 1;
while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL)
++i;
len = (int)STRLEN(p);
new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1);
if (new_cmdline == NULL)
- return NULL; /* out of memory */
+ return NULL; // out of memory
ptr = new_cmdline;
while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL)
{
@@ -4002,14 +4002,14 @@ replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
{
new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2);
if (new_cmdline == NULL)
- return NULL; /* out of memory */
+ return NULL; // out of memory
STRCPY(new_cmdline, program);
STRCAT(new_cmdline, " ");
STRCAT(new_cmdline, p);
}
msg_make(p);
- /* 'eap->cmd' is not set here, because it is not used at CMD_make */
+ // 'eap->cmd' is not set here, because it is not used at CMD_make
vim_free(*cmdlinep);
*cmdlinep = new_cmdline;
p = new_cmdline;
@@ -4029,7 +4029,7 @@ expand_filename(
char_u **cmdlinep,
char **errormsgp)
{
- int has_wildcards; /* need to expand wildcards */
+ int has_wildcards; // need to expand wildcards
char_u *repl;
int srclen;
char_u *p;
@@ -4037,7 +4037,7 @@ expand_filename(
int escaped;
#ifdef FEAT_QUICKFIX
- /* Skip a regexp pattern for ":vimgrep[add] pat file..." */
+ // Skip a regexp pattern for ":vimgrep[add] pat file..."
p = skip_grep_pat(eap);
#else
p = eap->arg;
@@ -4052,7 +4052,7 @@ expand_filename(
while (*p != NUL)
{
#ifdef FEAT_EVAL
- /* Skip over `=expr`, wildcards in it are not expanded. */
+ // Skip over `=expr`, wildcards in it are not expanded.
if (p[0] == '`' && p[1] == '=')
{
p += 2;
@@ -4077,16 +4077,16 @@ expand_filename(
*/
repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
errormsgp, &escaped);
- if (*errormsgp != NULL) /* error detected */
+ if (*errormsgp != NULL) // error detected
return FAIL;
- if (repl == NULL) /* no match found */
+ if (repl == NULL) // no match found
{
p += srclen;
continue;
}
- /* Wildcards won't be expanded below, the replacement is taken
- * literally. But do expand "~/file", "~user/file" and "$HOME/file". */
+ // Wildcards won't be expanded below, the replacement is taken
+ // literally. But do expand "~/file", "~user/file" and "$HOME/file".
if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL)
{
char_u *l = repl;
@@ -4095,13 +4095,12 @@ expand_filename(
vim_free(l);
}
- /* Need to escape white space et al. with a backslash.
- * Don't do this for:
- * - replacement that already has been escaped: "##"
- * - shell commands (may have to use quotes instead).
- * - non-unix systems when there is a single argument (spaces don't
- * separate arguments then).
- */
+ // Need to escape white space et al. with a backslash.
+ // Don't do this for:
+ // - replacement that already has been escaped: "##"
+ // - shell commands (may have to use quotes instead).
+ // - non-unix systems when there is a single argument (spaces don't
+ // separate arguments then).
if (!eap->usefilter
&& !escaped
&& eap->cmdidx != CMD_bang
@@ -4120,8 +4119,8 @@ expand_filename(
{
char_u *l;
#ifdef BACKSLASH_IN_FILENAME
- /* Don't escape a backslash here, because rem_backslash() doesn't
- * remove it later. */
+ // Don't escape a backslash here, because rem_backslash() doesn't
+ // remove it later.
static char_u *nobslash = (char_u *)" \t\"|";
# define ESCAPE_CHARS nobslash
#else
@@ -4141,7 +4140,7 @@ expand_filename(
}
}
- /* For a shell command a '!' must be escaped. */
+ // For a shell command a '!' must be escaped.
if ((eap->usefilter || eap->cmdidx == CMD_bang
|| eap->cmdidx == CMD_terminal)
&& vim_strpbrk(repl, (char_u *)"!") != NULL)
@@ -4210,7 +4209,7 @@ expand_filename(
else
p = NULL;
}
- else /* n == 2 */
+ else // n == 2
{
expand_T xpc;
int options = WILD_LIST_NOTFOUND
@@ -4229,7 +4228,7 @@ expand_filename(
{
(void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg),
p, cmdlinep);
- if (n == 2) /* p came from ExpandOne() */
+ if (n == 2) // p came from ExpandOne()
vim_free(p);
}
}
@@ -4266,9 +4265,9 @@ repl_cmdline(
len = (int)STRLEN(repl);
i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
if (eap->nextcmd != NULL)
- i += (int)STRLEN(eap->nextcmd);/* add space for next command */
+ i += (int)STRLEN(eap->nextcmd);// add space for next command
if ((new_cmdline = alloc(i)) == NULL)
- return NULL; /* out of memory! */
+ return NULL; // out of memory!
/*
* Copy the stuff before the expanded part.
@@ -4276,15 +4275,15 @@ repl_cmdline(
* Copy what came after the expanded part.
* Copy the next commands, if there are any.
*/
- i = (int)(src - *cmdlinep); /* length of part before match */
+ i = (int)(src - *cmdlinep); // length of part before match
mch_memmove(new_cmdline, *cmdlinep, (size_t)i);
mch_memmove(new_cmdline + i, repl, (size_t)len);
- i += len; /* remember the end of the string */
+ i += len; // remember the end of the string
STRCPY(new_cmdline + i, src + srclen);
- src = new_cmdline + i; /* remember where to continue */
+ src = new_cmdline + i; // remember where to continue
- if (eap->nextcmd != NULL) /* append next command */
+ if (eap->nextcmd != NULL) // append next command
{
i = (int)STRLEN(new_cmdline) + 1;
STRCPY(new_cmdline + i, eap->nextcmd);
@@ -4319,16 +4318,16 @@ separate_nextcmd(exarg_T *eap)
if (*p == Ctrl_V)
{
if (eap->argt & (EX_CTRLV | EX_XFILE))
- ++p; /* skip CTRL-V and next char */
+ ++p; // skip CTRL-V and next char
else
- /* remove CTRL-V and skip next char */
+ // remove CTRL-V and skip next char
STRMOVE(p, p + 1);
- if (*p == NUL) /* stop at NUL after CTRL-V */
+ if (*p == NUL) // stop at NUL after CTRL-V
break;
}
#ifdef FEAT_EVAL
- /* Skip over `=expr` when wildcards are expanded. */
+ // Skip over `=expr` when wildcards are expanded.
else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE))
{
p += 2;
@@ -4336,9 +4335,9 @@ separate_nextcmd(exarg_T *eap)
}
#endif
- /* Check for '"': start of comment or '|': next command */
- /* :@" and :*" do not start a comment!
- * :redir @" doesn't either. */
+ // Check for '"': start of comment or '|': next command
+ // :@" and :*" do not start a comment!
+ // :redir @" doesn't either.
else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM)
&& ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
|| p != eap->arg)
@@ -4353,7 +4352,7 @@ separate_nextcmd(exarg_T *eap)
if ((vim_strchr(p_cpo, CPO_BAR) == NULL
|| !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\')
{
- STRMOVE(p - 1, p); /* remove the '\' */
+ STRMOVE(p - 1, p); // remove the '\'
--p;
}
else
@@ -4365,7 +4364,7 @@ separate_nextcmd(exarg_T *eap)
}
}
- if (!(eap->argt & EX_NOTRLCOM)) /* remove trailing spaces */
+ if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces
del_trailing_spaces(eap->arg);
}
@@ -4378,7 +4377,7 @@ getargcmd(char_u **argp)
char_u *arg = *argp;
char_u *command = NULL;
- if (*arg == '+') /* +[command] */
+ if (*arg == '+') // +[command]
{
++arg;
if (vim_isspace(*arg) || *arg == NUL)
@@ -4388,10 +4387,10 @@ getargcmd(char_u **argp)
command = arg;
arg = skip_cmd_arg(command, TRUE);
if (*arg != NUL)
- *arg++ = NUL; /* terminate command with NUL */
+ *arg++ = NUL; // terminate command with NUL
}
- arg = skipwhite(arg); /* skip over spaces */
+ arg = skipwhite(arg); // skip over spaces
*argp = arg;
}
return command;
@@ -4403,7 +4402,7 @@ getargcmd(char_u **argp)
char_u *
skip_cmd_arg(
char_u *p,
- int rembs) /* TRUE to halve the number of backslashes */
+ int rembs) // TRUE to halve the number of backslashes
{
while (*p && !vim_isspace(*p))
{
@@ -4445,7 +4444,7 @@ getargopt(exarg_T *eap)
int bad_char_idx;
char_u *p;
- /* ":edit ++[no]bin[ary] file" */
+ // ":edit ++[no]bin[ary] file"
if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0)
{
if (*arg == 'n')
@@ -4461,7 +4460,7 @@ getargopt(exarg_T *eap)
return OK;
}
- /* ":read ++edit file" */
+ // ":read ++edit file"
if (STRNCMP(arg, "edit", 4) == 0)
{
eap->read_edit = TRUE;
@@ -4510,14 +4509,14 @@ getargopt(exarg_T *eap)
}
else if (pp == &eap->force_enc)
{
- /* Make 'fileencoding' lower case. */
+ // Make 'fileencoding' lower case.
for (p = eap->cmd + eap->force_enc; *p != NUL; ++p)
*p = TOLOWER_ASC(*p);
}
else
{
- /* Check ++bad= argument. Must be a single-byte character, "keep" or
- * "drop". */
+ // Check ++bad= argument. Must be a single-byte character, "keep" or
+ // "drop".
if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL)
return FAIL;
}
@@ -4554,7 +4553,7 @@ ex_doautocmd(exarg_T *eap)
int did_aucmd;
(void)do_doautocmd(arg, TRUE, &did_aucmd);
- /* Only when there is no <nomodeline>. */
+ // Only when there is no <nomodeline>.
if (call_do_modelines && did_aucmd)
do_modelines(0);
}
@@ -4589,7 +4588,7 @@ ex_buffer(exarg_T *eap)
eap->errmsg = e_trailing;
else
{
- if (eap->addr_count == 0) /* default is current buffer */
+ if (eap->addr_count == 0) // default is current buffer
goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0);
else
goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2);
@@ -4712,7 +4711,7 @@ check_nextcmd(char_u *p)
*/
static int
check_more(
- int message, /* when FALSE check only, no messages */
+ int message, // when FALSE check only, no messages
int forceit)
{
int n = ARGCOUNT - curwin->w_arg_idx - 1;
@@ -4737,7 +4736,7 @@ check_more(
#endif
semsg(NGETTEXT("E173: %d more file to edit",
"E173: %d more files to edit", n), n);
- quitmore = 2; /* next try to quit is allowed */
+ quitmore = 2; // next try to quit is allowed
}
return FAIL;
}
@@ -4859,7 +4858,7 @@ ex_quit(exarg_T *eap)
return;
}
#endif
- /* Don't quit while editing the command line. */
+ // Don't quit while editing the command line.
if (text_locked())
{
text_locked_msg();
@@ -4876,11 +4875,11 @@ ex_quit(exarg_T *eap)
else
wp = curwin;
- /* Refuse to quit when locked. */
+ // Refuse to quit when locked.
if (curbuf_locked())
return;
- /* Trigger QuitPre and maybe ExitPre */
+ // Trigger QuitPre and maybe ExitPre
if (before_quit_autocmds(wp, FALSE, eap->forceit))
return;
@@ -4904,20 +4903,19 @@ ex_quit(exarg_T *eap)
}
else
{
- /* quit last window
- * Note: only_one_window() returns true, even so a help window is
- * still open. In that case only quit, if no address has been
- * specified. Example:
- * :h|wincmd w|1q - don't quit
- * :h|wincmd w|q - quit
- */
+ // quit last window
+ // Note: only_one_window() returns true, even so a help window is
+ // still open. In that case only quit, if no address has been
+ // specified. Example:
+ // :h|wincmd w|1q - don't quit
+ // :h|wincmd w|q - quit
if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0))
getout(0);
not_exiting();
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
- /* close window; may free buffer */
+ // close window; may free buffer
win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit);
}
}
@@ -4928,8 +4926,8 @@ ex_quit(exarg_T *eap)
static void
ex_cquit(exarg_T *eap UNUSED)
{
- getout(1); /* this does not always pass on the exit code to the Manx
- compiler. why? */
+ getout(1); // this does not always pass on the exit code to the Manx
+ // compiler. why?
}
/*
@@ -4942,14 +4940,14 @@ ex_quit_all(exarg_T *eap)
if (cmdwin_type != 0)
{
if (eap->forceit)
- cmdwin_result = K_XF1; /* ex_window() takes care of this */
+ cmdwin_result = K_XF1; // ex_window() takes care of this
else
cmdwin_result = K_XF2;
return;
}
# endif
- /* Don't quit while editing the command line. */
+ // Don't quit while editing the command line.
if (text_locked())
{
text_locked_msg();
@@ -5028,7 +5026,7 @@ ex_pclose(exarg_T *eap)
ex_win_close(
int forceit,
win_T *win,
- tabpage_T *tp) /* NULL or the tab page "win" is in */
+ tabpage_T *tp) // NULL or the tab page "win" is in
{
int need_hide;
buf_T *buf = win->w_buffer;
@@ -5059,7 +5057,7 @@ ex_win_close(
need_mouse_correct = TRUE;
#endif
- /* free buffer when not hiding it or when it's a scratch buffer */
+ // free buffer when not hiding it or when it's a scratch buffer
if (tp == NULL)
win_close(win, !need_hide && !buf_hide(buf));
else
@@ -5081,8 +5079,8 @@ get_tabpage_arg(exarg_T *eap)
{
char_u *p = eap->arg;
char_u *p_save;
- int relative = 0; /* argument +N/-N means: go to N places to the
- * right/left relative to the current position. */
+ int relative = 0; // argument +N/-N means: go to N places to the
+ // right/left relative to the current position.
if (*p == '-')
{
@@ -5105,7 +5103,7 @@ get_tabpage_arg(exarg_T *eap)
else if (p == p_save || *p_save == '-' || *p != NUL
|| tab_number > LAST_TAB_NR)
{
- /* No numbers as argument. */
+ // No numbers as argument.
eap->errmsg = e_invarg;
goto theend;
}
@@ -5117,7 +5115,7 @@ get_tabpage_arg(exarg_T *eap)
else if (p == p_save || *p_save == '-' || *p != NUL
|| tab_number == 0)
{
- /* No numbers as argument. */
+ // No numbers as argument.
eap->errmsg = e_invarg;
goto theend;
}
@@ -5229,18 +5227,18 @@ ex_tabonly(exarg_T *eap)
if (eap->errmsg == NULL)
{
goto_tabpage(tab_number);
- /* Repeat this up to a 1000 times, because autocommands may
- * mess up the lists. */
+ // Repeat this up to a 1000 times, because autocommands may
+ // mess up the lists.
for (done = 0; done < 1000; ++done)
{
FOR_ALL_TABPAGES(tp)
if (tp->tp_topframe != topframe)
{
tabpage_close_other(tp, eap->forceit);
- /* if we failed to close it quit */
+ // if we failed to close it quit
if (valid_tabpage(tp))
done = 1000;
- /* start over, "tp" is now invalid */
+ // start over, "tp" is now invalid
break;
}
if (first_tabpage->tp_next == NULL)
@@ -5256,8 +5254,8 @@ ex_tabonly(exarg_T *eap)
void
tabpage_close(int forceit)
{
- /* First close all the windows but the current one. If that worked then
- * close the last window in this tab, that will close it. */
+ // First close all the windows but the current one. If that worked then
+ // close the last window in this tab, that will close it.
if (!ONE_WINDOW)
close_others(TRUE, forceit);
if (ONE_WINDOW)
@@ -5280,15 +5278,15 @@ tabpage_close_other(tabpage_T *tp, int forceit)
win_T *wp;
int h = tabline_height();
- /* Limit to 1000 windows, autocommands may add a window while we close
- * one. OK, so I'm paranoid... */
+ // Limit to 1000 windows, autocommands may add a window while we close
+ // one. OK, so I'm paranoid...
while (++done < 1000)
{
wp = tp->tp_firstwin;
ex_win_close(forceit, wp, tp);
- /* Autocommands may delete the tab page under our fingers and we may
- * fail to close a window with a modified buffer. */
+ // Autocommands may delete the tab page under our fingers and we may
+ // fail to close a window with a modified buffer.
if (!valid_tabpage(tp) || tp->tp_firstwin == wp)
break;
}
@@ -5329,14 +5327,14 @@ ex_only(exarg_T *eap)
static void
ex_hide(exarg_T *eap UNUSED)
{
- /* ":hide" or ":hide | cmd": hide current window */
+ // ":hide" or ":hide | cmd": hide current window
if (!eap->skip)
{
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
if (eap->addr_count == 0)
- win_close(curwin, FALSE); /* don't free buffer */
+ win_close(curwin, FALSE); // don't free buffer
else
{
int winnr = 0;
@@ -5372,19 +5370,19 @@ ex_stop(exarg_T *eap)
out_char('\n');
out_flush();
stoptermcap();
- out_flush(); /* needed for SUN to restore xterm buffer */
+ out_flush(); // needed for SUN to restore xterm buffer
#ifdef FEAT_TITLE
- mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */
+ mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
#endif
- ui_suspend(); /* call machine specific function */
+ ui_suspend(); // call machine specific function
#ifdef FEAT_TITLE
maketitle();
- resettitle(); /* force updating the title */
+ resettitle(); // force updating the title
#endif
starttermcap();
- scroll_start(); /* scroll screen before redrawing */
+ scroll_start(); // scroll screen before redrawing
redraw_later_clear();
- shell_resized(); /* may have resized window */
+ shell_resized(); // may have resized window
}
}
@@ -5401,7 +5399,7 @@ ex_exit(exarg_T *eap)
return;
}
#endif
- /* Don't quit while editing the command line. */
+ // Don't quit while editing the command line.
if (text_locked())
{
text_locked_msg();
@@ -5426,13 +5424,13 @@ ex_exit(exarg_T *eap)
}
else
{
- if (only_one_window()) /* quit last window, exit Vim */
+ if (only_one_window()) // quit last window, exit Vim
getout(0);
not_exiting();
# ifdef FEAT_GUI
need_mouse_correct = TRUE;
# endif
- /* Quit current window, may free the buffer. */
+ // Quit current window, may free the buffer.
win_close(curwin, !buf_hide(curwin->w_buffer));
}
}
@@ -5455,10 +5453,10 @@ ex_print(exarg_T *eap)
eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST));
if (++eap->line1 > eap->line2)
break;
- out_flush(); /* show one line at a time */
+ out_flush(); // show one line at a time
}
setpcmark();
- /* put cursor at last line */
+ // put cursor at last line
curwin->w_cursor.lnum = eap->line2;
beginline(BL_SOL | BL_FIX);
}
@@ -5502,11 +5500,10 @@ handle_drop_internal(void)
// recursively. Avoid that by setting drop_busy.
drop_busy = TRUE;
- /* Check whether the current buffer is changed. If so, we will need
- * to split the current window or data could be lost.
- * We don't need to check if the 'hidden' option is set, as in this
- * case the buffer won't be lost.
- */
+ // Check whether the current buffer is changed. If so, we will need
+ // to split the current window or data could be lost.
+ // We don't need to check if the 'hidden' option is set, as in this
+ // case the buffer won't be lost.
if (!buf_hide(curbuf) && !drop_split)
{
++emsg_off;
@@ -5519,8 +5516,8 @@ handle_drop_internal(void)
return;
RESET_BINDING(curwin);
- /* When splitting the window, create a new alist. Otherwise the
- * existing one is overwritten. */
+ // When splitting the window, create a new alist. Otherwise the
+ // existing one is overwritten.
alist_unlink(curwin->w_alist);
alist_new();
}
@@ -5533,18 +5530,18 @@ handle_drop_internal(void)
/*
* Move to the first file.
*/
- /* Fake up a minimal "next" command for do_argfile() */
+ // Fake up a minimal "next" command for do_argfile()
vim_memset(&ea, 0, sizeof(ea));
ea.cmd = (char_u *)"next";
do_argfile(&ea, 0);
- /* do_ecmd() may set need_start_insertmode, but since we never left Insert
- * mode that is not needed here. */
+ // do_ecmd() may set need_start_insertmode, but since we never left Insert
+ // mode that is not needed here.
need_start_insertmode = FALSE;
- /* Restore msg_scroll, otherwise a following command may cause scrolling
- * unexpectedly. The screen will be redrawn by the caller, thus
- * msg_scroll being set by displaying a message is irrelevant. */
+ // Restore msg_scroll, otherwise a following command may cause scrolling
+ // unexpectedly. The screen will be redrawn by the caller, thus
+ // msg_scroll being set by displaying a message is irrelevant.
msg_scroll = save_msg_scroll;
if (drop_callback != NULL)
@@ -5637,7 +5634,7 @@ ex_preserve(exarg_T *eap UNUSED)
static void
ex_recover(exarg_T *eap)
{
- /* Set recoverymode right away to avoid the ATTENTION prompt. */
+ // Set recoverymode right away to avoid the ATTENTION prompt.
recoverymode = TRUE;
if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0)
| CCGD_MULTWIN
@@ -5694,8 +5691,8 @@ ex_splitview(exarg_T *eap)
#endif
#ifdef FEAT_QUICKFIX
- /* A ":split" in the quickfix window works like ":new". Don't want two
- * quickfix windows. But it's OK when doing ":tab split". */
+ // A ":split" in the quickfix window works like ":new". Don't want two
+ // quickfix windows. But it's OK when doing ":tab split".
if (bt_quickfix(curbuf) && cmdmod.tab == 0)
{
if (eap->cmdidx == CMD_split)
@@ -5729,8 +5726,8 @@ ex_splitview(exarg_T *eap)
# 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 (*eap->arg == NUL || !mch_isdir(eap->arg))
eap->arg = (char_u *)".";
}
@@ -5745,7 +5742,7 @@ ex_splitview(exarg_T *eap)
eap->arg = fname;
}
}
- cmdmod.browse = FALSE; /* Don't browse again in do_ecmd(). */
+ cmdmod.browse = FALSE; // Don't browse again in do_ecmd().
#endif
/*
@@ -5759,7 +5756,7 @@ ex_splitview(exarg_T *eap)
{
do_exedit(eap, old_curwin);
- /* set the alternate buffer for the window we came from */
+ // set the alternate buffer for the window we came from
if (curwin != old_curwin
&& win_valid(old_curwin)
&& old_curwin->w_buffer != curbuf
@@ -5770,8 +5767,8 @@ ex_splitview(exarg_T *eap)
else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0,
*eap->cmd == 'v' ? WSP_VERT : 0) != FAIL)
{
- /* Reset 'scrollbind' when editing another file, but keep it when
- * doing ":split" without arguments. */
+ // Reset 'scrollbind' when editing another file, but keep it when
+ // doing ":split" without arguments.
if (*eap->arg != NUL
# ifdef FEAT_BROWSE
|| cmdmod.browse
@@ -5838,7 +5835,7 @@ ex_tabnext(exarg_T *eap)
if (p == p_save || *p_save == '-' || *p != NUL
|| tab_number == 0)
{
- /* No numbers as argument. */
+ // No numbers as argument.
eap->errmsg = e_invarg;
return;
}
@@ -5859,7 +5856,7 @@ ex_tabnext(exarg_T *eap)
}
goto_tabpage(-tab_number);
break;
- default: /* CMD_tabnext */
+ default: // CMD_tabnext
tab_number = get_tabpage_arg(eap);
if (eap->errmsg == NULL)
goto_tabpage(tab_number);
@@ -5897,7 +5894,7 @@ ex_tabs(exarg_T *eap UNUSED)
msg_putchar('\n');
vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++);
msg_outtrans_attr(IObuff, HL_ATTR(HLF_T));
- out_flush(); /* output one line at a time */
+ out_flush(); // output one line at a time
ui_breakcheck();
if (tp == curtab)
@@ -5917,7 +5914,7 @@ ex_tabs(exarg_T *eap UNUSED)
home_replace(wp->w_buffer, wp->w_buffer->b_fname,
IObuff, IOSIZE, TRUE);
msg_outtrans(IObuff);
- out_flush(); /* output one line at a time */
+ out_flush(); // output one line at a time
ui_breakcheck();
}
}
@@ -5961,7 +5958,7 @@ ex_resize(exarg_T *eap)
{
if (*eap->arg == '-' || *eap->arg == '+')
n += curwin->w_width;
- else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */
+ else if (n == 0 && eap->arg[0] == NUL) // default is very wide
n = 9999;
win_setwidth_win((int)n, wp);
}
@@ -5969,7 +5966,7 @@ ex_resize(exarg_T *eap)
{
if (*eap->arg == '-' || *eap->arg == '+')
n += curwin->w_height;
- else if (n == 0 && eap->arg[0] == NUL) /* default is very high */
+ else if (n == 0 && eap->arg[0] == NUL) // default is very high
n = 9999;
win_setheight_win((int)n, wp);
}
@@ -5989,8 +5986,8 @@ ex_find(exarg_T *eap)
TRUE, curbuf->b_ffname);
if (eap->addr_count > 0)
{
- /* Repeat finding the file "count" times. This matters when it
- * appears several times in the path. */
+ // Repeat finding the file "count" times. This matters when it
+ // appears several times in the path.
count = eap->line2;
while (fname != NULL && --count > 0)
{
@@ -6024,7 +6021,7 @@ ex_open(exarg_T *eap)
beginline(BL_SOL | BL_FIX);
if (*eap->arg == '/')
{
- /* ":open /pattern/": put cursor in column found with pattern */
+ // ":open /pattern/": put cursor in column found with pattern
++eap->arg;
p = skip_regexp(eap->arg, '/', p_magic, NULL);
*p = NUL;
@@ -6039,7 +6036,7 @@ ex_open(exarg_T *eap)
emsg(_(e_nomatch));
vim_regfree(regmatch.regprog);
}
- /* Move to the NUL, ignore any other arguments. */
+ // Move to the NUL, ignore any other arguments.
eap->arg += STRLEN(eap->arg);
}
check_cursor();
@@ -6063,7 +6060,7 @@ ex_edit(exarg_T *eap)
void
do_exedit(
exarg_T *eap,
- win_T *old_curwin) /* curwin before doing a split or NULL */
+ win_T *old_curwin) // curwin before doing a split or NULL
{
int n;
int need_hide;
@@ -6080,7 +6077,7 @@ do_exedit(
exmode_active = FALSE;
if (*eap->arg == NUL)
{
- /* Special case: ":global/pat/visual\NLvi-commands" */
+ // Special case: ":global/pat/visual\NLvi-commands"
if (global_busy)
{
int rd = RedrawingDisabled;
@@ -6125,7 +6122,7 @@ do_exedit(
|| eap->cmdidx == CMD_tabedit
|| eap->cmdidx == CMD_vnew) && *eap->arg == NUL)
{
- /* ":new" or ":tabnew" without argument: edit an new empty buffer */
+ // ":new" or ":tabnew" without argument: edit an new empty buffer
setpcmark();
(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
@@ -6138,8 +6135,8 @@ do_exedit(
#endif
)
{
- /* Can't edit another file when "curbuf_lock" is set. Only ":edit"
- * can bring us here, others are stopped earlier. */
+ // Can't edit another file when "curbuf_lock" is set. Only ":edit"
+ // can bring us here, others are stopped earlier.
if (*eap->arg != NUL && curbuf_locked())
return;
@@ -6147,23 +6144,23 @@ do_exedit(
if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview)
readonlymode = TRUE;
else if (eap->cmdidx == CMD_enew)
- readonlymode = FALSE; /* 'readonly' doesn't make sense in an
- empty buffer */
+ readonlymode = FALSE; // 'readonly' doesn't make sense in an
+ // empty buffer
setpcmark();
if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
NULL, eap,
- /* ":edit" goes to first line if Vi compatible */
+ // ":edit" goes to first line if Vi compatible
(*eap->arg == NUL && eap->do_ecmd_lnum == 0
&& vim_strchr(p_cpo, CPO_GOTO1) != NULL)
? ECMD_ONE : eap->do_ecmd_lnum,
(buf_hide(curbuf) ? ECMD_HIDE : 0)
+ (eap->forceit ? ECMD_FORCEIT : 0)
- /* after a split we can use an existing buffer */
+ // after a split we can use an existing buffer
+ (old_curwin != NULL ? ECMD_OLDBUF : 0)
+ (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 )
, old_curwin == NULL ? curwin : NULL) == FAIL)
{
- /* Editing the file failed. If the window was split, close it. */
+ // Editing the file failed. If the window was split, close it.
if (old_curwin != NULL)
{
need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);
@@ -6172,8 +6169,8 @@ do_exedit(
#if defined(FEAT_EVAL)
cleanup_T cs;
- /* Reset the error/interrupt/exception state here so that
- * aborting() returns FALSE when closing a window. */
+ // Reset the error/interrupt/exception state here so that
+ // aborting() returns FALSE when closing a window.
enter_cleanup(&cs);
#endif
#ifdef FEAT_GUI
@@ -6182,9 +6179,9 @@ do_exedit(
win_close(curwin, !need_hide && !buf_hide(curbuf));
#if defined(FEAT_EVAL)
- /* Restore the error/interrupt/exception state if not
- * discarded by a new aborting error, interrupt, or
- * uncaught exception. */
+ // Restore the error/interrupt/exception state if not
+ // discarded by a new aborting error, interrupt, or
+ // uncaught exception.
leave_cleanup(&cs);
#endif
}
@@ -6192,10 +6189,10 @@ do_exedit(
}
else if (readonlymode && curbuf->b_nwindows == 1)
{
- /* When editing an already visited buffer, 'readonly' won't be set
- * but the previous value is kept. With ":view" and ":sview" we
- * want the file to be readonly, except when another window is
- * editing the same buffer. */
+ // When editing an already visited buffer, 'readonly' won't be set
+ // but the previous value is kept. With ":view" and ":sview" we
+ // want the file to be readonly, except when another window is
+ // editing the same buffer.
curbuf->b_p_ro = TRUE;
}
readonlymode = n;
@@ -6360,7 +6357,7 @@ ex_read(exarg_T *eap)
int empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
linenr_T lnum;
- if (eap->usefilter) /* :r!cmd */
+ if (eap->usefilter) // :r!cmd
do_bang(1, eap, FALSE, FALSE, TRUE);
else
{
@@ -6387,7 +6384,7 @@ ex_read(exarg_T *eap)
#endif
if (*eap->arg == NUL)
{
- if (check_fname() == FAIL) /* check for no file name */
+ if (check_fname() == FAIL) // check for no file name
return;
i = readfile(curbuf->b_ffname, curbuf->b_fname,
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
@@ -6411,8 +6408,8 @@ ex_read(exarg_T *eap)
{
if (empty && exmode_active)
{
- /* Delete the empty line that remains. Historically ex does
- * this but vi doesn't. */
+ // Delete the empty line that remains. Historically ex does
+ // this but vi doesn't.
if (eap->line2 == 0)
lnum = curbuf->b_ml.ml_line_count;
else
@@ -6456,11 +6453,11 @@ post_chdir(cdscope_T scope)
VIM_CLEAR(curwin->w_localdir);
if (scope != CDSCOPE_GLOBAL)
{
- /* If still in global directory, need to remember current
- * directory as global directory. */
+ // If still in global directory, need to remember current
+ // directory as global directory.
if (globaldir == NULL && prev_dir != NULL)
globaldir = vim_strsave(prev_dir);
- /* Remember this local directory for the window. */
+ // Remember this local directory for the window.
if (mch_dirname(NameBuff, MAXPATHL) == OK)
{
if (scope == CDSCOPE_TABPAGE)
@@ -6471,8 +6468,8 @@ post_chdir(cdscope_T scope)
}
else
{
- /* We are now in the global directory, no need to remember its
- * name. */
+ // We are now in the global directory, no need to remember its
+ // name.
VIM_CLEAR(globaldir);
}
@@ -6747,7 +6744,7 @@ ex_wincmd(exarg_T *eap)
if (*eap->arg == 'g' || *eap->arg == Ctrl_G)
{
- /* CTRL-W g and CTRL-W CTRL-G have an extra command character */
+ // CTRL-W g and CTRL-W CTRL-G have an extra command character
if (eap->arg[1] == NUL)
{
emsg(_(e_invarg));
@@ -6765,7 +6762,7 @@ ex_wincmd(exarg_T *eap)
emsg(_(e_invarg));
else if (!eap->skip)
{
- /* Pass flags on for ":vertical wincmd ]". */
+ // Pass flags on for ":vertical wincmd ]".
postponed_split_flags = cmdmod.split;
postponed_split_tab = cmdmod.tab;
do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar);
@@ -6820,7 +6817,7 @@ ex_winpos(exarg_T *eap)
gui_mch_set_winpos(x, y);
else if (gui.starting)
{
- /* Remember the coordinates for when the window is opened. */
+ // Remember the coordinates for when the window is opened.
gui_win_x = x;
gui_win_y = y;
}
@@ -6854,7 +6851,7 @@ ex_operators(exarg_T *eap)
oa.line_count = eap->line2 - eap->line1 + 1;
oa.motion_type = MLINE;
virtual_op = FALSE;
- if (eap->cmdidx != CMD_yank) /* position cursor for undo */
+ if (eap->cmdidx != CMD_yank) // position cursor for undo
{
setpcmark();
curwin->w_cursor.lnum = eap->line1;
@@ -6876,7 +6873,7 @@ ex_operators(exarg_T *eap)
(void)op_yank(&oa, FALSE, TRUE);
break;
- default: /* CMD_rshift or CMD_lshift */
+ default: // CMD_rshift or CMD_lshift
if (
#ifdef FEAT_RIGHTLEFT
(eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl
@@ -6900,7 +6897,7 @@ ex_operators(exarg_T *eap)
static void
ex_put(exarg_T *eap)
{
- /* ":0put" works like ":1put!". */
+ // ":0put" works like ":1put!".
if (eap->line2 == 0)
{
eap->line2 = 1;
@@ -6920,7 +6917,7 @@ ex_copymove(exarg_T *eap)
long n;
n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
- if (eap->arg == NULL) /* error detected */
+ if (eap->arg == NULL) // error detected
{
eap->nextcmd = NULL;
return;
@@ -6984,7 +6981,7 @@ ex_join(exarg_T *eap)
curwin->w_cursor.lnum = eap->line1;
if (eap->line1 == eap->line2)
{
- if (eap->addr_count >= 2) /* :2,2join does nothing */
+ if (eap->addr_count >= 2) // :2,2join does nothing
return;
if (eap->line2 == curbuf->b_ml.ml_line_count)
{
@@ -7011,14 +7008,14 @@ ex_at(exarg_T *eap)
check_cursor_col();
#ifdef USE_ON_FLY_SCROLL
- dont_scroll = TRUE; /* disallow scrolling here */
+ dont_scroll = TRUE; // disallow scrolling here
#endif
- /* get the register name. No name means to use the previous one */
+ // get the register name. No name means to use the previous one
c = *eap->arg;
if (c == NUL || (c == '*' && *eap->cmd == '*'))
c = '@';
- /* Put the register in the typeahead buffer with the "silent" flag. */
+ // Put the register in the typeahead buffer with the "silent" flag.
if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE)
== FAIL)
{
@@ -7057,7 +7054,7 @@ ex_bang(exarg_T *eap)
static void
ex_undo(exarg_T *eap)
{
- if (eap->addr_count == 1) /* :undo 123 */
+ if (eap->addr_count == 1) // :undo 123
undo_time(eap->line2, FALSE, FALSE, TRUE);
else
u_undo(1);
@@ -7161,7 +7158,7 @@ ex_redir(exarg_T *eap)
close_redir();
- /* Expand environment variables and "~/". */
+ // Expand environment variables and "~/".
fname = expand_env_save(arg);
if (fname == NULL)
return;
@@ -7175,10 +7172,10 @@ ex_redir(exarg_T *eap)
fname, NULL, NULL,
(char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf);
if (browseFile == NULL)
- return; /* operation cancelled */
+ return; // operation cancelled
vim_free(fname);
fname = browseFile;
- eap->forceit = TRUE; /* since dialog already asked */
+ eap->forceit = TRUE; // since dialog already asked
}
#endif
@@ -7188,7 +7185,7 @@ ex_redir(exarg_T *eap)
#ifdef FEAT_EVAL
else if (*arg == '@')
{
- /* redirect to a register a-z (resp. A-Z for appending) */
+ // redirect to a register a-z (resp. A-Z for appending)
close_redir();
++arg;
if (ASCII_ISALPHA(*arg)
@@ -7199,15 +7196,15 @@ ex_redir(exarg_T *eap)
|| *arg == '"')
{
redir_reg = *arg++;
- if (*arg == '>' && arg[1] == '>') /* append */
+ if (*arg == '>' && arg[1] == '>') // append
arg += 2;
else
{
- /* Can use both "@a" and "@a>". */
+ // Can use both "@a" and "@a>".
if (*arg == '>')
arg++;
- /* Make register empty when not using @A-@Z and the
- * command is valid. */
+ // Make register empty when not using @A-@Z and the
+ // command is valid.
if (*arg == NUL && !isupper(redir_reg))
write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
}
@@ -7222,7 +7219,7 @@ ex_redir(exarg_T *eap)
{
int append;
- /* redirect to a variable */
+ // redirect to a variable
close_redir();
arg += 2;
@@ -7239,14 +7236,14 @@ ex_redir(exarg_T *eap)
}
#endif
- /* TODO: redirect to a buffer */
+ // TODO: redirect to a buffer
else
semsg(_(e_invarg2), eap->arg);
}
- /* Make sure redirection is not off. Can happen for cmdline completion
- * that indirectly invokes a command to catch its output. */
+ // Make sure redirection is not off. Can happen for cmdline completion
+ // that indirectly invokes a command to catch its output.
if (redir_fd != NULL
#ifdef FEAT_EVAL
|| redir_reg || redir_vname
@@ -7282,11 +7279,11 @@ ex_redraw(exarg_T *eap)
RedrawingDisabled = r;
p_lz = p;
- /* Reset msg_didout, so that a message that's there is overwritten. */
+ // Reset msg_didout, so that a message that's there is overwritten.
msg_didout = FALSE;
msg_col = 0;
- /* No need to wait after an intentional redraw. */
+ // No need to wait after an intentional redraw.
need_wait_return = FALSE;
out_flush();
@@ -7371,12 +7368,12 @@ vim_mkdir_emsg(char_u *name, int prot UNUSED)
open_exfile(
char_u *fname,
int forceit,
- char *mode) /* "w" for create new file or "a" for append */
+ char *mode) // "w" for create new file or "a" for append
{
FILE *fd;
#ifdef UNIX
- /* with Unix it is possible to open a directory */
+ // with Unix it is possible to open a directory
if (mch_isdir(fname))
{
semsg(_(e_isadir2), fname);
@@ -7403,18 +7400,18 @@ ex_mark(exarg_T *eap)
{
pos_T pos;
- if (*eap->arg == NUL) /* No argument? */
+ if (*eap->arg == NUL) // No argument?
emsg(_(e_argreq));
- else if (eap->arg[1] != NUL) /* more than one character? */
+ else if (eap->arg[1] != NUL) // more than one character?
emsg(_(e_trailing));
else
{
- pos = curwin->w_cursor; /* save curwin->w_cursor */
+ pos = curwin->w_cursor; // save curwin->w_cursor
curwin->w_cursor.lnum = eap->line2;
beginline(BL_WHITE | BL_FIX);
- if (setmark(*eap->arg) == FAIL) /* set mark */
+ if (setmark(*eap->arg) == FAIL) // set mark
emsg(_("E191: Argument must be a letter or forward/backward quote"));
- curwin->w_cursor = pos; /* restore curwin->w_cursor */
+ curwin->w_cursor = pos; // restore curwin->w_cursor
}
}
@@ -7424,7 +7421,7 @@ ex_mark(exarg_T *eap)
void
update_topline_cursor(void)
{
- check_cursor(); /* put cursor on valid line */
+ check_cursor(); // put cursor on valid line
update_topline();
if (!curwin->w_p_wrap)
validate_cursor();
@@ -7447,9 +7444,9 @@ save_current_state(save_state_T *sst)
sst->save_opcount = opcount;
sst->save_reg_executing = reg_executing;
- msg_scroll = FALSE; /* no msg scrolling in Normal mode */
- restart_edit = 0; /* don't go to Insert mode */
- p_im = FALSE; /* don't use 'insertmode' */
+ msg_scroll = FALSE; // no msg scrolling in Normal mode
+ restart_edit = 0; // don't go to Insert mode
+ p_im = FALSE; // don't use 'insertmode'
/*
* Save the current typeahead. This is required to allow using ":normal"
@@ -7463,7 +7460,7 @@ save_current_state(save_state_T *sst)
void
restore_current_state(save_state_T *sst)
{
- /* Restore the previous typeahead. */
+ // Restore the previous typeahead.
restore_typeahead(&sst->tabuf);
msg_scroll = sst->save_msg_scroll;
@@ -7472,13 +7469,13 @@ restore_current_state(save_state_T *sst)
finish_op = sst->save_finish_op;
opcount = sst->save_opcount;
reg_executing = sst->save_reg_executing;
- msg_didout |= sst->save_msg_didout; /* don't reset msg_didout now */
+ msg_didout |= sst->save_msg_didout; // don't reset msg_didout now
- /* Restore the state (needed when called from a function executed for
- * 'indentexpr'). Update the mouse and cursor, they may have changed. */
+ // Restore the state (needed when called from a function executed for
+ // 'indentexpr'). Update the mouse and cursor, they may have changed.
State = sst->save_State;
#ifdef CURSOR_SHAPE
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
#endif
}
@@ -7513,15 +7510,15 @@ ex_normal(exarg_T *eap)
{
int len = 0;
- /* Count the number of characters to be escaped. */
+ // Count the number of characters to be escaped.
for (p = eap->arg; *p != NUL; ++p)
{
#ifdef FEAT_GUI
- if (*p == CSI) /* leadbyte CSI */
+ if (*p == CSI) // leadbyte CSI
len += 2;
#endif
for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
- if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */
+ if (*++p == K_SPECIAL // trailbyte K_SPECIAL or CSI
#ifdef FEAT_GUI
|| *p == CSI
#endif
@@ -7590,14 +7587,14 @@ ex_normal(exarg_T *eap)
while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
}
- /* Might not return to the main loop when in an event handler. */
+ // Might not return to the main loop when in an event handler.
update_topline_cursor();
restore_current_state(&save_state);
--ex_normal_busy;
setmouse();
#ifdef CURSOR_SHAPE
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
#endif
vim_free(arg);
@@ -7655,7 +7652,7 @@ ex_stopinsert(exarg_T *eap UNUSED)
void
exec_normal_cmd(char_u *cmd, int remap, int silent)
{
- /* Stuff the argument into the typeahead buffer. */
+ // Stuff the argument into the typeahead buffer.
ins_typebuf(cmd, remap, 0, TRUE, silent);
exec_normal(FALSE, FALSE, FALSE);
}
@@ -7685,15 +7682,15 @@ exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop UNUSED)
&& oa.op_type == OP_NOP && oa.regname == NUL
&& !VIsual_active)
{
- /* If terminal_loop() returns OK we got a key that is handled
- * in Normal model. With FAIL we first need to position the
- * cursor and the screen needs to be redrawn. */
+ // If terminal_loop() returns OK we got a key that is handled
+ // in Normal model. With FAIL we first need to position the
+ // cursor and the screen needs to be redrawn.
if (terminal_loop(TRUE) == OK)
normal_cmd(&oa, TRUE);
}
else
#endif
- /* execute a Normal mode cmd */
+ // execute a Normal mode cmd
normal_cmd(&oa, TRUE);
}
}
@@ -7730,30 +7727,30 @@ ex_findpat(exarg_T *eap)
switch (cmdnames[eap->cmdidx].cmd_name[2])
{
- case 'e': /* ":psearch", ":isearch" and ":dsearch" */
+ case 'e': // ":psearch", ":isearch" and ":dsearch"
if (cmdnames[eap->cmdidx].cmd_name[0] == 'p')
action = ACTION_GOTO;
else
action = ACTION_SHOW;
break;
- case 'i': /* ":ilist" and ":dlist" */
+ case 'i': // ":ilist" and ":dlist"
action = ACTION_SHOW_ALL;
break;
- case 'u': /* ":ijump" and ":djump" */
+ case 'u': // ":ijump" and ":djump"
action = ACTION_GOTO;
break;
- default: /* ":isplit" and ":dsplit" */
+ default: // ":isplit" and ":dsplit"
action = ACTION_SPLIT;
break;
}
n = 1;
- if (vim_isdigit(*eap->arg)) /* get count */
+ if (vim_isdigit(*eap->arg)) // get count
{
n = getdigits(&eap->arg);
eap->arg = skipwhite(eap->arg);
}
- if (*eap->arg == '/') /* Match regexp, not just whole words */
+ if (*eap->arg == '/') // Match regexp, not just whole words
{
whole = FALSE;
++eap->arg;
@@ -7763,7 +7760,7 @@ ex_findpat(exarg_T *eap)
*p++ = NUL;
p = skipwhite(p);
- /* Check for trailing illegal characters */
+ // Check for trailing illegal characters
if (!ends_excmd(*p))
eap->errmsg = e_trailing;
else
@@ -7786,7 +7783,7 @@ ex_findpat(exarg_T *eap)
static void
ex_ptag(exarg_T *eap)
{
- g_do_tagpreview = p_pvh; /* will be reset to 0 in ex_tag_cmd() */
+ g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd()
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
}
@@ -7853,24 +7850,24 @@ ex_tag_cmd(exarg_T *eap, char_u *name)
switch (name[1])
{
- case 'j': cmd = DT_JUMP; /* ":tjump" */
+ case 'j': cmd = DT_JUMP; // ":tjump"
break;
- case 's': cmd = DT_SELECT; /* ":tselect" */
+ case 's': cmd = DT_SELECT; // ":tselect"
break;
- case 'p': cmd = DT_PREV; /* ":tprevious" */
+ case 'p': cmd = DT_PREV; // ":tprevious"
break;
- case 'N': cmd = DT_PREV; /* ":tNext" */
+ case 'N': cmd = DT_PREV; // ":tNext"
break;
- case 'n': cmd = DT_NEXT; /* ":tnext" */
+ case 'n': cmd = DT_NEXT; // ":tnext"
break;
- case 'o': cmd = DT_POP; /* ":pop" */
+ case 'o': cmd = DT_POP; // ":pop"
break;
- case 'f': /* ":tfirst" */
- case 'r': cmd = DT_FIRST; /* ":trewind" */
+ case 'f': // ":tfirst"
+ case 'r': cmd = DT_FIRST; // ":trewind"
break;
- case 'l': cmd = DT_LAST; /* ":tlast" */
+ case 'l': cmd = DT_LAST; // ":tlast"
break;
- default: /* ":tag" */
+ default: // ":tag"
#ifdef FEAT_CSCOPE
if (p_cst && *eap->arg != NUL)
{
@@ -7911,25 +7908,25 @@ find_cmdline_var(char_u *src, int *usedlen)
#define SPEC_PERC 0
"#",
#define SPEC_HASH (SPEC_PERC + 1)
- "<cword>", /* cursor word */
+ "<cword>", // cursor word
#define SPEC_CWORD (SPEC_HASH + 1)
- "<cWORD>", /* cursor WORD */
+ "<cWORD>", // cursor WORD
#define SPEC_CCWORD (SPEC_CWORD + 1)
- "<cexpr>", /* expr under cursor */
+ "<cexpr>", // expr under cursor
#define SPEC_CEXPR (SPEC_CCWORD + 1)
- "<cfile>", /* cursor path name */
+ "<cfile>", // cursor path name
#define SPEC_CFILE (SPEC_CEXPR + 1)
- "<sfile>", /* ":so" file name */
+ "<sfile>", // ":so" file name
#define SPEC_SFILE (SPEC_CFILE + 1)
- "<slnum>", /* ":so" file line number */
+ "<slnum>", // ":so" file line number
#define SPEC_SLNUM (SPEC_SFILE + 1)
- "<afile>", /* autocommand file name */
+ "<afile>", // autocommand file name
#define SPEC_AFILE (SPEC_SLNUM + 1)
- "<abuf>", /* autocommand buffer number */
+ "<abuf>", // autocommand buffer number
#define SPEC_ABUF (SPEC_AFILE + 1)
- "<amatch>", /* autocommand match name */
+ "<amatch>", // autocommand match name
#define SPEC_AMATCH (SPEC_ABUF + 1)
- "<sflnum>", /* script file line number */
+ "<sflnum>", // script file line number
#define SPEC_SFLNUM (SPEC_AMATCH + 1)
#ifdef FEAT_CLIENTSERVER
"<client>"
@@ -7972,13 +7969,13 @@ find_cmdline_var(char_u *src, int *usedlen)
*/
char_u *
eval_vars(
- char_u *src, /* pointer into commandline */
- char_u *srcstart, /* beginning of valid memory for src */
- int *usedlen, /* characters after src that are used */
- linenr_T *lnump, /* line number for :e command, or NULL */
- char **errormsg, /* pointer to error message */
- int *escaped) /* return value has escaped white space (can
- * be NULL) */
+ char_u *src, // pointer into commandline
+ char_u *srcstart, // beginning of valid memory for src
+ int *usedlen, // characters after src that are used
+ linenr_T *lnump, // line number for :e command, or NULL
+ char **errormsg, // pointer to error message
+ int *escaped) // return value has escaped white space (can
+ // be NULL)
{
int i;
char_u *s;
@@ -7986,7 +7983,7 @@ eval_vars(
char_u *resultbuf = NULL;
int resultlen;
buf_T *buf;
- int valid = VALID_HEAD + VALID_PATH; /* assume valid result */
+ int valid = VALID_HEAD + VALID_PATH; // assume valid result
int spec_idx;
int tilde_file = FALSE;
int skip_mod = FALSE;
@@ -8000,7 +7997,7 @@ eval_vars(
* Check if there is something to do.
*/
spec_idx = find_cmdline_var(src, usedlen);
- if (spec_idx < 0) /* no match */
+ if (spec_idx < 0) // no match
{
*usedlen = 1;
return NULL;
@@ -8013,7 +8010,7 @@ eval_vars(
if (src > srcstart && src[-1] == '\\')
{
*usedlen = 0;
- STRMOVE(src - 1, src); /* remove backslash */
+ STRMOVE(src - 1, src); // remove backslash
return NULL;
}
@@ -8045,11 +8042,11 @@ eval_vars(
{
switch (spec_idx)
{
- case SPEC_PERC: /* '%': current file */
+ case SPEC_PERC: // '%': current file
if (curbuf->b_fname == NULL)
{
result = (char_u *)"";
- valid = 0; /* Must have ":p:h" to be valid */
+ valid = 0; // Must have ":p:h" to be valid
}
else
{
@@ -8058,8 +8055,8 @@ eval_vars(
}
break;
- case SPEC_HASH: /* '#' or "#99": alternate file */
- if (src[1] == '#') /* "##": the argument list */
+ case SPEC_HASH: // '#' or "#99": alternate file
+ if (src[1] == '#') // "##": the argument list
{
result = arg_all();
resultbuf = result;
@@ -8070,19 +8067,19 @@ eval_vars(
break;
}
s = src + 1;
- if (*s == '<') /* "#<99" uses v:oldfiles */
+ if (*s == '<') // "#<99" uses v:oldfiles
++s;
i = (int)getdigits(&s);
if (s == src + 2 && src[1] == '-')
- /* just a minus sign, don't skip over it */
+ // just a minus sign, don't skip over it
s--;
- *usedlen = (int)(s - src); /* length of what we expand */
+ *usedlen = (int)(s - src); // length of what we expand
if (src[1] == '<' && i != 0)
{
if (*usedlen < 2)
{
- /* Should we give an error message for #<text? */
+ // Should we give an error message for #<text?
*usedlen = 1;
return NULL;
}
@@ -8114,7 +8111,7 @@ eval_vars(
if (buf->b_fname == NULL)
{
result = (char_u *)"";
- valid = 0; /* Must have ":p:h" to be valid */
+ valid = 0; // Must have ":p:h" to be valid
}
else
{
@@ -8125,23 +8122,23 @@ eval_vars(
break;
#ifdef FEAT_SEARCHPATH
- case SPEC_CFILE: /* file name under cursor */
+ case SPEC_CFILE: // file name under cursor
result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
if (result == NULL)
{
*errormsg = "";
return NULL;
}
- resultbuf = result; /* remember allocated string */
+ resultbuf = result; // remember allocated string
break;
#endif
- case SPEC_AFILE: /* file name for autocommand */
+ case SPEC_AFILE: // file name for autocommand
result = autocmd_fname;
if (result != NULL && !autocmd_fname_full)
{
- /* Still need to turn the fname into a full path. It is
- * postponed to avoid a delay when <afile> is not used. */
+ // Still need to turn the fname into a full path. It is
+ // postponed to avoid a delay when <afile> is not used.
autocmd_fname_full = TRUE;
result = FullName_save(autocmd_fname, FALSE);
vim_free(autocmd_fname);
@@ -8155,7 +8152,7 @@ eval_vars(
result = shorten_fname1(result);
break;
- case SPEC_ABUF: /* buffer number for autocommand */
+ case SPEC_ABUF: // buffer number for autocommand
if (autocmd_bufnr <= 0)
{
*errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\"");
@@ -8165,7 +8162,7 @@ eval_vars(
result = strbuf;
break;
- case SPEC_AMATCH: /* match name for autocommand */
+ case SPEC_AMATCH: // match name for autocommand
result = autocmd_match;
if (result == NULL)
{
@@ -8174,7 +8171,7 @@ eval_vars(
}
break;
- case SPEC_SFILE: /* file name for ":so" command */
+ case SPEC_SFILE: // file name for ":so" command
result = sourcing_name;
if (result == NULL)
{
@@ -8183,7 +8180,7 @@ eval_vars(
}
break;
- case SPEC_SLNUM: /* line in file for ":so" command */
+ case SPEC_SLNUM: // line in file for ":so" command
if (sourcing_name == NULL || sourcing_lnum == 0)
{
*errormsg = _("E842: no line number to use for \"<slnum>\"");
@@ -8194,7 +8191,7 @@ eval_vars(
break;
#ifdef FEAT_EVAL
- case SPEC_SFLNUM: /* line in script file */
+ case SPEC_SFLNUM: // line in script file
if (current_sctx.sc_lnum + sourcing_lnum == 0)
{
*errormsg = _("E961: no line number to use for \"<sflnum>\"");
@@ -8207,7 +8204,7 @@ eval_vars(
#endif
#ifdef FEAT_CLIENTSERVER
- case SPEC_CLIENT: /* Source of last submitted input */
+ case SPEC_CLIENT: // Source of last submitted input
sprintf((char *)strbuf, PRINTF_HEX_LONG_U,
(long_u)clientWindow);
result = strbuf;
@@ -8215,12 +8212,12 @@ eval_vars(
#endif
default:
- result = (char_u *)""; /* avoid gcc warning */
+ result = (char_u *)""; // avoid gcc warning
break;
}
- resultlen = (int)STRLEN(result); /* length of new string */
- if (src[*usedlen] == '<') /* remove the file name extension */
+ resultlen = (int)STRLEN(result); // length of new string
+ if (src[*usedlen] == '<') // remove the file name extension
{
++*usedlen;
if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))
@@ -8241,7 +8238,7 @@ eval_vars(
if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)
{
if (valid != VALID_HEAD + VALID_PATH)
- /* xgettext:no-c-format */
+ // xgettext:no-c-format
*errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\"");
else
*errormsg = _("E500: Evaluates to an empty string");
@@ -8279,7 +8276,7 @@ expand_sfile(char_u *arg)
++p;
else
{
- /* replace "<sfile>" with the sourced file name, and do ":" stuff */
+ // replace "<sfile>" with the sourced file name, and do ":" stuff
repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL);
if (errormsg != NULL)
{
@@ -8288,7 +8285,7 @@ expand_sfile(char_u *arg)
vim_free(result);
return NULL;
}
- if (repl == NULL) /* no match (cannot happen) */
+ if (repl == NULL) // no match (cannot happen)
{
p += srclen;
continue;
@@ -8308,7 +8305,7 @@ expand_sfile(char_u *arg)
vim_free(repl);
vim_free(result);
result = newres;
- p = newres + len; /* continue after the match */
+ p = newres + len; // continue after the match
}
}
@@ -8376,7 +8373,7 @@ ex_filetype(exarg_T *eap)
if (*eap->arg == NUL)
{
- /* Print current status. */
+ // Print current status.
smsg("filetype detection:%s plugin:%s indent:%s",
filetype_detect ? "ON" : "OFF",
filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF",
@@ -8384,7 +8381,7 @@ ex_filetype(exarg_T *eap)
return;
}
- /* Accept "plugin" and "indent" in any order. */
+ // Accept "plugin" and "indent" in any order.
for (;;)
{
if (STRNCMP(arg, "plugin", 6) == 0)
@@ -8555,14 +8552,14 @@ ex_folddo(exarg_T *eap)
start_global_changes();
# endif
- /* First set the marks for all lines closed/open. */
+ // First set the marks for all lines closed/open.
for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed))
ml_setmarked(lnum);
- /* Execute the command on the marked lines. */
+ // Execute the command on the marked lines.
global_exe(eap->arg);
- ml_clearmarked(); /* clear rest of the marks */
+ ml_clearmarked(); // clear rest of the marks
# ifdef FEAT_CLIPBOARD
end_global_changes();
# endif
diff --git a/src/ex_eval.c b/src/ex_eval.c
index 097280a67..645b27d8c 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -52,12 +52,12 @@ static char *get_end_emsg(struct condstack *cstack);
* for a variable that is allowed to be changed during execution of a script.
*/
#if 0
-/* Expressions used for testing during the development phase. */
+// Expressions used for testing during the development phase.
# define THROW_ON_ERROR (!eval_to_number("$VIMNOERRTHROW"))
# define THROW_ON_INTERRUPT (!eval_to_number("$VIMNOINTTHROW"))
# define THROW_TEST
#else
-/* Values used for the Vim release. */
+// Values used for the Vim release.
# define THROW_ON_ERROR TRUE
# define THROW_ON_ERROR_TRUE
# define THROW_ON_INTERRUPT TRUE
@@ -127,8 +127,8 @@ should_abort(int retcode)
int
aborted_in_try(void)
{
- /* This function is only called after an error. In this case, "force_abort"
- * determines whether searching for finally clauses is necessary. */
+ // This function is only called after an error. In this case, "force_abort"
+ // determines whether searching for finally clauses is necessary.
return force_abort;
}
@@ -215,9 +215,9 @@ cause_errthrow(
*/
if (did_throw)
{
- /* When discarding an interrupt exception, reset got_int to prevent the
- * same interrupt being converted to an exception again and discarding
- * the error exception we are about to throw here. */
+ // When discarding an interrupt exception, reset got_int to prevent the
+ // same interrupt being converted to an exception again and discarding
+ // the error exception we are about to throw here.
if (current_exception->type == ET_INTERRUPT)
got_int = FALSE;
discard_current_exception();
@@ -276,7 +276,7 @@ cause_errthrow(
{
char *tmsg;
- /* Skip the extra "Vim " prefix for message "E458". */
+ // Skip the extra "Vim " prefix for message "E458".
tmsg = elem->msg;
if (STRNCMP(tmsg, "Vim E", 5) == 0
&& VIM_ISDIGIT(tmsg[5])
@@ -342,8 +342,8 @@ do_errthrow(struct condstack *cstack, char_u *cmdname)
force_abort = TRUE;
}
- /* If no exception is to be thrown or the conversion should be done after
- * returning to a previous invocation of do_one_cmd(), do nothing. */
+ // If no exception is to be thrown or the conversion should be done after
+ // returning to a previous invocation of do_one_cmd(), do nothing.
if (msg_list == NULL || *msg_list == NULL)
return;
@@ -374,7 +374,7 @@ do_intthrow(struct condstack *cstack)
if (!got_int || (trylevel == 0 && !did_throw))
return FALSE;
-#ifdef THROW_TEST /* avoid warning for condition always true */
+#ifdef THROW_TEST // avoid warning for condition always true
if (!THROW_ON_INTERRUPT)
{
/*
@@ -401,7 +401,7 @@ do_intthrow(struct condstack *cstack)
if (current_exception->type == ET_INTERRUPT)
return FALSE;
- /* An interrupt exception replaces any user or error exception. */
+ // An interrupt exception replaces any user or error exception.
discard_current_exception();
}
if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) != FAIL)
@@ -449,9 +449,9 @@ get_exception_string(
val = ret + 4;
}
- /* msg_add_fname may have been used to prefix the message with a file
- * name in quotes. In the exception value, put the file name in
- * parentheses and move it to the end. */
+ // msg_add_fname may have been used to prefix the message with a file
+ // name in quotes. In the exception value, put the file name in
+ // parentheses and move it to the end.
for (p = mesg; ; p++)
{
if (*p == NUL
@@ -464,13 +464,13 @@ get_exception_string(
&& p[4] == ':'))))))
{
if (*p == NUL || p == mesg)
- STRCAT(val, mesg); /* 'E123' missing or at beginning */
+ STRCAT(val, mesg); // 'E123' missing or at beginning
else
{
- /* '"filename" E123: message text' */
+ // '"filename" E123: message text'
if (mesg[0] != '"' || p-2 < &mesg[1] ||
p[-2] != '"' || p[-1] != ' ')
- /* "E123:" is part of the file name. */
+ // "E123:" is part of the file name.
continue;
STRCAT(val, p);
@@ -525,8 +525,8 @@ throw_exception(void *value, except_type_T type, char_u *cmdname)
goto nomem;
if (type == ET_ERROR)
- /* Store the original message and prefix the exception value with
- * "Vim:" or, if a command name is given, "Vim(cmdname):". */
+ // Store the original message and prefix the exception value with
+ // "Vim:" or, if a command name is given, "Vim(cmdname):".
excp->messages = (struct msglist *)value;
excp->value = get_exception_string(value, type, cmdname, &should_free);
@@ -549,15 +549,15 @@ throw_exception(void *value, except_type_T type, char_u *cmdname)
int save_msg_silent = msg_silent;
if (debug_break_level > 0)
- msg_silent = FALSE; /* display messages */
+ msg_silent = FALSE; // display messages
else
verbose_enter();
++no_wait_return;
if (debug_break_level > 0 || *p_vfile == NUL)
- msg_scroll = TRUE; /* always scroll up, don't overwrite */
+ msg_scroll = TRUE; // always scroll up, don't overwrite
smsg(_("Exception thrown: %s"), excp->value);
- msg_puts("\n"); /* don't overwrite this either */
+ msg_puts("\n"); // don't overwrite this either
if (debug_break_level > 0 || *p_vfile == NUL)
cmdline_row = msg_row;
@@ -601,17 +601,17 @@ discard_exception(except_T *excp, int was_finished)
saved_IObuff = vim_strsave(IObuff);
if (debug_break_level > 0)
- msg_silent = FALSE; /* display messages */
+ msg_silent = FALSE; // display messages
else
verbose_enter();
++no_wait_return;
if (debug_break_level > 0 || *p_vfile == NUL)
- msg_scroll = TRUE; /* always scroll up, don't overwrite */
+ msg_scroll = TRUE; // always scroll up, don't overwrite
smsg(was_finished
? _("Exception finished: %s")
: _("Exception discarded: %s"),
excp->value);
- msg_puts("\n"); /* don't overwrite this either */
+ msg_puts("\n"); // don't overwrite this either
if (debug_break_level > 0 || *p_vfile == NUL)
cmdline_row = msg_row;
--no_wait_return;
@@ -664,7 +664,7 @@ catch_exception(except_T *excp)
set_vim_var_string(VV_THROWPOINT, IObuff, -1);
}
else
- /* throw_name not set on an exception from a command that was typed. */
+ // throw_name not set on an exception from a command that was typed.
set_vim_var_string(VV_THROWPOINT, NULL, -1);
if (p_verbose >= 13 || debug_break_level > 0)
@@ -672,15 +672,15 @@ catch_exception(except_T *excp)
int save_msg_silent = msg_silent;
if (debug_break_level > 0)
- msg_silent = FALSE; /* display messages */
+ msg_silent = FALSE; // display messages
else
verbose_enter();
++no_wait_return;
if (debug_break_level > 0 || *p_vfile == NUL)
- msg_scroll = TRUE; /* always scroll up, don't overwrite */
+ msg_scroll = TRUE; // always scroll up, don't overwrite
smsg(_("Exception caught: %s"), excp->value);
- msg_puts("\n"); /* don't overwrite this either */
+ msg_puts("\n"); // don't overwrite this either
if (debug_break_level > 0 || *p_vfile == NUL)
cmdline_row = msg_row;
@@ -716,8 +716,8 @@ finish_exception(except_T *excp)
set_vim_var_string(VV_THROWPOINT, IObuff, -1);
}
else
- /* throw_name not set on an exception from a command that was
- * typed. */
+ // throw_name not set on an exception from a command that was
+ // typed.
set_vim_var_string(VV_THROWPOINT, NULL, -1);
}
else
@@ -726,7 +726,7 @@ finish_exception(except_T *excp)
set_vim_var_string(VV_THROWPOINT, NULL, -1);
}
- /* Discard the exception, but use the finish message for 'verbose'. */
+ // Discard the exception, but use the finish message for 'verbose'.
discard_exception(excp, TRUE);
}
@@ -760,7 +760,7 @@ report_pending(int action, int pending, void *value)
case RP_RESUME:
mesg = _("%s resumed");
break;
- /* case RP_DISCARD: */
+ // case RP_DISCARD:
default:
mesg = _("%s discarded");
break;
@@ -781,7 +781,7 @@ report_pending(int action, int pending, void *value)
s = ":finish";
break;
case CSTP_RETURN:
- /* ":return" command producing value, allocated */
+ // ":return" command producing value, allocated
s = (char *)get_return_cmd(value);
break;
@@ -797,17 +797,17 @@ report_pending(int action, int pending, void *value)
s = _("Error and interrupt");
else if (pending & CSTP_ERROR)
s = _("Error");
- else /* if (pending & CSTP_INTERRUPT) */
+ else // if (pending & CSTP_INTERRUPT)
s = _("Interrupt");
}
save_msg_silent = msg_silent;
if (debug_break_level > 0)
- msg_silent = FALSE; /* display messages */
+ msg_silent = FALSE; // display messages
++no_wait_return;
- msg_scroll = TRUE; /* always scroll up, don't overwrite */
+ msg_scroll = TRUE; // always scroll up, don't overwrite
smsg(mesg, s);
- msg_puts("\n"); /* don't overwrite this either */
+ msg_puts("\n"); // don't overwrite this either
cmdline_row = msg_row;
--no_wait_return;
if (debug_break_level > 0)
@@ -916,7 +916,7 @@ ex_if(exarg_T *eap)
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE;
}
else
- /* set TRUE, so this conditional will never get active */
+ // set TRUE, so this conditional will never get active
cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
}
}
@@ -992,12 +992,12 @@ ex_else(exarg_T *eap)
skip = TRUE;
}
- /* if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it */
+ // if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it
if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE)
{
if (eap->errmsg == NULL)
cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
- skip = TRUE; /* don't evaluate an ":elseif" */
+ skip = TRUE; // don't evaluate an ":elseif"
}
else
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE;
@@ -1021,11 +1021,11 @@ ex_else(exarg_T *eap)
if (eap->cmdidx == CMD_elseif)
{
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
- /* When throwing error exceptions, we want to throw always the first
- * of several errors in a row. This is what actually happens when
- * a conditional error was detected above and there is another failure
- * when parsing the expression. Since the skip flag is set in this
- * case, the parsing error will be ignored by emsg(). */
+ // When throwing error exceptions, we want to throw always the first
+ // of several errors in a row. This is what actually happens when
+ // a conditional error was detected above and there is another failure
+ // when parsing the expression. Since the skip flag is set in this
+ // case, the parsing error will be ignored by emsg().
if (!skip && !error)
{
@@ -1035,7 +1035,7 @@ ex_else(exarg_T *eap)
cstack->cs_flags[cstack->cs_idx] = 0;
}
else if (eap->errmsg == NULL)
- /* set TRUE, so this conditional will never get active */
+ // set TRUE, so this conditional will never get active
cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
}
else
@@ -1093,19 +1093,19 @@ ex_while(exarg_T *eap)
*/
if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0)
{
- /* Jumping here from a ":continue" or ":endfor": use the
- * previously evaluated list. */
+ // Jumping here from a ":continue" or ":endfor": use the
+ // previously evaluated list.
fi = cstack->cs_forinfo[cstack->cs_idx];
error = FALSE;
}
else
{
- /* Evaluate the argument and get the info in a structure. */
+ // Evaluate the argument and get the info in a structure.
fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip);
cstack->cs_forinfo[cstack->cs_idx] = fi;
}
- /* use the element at the start of the list and advance */
+ // use the element at the start of the list and advance
if (!error && fi != NULL && !skip)
result = next_for_item(fi, eap->arg);
else
@@ -1131,10 +1131,10 @@ ex_while(exarg_T *eap)
else
{
cstack->cs_lflags &= ~CSL_HAD_LOOP;
- /* If the ":while" evaluates to FALSE or ":for" is past the end of
- * the list, show the debug prompt at the ":endwhile"/":endfor" as
- * if there was a ":break" in a ":while"/":for" evaluating to
- * TRUE. */
+ // If the ":while" evaluates to FALSE or ":for" is past the end of
+ // the list, show the debug prompt at the ":endwhile"/":endfor" as
+ // if there was a ":break" in a ":while"/":for" evaluating to
+ // TRUE.
if (!skip && !error)
cstack->cs_flags[cstack->cs_idx] |= CSF_TRUE;
}
@@ -1154,10 +1154,10 @@ ex_continue(exarg_T *eap)
eap->errmsg = N_("E586: :continue without :while or :for");
else
{
- /* Try to find the matching ":while". This might stop at a try
- * conditional not in its finally clause (which is then to be executed
- * next). Therefor, inactivate all conditionals except the ":while"
- * itself (if reached). */
+ // Try to find the matching ":while". This might stop at a try
+ // conditional not in its finally clause (which is then to be executed
+ // next). Therefor, inactivate all conditionals except the ":while"
+ // itself (if reached).
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
if (idx >= 0 && (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
{
@@ -1167,12 +1167,12 @@ ex_continue(exarg_T *eap)
* Set CSL_HAD_CONT, so do_cmdline() will jump back to the
* matching ":while".
*/
- cstack->cs_lflags |= CSL_HAD_CONT; /* let do_cmdline() handle it */
+ cstack->cs_lflags |= CSL_HAD_CONT; // let do_cmdline() handle it
}
else
{
- /* If a try conditional not in its finally clause is reached first,
- * make the ":continue" pending for execution at the ":endtry". */
+ // If a try conditional not in its finally clause is reached first,
+ // make the ":continue" pending for execution at the ":endtry".
cstack->cs_pending[idx] = CSTP_CONTINUE;
report_make_pending(CSTP_CONTINUE, NULL);
}
@@ -1192,10 +1192,10 @@ ex_break(exarg_T *eap)
eap->errmsg = N_("E587: :break without :while or :for");
else
{
- /* Inactivate conditionals until the matching ":while" or a try
- * conditional not in its finally clause (which is then to be
- * executed next) is found. In the latter case, make the ":break"
- * pending for execution at the ":endtry". */
+ // Inactivate conditionals until the matching ":while" or a try
+ // conditional not in its finally clause (which is then to be
+ // executed next) is found. In the latter case, make the ":break"
+ // pending for execution at the ":endtry".
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, TRUE);
if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
{
@@ -1235,8 +1235,8 @@ ex_endwhile(exarg_T *eap)
fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf))
{
- /* If we are in a ":while" or ":for" but used the wrong endloop
- * command, do not rewind to the next enclosing ":for"/":while". */
+ // If we are in a ":while" or ":for" but used the wrong endloop
+ // command, do not rewind to the next enclosing ":for"/":while".
if (fl & CSF_WHILE)
eap->errmsg = _("E732: Using :endfor with :while");
else if (fl & CSF_FOR)
@@ -1248,21 +1248,21 @@ ex_endwhile(exarg_T *eap)
eap->errmsg = e_endif;
else if (fl & CSF_FINALLY)
eap->errmsg = e_endtry;
- /* Try to find the matching ":while" and report what's missing. */
+ // Try to find the matching ":while" and report what's missing.
for (idx = cstack->cs_idx; idx > 0; --idx)
{
fl = cstack->cs_flags[idx];
if ((fl & CSF_TRY) && !(fl & CSF_FINALLY))
{
- /* Give up at a try conditional not in its finally clause.
- * Ignore the ":endwhile"/":endfor". */
+ // Give up at a try conditional not in its finally clause.
+ // Ignore the ":endwhile"/":endfor".
eap->errmsg = err;
return;
}
if (fl & csf)
break;
}
- /* Cleanup and rewind all contained (and unclosed) conditionals. */
+ // Cleanup and rewind all contained (and unclosed) conditionals.
(void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
}
@@ -1308,8 +1308,8 @@ ex_throw(exarg_T *eap)
value = NULL;
}
- /* On error or when an exception is thrown during argument evaluation, do
- * not throw. */
+ // On error or when an exception is thrown during argument evaluation, do
+ // not throw.
if (!eap->skip && value != NULL)
{
if (throw_exception(value, ET_USER, NULL) == FAIL)
@@ -1374,17 +1374,17 @@ do_throw(struct condstack *cstack)
if (cstack->cs_flags[idx] & CSF_ACTIVE)
cstack->cs_flags[idx] |= CSF_THROWN;
else
- /* THROWN may have already been set for a catchable exception
- * that has been discarded. Ensure it is reset for the new
- * exception. */
+ // THROWN may have already been set for a catchable exception
+ // that has been discarded. Ensure it is reset for the new
+ // exception.
cstack->cs_flags[idx] &= ~CSF_THROWN;
}
cstack->cs_flags[idx] &= ~CSF_ACTIVE;
cstack->cs_exception[idx] = current_exception;
}
#if 0
- /* TODO: Add optimization below. Not yet done because of interface
- * problems to eval.c and ex_cmds2.c. (Servatius) */
+ // TODO: Add optimization below. Not yet done because of interface
+ // problems to eval.c and ex_cmds2.c. (Servatius)
else
{
/*
@@ -1429,9 +1429,9 @@ ex_try(exarg_T *eap)
if (!skip)
{
- /* Set ACTIVE and TRUE. TRUE means that the corresponding ":catch"
- * commands should check for a match if an exception is thrown and
- * that the finally clause needs to be executed. */
+ // Set ACTIVE and TRUE. TRUE means that the corresponding ":catch"
+ // commands should check for a match if an exception is thrown and
+ // that the finally clause needs to be executed.
cstack->cs_flags[cstack->cs_idx] |= CSF_ACTIVE | CSF_TRUE;
/*
@@ -1498,8 +1498,8 @@ ex_catch(exarg_T *eap)
{
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
- /* Report what's missing if the matching ":try" is not in its
- * finally clause. */
+ // Report what's missing if the matching ":try" is not in its
+ // finally clause.
eap->errmsg = get_end_emsg(cstack);
skip = TRUE;
}
@@ -1508,8 +1508,8 @@ ex_catch(exarg_T *eap)
break;
if (cstack->cs_flags[idx] & CSF_FINALLY)
{
- /* Give up for a ":catch" after ":finally" and ignore it.
- * Just parse. */
+ // Give up for a ":catch" after ":finally" and ignore it.
+ // Just parse.
eap->errmsg = N_("E604: :catch after :finally");
give_up = TRUE;
}
@@ -1518,7 +1518,7 @@ ex_catch(exarg_T *eap)
&cstack->cs_looplevel);
}
- if (ends_excmd(*eap->arg)) /* no argument, catch all errors */
+ if (ends_excmd(*eap->arg)) // no argument, catch all errors
{
pat = (char_u *)".*";
end = NULL;
@@ -1554,17 +1554,17 @@ ex_catch(exarg_T *eap)
return;
}
- /* When debugging or a breakpoint was encountered, display the
- * debug prompt (if not already done) before checking for a match.
- * This is a helpful hint for the user when the regular expression
- * matching fails. Handle a ">quit" debug command as if an
- * interrupt had occurred before the ":catch". That is, discard
- * the original exception, replace it by an interrupt exception,
- * and don't catch it in this try block. */
+ // When debugging or a breakpoint was encountered, display the
+ // debug prompt (if not already done) before checking for a match.
+ // This is a helpful hint for the user when the regular expression
+ // matching fails. Handle a ">quit" debug command as if an
+ // interrupt had occurred before the ":catch". That is, discard
+ // the original exception, replace it by an interrupt exception,
+ // and don't catch it in this try block.
if (!dbg_check_skipped(eap) || !do_intthrow(cstack))
{
- /* Terminate the pattern and avoid the 'l' flag in 'cpoptions'
- * while compiling it. */
+ // Terminate the pattern and avoid the 'l' flag in 'cpoptions'
+ // while compiling it.
if (end != NULL)
{
save_char = *end;
@@ -1572,8 +1572,8 @@ ex_catch(exarg_T *eap)
}
save_cpo = p_cpo;
p_cpo = (char_u *)"";
- /* Disable error messages, it will make current_exception
- * invalid. */
+ // Disable error messages, it will make current_exception
+ // invalid.
++emsg_off;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
--emsg_off;
@@ -1602,16 +1602,16 @@ ex_catch(exarg_T *eap)
if (caught)
{
- /* Make this ":catch" clause active and reset did_emsg, got_int,
- * and did_throw. Put the exception on the caught stack. */
+ // Make this ":catch" clause active and reset did_emsg, got_int,
+ // and did_throw. Put the exception on the caught stack.
cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT;
did_emsg = got_int = did_throw = FALSE;
catch_exception((except_T *)cstack->cs_exception[idx]);
- /* It's mandatory that the current exception is stored in the cstack
- * so that it can be discarded at the next ":catch", ":finally", or
- * ":endtry" or when the catch clause is left by a ":continue",
- * ":break", ":return", ":finish", error, interrupt, or another
- * exception. */
+ // It's mandatory that the current exception is stored in the cstack
+ // so that it can be discarded at the next ":catch", ":finally", or
+ // ":endtry" or when the catch clause is left by a ":continue",
+ // ":break", ":return", ":finish", error, interrupt, or another
+ // exception.
if (cstack->cs_exception[cstack->cs_idx] != current_exception)
internal_error("ex_catch()");
}
@@ -1656,9 +1656,9 @@ ex_finally(exarg_T *eap)
for (idx = cstack->cs_idx - 1; idx > 0; --idx)
if (cstack->cs_flags[idx] & CSF_TRY)
break;
- /* Make this error pending, so that the commands in the following
- * finally clause can be executed. This overrules also a pending
- * ":continue", ":break", ":return", or ":finish". */
+ // Make this error pending, so that the commands in the following
+ // finally clause can be executed. This overrules also a pending
+ // ":continue", ":break", ":return", or ":finish".
pending = CSTP_ERROR;
}
else
@@ -1666,7 +1666,7 @@ ex_finally(exarg_T *eap)
if (cstack->cs_flags[idx] & CSF_FINALLY)
{
- /* Give up for a multiple ":finally" and ignore it. */
+ // Give up for a multiple ":finally" and ignore it.
eap->errmsg = N_("E607: multiple :finally");
return;
}
@@ -1685,15 +1685,15 @@ ex_finally(exarg_T *eap)
if (!skip)
{
- /* When debugging or a breakpoint was encountered, display the
- * debug prompt (if not already done). The user then knows that the
- * finally clause is executed. */
+ // When debugging or a breakpoint was encountered, display the
+ // debug prompt (if not already done). The user then knows that the
+ // finally clause is executed.
if (dbg_check_skipped(eap))
{
- /* Handle a ">quit" debug command as if an interrupt had
- * occurred before the ":finally". That is, discard the
- * original exception and replace it by an interrupt
- * exception. */
+ // Handle a ">quit" debug command as if an interrupt had
+ // occurred before the ":finally". That is, discard the
+ // original exception and replace it by an interrupt
+ // exception.
(void)do_intthrow(cstack);
}
@@ -1738,13 +1738,13 @@ ex_finally(exarg_T *eap)
pending |= got_int ? CSTP_INTERRUPT : 0;
cstack->cs_pending[cstack->cs_idx] = pending;
- /* It's mandatory that the current exception is stored in the
- * cstack so that it can be rethrown at the ":endtry" or be
- * discarded if the finally clause is left by a ":continue",
- * ":break", ":return", ":finish", error, interrupt, or another
- * exception. When emsg() is called for a missing ":endif" or
- * a missing ":endwhile"/":endfor" detected here, the
- * exception will be discarded. */
+ // It's mandatory that the current exception is stored in the
+ // cstack so that it can be rethrown at the ":endtry" or be
+ // discarded if the finally clause is left by a ":continue",
+ // ":break", ":return", ":finish", error, interrupt, or another
+ // exception. When emsg() is called for a missing ":endif" or
+ // a missing ":endwhile"/":endfor" detected here, the
+ // exception will be discarded.
if (did_throw && cstack->cs_exception[cstack->cs_idx]
!= current_exception)
internal_error("ex_finally()");
@@ -1796,7 +1796,7 @@ ex_endtry(exarg_T *eap)
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
{
eap->errmsg = get_end_emsg(cstack);
- /* Find the matching ":try" and report what's missing. */
+ // Find the matching ":try" and report what's missing.
idx = cstack->cs_idx;
do
--idx;
@@ -1830,28 +1830,27 @@ ex_endtry(exarg_T *eap)
rethrow = TRUE;
}
- /* If there was no finally clause, show the user when debugging or
- * a breakpoint was encountered that the end of the try conditional has
- * been reached: display the debug prompt (if not already done). Do
- * this on normal control flow or when an exception was thrown, but not
- * on an interrupt or error not converted to an exception or when
- * a ":break", ":continue", ":return", or ":finish" is pending. These
- * actions are carried out immediately.
- */
+ // If there was no finally clause, show the user when debugging or
+ // a breakpoint was encountered that the end of the try conditional has
+ // been reached: display the debug prompt (if not already done). Do
+ // this on normal control flow or when an exception was thrown, but not
+ // on an interrupt or error not converted to an exception or when
+ // a ":break", ":continue", ":return", or ":finish" is pending. These
+ // actions are carried out immediately.
if ((rethrow || (!skip
&& !(cstack->cs_flags[idx] & CSF_FINALLY)
&& !cstack->cs_pending[idx]))
&& dbg_check_skipped(eap))
{
- /* Handle a ">quit" debug command as if an interrupt had occurred
- * before the ":endtry". That is, throw an interrupt exception and
- * set "skip" and "rethrow". */
+ // Handle a ">quit" debug command as if an interrupt had occurred
+ // before the ":endtry". That is, throw an interrupt exception and
+ // set "skip" and "rethrow".
if (got_int)
{
skip = TRUE;
(void)do_intthrow(cstack);
- /* The do_intthrow() call may have reset did_throw or
- * cstack->cs_pending[idx].*/
+ // The do_intthrow() call may have reset did_throw or
+ // cstack->cs_pending[idx].
rethrow = FALSE;
if (did_throw && !(cstack->cs_flags[idx] & CSF_FINALLY))
rethrow = TRUE;
@@ -1899,13 +1898,13 @@ ex_endtry(exarg_T *eap)
case CSTP_NONE:
break;
- /* Reactivate a pending ":continue", ":break", ":return",
- * ":finish" from the try block or a catch clause of this try
- * conditional. This is skipped, if there was an error in an
- * (unskipped) conditional command or an interrupt afterwards
- * or if the finally clause is present and executed a new error,
- * interrupt, throw, ":continue", ":break", ":return", or
- * ":finish". */
+ // Reactivate a pending ":continue", ":break", ":return",
+ // ":finish" from the try block or a catch clause of this try
+ // conditional. This is skipped, if there was an error in an
+ // (unskipped) conditional command or an interrupt afterwards
+ // or if the finally clause is present and executed a new error,
+ // interrupt, throw, ":continue", ":break", ":return", or
+ // ":finish".
case CSTP_CONTINUE:
ex_continue(eap);
break;
@@ -1919,12 +1918,12 @@ ex_endtry(exarg_T *eap)
do_finish(eap, FALSE);
break;
- /* When the finally clause was entered due to an error,
- * interrupt or throw (as opposed to a ":continue", ":break",
- * ":return", or ":finish"), restore the pending values of
- * did_emsg, got_int, and did_throw. This is skipped, if there
- * was a new error, interrupt, throw, ":continue", ":break",
- * ":return", or ":finish". in the finally clause. */
+ // When the finally clause was entered due to an error,
+ // interrupt or throw (as opposed to a ":continue", ":break",
+ // ":return", or ":finish"), restore the pending values of
+ // did_emsg, got_int, and did_throw. This is skipped, if there
+ // was a new error, interrupt, throw, ":continue", ":break",
+ // ":return", or ":finish". in the finally clause.
default:
if (pending & CSTP_ERROR)
did_emsg = TRUE;
@@ -1937,7 +1936,7 @@ ex_endtry(exarg_T *eap)
}
if (rethrow)
- /* Rethrow the current exception (within this cstack). */
+ // Rethrow the current exception (within this cstack).
do_throw(cstack);
}
}
@@ -1980,13 +1979,12 @@ enter_cleanup(cleanup_T *csp)
| (did_throw ? CSTP_THROW : 0)
| (need_rethrow ? CSTP_THROW : 0);
- /* If we are currently throwing an exception (did_throw), save it as
- * well. On an error not yet converted to an exception, update
- * "force_abort" and reset "cause_abort" (as do_errthrow() would do).
- * This is needed for the do_cmdline() call that is going to be made
- * for autocommand execution. We need not save *msg_list because
- * there is an extra instance for every call of do_cmdline(), anyway.
- */
+ // If we are currently throwing an exception (did_throw), save it as
+ // well. On an error not yet converted to an exception, update
+ // "force_abort" and reset "cause_abort" (as do_errthrow() would do).
+ // This is needed for the do_cmdline() call that is going to be made
+ // for autocommand execution. We need not save *msg_list because
+ // there is an extra instance for every call of do_cmdline(), anyway.
if (did_throw || need_rethrow)
{
csp->exception = current_exception;
@@ -2003,7 +2001,7 @@ enter_cleanup(cleanup_T *csp)
}
did_emsg = got_int = did_throw = need_rethrow = FALSE;
- /* Report if required by the 'verbose' option or when debugging. */
+ // Report if required by the 'verbose' option or when debugging.
report_make_pending(pending, csp->exception);
}
else
@@ -2033,23 +2031,23 @@ leave_cleanup(cleanup_T *csp)
{
int pending = csp->pending;
- if (pending == CSTP_NONE) /* nothing to do */
+ if (pending == CSTP_NONE) // nothing to do
return;
- /* If there was an aborting error, an interrupt, or an uncaught exception
- * after the corresponding call to enter_cleanup(), discard what has been
- * made pending by it. Report this to the user if required by the
- * 'verbose' option or when debugging. */
+ // If there was an aborting error, an interrupt, or an uncaught exception
+ // after the corresponding call to enter_cleanup(), discard what has been
+ // made pending by it. Report this to the user if required by the
+ // 'verbose' option or when debugging.
if (aborting() || need_rethrow)
{
if (pending & CSTP_THROW)
- /* Cancel the pending exception (includes report). */
+ // Cancel the pending exception (includes report).
discard_exception((except_T *)csp->exception, FALSE);
else
report_discard_pending(pending, NULL);
- /* If an error was about to be converted to an exception when
- * enter_cleanup() was called, free the message list. */
+ // If an error was about to be converted to an exception when
+ // enter_cleanup() was called, free the message list.
if (msg_list != NULL)
free_global_msglist();
}
@@ -2088,9 +2086,9 @@ leave_cleanup(cleanup_T *csp)
if (pending & CSTP_INTERRUPT)
got_int = TRUE;
if (pending & CSTP_THROW)
- need_rethrow = TRUE; /* did_throw will be set by do_one_cmd() */
+ need_rethrow = TRUE; // did_throw will be set by do_one_cmd()
- /* Report if required by the 'verbose' option or when debugging. */
+ // Report if required by the 'verbose' option or when debugging.
report_resume_pending(pending,
(pending & CSTP_THROW) ? (void *)current_exception : NULL);
}
@@ -2158,9 +2156,9 @@ cleanup_conditionals(
{
if (cstack->cs_pending[idx] & CSTP_THROW)
{
- /* Cancel the pending exception. This is in the
- * finally clause, so that the stack of the
- * caught exceptions is not involved. */
+ // Cancel the pending exception. This is in the
+ // finally clause, so that the stack of the
+ // caught exceptions is not involved.
discard_exception((except_T *)
cstack->cs_exception[idx],
FALSE);
@@ -2184,10 +2182,10 @@ cleanup_conditionals(
if ((cstack->cs_flags[idx] & CSF_ACTIVE)
&& (cstack->cs_flags[idx] & CSF_CAUGHT))
finish_exception((except_T *)cstack->cs_exception[idx]);
- /* Stop at this try conditional - except the try block never
- * got active (because of an inactive surrounding conditional
- * or when the ":try" appeared after an error or interrupt or
- * throw). */
+ // Stop at this try conditional - except the try block never
+ // got active (because of an inactive surrounding conditional
+ // or when the ":try" appeared after an error or interrupt or
+ // throw).
if (cstack->cs_flags[idx] & CSF_TRUE)
{
if (searched_cond == 0 && !inclusive)
@@ -2197,10 +2195,10 @@ cleanup_conditionals(
}
}
- /* Stop on the searched conditional type (even when the surrounding
- * conditional is not active or something has been made pending).
- * If "inclusive" is TRUE and "searched_cond" is CSF_TRY|CSF_SILENT,
- * check first whether "emsg_silent" needs to be restored. */
+ // Stop on the searched conditional type (even when the surrounding
+ // conditional is not active or something has been made pending).
+ // If "inclusive" is TRUE and "searched_cond" is CSF_TRY|CSF_SILENT,
+ // check first whether "emsg_silent" needs to be restored.
if (cstack->cs_flags[idx] & searched_cond)
{
if (!inclusive)
@@ -2288,7 +2286,7 @@ has_loop_cmd(char_u *p)
{
int len;
- /* skip modifiers, white space and ':' */
+ // skip modifiers, white space and ':'
for (;;)
{
while (*p == ' ' || *p == '\t' || *p == ':')
@@ -2304,4 +2302,4 @@ has_loop_cmd(char_u *p)
return FALSE;
}
-#endif /* FEAT_EVAL */
+#endif // FEAT_EVAL
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 4a4d76ec9..25f409b74 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -23,15 +23,15 @@
static cmdline_info_T ccline;
#ifdef FEAT_EVAL
-static int new_cmdpos; /* position set by set_cmdline_pos() */
+static int new_cmdpos; // position set by set_cmdline_pos()
#endif
-static int extra_char = NUL; /* extra character to display when redrawing
- * the command line */
+static int extra_char = NUL; // extra character to display when redrawing
+ // the command line
static int extra_char_shift;
#ifdef FEAT_RIGHTLEFT
-static int cmd_hkmap = 0; /* Hebrew mapping during command line */
+static int cmd_hkmap = 0; // Hebrew mapping during command line
#endif
static char_u *getcmdline_int(int firstc, long count, int indent, int init_ccline);
@@ -90,7 +90,7 @@ empty_pattern(char_u *p)
{
size_t n = STRLEN(p);
- /* remove trailing \v and the like */
+ // remove trailing \v and the like
while (n >= 2 && p[n - 2] == '\\'
&& vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL)
n -= 2;
@@ -359,7 +359,7 @@ finish_incsearch_highlighting(
p_magic = is_state->magic_save;
- validate_cursor(); /* needed for TAB */
+ validate_cursor(); // needed for TAB
redraw_all_later(SOME_VALID);
if (call_update_screen)
update_screen(SOME_VALID);
@@ -794,22 +794,22 @@ getcmdline_int(
int c;
int i;
int j;
- int gotesc = FALSE; /* TRUE when <ESC> just typed */
- int do_abbr; /* when TRUE check for abbr. */
- char_u *lookfor = NULL; /* string to match */
- int hiscnt; /* current history line in use */
- int histype; /* history type to be used */
+ int gotesc = FALSE; // TRUE when <ESC> just typed
+ int do_abbr; // when TRUE check for abbr.
+ char_u *lookfor = NULL; // string to match
+ int hiscnt; // current history line in use
+ int histype; // history type to be used
#ifdef FEAT_SEARCH_EXTRA
incsearch_state_T is_state;
#endif
- int did_wild_list = FALSE; /* did wild_list() recently */
- int wim_index = 0; /* index in wim_flags[] */
+ int did_wild_list = FALSE; // did wild_list() recently
+ int wim_index = 0; // index in wim_flags[]
int res;
int save_msg_scroll = msg_scroll;
- int save_State = State; /* remember State when called */
- int some_key_typed = FALSE; /* one of the keys was typed */
- /* mouse drag and release events are ignored, unless they are
- * preceded with a mouse down event */
+ int save_State = State; // remember State when called
+ int some_key_typed = FALSE; // one of the keys was typed
+ // mouse drag and release events are ignored, unless they are
+ // preceded with a mouse down event
int ignore_drag_release = TRUE;
#ifdef FEAT_EVAL
int break_ctrl_c = FALSE;
@@ -838,12 +838,12 @@ getcmdline_int(
}
#endif
#ifdef FEAT_RIGHTLEFT
- /* start without Hebrew mapping for a command line */
+ // start without Hebrew mapping for a command line
if (firstc == ':' || firstc == '=' || firstc == '>')
cmd_hkmap = 0;
#endif
- ccline.overstrike = FALSE; /* always start in insert mode */
+ ccline.overstrike = FALSE; // always start in insert mode
#ifdef FEAT_SEARCH_EXTRA
init_incsearch_state(&is_state);
@@ -855,7 +855,7 @@ getcmdline_int(
ccline.cmdfirstc = (firstc == '@' ? 0 : firstc);
ccline.cmdindent = (firstc > 0 ? indent : 0);
- /* alloc initial ccline.cmdbuff */
+ // alloc initial ccline.cmdbuff
alloc_cmdbuff(exmode_active ? 250 : indent + 1);
if (ccline.cmdbuff == NULL)
goto theend; // out of memory
@@ -863,7 +863,7 @@ getcmdline_int(
ccline.cmdbuff[0] = NUL;
sb_text_start_cmdline();
- /* autoindent for :insert and :append */
+ // autoindent for :insert and :append
if (firstc <= 0)
{
vim_memset(ccline.cmdbuff, ' ', indent);
@@ -884,14 +884,14 @@ getcmdline_int(
cmdmsg_rl = FALSE;
#endif
- redir_off = TRUE; /* don't redirect the typed command */
+ redir_off = TRUE; // don't redirect the typed command
if (!cmd_silent)
{
i = msg_scrolled;
- msg_scrolled = 0; /* avoid wait_return message */
+ msg_scrolled = 0; // avoid wait_return message
gotocmdline(TRUE);
msg_scrolled += i;
- redrawcmdprompt(); /* draw prompt or indent */
+ redrawcmdprompt(); // draw prompt or indent
set_cmdspos();
}
xpc.xp_context = EXPAND_NOTHING;
@@ -919,7 +919,7 @@ getcmdline_int(
if (firstc == '/' || firstc == '?' || firstc == '@')
{
- /* Use ":lmap" mappings for search pattern and input(). */
+ // Use ":lmap" mappings for search pattern and input().
if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT)
b_im_ptr = &curbuf->b_p_iminsert;
else
@@ -937,27 +937,27 @@ getcmdline_int(
setmouse();
#ifdef CURSOR_SHAPE
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
#endif
- /* When inside an autocommand for writing "exiting" may be set and
- * terminal mode set to cooked. Need to set raw mode here then. */
+ // When inside an autocommand for writing "exiting" may be set and
+ // terminal mode set to cooked. Need to set raw mode here then.
settmode(TMODE_RAW);
- /* Trigger CmdlineEnter autocommands. */
+ // Trigger CmdlineEnter autocommands.
cmdline_type = firstc == NUL ? '-' : firstc;
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER);
init_history();
- hiscnt = get_hislen(); /* set hiscnt to impossible history value */
+ hiscnt = get_hislen(); // set hiscnt to impossible history value
histype = hist_char2type(firstc);
#ifdef FEAT_DIGRAPHS
- do_digraph(-1); /* init digraph typeahead */
+ do_digraph(-1); // init digraph typeahead
#endif
- /* If something above caused an error, reset the flags, we do want to type
- * and execute commands. Display may be messed up a bit. */
+ // If something above caused an error, reset the flags, we do want to type
+ // and execute commands. Display may be messed up a bit.
if (did_emsg)
redrawcmd();
did_emsg = FALSE;
@@ -968,25 +968,25 @@ getcmdline_int(
*/
for (;;)
{
- redir_off = TRUE; /* Don't redirect the typed command.
- Repeated, because a ":redir" inside
- completion may switch it on. */
+ redir_off = TRUE; // Don't redirect the typed command.
+ // Repeated, because a ":redir" inside
+ // completion may switch it on.
#ifdef USE_ON_FLY_SCROLL
- dont_scroll = FALSE; /* allow scrolling here */
+ dont_scroll = FALSE; // allow scrolling here
#endif
- quit_more = FALSE; /* reset after CTRL-D which had a more-prompt */
+ quit_more = FALSE; // reset after CTRL-D which had a more-prompt
- did_emsg = FALSE; /* There can't really be a reason why an error
- that occurs while typing a command should
- cause the command not to be executed. */
+ did_emsg = FALSE; // There can't really be a reason why an error
+ // that occurs while typing a command should
+ // cause the command not to be executed.
// Trigger SafeState if nothing is pending.
may_trigger_safestate(xpc.xp_numfiles <= 0);
- cursorcmd(); /* set the cursor on the right spot */
+ cursorcmd(); // set the cursor on the right spot
- /* Get a character. Ignore K_IGNORE and K_NOP, they should not do
- * anything, such as stop completion. */
+ // Get a character. Ignore K_IGNORE and K_NOP, they should not do
+ // anything, such as stop completion.
do
c = safe_vgetc();
while (c == K_IGNORE || c == K_NOP);
@@ -999,9 +999,9 @@ getcmdline_int(
c = hkmap(c);
if (cmdmsg_rl && !KeyStuffed)
{
- /* Invert horizontal movements and operations. Only when
- * typed by the user directly, not when the result of a
- * mapping. */
+ // Invert horizontal movements and operations. Only when
+ // typed by the user directly, not when the result of a
+ // mapping.
switch (c)
{
case K_RIGHT: c = K_LEFT; break;
@@ -1054,7 +1054,7 @@ getcmdline_int(
c = Ctrl_P;
#ifdef FEAT_WILDMENU
- /* Special translations for 'wildmenu' */
+ // Special translations for 'wildmenu'
if (did_wild_list && p_wmnu)
{
if (c == K_LEFT)
@@ -1062,7 +1062,7 @@ getcmdline_int(
else if (c == K_RIGHT)
c = Ctrl_N;
}
- /* Hitting CR after "emenu Name.": complete submenu */
+ // Hitting CR after "emenu Name.": complete submenu
if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu
&& ccline.cmdpos > 1
&& ccline.cmdbuff[ccline.cmdpos - 1] == '.'
@@ -1071,7 +1071,7 @@ getcmdline_int(
c = K_DOWN;
#endif
- /* free expanded names when finished walking through matches */
+ // free expanded names when finished walking through matches
if (xpc.xp_numfiles != -1
&& !(c == p_wc && KeyTyped) && c != p_wcm
&& c != Ctrl_N && c != Ctrl_P && c != Ctrl_A
@@ -1095,17 +1095,17 @@ getcmdline_int(
if (wild_menu_showing == WM_SCROLLED)
{
- /* Entered command line, move it up */
+ // Entered command line, move it up
cmdline_row--;
redrawcmd();
}
else if (save_p_ls != -1)
{
- /* restore 'laststatus' and 'winminheight' */
+ // restore 'laststatus' and 'winminheight'
p_ls = save_p_ls;
p_wmh = save_p_wmh;
last_status(FALSE);
- update_screen(VALID); /* redraw the screen NOW */
+ update_screen(VALID); // redraw the screen NOW
redrawcmd();
save_p_ls = -1;
}
@@ -1123,31 +1123,31 @@ getcmdline_int(
}
#ifdef FEAT_WILDMENU
- /* Special translations for 'wildmenu' */
+ // Special translations for 'wildmenu'
if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu)
{
- /* Hitting <Down> after "emenu Name.": complete submenu */
+ // Hitting <Down> after "emenu Name.": complete submenu
if (c == K_DOWN && ccline.cmdpos > 0
&& ccline.cmdbuff[ccline.cmdpos - 1] == '.')
c = p_wc;
else if (c == K_UP)
{
- /* Hitting <Up>: Remove one submenu name in front of the
- * cursor */
+ // Hitting <Up>: Remove one submenu name in front of the
+ // cursor
int found = FALSE;
j = (int)(xpc.xp_pattern - ccline.cmdbuff);
i = 0;
while (--j > 0)
{
- /* check for start of menu name */
+ // check for start of menu name
if (ccline.cmdbuff[j] == ' '
&& ccline.cmdbuff[j - 1] != '\\')
{
i = j + 1;
break;
}
- /* check for start of submenu name */
+ // check for start of submenu name
if (ccline.cmdbuff[j] == '.'
&& ccline.cmdbuff[j - 1] != '\\')
{
@@ -1185,12 +1185,12 @@ getcmdline_int(
|| ccline.cmdbuff[ccline.cmdpos - 2] != '.'
|| ccline.cmdbuff[ccline.cmdpos - 3] != '.'))
{
- /* go down a directory */
+ // go down a directory
c = p_wc;
}
else if (STRNCMP(xpc.xp_pattern, upseg + 1, 3) == 0 && c == K_DOWN)
{
- /* If in a direct ancestor, strip off one ../ to go down */
+ // If in a direct ancestor, strip off one ../ to go down
int found = FALSE;
j = ccline.cmdpos;
@@ -1216,7 +1216,7 @@ getcmdline_int(
}
else if (c == K_UP)
{
- /* go up a directory */
+ // go up a directory
int found = FALSE;
j = ccline.cmdpos - 1;
@@ -1253,25 +1253,25 @@ getcmdline_int(
j = 0;
if (j > 0)
{
- /* TODO this is only for DOS/UNIX systems - need to put in
- * machine-specific stuff here and in upseg init */
+ // TODO this is only for DOS/UNIX systems - need to put in
+ // machine-specific stuff here and in upseg init
cmdline_del(j);
put_on_cmdline(upseg + 1, 3, FALSE);
}
else if (ccline.cmdpos > i)
cmdline_del(i);
- /* Now complete in the new directory. Set KeyTyped in case the
- * Up key came from a mapping. */
+ // Now complete in the new directory. Set KeyTyped in case the
+ // Up key came from a mapping.
c = p_wc;
KeyTyped = TRUE;
}
}
-#endif /* FEAT_WILDMENU */
+#endif // FEAT_WILDMENU
- /* CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert
- * mode when 'insertmode' is set, CTRL-\ e prompts for an expression. */
+ // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert
+ // mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
if (c == Ctrl_BSL)
{
++no_mapping;
@@ -1279,8 +1279,8 @@ getcmdline_int(
c = plain_vgetc();
--no_mapping;
--allow_keys;
- /* CTRL-\ e doesn't work when obtaining an expression, unless it
- * is in a mapping. */
+ // CTRL-\ e doesn't work when obtaining an expression, unless it
+ // is in a mapping.
if (c != Ctrl_N && c != Ctrl_G && (c != 'e'
|| (ccline.cmdfirstc == '=' && KeyTyped)
#ifdef FEAT_EVAL
@@ -1303,16 +1303,16 @@ getcmdline_int(
* able to enter a new one...
*/
if (ccline.cmdpos == ccline.cmdlen)
- new_cmdpos = 99999; /* keep it at the end */
+ new_cmdpos = 99999; // keep it at the end
else
new_cmdpos = ccline.cmdpos;
c = get_expr_register();
if (c == '=')
{
- /* Need to save and restore ccline. And set "textlock"
- * to avoid nasty things like going to another buffer when
- * evaluating an expression. */
+ // Need to save and restore ccline. And set "textlock"
+ // to avoid nasty things like going to another buffer when
+ // evaluating an expression.
++textlock;
p = get_expr_line();
--textlock;
@@ -1326,14 +1326,14 @@ getcmdline_int(
STRCPY(ccline.cmdbuff, p);
vim_free(p);
- /* Restore the cursor or use the position set with
- * set_cmdline_pos(). */
+ // Restore the cursor or use the position set with
+ // set_cmdline_pos().
if (new_cmdpos > ccline.cmdlen)
ccline.cmdpos = ccline.cmdlen;
else
ccline.cmdpos = new_cmdpos;
- KeyTyped = FALSE; /* Don't do p_wc completion. */
+ KeyTyped = FALSE; // Don't do p_wc completion.
redrawcmd();
goto cmdline_changed;
}
@@ -1341,7 +1341,7 @@ getcmdline_int(
}
}
beep_flush();
- got_int = FALSE; /* don't abandon the command line */
+ got_int = FALSE; // don't abandon the command line
did_emsg = FALSE;
emsg_on_display = FALSE;
redrawcmd();
@@ -1352,9 +1352,9 @@ getcmdline_int(
{
if (c == Ctrl_G && p_im && restart_edit == 0)
restart_edit = 'a';
- gotesc = TRUE; /* will free ccline.cmdbuff after putting it
- in history */
- goto returncmd; /* back to Normal mode */
+ gotesc = TRUE; // will free ccline.cmdbuff after putting it
+ // in history
+ goto returncmd; // back to Normal mode
}
}
@@ -1381,7 +1381,7 @@ getcmdline_int(
if (c == '\n' || c == '\r' || c == K_KENTER || (c == ESC
&& (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL)))
{
- /* In Ex mode a backslash escapes a newline. */
+ // In Ex mode a backslash escapes a newline.
if (exmode_active
&& c != ESC
&& ccline.cmdpos == ccline.cmdlen
@@ -1393,8 +1393,8 @@ getcmdline_int(
}
else
{
- gotesc = FALSE; /* Might have typed ESC previously, don't
- truncate the cmdline now. */
+ gotesc = FALSE; // Might have typed ESC previously, don't
+ // truncate the cmdline now.
if (ccheck_abbr(c + ABBR_OFF))
goto cmdline_changed;
if (!cmd_silent)
@@ -1417,9 +1417,9 @@ getcmdline_int(
int options = WILD_NO_BEEP;
if (wim_flags[wim_index] & WIM_BUFLASTUSED)
options |= WILD_BUFLASTUSED;
- if (xpc.xp_numfiles > 0) /* typed p_wc at least twice */
+ if (xpc.xp_numfiles > 0) // typed p_wc at least twice
{
- /* if 'wildmode' contains "list" may still need to list */
+ // if 'wildmode' contains "list" may still need to list
if (xpc.xp_numfiles > 1
&& !did_wild_list
&& (wim_flags[wim_index] & WIM_LIST))
@@ -1435,14 +1435,14 @@ getcmdline_int(
res = nextwild(&xpc, WILD_NEXT, options,
firstc != '@');
else
- res = OK; /* don't insert 'wildchar' now */
+ res = OK; // don't insert 'wildchar' now
}
- else /* typed p_wc first time */
+ else // typed p_wc first time
{
wim_index = 0;
j = ccline.cmdpos;
- /* if 'wildmode' first contains "longest", get longest
- * common part */
+ // if 'wildmode' first contains "longest", get longest
+ // common part
if (wim_flags[0] & WIM_LONGEST)
res = nextwild(&xpc, WILD_LONGEST, options,
firstc != '@');
@@ -1450,11 +1450,11 @@ getcmdline_int(
res = nextwild(&xpc, WILD_EXPAND_KEEP, options,
firstc != '@');
- /* if interrupted while completing, behave like it failed */
+ // if interrupted while completing, behave like it failed
if (got_int)
{
- (void)vpeekc(); /* remove <C-C> from input stream */
- got_int = FALSE; /* don't abandon the command line */
+ (void)vpeekc(); // remove <C-C> from input stream
+ got_int = FALSE; // don't abandon the command line
(void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);
#ifdef FEAT_WILDMENU
xpc.xp_context = EXPAND_NOTHING;
@@ -1462,13 +1462,13 @@ getcmdline_int(
goto cmdline_changed;
}
- /* when more than one match, and 'wildmode' first contains
- * "list", or no change and 'wildmode' contains "longest,list",
- * list all matches */
+ // when more than one match, and 'wildmode' first contains
+ // "list", or no change and 'wildmode' contains "longest,list",
+ // list all matches
if (res == OK && xpc.xp_numfiles > 1)
{
- /* a "longest" that didn't do anything is skipped (but not
- * "list:longest") */
+ // a "longest" that didn't do anything is skipped (but not
+ // "list:longest")
if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j)
wim_index = 1;
if ((wim_flags[wim_index] & WIM_LIST)
@@ -1483,7 +1483,7 @@ getcmdline_int(
int p_wmnu_save = p_wmnu;
p_wmnu = 0;
#endif
- /* remove match */
+ // remove match
nextwild(&xpc, WILD_PREV, 0, firstc != '@');
#ifdef FEAT_WILDMENU
p_wmnu = p_wmnu_save;
@@ -1522,7 +1522,7 @@ getcmdline_int(
gotesc = FALSE;
- /* <S-Tab> goes to last match, in a clumsy way */
+ // <S-Tab> goes to last match, in a clumsy way
if (c == K_S_TAB && KeyTyped)
{
if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK
@@ -1531,10 +1531,10 @@ getcmdline_int(
goto cmdline_changed;
}
- if (c == NUL || c == K_ZERO) /* NUL is stored as NL */
+ if (c == NUL || c == K_ZERO) // NUL is stored as NL
c = NL;
- do_abbr = TRUE; /* default: check for abbreviation */
+ do_abbr = TRUE; // default: check for abbreviation
/*
* Big switch for a typed command line character.
@@ -1595,14 +1595,14 @@ getcmdline_int(
while (i < ccline.cmdlen)
ccline.cmdbuff[i++] = ccline.cmdbuff[j++];
- /* Truncate at the end, required for multi-byte chars. */
+ // Truncate at the end, required for multi-byte chars.
ccline.cmdbuff[ccline.cmdlen] = NUL;
#ifdef FEAT_SEARCH_EXTRA
if (ccline.cmdlen == 0)
{
is_state.search_start = is_state.save_cursor;
- /* save view settings, so that the screen
- * won't be restored at the wrong position */
+ // save view settings, so that the screen
+ // won't be restored at the wrong position
is_state.old_viewstate = is_state.init_viewstate;
}
#endif
@@ -1611,7 +1611,7 @@ getcmdline_int(
else if (ccline.cmdlen == 0 && c != Ctrl_W
&& ccline.cmdprompt == NULL && indent == 0)
{
- /* In ex and debug mode it doesn't make sense to return. */
+ // In ex and debug mode it doesn't make sense to return.
if (exmode_active
#ifdef FEAT_EVAL
|| ccline.cmdfirstc == '>'
@@ -1619,7 +1619,7 @@ getcmdline_int(
)
goto cmdline_not_changed;
- VIM_CLEAR(ccline.cmdbuff); /* no commandline to return */
+ VIM_CLEAR(ccline.cmdbuff); // no commandline to return
if (!cmd_silent)
{
#ifdef FEAT_RIGHTLEFT
@@ -1628,14 +1628,14 @@ getcmdline_int(
else
#endif
msg_col = 0;
- msg_putchar(' '); /* delete ':' */
+ msg_putchar(' '); // delete ':'
}
#ifdef FEAT_SEARCH_EXTRA
if (ccline.cmdlen == 0)
is_state.search_start = is_state.save_cursor;
#endif
redraw_cmdline = TRUE;
- goto returncmd; /* back to cmd mode */
+ goto returncmd; // back to cmd mode
}
goto cmdline_changed;
@@ -1643,17 +1643,17 @@ getcmdline_int(
case K_KINS:
ccline.overstrike = !ccline.overstrike;
#ifdef CURSOR_SHAPE
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
#endif
goto cmdline_not_changed;
case Ctrl_HAT:
if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE))
{
- /* ":lmap" mappings exists, toggle use of mappings. */
+ // ":lmap" mappings exists, toggle use of mappings.
State ^= LANGMAP;
#ifdef HAVE_INPUT_METHOD
- im_set_active(FALSE); /* Disable input method */
+ im_set_active(FALSE); // Disable input method
#endif
if (b_im_ptr != NULL)
{
@@ -1666,19 +1666,19 @@ getcmdline_int(
#ifdef HAVE_INPUT_METHOD
else
{
- /* There are no ":lmap" mappings, toggle IM. When
- * 'imdisable' is set don't try getting the status, it's
- * always off. */
+ // There are no ":lmap" mappings, toggle IM. When
+ // 'imdisable' is set don't try getting the status, it's
+ // always off.
if ((p_imdisable && b_im_ptr != NULL)
? *b_im_ptr == B_IMODE_IM : im_get_status())
{
- im_set_active(FALSE); /* Disable input method */
+ im_set_active(FALSE); // Disable input method
if (b_im_ptr != NULL)
*b_im_ptr = B_IMODE_NONE;
}
else
{
- im_set_active(TRUE); /* Enable input method */
+ im_set_active(TRUE); // Enable input method
if (b_im_ptr != NULL)
*b_im_ptr = B_IMODE_IM;
}
@@ -1692,23 +1692,23 @@ getcmdline_int(
set_imsearch_global();
}
#ifdef CURSOR_SHAPE
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
#endif
#if defined(FEAT_KEYMAP)
- /* Show/unshow value of 'keymap' in status lines later. */
+ // Show/unshow value of 'keymap' in status lines later.
status_redraw_curbuf();
#endif
goto cmdline_not_changed;
-/* case '@': only in very old vi */
+// case '@': only in very old vi
case Ctrl_U:
- /* delete all characters left of the cursor */
+ // delete all characters left of the cursor
j = ccline.cmdpos;
ccline.cmdlen -= j;
i = ccline.cmdpos = 0;
while (i < ccline.cmdlen)
ccline.cmdbuff[i++] = ccline.cmdbuff[j++];
- /* Truncate at the end, required for multi-byte chars. */
+ // Truncate at the end, required for multi-byte chars.
ccline.cmdbuff[ccline.cmdlen] = NUL;
#ifdef FEAT_SEARCH_EXTRA
if (ccline.cmdlen == 0)
@@ -1719,7 +1719,7 @@ getcmdline_int(
#ifdef FEAT_CLIPBOARD
case Ctrl_Y:
- /* Copy the modeless selection, if there is one. */
+ // Copy the modeless selection, if there is one.
if (clip_star.state != SELECT_CLEARED)
{
if (clip_star.state == SELECT_DONE)
@@ -1729,30 +1729,30 @@ getcmdline_int(
break;
#endif
- case ESC: /* get here if p_wc != ESC or when ESC typed twice */
+ case ESC: // get here if p_wc != ESC or when ESC typed twice
case Ctrl_C:
- /* In exmode it doesn't make sense to return. Except when
- * ":normal" runs out of characters. */
+ // In exmode it doesn't make sense to return. Except when
+ // ":normal" runs out of characters.
if (exmode_active
&& (ex_normal_busy == 0 || typebuf.tb_len > 0))
goto cmdline_not_changed;
- gotesc = TRUE; /* will free ccline.cmdbuff after
- putting it in history */
- goto returncmd; /* back to cmd mode */
+ gotesc = TRUE; // will free ccline.cmdbuff after
+ // putting it in history
+ goto returncmd; // back to cmd mode
- case Ctrl_R: /* insert register */
+ case Ctrl_R: // insert register
#ifdef USE_ON_FLY_SCROLL
- dont_scroll = TRUE; /* disallow scrolling here */
+ dont_scroll = TRUE; // disallow scrolling here
#endif
putcmdline('"', TRUE);
++no_mapping;
++allow_keys;
- i = c = plain_vgetc(); /* CTRL-R <char> */
+ i = c = plain_vgetc(); // CTRL-R <char>
if (i == Ctrl_O)
- i = Ctrl_R; /* CTRL-R CTRL-O == CTRL-R CTRL-R */
+ i = Ctrl_R; // CTRL-R CTRL-O == CTRL-R CTRL-R
if (i == Ctrl_R)
- c = plain_vgetc(); /* CTRL-R CTRL-R <char> */
+ c = plain_vgetc(); // CTRL-R CTRL-R <char>
extra_char = NUL;
--no_mapping;
--allow_keys;
@@ -1775,25 +1775,25 @@ getcmdline_int(
c = get_expr_register();
}
#endif
- if (c != ESC) /* use ESC to cancel inserting register */
+ if (c != ESC) // use ESC to cancel inserting register
{
cmdline_paste(c, i == Ctrl_R, FALSE);
#ifdef FEAT_EVAL
- /* When there was a serious error abort getting the
- * command line. */
+ // When there was a serious error abort getting the
+ // command line.
if (aborting())
{
- gotesc = TRUE; /* will free ccline.cmdbuff after
- putting it in history */
- goto returncmd; /* back to cmd mode */
+ gotesc = TRUE; // will free ccline.cmdbuff after
+ // putting it in history
+ goto returncmd; // back to cmd mode
}
#endif
- KeyTyped = FALSE; /* Don't do p_wc completion. */
+ KeyTyped = FALSE; // Don't do p_wc completion.
#ifdef FEAT_EVAL
if (new_cmdpos >= 0)
{
- /* set_cmdline_pos() was used */
+ // set_cmdline_pos() was used
if (new_cmdpos > ccline.cmdlen)
ccline.cmdpos = ccline.cmdlen;
else
@@ -1806,10 +1806,10 @@ getcmdline_int(
case Ctrl_D:
if (showmatches(&xpc, FALSE) == EXPAND_NOTHING)
- break; /* Use ^D as normal char instead */
+ break; // Use ^D as normal char instead
redrawcmd();
- continue; /* don't do incremental search now */
+ continue; // don't do incremental search now
case K_RIGHT:
case K_S_RIGHT:
@@ -1843,7 +1843,7 @@ getcmdline_int(
do
{
--ccline.cmdpos;
- if (has_mbyte) /* move to first byte of char */
+ if (has_mbyte) // move to first byte of char
ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos);
ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
@@ -1857,16 +1857,16 @@ getcmdline_int(
goto cmdline_not_changed;
case K_IGNORE:
- /* Ignore mouse event or open_cmdwin() result. */
+ // Ignore mouse event or open_cmdwin() result.
goto cmdline_not_changed;
#ifdef FEAT_GUI_MSWIN
- /* On MS-Windows ignore <M-F4>, we get it when closing the window
- * was cancelled. */
+ // On MS-Windows ignore <M-F4>, we get it when closing the window
+ // was cancelled.
case K_F4:
if (mod_mask == MOD_MASK_ALT)
{
- redrawcmd(); /* somehow the cmdline is cleared */
+ redrawcmd(); // somehow the cmdline is cleared
goto cmdline_not_changed;
}
break;
@@ -1874,15 +1874,15 @@ getcmdline_int(
case K_MIDDLEDRAG:
case K_MIDDLERELEASE:
- goto cmdline_not_changed; /* Ignore mouse */
+ goto cmdline_not_changed; // Ignore mouse
case K_MIDDLEMOUSE:
# ifdef FEAT_GUI
- /* When GUI is active, also paste when 'mouse' is empty */
+ // When GUI is active, also paste when 'mouse' is empty
if (!gui.in_use)
# endif
if (!mouse_has(MOUSE_COMMAND))
- goto cmdline_not_changed; /* Ignore mouse */
+ goto cmdline_not_changed; // Ignore mouse
# ifdef FEAT_CLIPBOARD
if (clip_star.available)
cmdline_paste('*', TRUE, TRUE);
@@ -1903,11 +1903,11 @@ getcmdline_int(
case K_LEFTRELEASE:
case K_RIGHTDRAG:
case K_RIGHTRELEASE:
- /* Ignore drag and release events when the button-down wasn't
- * seen before. */
+ // Ignore drag and release events when the button-down wasn't
+ // seen before.
if (ignore_drag_release)
goto cmdline_not_changed;
- /* FALLTHROUGH */
+ // FALLTHROUGH
case K_LEFTMOUSE:
case K_RIGHTMOUSE:
if (c == K_LEFTRELEASE || c == K_RIGHTRELEASE)
@@ -1915,11 +1915,11 @@ getcmdline_int(
else
ignore_drag_release = FALSE;
# ifdef FEAT_GUI
- /* When GUI is active, also move when 'mouse' is empty */
+ // When GUI is active, also move when 'mouse' is empty
if (!gui.in_use)
# endif
if (!mouse_has(MOUSE_COMMAND))
- goto cmdline_not_changed; /* Ignore mouse */
+ goto cmdline_not_changed; // Ignore mouse
# ifdef FEAT_CLIPBOARD
if (mouse_row < cmdline_row && clip_star.available)
{
@@ -1933,7 +1933,7 @@ getcmdline_int(
if (mouse_model_popup() && button == MOUSE_LEFT
&& (mod_mask & MOD_MASK_SHIFT))
{
- /* Translate shift-left to right button. */
+ // Translate shift-left to right button.
button = MOUSE_RIGHT;
mod_mask &= ~MOD_MASK_SHIFT;
}
@@ -1952,7 +1952,7 @@ getcmdline_int(
break;
if (has_mbyte)
{
- /* Count ">" for double-wide char that doesn't fit. */
+ // Count ">" for double-wide char that doesn't fit.
correct_cmdspos(ccline.cmdpos, i);
ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ ccline.cmdpos) - 1;
@@ -1961,12 +1961,12 @@ getcmdline_int(
}
goto cmdline_not_changed;
- /* Mouse scroll wheel: ignored here */
+ // Mouse scroll wheel: ignored here
case K_MOUSEDOWN:
case K_MOUSEUP:
case K_MOUSELEFT:
case K_MOUSERIGHT:
- /* Alternate buttons ignored here */
+ // Alternate buttons ignored here
case K_X1MOUSE:
case K_X1DRAG:
case K_X1RELEASE:
@@ -1977,7 +1977,7 @@ getcmdline_int(
goto cmdline_not_changed;
#ifdef FEAT_GUI
- case K_LEFTMOUSE_NM: /* mousefocus click, ignored */
+ case K_LEFTMOUSE_NM: // mousefocus click, ignored
case K_LEFTRELEASE_NM:
goto cmdline_not_changed;
@@ -2000,17 +2000,17 @@ getcmdline_int(
#ifdef FEAT_GUI_TABLINE
case K_TABLINE:
case K_TABMENU:
- /* Don't want to change any tabs here. Make sure the same tab
- * is still selected. */
+ // Don't want to change any tabs here. Make sure the same tab
+ // is still selected.
if (gui_use_tabline())
gui_mch_set_curtab(tabpage_index(curtab));
goto cmdline_not_changed;
#endif
- case K_SELECT: /* end of Select mode mapping - ignore */
+ case K_SELECT: // end of Select mode mapping - ignore
goto cmdline_not_changed;
- case Ctrl_B: /* begin of command line */
+ case Ctrl_B: // begin of command line
case K_HOME:
case K_KHOME:
case K_S_HOME:
@@ -2019,7 +2019,7 @@ getcmdline_int(
set_cmdspos();
goto cmdline_not_changed;
- case Ctrl_E: /* end of command line */
+ case Ctrl_E: // end of command line
case K_END:
case K_KEND:
case K_S_END:
@@ -2028,7 +2028,7 @@ getcmdline_int(
set_cmdspos_cursor();
goto cmdline_not_changed;
- case Ctrl_A: /* all matches */
+ case Ctrl_A: // all matches
if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)
break;
goto cmdline_changed;
@@ -2039,13 +2039,13 @@ getcmdline_int(
goto cmdline_not_changed;
#endif
- /* completion: longest common part */
+ // completion: longest common part
if (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL)
break;
goto cmdline_changed;
- case Ctrl_N: /* next match */
- case Ctrl_P: /* previous match */
+ case Ctrl_N: // next match
+ case Ctrl_P: // previous match
if (xpc.xp_numfiles > 0)
{
if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
@@ -2053,7 +2053,7 @@ getcmdline_int(
break;
goto cmdline_not_changed;
}
- /* FALLTHROUGH */
+ // FALLTHROUGH
case K_UP:
case K_DOWN:
case K_S_UP:
@@ -2062,12 +2062,12 @@ getcmdline_int(
case K_KPAGEUP:
case K_PAGEDOWN:
case K_KPAGEDOWN:
- if (get_hislen() == 0 || firstc == NUL) /* no history */
+ if (get_hislen() == 0 || firstc == NUL) // no history
goto cmdline_not_changed;
i = hiscnt;
- /* save current command string so it can be restored later */
+ // save current command string so it can be restored later
if (lookfor == NULL)
{
if ((lookfor = vim_strsave(ccline.cmdbuff)) == NULL)
@@ -2078,40 +2078,42 @@ getcmdline_int(
j = (int)STRLEN(lookfor);
for (;;)
{
- /* one step backwards */
+ // one step backwards
if (c == K_UP|| c == K_S_UP || c == Ctrl_P
|| c == K_PAGEUP || c == K_KPAGEUP)
{
- if (hiscnt == get_hislen()) /* first time */
+ if (hiscnt == get_hislen()) // first time
hiscnt = *get_hisidx(histype);
- else if (hiscnt == 0 && *get_hisidx(histype) != get_hislen() - 1)
+ else if (hiscnt == 0 && *get_hisidx(histype)
+ != get_hislen() - 1)
hiscnt = get_hislen() - 1;
else if (hiscnt != *get_hisidx(histype) + 1)
--hiscnt;
- else /* at top of list */
+ else // at top of list
{
hiscnt = i;
break;
}
}
- else /* one step forwards */
+ else // one step forwards
{
- /* on last entry, clear the line */
+ // on last entry, clear the line
if (hiscnt == *get_hisidx(histype))
{
hiscnt = get_hislen();
break;
}
- /* not on a history line, nothing to do */
+ // not on a history line, nothing to do
if (hiscnt == get_hislen())
break;
- if (hiscnt == get_hislen() - 1) /* wrap around */
+ if (hiscnt == get_hislen() - 1) // wrap around
hiscnt = 0;
else
++hiscnt;
}
- if (hiscnt < 0 || get_histentry(histype)[hiscnt].hisstr == NULL)
+ if (hiscnt < 0 || get_histentry(histype)[hiscnt].hisstr
+ == NULL)
{
hiscnt = i;
break;
@@ -2123,7 +2125,7 @@ getcmdline_int(
break;
}
- if (hiscnt != i) /* jumped to other entry */
+ if (hiscnt != i) // jumped to other entry
{
char_u *p;
int len;
@@ -2132,7 +2134,7 @@ getcmdline_int(
VIM_CLEAR(ccline.cmdbuff);
xpc.xp_context = EXPAND_NOTHING;
if (hiscnt == get_hislen())
- p = lookfor; /* back to the old one */
+ p = lookfor; // back to the old one
else
p = get_histentry(histype)[hiscnt].hisstr;
@@ -2140,17 +2142,17 @@ getcmdline_int(
&& p != lookfor
&& (old_firstc = p[STRLEN(p) + 1]) != firstc)
{
- /* Correct for the separator character used when
- * adding the history entry vs the one used now.
- * First loop: count length.
- * Second loop: copy the characters. */
+ // Correct for the separator character used when
+ // adding the history entry vs the one used now.
+ // First loop: count length.
+ // Second loop: copy the characters.
for (i = 0; i <= 1; ++i)
{
len = 0;
for (j = 0; p[j] != NUL; ++j)
{
- /* Replace old sep with new sep, unless it is
- * escaped. */
+ // Replace old sep with new sep, unless it is
+ // escaped.
if (p[j] == old_firstc
&& (j == 0 || p[j - 1] != '\\'))
{
@@ -2159,8 +2161,8 @@ getcmdline_int(
}
else
{
- /* Escape new sep, unless it is already
- * escaped. */
+ // Escape new sep, unless it is already
+ // escaped.
if (p[j] == firstc
&& (j == 0 || p[j - 1] != '\\'))
{
@@ -2198,8 +2200,8 @@ getcmdline_int(
goto cmdline_not_changed;
#ifdef FEAT_SEARCH_EXTRA
- case Ctrl_G: /* next match */
- case Ctrl_T: /* previous match */
+ case Ctrl_G: // next match
+ case Ctrl_T: // previous match
if (may_adjust_incsearch_highlighting(
firstc, count, &is_state, c) == FAIL)
goto cmdline_not_changed;
@@ -2240,7 +2242,7 @@ getcmdline_int(
ignore_drag_release = TRUE;
putcmdline('?', TRUE);
# ifdef USE_ON_FLY_SCROLL
- dont_scroll = TRUE; /* disallow scrolling here */
+ dont_scroll = TRUE; // disallow scrolling here
# endif
c = get_digraph(TRUE);
extra_char = NUL;
@@ -2252,7 +2254,7 @@ getcmdline_int(
#endif // FEAT_DIGRAPHS
#ifdef FEAT_RIGHTLEFT
- case Ctrl__: /* CTRL-_: switch language mode */
+ case Ctrl__: // CTRL-_: switch language mode
if (!p_ari)
break;
cmd_hkmap = !cmd_hkmap;
@@ -2267,9 +2269,9 @@ getcmdline_int(
#ifdef UNIX
if (c == intr_char)
{
- gotesc = TRUE; /* will free ccline.cmdbuff after
- putting it in history */
- goto returncmd; /* back to Normal mode */
+ gotesc = TRUE; // will free ccline.cmdbuff after
+ // putting it in history
+ goto returncmd; // back to Normal mode
}
#endif
/*
@@ -2304,7 +2306,7 @@ getcmdline_int(
if (has_mbyte)
{
j = (*mb_char2bytes)(c, IObuff);
- IObuff[j] = NUL; /* exclude composing chars */
+ IObuff[j] = NUL; // exclude composing chars
put_on_cmdline(IObuff, j, TRUE);
}
else
@@ -2330,7 +2332,7 @@ cmdline_not_changed:
#endif
cmdline_changed:
- /* Trigger CmdlineChanged autocommands. */
+ // Trigger CmdlineChanged autocommands.
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
#ifdef FEAT_SEARCH_EXTRA
@@ -2344,10 +2346,10 @@ cmdline_changed:
&& cmdline_has_arabic(0, ccline.cmdlen))
# endif
)
- /* Always redraw the whole command line to fix shaping and
- * right-left typing. Not efficient, but it works.
- * Do it only when there are no characters left to read
- * to avoid useless intermediate redraws. */
+ // Always redraw the whole command line to fix shaping and
+ // right-left typing. Not efficient, but it works.
+ // Do it only when there are no characters left to read
+ // to avoid useless intermediate redraws.
if (vpeekc() == NUL)
redrawcmd();
#endif
@@ -2396,11 +2398,11 @@ returncmd:
msg_scroll = save_msg_scroll;
redir_off = FALSE;
- /* When the command line was typed, no need for a wait-return prompt. */
+ // When the command line was typed, no need for a wait-return prompt.
if (some_key_typed)
need_wait_return = FALSE;
- /* Trigger CmdlineLeave autocommands. */
+ // Trigger CmdlineLeave autocommands.
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);
State = save_State;
@@ -2411,7 +2413,7 @@ returncmd:
#endif
setmouse();
#ifdef CURSOR_SHAPE
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
#endif
sb_text_end_cmdline();
@@ -2437,10 +2439,10 @@ theend:
char_u *
getcmdline_prompt(
int firstc,
- char_u *prompt, /* command line prompt */
- int attr, /* attributes for prompt */
- int xp_context, /* type of expansion */
- char_u *xp_arg) /* user-defined expansion argument */
+ char_u *prompt, // command line prompt
+ int attr, // attributes for prompt
+ int xp_context, // type of expansion
+ char_u *xp_arg) // user-defined expansion argument
{
char_u *s;
cmdline_info_T save_ccline;
@@ -2470,10 +2472,10 @@ getcmdline_prompt(
restore_cmdline(&save_ccline);
msg_silent = msg_silent_save;
- /* Restore msg_col, the prompt from input() may have changed it.
- * But only if called recursively and the commandline is therefore being
- * restored to an old one; if not, the input() prompt stays on the screen,
- * so we need its modified msg_col left intact. */
+ // Restore msg_col, the prompt from input() may have changed it.
+ // But only if called recursively and the commandline is therefore being
+ // restored to an old one; if not, the input() prompt stays on the screen,
+ // so we need its modified msg_col left intact.
if (ccline.cmdbuff != NULL)
msg_col = msg_col_save;
@@ -2522,14 +2524,14 @@ check_opt_wim(void)
}
}
- /* fill remaining entries with last flag */
+ // fill remaining entries with last flag
while (idx < 3)
{
new_wim_flags[idx + 1] = new_wim_flags[idx];
++idx;
}
- /* only when there are no errors, wim_flags[] is changed */
+ // only when there are no errors, wim_flags[] is changed
for (i = 0; i < 4; ++i)
wim_flags[i] = new_wim_flags[i];
return OK;
@@ -2604,7 +2606,7 @@ allbuf_locked(void)
cmdline_charsize(int idx)
{
#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
- if (cmdline_star > 0) /* showing '*', always 1 position */
+ if (cmdline_star > 0) // showing '*', always 1 position
return 1;
#endif
return ptr2cells(ccline.cmdbuff + idx);
@@ -2635,7 +2637,7 @@ set_cmdspos_cursor(void)
if (KeyTyped)
{
m = Columns * Rows;
- if (m < 0) /* overflow, Columns or Rows at weird value */
+ if (m < 0) // overflow, Columns or Rows at weird value
m = MAXCOL;
}
else
@@ -2643,11 +2645,11 @@ set_cmdspos_cursor(void)
for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i)
{
c = cmdline_charsize(i);
- /* Count ">" for double-wide multi-byte char that doesn't fit. */
+ // Count ">" for double-wide multi-byte char that doesn't fit.
if (has_mbyte)
correct_cmdspos(i, c);
- /* If the cmdline doesn't fit, show cursor on last visible char.
- * Don't move the cursor itself, so we can still append. */
+ // If the cmdline doesn't fit, show cursor on last visible char.
+ // Don't move the cursor itself, so we can still append.
if ((ccline.cmdspos += c) >= m)
{
ccline.cmdspos -= c;
@@ -2676,12 +2678,12 @@ correct_cmdspos(int idx, int cells)
*/
char_u *
getexline(
- int c, /* normally ':', NUL for ":append" */
+ int c, // normally ':', NUL for ":append"
void *cookie UNUSED,
- int indent, /* indent for inside conditionals */
+ int indent, // indent for inside conditionals
int do_concat)
{
- /* When executing a register, remove ':' that's in front of each line. */
+ // When executing a register, remove ':' that's in front of each line.
if (exec_from_reg && vpeekc() == ':')
(void)vgetc();
return getcmdline(c, 1L, indent, do_concat);
@@ -2695,33 +2697,33 @@ getexline(
*/
char_u *
getexmodeline(
- int promptc, /* normally ':', NUL for ":append" and '?' for
- :s prompt */
+ int promptc, // normally ':', NUL for ":append" and '?' for
+ // :s prompt
void *cookie UNUSED,
- int indent, /* indent for inside conditionals */
+ int indent, // indent for inside conditionals
int do_concat UNUSED)
{
garray_T line_ga;
char_u *pend;
int startcol = 0;
int c1 = 0;
- int escaped = FALSE; /* CTRL-V typed */
+ int escaped = FALSE; // CTRL-V typed
int vcol = 0;
char_u *p;
int prev_char;
int len;
- /* Switch cursor on now. This avoids that it happens after the "\n", which
- * confuses the system function that computes tabstops. */
+ // Switch cursor on now. This avoids that it happens after the "\n", which
+ // confuses the system function that computes tabstops.
cursor_on();
- /* always start in column 0; write a newline if necessary */
+ // always start in column 0; write a newline if necessary
compute_cmdrow();
if ((msg_col || msg_didout) && promptc != '?')
msg_putchar('\n');
if (promptc == ':')
{
- /* indent that is only displayed, not in the line itself */
+ // indent that is only displayed, not in the line itself
if (p_prompt)
msg_putchar(':');
while (indent-- > 0)
@@ -2731,7 +2733,7 @@ getexmodeline(
ga_init2(&line_ga, 1, 30);
- /* autoindent for :insert and :append is in the line itself */
+ // autoindent for :insert and :append is in the line itself
if (promptc <= 0)
{
vcol = indent;
@@ -2767,7 +2769,7 @@ getexmodeline(
*/
prev_char = c1;
- /* Check for a ":normal" command and no more characters left. */
+ // Check for a ":normal" command and no more characters left.
if (ex_normal_busy > 0 && typebuf.tb_len == 0)
c1 = '\n';
else
@@ -2792,7 +2794,7 @@ getexmodeline(
if (!escaped)
{
- /* CR typed means "enter", which is NL */
+ // CR typed means "enter", which is NL
if (c1 == '\r')
c1 = '\n';
@@ -2833,7 +2835,7 @@ getexmodeline(
add_indent:
while (get_indent_str(p, 8, FALSE) < indent)
{
- (void)ga_grow(&line_ga, 2); /* one more for the NUL */
+ (void)ga_grow(&line_ga, 2); // one more for the NUL
p = (char_u *)line_ga.ga_data;
s = skipwhite(p);
mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);
@@ -2841,7 +2843,7 @@ add_indent:
++line_ga.ga_len;
}
redraw:
- /* redraw the line */
+ // redraw the line
msg_col = startcol;
vcol = 0;
p = (char_u *)line_ga.ga_data;
@@ -2870,7 +2872,7 @@ redraw:
if (c1 == Ctrl_D)
{
- /* Delete one shiftwidth. */
+ // Delete one shiftwidth.
p = (char_u *)line_ga.ga_data;
if (prev_char == '0' || prev_char == '^')
{
@@ -2904,7 +2906,7 @@ redraw:
continue;
}
- /* Ignore special key codes: mouse movement, K_IGNORE, etc. */
+ // Ignore special key codes: mouse movement, K_IGNORE, etc.
if (IS_SPECIAL(c1))
continue;
}
@@ -2923,7 +2925,7 @@ redraw:
msg_putchar('\n');
else if (c1 == TAB)
{
- /* Don't use chartabsize(), 'ts' can be different */
+ // Don't use chartabsize(), 'ts' can be different
do
msg_putchar(' ');
while (++vcol % 8);
@@ -2940,8 +2942,8 @@ redraw:
windgoto(msg_row, msg_col);
pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len;
- /* We are done when a NL is entered, but not when it comes after an
- * odd number of backslashes, that results in a NUL. */
+ // We are done when a NL is entered, but not when it comes after an
+ // odd number of backslashes, that results in a NUL.
if (line_ga.ga_len > 0 && pend[-1] == '\n')
{
int bcount = 0;
@@ -2951,8 +2953,8 @@ redraw:
if (bcount > 0)
{
- /* Halve the number of backslashes: "\NL" -> "NUL", "\\NL" ->
- * "\NL", etc. */
+ // Halve the number of backslashes: "\NL" -> "NUL", "\\NL" ->
+ // "\NL", etc.
line_ga.ga_len -= (bcount + 1) / 2;
pend -= (bcount + 1) / 2;
pend[-1] = '\n';
@@ -2971,12 +2973,12 @@ redraw:
--no_mapping;
--allow_keys;
- /* make following messages go to the next line */
+ // make following messages go to the next line
msg_didout = FALSE;
msg_col = 0;
if (msg_row < Rows - 1)
++msg_row;
- emsg_on_display = FALSE; /* don't want ui_delay() */
+ emsg_on_display = FALSE; // don't want ui_delay()
if (got_int)
ga_clear(&line_ga);
@@ -3041,7 +3043,7 @@ redrawcmd_preedit(void)
{
if ((State & CMDLINE)
&& xic != NULL
- /* && im_get_status() doesn't work when using SCIM */
+ // && im_get_status() doesn't work when using SCIM
&& !p_imdisable
&& im_is_preediting())
{
@@ -3082,7 +3084,7 @@ redrawcmd_preedit(void)
char_attr = im_get_feedback_attr(col);
if (char_attr < 0)
- break; /* end of preedit string */
+ break; // end of preedit string
if (has_mbyte)
char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos);
@@ -3097,7 +3099,7 @@ redrawcmd_preedit(void)
msg_col = old_col;
}
}
-#endif /* FEAT_XIM && FEAT_GUI_GTK */
+#endif // FEAT_XIM && FEAT_GUI_GTK
/*
* Allocate a new command line buffer.
@@ -3114,7 +3116,7 @@ alloc_cmdbuff(int len)
else
len += 20;
- ccline.cmdbuff = alloc(len); /* caller should check for out-of-memory */
+ ccline.cmdbuff = alloc(len); // caller should check for out-of-memory
ccline.cmdbufflen = len;
}
@@ -3128,17 +3130,17 @@ realloc_cmdbuff(int len)
char_u *p;
if (len < ccline.cmdbufflen)
- return OK; /* no need to resize */
+ return OK; // no need to resize
p = ccline.cmdbuff;
- alloc_cmdbuff(len); /* will get some more */
- if (ccline.cmdbuff == NULL) /* out of memory */
+ alloc_cmdbuff(len); // will get some more
+ if (ccline.cmdbuff == NULL) // out of memory
{
- ccline.cmdbuff = p; /* keep the old one */
+ ccline.cmdbuff = p; // keep the old one
return FAIL;
}
- /* There isn't always a NUL after the command, but it may need to be
- * there, thus copy up to the NUL and add a NUL. */
+ // There isn't always a NUL after the command, but it may need to be
+ // there, thus copy up to the NUL and add a NUL.
mch_memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen);
ccline.cmdbuff[ccline.cmdlen] = NUL;
vim_free(p);
@@ -3150,8 +3152,8 @@ realloc_cmdbuff(int len)
{
int i = (int)(ccline.xpc->xp_pattern - p);
- /* If xp_pattern points inside the old cmdbuff it needs to be adjusted
- * to point into the newly allocated memory. */
+ // If xp_pattern points inside the old cmdbuff it needs to be adjusted
+ // to point into the newly allocated memory.
if (i >= 0 && i <= ccline.cmdlen)
ccline.xpc->xp_pattern = ccline.cmdbuff + i;
}
@@ -3211,18 +3213,18 @@ draw_cmdline(int start, int len)
*/
if (len * 2 + 2 > buflen)
{
- /* Re-allocate the buffer. We keep it around to avoid a lot of
- * alloc()/free() calls. */
+ // Re-allocate the buffer. We keep it around to avoid a lot of
+ // alloc()/free() calls.
vim_free(arshape_buf);
buflen = len * 2 + 2;
arshape_buf = alloc(buflen);
if (arshape_buf == NULL)
- return; /* out of memory */
+ return; // out of memory
}
if (utf_iscomposing(utf_ptr2char(ccline.cmdbuff + start)))
{
- /* Prepend a space to draw the leading composing char on. */
+ // Prepend a space to draw the leading composing char on.
arshape_buf[0] = ' ';
newlen = 1;
}
@@ -3234,10 +3236,10 @@ draw_cmdline(int start, int len)
mb_l = utfc_ptr2len_len(p, start + len - j);
if (ARABIC_CHAR(u8c))
{
- /* Do Arabic shaping. */
+ // Do Arabic shaping.
if (cmdmsg_rl)
{
- /* displaying from right to left */
+ // displaying from right to left
pc = prev_c;
pc1 = prev_c1;
prev_c1 = u8cc[0];
@@ -3248,7 +3250,7 @@ draw_cmdline(int start, int len)
}
else
{
- /* displaying from left to right */
+ // displaying from left to right
if (j + mb_l >= start + len)
pc = NUL;
else
@@ -3349,7 +3351,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
if (len < 0)
len = (int)STRLEN(str);
- /* Check if ccline.cmdbuff needs to be longer */
+ // Check if ccline.cmdbuff needs to be longer
if (ccline.cmdlen + len + 1 >= ccline.cmdbufflen)
retval = realloc_cmdbuff(ccline.cmdlen + len + 1);
else
@@ -3367,12 +3369,12 @@ put_on_cmdline(char_u *str, int len, int redraw)
{
if (has_mbyte)
{
- /* Count nr of characters in the new string. */
+ // Count nr of characters in the new string.
m = 0;
for (i = 0; i < len; i += (*mb_ptr2len)(str + i))
++m;
- /* Count nr of bytes in cmdline that are overwritten by these
- * characters. */
+ // Count nr of bytes in cmdline that are overwritten by these
+ // characters.
for (i = ccline.cmdpos; i < ccline.cmdlen && m > 0;
i += (*mb_ptr2len)(ccline.cmdbuff + i))
--m;
@@ -3393,9 +3395,8 @@ put_on_cmdline(char_u *str, int len, int redraw)
if (enc_utf8)
{
- /* When the inserted text starts with a composing character,
- * backup to the character before it. There could be two of them.
- */
+ // When the inserted text starts with a composing character,
+ // backup to the character before it. There could be two of them.
i = 0;
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
while (ccline.cmdpos > 0 && utf_iscomposing(c))
@@ -3409,7 +3410,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
#ifdef FEAT_ARABIC
if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c))
{
- /* Check the previous character for Arabic combining pair. */
+ // Check the previous character for Arabic combining pair.
i = (*mb_head_off)(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos - 1) + 1;
if (arabic_combine(utf_ptr2char(ccline.cmdbuff
@@ -3424,7 +3425,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
#endif
if (i != 0)
{
- /* Also backup the cursor position. */
+ // Also backup the cursor position.
i = ptr2cells(ccline.cmdbuff + ccline.cmdpos);
ccline.cmdspos -= i;
msg_col -= i;
@@ -3442,7 +3443,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
i = cmdline_row;
cursorcmd();
draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos);
- /* Avoid clearing the rest of the line too often. */
+ // Avoid clearing the rest of the line too often.
if (cmdline_row != i || ccline.overstrike)
msg_clr_eos();
msg_no_more = FALSE;
@@ -3450,7 +3451,7 @@ put_on_cmdline(char_u *str, int len, int redraw)
if (KeyTyped)
{
m = Columns * Rows;
- if (m < 0) /* overflow, Columns or Rows at weird value */
+ if (m < 0) // overflow, Columns or Rows at weird value
m = MAXCOL;
}
else
@@ -3458,12 +3459,12 @@ put_on_cmdline(char_u *str, int len, int redraw)
for (i = 0; i < len; ++i)
{
c = cmdline_charsize(ccline.cmdpos);
- /* count ">" for a double-wide char that doesn't fit. */
+ // count ">" for a double-wide char that doesn't fit.
if (has_mbyte)
correct_cmdspos(ccline.cmdpos, c);
- /* Stop cursor at the end of the screen, but do increment the
- * insert position, so that entering a very long command
- * works, even though you can't see it. */
+ // Stop cursor at the end of the screen, but do increment the
+ // insert position, so that entering a very long command
+ // works, even though you can't see it.
if (ccline.cmdspos + c < m)
ccline.cmdspos += c;
@@ -3525,23 +3526,23 @@ restore_cmdline(cmdline_info_T *ccp)
static int
cmdline_paste(
int regname,
- int literally, /* Insert text literally instead of "as typed" */
- int remcr) /* remove trailing CR */
+ int literally, // Insert text literally instead of "as typed"
+ int remcr) // remove trailing CR
{
long i;
char_u *arg;
char_u *p;
int allocated;
- /* check for valid regname; also accept special characters for CTRL-R in
- * the command line */
+ // check for valid regname; also accept special characters for CTRL-R in
+ // the command line
if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W
&& regname != Ctrl_A && regname != Ctrl_L
&& !valid_yank_reg(regname, FALSE))
return FAIL;
- /* A register containing CTRL-R can cause an endless loop. Allow using
- * CTRL-C to break the loop. */
+ // A register containing CTRL-R can cause an endless loop. Allow using
+ // CTRL-C to break the loop.
line_breakcheck();
if (got_int)
return FAIL;
@@ -3558,19 +3559,19 @@ cmdline_paste(
if (i)
{
- /* Got the value of a special register in "arg". */
+ // Got the value of a special register in "arg".
if (arg == NULL)
return FAIL;
- /* When 'incsearch' is set and CTRL-R CTRL-W used: skip the duplicate
- * part of the word. */
+ // When 'incsearch' is set and CTRL-R CTRL-W used: skip the duplicate
+ // part of the word.
p = arg;
if (p_is && regname == Ctrl_W)
{
char_u *w;
int len;
- /* Locate start of last word in the cmd buffer. */
+ // Locate start of last word in the cmd buffer.
for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; )
{
if (has_mbyte)
@@ -3686,7 +3687,7 @@ redrawcmdprompt(void)
{
msg_puts_attr((char *)ccline.cmdprompt, ccline.cmdattr);
ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns;
- /* do the reverse of set_cmdspos() */
+ // do the reverse of set_cmdspos()
if (ccline.cmdfirstc != NUL)
--ccline.cmdindent;
}
@@ -3704,7 +3705,7 @@ redrawcmd(void)
if (cmd_silent)
return;
- /* when 'incsearch' is set there may be no command line while redrawing */
+ // when 'incsearch' is set there may be no command line while redrawing
if (ccline.cmdbuff == NULL)
{
windgoto(cmdline_row, 0);
@@ -3715,7 +3716,7 @@ redrawcmd(void)
msg_start();
redrawcmdprompt();
- /* Don't use more prompt, truncate the cmdline if it doesn't fit. */
+ // Don't use more prompt, truncate the cmdline if it doesn't fit.
msg_no_more = TRUE;
draw_cmdline(0, ccline.cmdlen);
msg_clr_eos();
@@ -3729,10 +3730,10 @@ redrawcmd(void)
* An emsg() before may have set msg_scroll. This is used in normal mode,
* in cmdline mode we can reset them now.
*/
- msg_scroll = FALSE; /* next message overwrites cmdline */
+ msg_scroll = FALSE; // next message overwrites cmdline
- /* Typing ':' at the more prompt may set skip_redraw. We don't want this
- * in cmdline mode */
+ // Typing ':' at the more prompt may set skip_redraw. We don't want this
+ // in cmdline mode
skip_redraw = FALSE;
}
@@ -3788,9 +3789,9 @@ gotocmdline(int clr)
msg_col = Columns - 1;
else
#endif
- msg_col = 0; /* always start in column 0 */
- if (clr) /* clear the bottom line(s) */
- msg_clr_eos(); /* will reset clear_cmdline */
+ msg_col = 0; // always start in column 0
+ if (clr) // clear the bottom line(s)
+ msg_clr_eos(); // will reset clear_cmdline
windgoto(cmdline_row, 0);
}
@@ -3805,11 +3806,11 @@ ccheck_abbr(int c)
{
int spos = 0;
- if (p_paste || no_abbr) /* no abbreviations or in paste mode */
+ if (p_paste || no_abbr) // no abbreviations or in paste mode
return FALSE;
- /* Do not consider '<,'> be part of the mapping, skip leading whitespace.
- * Actually accepts any mark. */
+ // Do not consider '<,'> be part of the mapping, skip leading whitespace.
+ // Actually accepts any mark.
while (VIM_ISWHITE(ccline.cmdbuff[spos]) && spos < ccline.cmdlen)
spos++;
if (ccline.cmdlen - spos > 5
@@ -3818,7 +3819,7 @@ ccheck_abbr(int c)
&& ccline.cmdbuff[spos + 3] == '\'')
spos += 5;
else
- /* check abbreviation from the beginning of the commandline */
+ // check abbreviation from the beginning of the commandline
spos = 0;
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos);
@@ -3837,7 +3838,7 @@ vim_strsave_fnameescape(char_u *fname, int shell UNUSED)
char_u buf[20];
int j = 0;
- /* Don't escape '[', '{' and '!' if they are in 'isfname'. */
+ // Don't escape '[', '{' and '!' if they are in 'isfname'.
for (p = PATH_ESC_CHARS; *p != NUL; ++p)
if ((*p != '[' && *p != '{' && *p != '!') || !vim_isfilec(*p))
buf[j++] = *p;
@@ -3849,16 +3850,16 @@ vim_strsave_fnameescape(char_u *fname, int shell UNUSED)
{
char_u *s;
- /* For csh and similar shells need to put two backslashes before '!'.
- * One is taken by Vim, one by the shell. */
+ // For csh and similar shells need to put two backslashes before '!'.
+ // One is taken by Vim, one by the shell.
s = vim_strsave_escaped(p, (char_u *)"!");
vim_free(p);
p = s;
}
#endif
- /* '>' and '+' are special at the start of some commands, e.g. ":edit" and
- * ":write". "cd -" has a special meaning. */
+ // '>' and '+' are special at the start of some commands, e.g. ":edit" and
+ // ":write". "cd -" has a special meaning.
if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL)))
escape_fname(&p);
@@ -3993,8 +3994,8 @@ set_cmdline_pos(
if (p == NULL)
return 1;
- /* The position is not set directly but after CTRL-\ e or CTRL-R = has
- * changed the command line. */
+ // The position is not set directly but after CTRL-\ e or CTRL-R = has
+ // changed the command line.
if (pos < 0)
new_cmdpos = 0;
else
@@ -4077,7 +4078,7 @@ get_list_range(char_u **str, int *num1, int *num2)
varnumber_T num;
*str = skipwhite(*str);
- if (**str == '-' || vim_isdigit(**str)) /* parse "from" part of range */
+ if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range
{
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE);
*str += len;
@@ -4085,7 +4086,7 @@ get_list_range(char_u **str, int *num1, int *num2)
first = TRUE;
}
*str = skipwhite(*str);
- if (**str == ',') /* parse "to" part of range */
+ if (**str == ',') // parse "to" part of range
{
*str = skipwhite(*str + 1);
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE);
@@ -4094,10 +4095,10 @@ get_list_range(char_u **str, int *num1, int *num2)
*num2 = (int)num;
*str = skipwhite(*str + len);
}
- else if (!first) /* no number given at all */
+ else if (!first) // no number given at all
return FAIL;
}
- else if (first) /* only one number given */
+ else if (first) // only one number given
*num2 = *num1;
return OK;
}
@@ -4153,7 +4154,7 @@ open_cmdwin(void)
int save_KeyTyped;
#endif
- /* Can't do this recursively. Can't do it when typing a password. */
+ // Can't do this recursively. Can't do it when typing a password.
if (cmdwin_type != 0
# if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
|| cmdline_star > 0
@@ -4240,8 +4241,8 @@ open_cmdwin(void)
}
}
- /* Replace the empty last line with the current command-line and put the
- * cursor there. */
+ // Replace the empty last line with the current command-line and put the
+ // cursor there.
ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, TRUE);
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
curwin->w_cursor.col = ccline.cmdpos;
@@ -4288,8 +4289,8 @@ open_cmdwin(void)
cmdwin_type = 0;
exmode_active = save_exmode;
- /* Safety check: The old window or buffer was deleted: It's a bug when
- * this happens! */
+ // Safety check: The old window or buffer was deleted: It's a bug when
+ // this happens!
if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf))
{
cmdwin_result = Ctrl_C;
@@ -4298,40 +4299,40 @@ open_cmdwin(void)
else
{
# if defined(FEAT_EVAL)
- /* autocmds may abort script processing */
+ // autocmds may abort script processing
if (aborting() && cmdwin_result != K_IGNORE)
cmdwin_result = Ctrl_C;
# endif
- /* Set the new command line from the cmdline buffer. */
+ // Set the new command line from the cmdline buffer.
vim_free(ccline.cmdbuff);
- if (cmdwin_result == K_XF1 || cmdwin_result == K_XF2) /* :qa[!] typed */
+ if (cmdwin_result == K_XF1 || cmdwin_result == K_XF2) // :qa[!] typed
{
char *p = (cmdwin_result == K_XF2) ? "qa" : "qa!";
if (histtype == HIST_CMD)
{
- /* Execute the command directly. */
+ // Execute the command directly.
ccline.cmdbuff = vim_strsave((char_u *)p);
cmdwin_result = CAR;
}
else
{
- /* First need to cancel what we were doing. */
+ // First need to cancel what we were doing.
ccline.cmdbuff = NULL;
stuffcharReadbuff(':');
stuffReadbuff((char_u *)p);
stuffcharReadbuff(CAR);
}
}
- else if (cmdwin_result == K_XF2) /* :qa typed */
+ else if (cmdwin_result == K_XF2) // :qa typed
{
ccline.cmdbuff = vim_strsave((char_u *)"qa");
cmdwin_result = CAR;
}
else if (cmdwin_result == Ctrl_C)
{
- /* :q or :close, don't execute any command
- * and don't modify the cmd window. */
+ // :q or :close, don't execute any command
+ // and don't modify the cmd window.
ccline.cmdbuff = NULL;
}
else
diff --git a/src/fileio.c b/src/fileio.c
index c15c7bd28..6600b5920 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -14,10 +14,10 @@
#include "vim.h"
#if defined(__TANDEM) || defined(__MINT__)
-# include <limits.h> /* for SSIZE_MAX */
+# include <limits.h> // for SSIZE_MAX
#endif
-/* Is there any system that doesn't have access()? */
+// Is there any system that doesn't have access()?
#define USE_MCH_ACCESS
static char_u *next_fenc(char_u **pp, int *alloced);
@@ -43,8 +43,8 @@ filemess(
if (msg_silent != 0)
return;
- msg_add_fname(buf, name); /* put file name in IObuff with quotes */
- /* If it's extremely long, truncate it. */
+ msg_add_fname(buf, name); // put file name in IObuff with quotes
+ // If it's extremely long, truncate it.
if (STRLEN(IObuff) > IOSIZE - 80)
IObuff[IOSIZE - 80] = NUL;
STRCAT(IObuff, s);
@@ -56,14 +56,14 @@ filemess(
msg_scroll_save = msg_scroll;
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();
if (prev_msg_col != 0 && msg_col == 0)
msg_putchar('\r'); // overwrite any previous message.
msg_scroll = msg_scroll_save;
msg_scrolled_ign = TRUE;
- /* may truncate the message to avoid a hit-return prompt */
+ // may truncate the message to avoid a hit-return prompt
msg_outtrans_attr(msg_may_trunc(FALSE, IObuff), attr);
msg_clr_eos();
out_flush();
@@ -102,7 +102,7 @@ readfile(
linenr_T from,
linenr_T lines_to_skip,
linenr_T lines_to_read,
- exarg_T *eap, /* can be NULL! */
+ exarg_T *eap, // can be NULL!
int flags)
{
int fd = 0;
@@ -114,15 +114,15 @@ readfile(
int read_fifo = (flags & READ_FIFO);
int set_options = newfile || read_buffer
|| (eap != NULL && eap->read_edit);
- linenr_T read_buf_lnum = 1; /* next line to read from curbuf */
- colnr_T read_buf_col = 0; /* next char to read from this line */
+ linenr_T read_buf_lnum = 1; // next line to read from curbuf
+ colnr_T read_buf_col = 0; // next char to read from this line
char_u c;
linenr_T lnum = from;
- char_u *ptr = NULL; /* pointer into read buffer */
- char_u *buffer = NULL; /* read buffer */
- char_u *new_buffer = NULL; /* init to shut up gcc */
- char_u *line_start = NULL; /* init to shut up gcc */
- int wasempty; /* buffer was empty before reading */
+ char_u *ptr = NULL; // pointer into read buffer
+ char_u *buffer = NULL; // read buffer
+ char_u *new_buffer = NULL; // init to shut up gcc
+ char_u *line_start = NULL; // init to shut up gcc
+ int wasempty; // buffer was empty before reading
colnr_T len;
long size = 0;
char_u *p;
@@ -136,58 +136,58 @@ readfile(
context_sha256_T sha_ctx;
int read_undo_file = FALSE;
#endif
- int split = 0; /* number of split lines */
-#define UNKNOWN 0x0fffffff /* file size is unknown */
+ int split = 0; // number of split lines
+#define UNKNOWN 0x0fffffff // file size is unknown
linenr_T linecnt;
- int error = FALSE; /* errors encountered */
- int ff_error = EOL_UNKNOWN; /* file format with errors */
- long linerest = 0; /* remaining chars in line */
+ int error = FALSE; // errors encountered
+ int ff_error = EOL_UNKNOWN; // file format with errors
+ long linerest = 0; // remaining chars in line
#ifdef UNIX
int perm = 0;
- int swap_mode = -1; /* protection bits for swap file */
+ int swap_mode = -1; // protection bits for swap file
#else
int perm;
#endif
- int fileformat = 0; /* end-of-line format */
+ int fileformat = 0; // end-of-line format
int keep_fileformat = FALSE;
stat_T st;
int file_readonly;
linenr_T skip_count = 0;
linenr_T read_count = 0;
int msg_save = msg_scroll;
- linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of
- * last read was missing the eol */
+ linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of
+ // last read was missing the eol
int try_mac;
int try_dos;
int try_unix;
int file_rewind = FALSE;
int can_retry;
- linenr_T conv_error = 0; /* line nr with conversion error */
- linenr_T illegal_byte = 0; /* line nr with illegal byte */
- int keep_dest_enc = FALSE; /* don't retry when char doesn't fit
- in destination encoding */
+ linenr_T conv_error = 0; // line nr with conversion error
+ linenr_T illegal_byte = 0; // line nr with illegal byte
+ int keep_dest_enc = FALSE; // don't retry when char doesn't fit
+ // in destination encoding
int bad_char_behavior = BAD_REPLACE;
- /* BAD_KEEP, BAD_DROP or character to
- * replace with */
- char_u *tmpname = NULL; /* name of 'charconvert' output file */
+ // BAD_KEEP, BAD_DROP or character to
+ // replace with
+ char_u *tmpname = NULL; // name of 'charconvert' output file
int fio_flags = 0;
- char_u *fenc; /* fileencoding to use */
- int fenc_alloced; /* fenc_next is in allocated memory */
- char_u *fenc_next = NULL; /* next item in 'fencs' or NULL */
+ char_u *fenc; // fileencoding to use
+ int fenc_alloced; // fenc_next is in allocated memory
+ char_u *fenc_next = NULL; // next item in 'fencs' or NULL
int advance_fenc = FALSE;
long real_size = 0;
#ifdef USE_ICONV
- iconv_t iconv_fd = (iconv_t)-1; /* descriptor for iconv() or -1 */
+ iconv_t iconv_fd = (iconv_t)-1; // descriptor for iconv() or -1
# ifdef FEAT_EVAL
- int did_iconv = FALSE; /* TRUE when iconv() failed and trying
- 'charconvert' next */
+ int did_iconv = FALSE; // TRUE when iconv() failed and trying
+ // 'charconvert' next
# endif
#endif
- int converted = FALSE; /* TRUE if conversion done */
- int notconverted = FALSE; /* TRUE if conversion wanted but it
- wasn't possible */
+ int converted = FALSE; // TRUE if conversion done
+ int notconverted = FALSE; // TRUE if conversion wanted but it
+ // wasn't possible
char_u conv_rest[CONV_RESTLEN];
- int conv_restlen = 0; /* nr of bytes in conv_rest[] */
+ int conv_restlen = 0; // nr of bytes in conv_rest[]
pos_T orig_start;
buf_T *old_curbuf;
char_u *old_b_ffname;
@@ -195,9 +195,9 @@ readfile(
int using_b_ffname;
int using_b_fname;
- au_did_filetype = FALSE; /* reset before triggering any autocommands */
+ au_did_filetype = FALSE; // reset before triggering any autocommands
- curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */
+ curbuf->b_no_eol_lnum = 0; // in case it was set by the previous read
/*
* If there is no file name yet, use the one for the read file.
@@ -215,10 +215,10 @@ readfile(
return FAIL;
}
- /* Remember the initial values of curbuf, curbuf->b_ffname and
- * curbuf->b_fname to detect whether they are altered as a result of
- * executing nasty autocommands. Also check if "fname" and "sfname"
- * point to one of these values. */
+ // Remember the initial values of curbuf, curbuf->b_ffname and
+ // curbuf->b_fname to detect whether they are altered as a result of
+ // executing nasty autocommands. Also check if "fname" and "sfname"
+ // point to one of these values.
old_curbuf = curbuf;
old_b_ffname = curbuf->b_ffname;
old_b_fname = curbuf->b_fname;
@@ -226,11 +226,11 @@ readfile(
|| (sfname == curbuf->b_ffname);
using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname);
- /* After reading a file the cursor line changes but we don't want to
- * display the line. */
+ // After reading a file the cursor line changes but we don't want to
+ // display the line.
ex_no_reprint = TRUE;
- /* don't display the file info for another buffer now */
+ // don't display the file info for another buffer now
need_fileinfo = FALSE;
/*
@@ -253,7 +253,7 @@ readfile(
{
orig_start = curbuf->b_op_start;
- /* Set '[ mark to the line above where the lines go (line 1 if zero). */
+ // Set '[ mark to the line above where the lines go (line 1 if zero).
curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
curbuf->b_op_start.col = 0;
@@ -279,9 +279,9 @@ readfile(
}
if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0)
- msg_scroll = FALSE; /* overwrite previous file message */
+ msg_scroll = FALSE; // overwrite previous file message
else
- msg_scroll = TRUE; /* don't overwrite previous file message */
+ msg_scroll = TRUE; // don't overwrite previous file message
/*
* If the name ends in a path separator, we can't open it. Check here,
@@ -309,12 +309,12 @@ readfile(
* check for it before the mch_open().
*/
perm = mch_getperm(fname);
- if (perm >= 0 && !S_ISREG(perm) /* not a regular file ... */
- && !S_ISFIFO(perm) /* ... or fifo */
- && !S_ISSOCK(perm) /* ... or socket */
+ if (perm >= 0 && !S_ISREG(perm) // not a regular file ...
+ && !S_ISFIFO(perm) // ... or fifo
+ && !S_ISSOCK(perm) // ... or socket
# ifdef OPEN_CHR_FILES
&& !(S_ISCHR(perm) && is_dev_fd_file(fname))
- /* ... or a character special file named /dev/fd/<n> */
+ // ... or a character special file named /dev/fd/<n>
# endif
)
{
@@ -347,7 +347,7 @@ readfile(
#endif
}
- /* Set default or forced 'fileformat' and 'binary'. */
+ // Set default or forced 'fileformat' and 'binary'.
set_file_options(set_options, eap);
/*
@@ -362,7 +362,7 @@ readfile(
if (newfile && !read_stdin && !read_buffer && !read_fifo)
{
- /* Remember time of file. */
+ // Remember time of file.
if (mch_stat((char *)fname, &st) >= 0)
{
buf_store_time(curbuf, &st, fname);
@@ -382,9 +382,8 @@ readfile(
swap_mode = (st.st_mode & 0644) | 0600;
#endif
#ifdef FEAT_CW_EDITOR
- /* Get the FSSpec on MacOS
- * TODO: Update it properly when the buffer name changes
- */
+ // Get the FSSpec on MacOS
+ // TODO: Update it properly when the buffer name changes
(void)GetFSSpecFromPath(curbuf->b_ffname, &curbuf->b_FSSpec);
#endif
#ifdef VMS
@@ -401,8 +400,8 @@ readfile(
curbuf->b_orig_mode = 0;
}
- /* Reset the "new file" flag. It will be set again below when the
- * file doesn't exist. */
+ // Reset the "new file" flag. It will be set again below when the
+ // file doesn't exist.
curbuf->b_flags &= ~(BF_NEW | BF_NEW_W);
}
@@ -414,7 +413,7 @@ readfile(
if (read_stdin)
{
#if defined(MSWIN)
- /* Force binary I/O on stdin to avoid CR-LF -> LF conversion. */
+ // Force binary I/O on stdin to avoid CR-LF -> LF conversion.
setmode(0, O_BINARY);
#endif
}
@@ -434,13 +433,13 @@ readfile(
|| (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0)
{
file_readonly = TRUE;
- /* try to open ro */
+ // try to open ro
fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0);
}
#endif
}
- if (fd < 0) /* cannot open at all */
+ if (fd < 0) // cannot open at all
{
#ifndef UNIX
int isdir_f;
@@ -451,11 +450,11 @@ readfile(
* On Amiga we can't open a directory, check here.
*/
isdir_f = (mch_isdir(fname));
- perm = mch_getperm(fname); /* check if the file exists */
+ perm = mch_getperm(fname); // check if the file exists
if (isdir_f)
{
filemess(curbuf, sfname, (char_u *)_("is a directory"), 0);
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
}
else
#endif
@@ -473,15 +472,15 @@ readfile(
*/
curbuf->b_flags |= BF_NEW;
- /* Create a swap file now, so that other Vims are warned
- * that we are editing this file. Don't do this for a
- * "nofile" or "nowrite" buffer type. */
+ // Create a swap file now, so that other Vims are warned
+ // that we are editing this file. Don't do this for a
+ // "nofile" or "nowrite" buffer type.
#ifdef FEAT_QUICKFIX
if (!bt_dontwrite(curbuf))
#endif
{
check_need_swap(newfile);
- /* SwapExists autocommand may mess things up */
+ // SwapExists autocommand may mess things up
if (curbuf != old_curbuf
|| (using_b_ffname
&& (old_b_ffname != curbuf->b_ffname))
@@ -498,23 +497,23 @@ readfile(
filemess(curbuf, sfname,
(char_u *)_("[New DIRECTORY]"), 0);
#ifdef FEAT_VIMINFO
- /* Even though this is a new file, it might have been
- * edited before and deleted. Get the old marks. */
+ // Even though this is a new file, it might have been
+ // edited before and deleted. Get the old marks.
check_marks_read();
#endif
- /* Set forced 'fileencoding'. */
+ // Set forced 'fileencoding'.
if (eap != NULL)
set_forced_fenc(eap);
apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname,
FALSE, curbuf, eap);
- /* remember the current fileformat */
+ // remember the current fileformat
save_file_ff(curbuf);
#if defined(FEAT_EVAL)
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
- return OK; /* a new file is not an error */
+ return OK; // a new file is not an error
}
else
{
@@ -526,7 +525,7 @@ readfile(
(errno == EOVERFLOW) ? _("[File too big]") :
# endif
_("[Permission Denied]")), 0);
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
}
}
@@ -542,8 +541,8 @@ readfile(
if (set_options)
{
- /* Don't change 'eol' if reading from buffer as it will already be
- * correctly set when reading stdin. */
+ // Don't change 'eol' if reading from buffer as it will already be
+ // correctly set when reading stdin.
if (!read_buffer)
{
curbuf->b_p_eol = TRUE;
@@ -553,9 +552,9 @@ readfile(
curbuf->b_start_bomb = FALSE;
}
- /* Create a swap file now, so that other Vims are warned that we are
- * editing this file.
- * Don't do this for a "nofile" or "nowrite" buffer type. */
+ // Create a swap file now, so that other Vims are warned that we are
+ // editing this file.
+ // Don't do this for a "nofile" or "nowrite" buffer type.
#ifdef FEAT_QUICKFIX
if (!bt_dontwrite(curbuf))
#endif
@@ -571,7 +570,7 @@ readfile(
return FAIL;
}
#ifdef UNIX
- /* Set swap file protection bits after creating it. */
+ // Set swap file protection bits after creating it.
if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
&& curbuf->b_ml.ml_mfp->mf_fname != NULL)
{
@@ -611,7 +610,7 @@ readfile(
return FAIL;
}
- ++no_wait_return; /* don't wait for return yet */
+ ++no_wait_return; // don't wait for return yet
/*
* Set '[ mark to the line above where the lines go (line 1 if zero).
@@ -634,7 +633,7 @@ readfile(
* the file before reading it.
*/
if (!read_stdin)
- close(fd); /* ignore errors */
+ close(fd); // ignore errors
/*
* The output from the autocommands should not overwrite anything and
@@ -654,7 +653,7 @@ readfile(
else
apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname,
FALSE, NULL, eap);
- /* autocommands may have changed it */
+ // autocommands may have changed it
try_mac = (vim_strchr(p_ffs, 'm') != NULL);
try_dos = (vim_strchr(p_ffs, 'd') != NULL);
try_unix = (vim_strchr(p_ffs, 'x') != NULL);
@@ -664,11 +663,11 @@ readfile(
msg_scroll = m;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
{
--no_wait_return;
msg_scroll = msg_save;
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
return FAIL;
}
#endif
@@ -690,12 +689,12 @@ readfile(
emsg(_("E200: *ReadPre autocommands made the file unreadable"));
else
emsg(_("E201: *ReadPre autocommands must not change current buffer"));
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
return FAIL;
}
}
- /* Autocommands may add lines to the file, need to check if it is empty */
+ // Autocommands may add lines to the file, need to check if it is empty
wasempty = (curbuf->b_ml.ml_flags & ML_EMPTY);
if (!recoverymode && !filtering && !(flags & READ_DUMMY))
@@ -717,7 +716,7 @@ readfile(
mch_msg(_("Vim: Reading from stdin...\n"));
#endif
#ifdef FEAT_GUI
- /* Also write a message in the GUI window, if there is one. */
+ // Also write a message in the GUI window, if there is one.
if (gui.in_use && !gui.dying && !gui.starting)
{
p = (char_u *)_("Reading from stdin...");
@@ -730,7 +729,7 @@ readfile(
filemess(curbuf, sfname, (char_u *)"", 0);
}
- msg_scroll = FALSE; /* overwrite the file message */
+ msg_scroll = FALSE; // overwrite the file message
/*
* Set linecnt now, before the "retry" caused by a wrong guess for
@@ -738,7 +737,7 @@ readfile(
*/
linecnt = curbuf->b_ml.ml_line_count;
- /* "++bad=" argument. */
+ // "++bad=" argument.
if (eap != NULL && eap->bad_char != 0)
{
bad_char_behavior = eap->bad_char;
@@ -759,7 +758,7 @@ readfile(
}
else if (curbuf->b_p_bin)
{
- fenc = (char_u *)""; /* binary: don't convert */
+ fenc = (char_u *)""; // binary: don't convert
fenc_alloced = FALSE;
}
else if (curbuf->b_help)
@@ -767,12 +766,12 @@ readfile(
char_u firstline[80];
int fc;
- /* Help files are either utf-8 or latin1. Try utf-8 first, if this
- * fails it must be latin1.
- * Always do this when 'encoding' is "utf-8". Otherwise only do
- * this when needed to avoid [converted] remarks all the time.
- * It is needed when the first line contains non-ASCII characters.
- * That is only in *.??x files. */
+ // Help files are either utf-8 or latin1. Try utf-8 first, if this
+ // fails it must be latin1.
+ // Always do this when 'encoding' is "utf-8". Otherwise only do
+ // this when needed to avoid [converted] remarks all the time.
+ // It is needed when the first line contains non-ASCII characters.
+ // That is only in *.??x files.
fenc = (char_u *)"latin1";
c = enc_utf8;
if (!c && !read_stdin)
@@ -780,8 +779,8 @@ readfile(
fc = fname[STRLEN(fname) - 1];
if (TOLOWER_ASC(fc) == 'x')
{
- /* Read the first line (and a bit more). Immediately rewind to
- * the start of the file. If the read() fails "len" is -1. */
+ // Read the first line (and a bit more). Immediately rewind to
+ // the start of the file. If the read() fails "len" is -1.
len = read_eintr(fd, firstline, 80);
vim_lseek(fd, (off_T)0L, SEEK_SET);
for (p = firstline; p < firstline + len; ++p)
@@ -798,9 +797,9 @@ readfile(
fenc_next = fenc;
fenc = (char_u *)"utf-8";
- /* When the file is utf-8 but a character doesn't fit in
- * 'encoding' don't retry. In help text editing utf-8 bytes
- * doesn't make sense. */
+ // When the file is utf-8 but a character doesn't fit in
+ // 'encoding' don't retry. In help text editing utf-8 bytes
+ // doesn't make sense.
if (!enc_utf8)
keep_dest_enc = TRUE;
}
@@ -808,12 +807,12 @@ readfile(
}
else if (*p_fencs == NUL)
{
- fenc = curbuf->b_p_fenc; /* use format from buffer */
+ fenc = curbuf->b_p_fenc; // use format from buffer
fenc_alloced = FALSE;
}
else
{
- fenc_next = p_fencs; /* try items in 'fileencodings' */
+ fenc_next = p_fencs; // try items in 'fileencodings'
fenc = next_fenc(&fenc_next, &fenc_alloced);
}
@@ -847,11 +846,11 @@ retry:
}
else if (read_stdin || vim_lseek(fd, (off_T)0L, SEEK_SET) != 0)
{
- /* Can't rewind the file, give up. */
+ // Can't rewind the file, give up.
error = TRUE;
goto failed;
}
- /* Delete the previously read lines. */
+ // Delete the previously read lines.
while (lnum > from)
ml_delete(lnum--, FALSE);
file_rewind = FALSE;
@@ -877,17 +876,17 @@ retry:
try_unix = try_dos = try_mac = FALSE;
}
else if (curbuf->b_p_bin)
- fileformat = EOL_UNIX; /* binary: use Unix format */
+ fileformat = EOL_UNIX; // binary: use Unix format
else if (*p_ffs == NUL)
- fileformat = get_fileformat(curbuf);/* use format from buffer */
+ fileformat = get_fileformat(curbuf);// use format from buffer
else
- fileformat = EOL_UNKNOWN; /* detect from file */
+ fileformat = EOL_UNKNOWN; // detect from file
}
#ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
{
- /* aborted conversion with iconv(), close the descriptor */
+ // aborted conversion with iconv(), close the descriptor
iconv_close(iconv_fd);
iconv_fd = (iconv_t)-1;
}
@@ -902,8 +901,8 @@ retry:
if (eap != NULL && eap->force_enc != 0)
{
- /* Conversion given with "++cc=" wasn't possible, read
- * without conversion. */
+ // Conversion given with "++cc=" wasn't possible, read
+ // without conversion.
notconverted = TRUE;
conv_error = 0;
if (fenc_alloced)
@@ -927,7 +926,7 @@ retry:
}
if (tmpname != NULL)
{
- mch_remove(tmpname); /* delete converted file */
+ mch_remove(tmpname); // delete converted file
VIM_CLEAR(tmpname);
}
}
@@ -941,8 +940,8 @@ retry:
if (converted)
{
- /* "ucs-bom" means we need to check the first bytes of the file
- * for a BOM. */
+ // "ucs-bom" means we need to check the first bytes of the file
+ // for a BOM.
if (STRCMP(fenc, ENC_UCSBOM) == 0)
fio_flags = FIO_UCSBOM;
@@ -968,7 +967,7 @@ retry:
#endif
#ifdef MACOS_CONVERT
- /* Conversion from Apple MacRoman to latin1 or UTF-8 */
+ // Conversion from Apple MacRoman to latin1 or UTF-8
if (fio_flags == 0)
fio_flags = get_mac_fio_flags(fenc);
#endif
@@ -1001,18 +1000,18 @@ retry:
# ifdef USE_ICONV
did_iconv = FALSE;
# endif
- /* Skip conversion when it's already done (retry for wrong
- * "fileformat"). */
+ // Skip conversion when it's already done (retry for wrong
+ // "fileformat").
if (tmpname == NULL)
{
tmpname = readfile_charconvert(fname, fenc, &fd);
if (tmpname == NULL)
{
- /* Conversion failed. Try another one. */
+ // Conversion failed. Try another one.
advance_fenc = TRUE;
if (fd < 0)
{
- /* Re-opening the original file failed! */
+ // Re-opening the original file failed!
emsg(_("E202: Conversion made file unreadable!"));
error = TRUE;
goto failed;
@@ -1030,17 +1029,17 @@ retry:
#endif
)
{
- /* Conversion wanted but we can't.
- * Try the next conversion in 'fileencodings' */
+ // Conversion wanted but we can't.
+ // Try the next conversion in 'fileencodings'
advance_fenc = TRUE;
goto retry;
}
}
}
- /* Set "can_retry" when it's possible to rewind the file and try with
- * another "fenc" value. It's FALSE when no other "fenc" to try, reading
- * stdin or fixed at a specific encoding. */
+ // Set "can_retry" when it's possible to rewind the file and try with
+ // another "fenc" value. It's FALSE when no other "fenc" to try, reading
+ // stdin or fixed at a specific encoding.
can_retry = (*fenc != NUL && !read_stdin && !read_fifo && !keep_dest_enc);
if (!skip_read)
@@ -1064,8 +1063,8 @@ retry:
#ifdef FEAT_CRYPT
if (curbuf->b_cryptstate != NULL)
{
- /* Need to free the state, but keep the key, don't want to ask for
- * it again. */
+ // Need to free the state, but keep the key, don't want to ask for
+ // it again.
crypt_free_state(curbuf->b_cryptstate);
curbuf->b_cryptstate = NULL;
}
@@ -1083,23 +1082,22 @@ retry:
if (!skip_read)
{
#if defined(SSIZE_MAX) && (SSIZE_MAX < 0x10000L)
- size = SSIZE_MAX; /* use max I/O size, 52K */
+ size = SSIZE_MAX; // use max I/O size, 52K
#else
- /* Use buffer >= 64K. Add linerest to double the size if the
- * line gets very long, to avoid a lot of copying. But don't
- * read more than 1 Mbyte at a time, so we can be interrupted.
- */
+ // Use buffer >= 64K. Add linerest to double the size if the
+ // line gets very long, to avoid a lot of copying. But don't
+ // read more than 1 Mbyte at a time, so we can be interrupted.
size = 0x10000L + linerest;
if (size > 0x100000L)
size = 0x100000L;
#endif
}
- /* Protect against the argument of lalloc() going negative. */
+ // Protect against the argument of lalloc() going negative.
if (size < 0 || size + linerest + 1 < 0 || linerest >= MAXCOL)
{
++split;
- *ptr = NL; /* split line by inserting a NL */
+ *ptr = NL; // split line by inserting a NL
size = 1;
}
else
@@ -1118,23 +1116,23 @@ retry:
error = TRUE;
break;
}
- if (linerest) /* copy characters from the previous buffer */
+ if (linerest) // copy characters from the previous buffer
mch_memmove(new_buffer, ptr - linerest, (size_t)linerest);
vim_free(buffer);
buffer = new_buffer;
ptr = buffer + linerest;
line_start = buffer;
- /* May need room to translate into.
- * For iconv() we don't really know the required space, use a
- * factor ICONV_MULT.
- * latin1 to utf-8: 1 byte becomes up to 2 bytes
- * utf-16 to utf-8: 2 bytes become up to 3 bytes, 4 bytes
- * become up to 4 bytes, size must be multiple of 2
- * ucs-2 to utf-8: 2 bytes become up to 3 bytes, size must be
- * multiple of 2
- * ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be
- * multiple of 4 */
+ // May need room to translate into.
+ // For iconv() we don't really know the required space, use a
+ // factor ICONV_MULT.
+ // latin1 to utf-8: 1 byte becomes up to 2 bytes
+ // utf-16 to utf-8: 2 bytes become up to 3 bytes, 4 bytes
+ // become up to 4 bytes, size must be multiple of 2
+ // ucs-2 to utf-8: 2 bytes become up to 3 bytes, size must be
+ // multiple of 2
+ // ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be
+ // multiple of 4
real_size = (int)size;
#ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
@@ -1148,19 +1146,19 @@ retry:
else if (fio_flags & FIO_UCS4)
size = (size * 2 / 3) & ~3;
else if (fio_flags == FIO_UCSBOM)
- size = size / ICONV_MULT; /* worst case */
+ size = size / ICONV_MULT; // worst case
#ifdef MSWIN
else if (fio_flags & FIO_CODEPAGE)
- size = size / ICONV_MULT; /* also worst case */
+ size = size / ICONV_MULT; // also worst case
#endif
#ifdef MACOS_CONVERT
else if (fio_flags & FIO_MACROMAN)
- size = size / ICONV_MULT; /* also worst case */
+ size = size / ICONV_MULT; // also worst case
#endif
if (conv_restlen > 0)
{
- /* Insert unconverted bytes from previous line. */
+ // Insert unconverted bytes from previous line.
mch_memmove(ptr, conv_rest, conv_restlen);
ptr += conv_restlen;
size -= conv_restlen;
@@ -1186,9 +1184,9 @@ retry:
n = (int)STRLEN(p);
if ((int)tlen + n + 1 > size)
{
- /* Filled up to "size", append partial line.
- * Change NL to NUL to reverse the effect done
- * below. */
+ // Filled up to "size", append partial line.
+ // Change NL to NUL to reverse the effect done
+ // below.
n = (int)(size - tlen);
for (ni = 0; ni < n; ++ni)
{
@@ -1202,8 +1200,8 @@ retry:
}
else
{
- /* Append whole line and new-line. Change NL
- * to NUL to reverse the effect done below. */
+ // Append whole line and new-line. Change NL
+ // to NUL to reverse the effect done below.
for (ni = 0; ni < n; ++ni)
{
if (p[ni] == NL)
@@ -1215,8 +1213,8 @@ retry:
read_buf_col = 0;
if (++read_buf_lnum > from)
{
- /* When the last line didn't have an
- * end-of-line don't add it now either. */
+ // When the last line didn't have an
+ // end-of-line don't add it now either.
if (!curbuf->b_p_eol)
--tlen;
size = tlen;
@@ -1264,22 +1262,22 @@ retry:
decrypted_size = crypt_decode_alloc(
curbuf->b_cryptstate, ptr, size, &newptr);
- /* If the crypt layer is buffering, not producing
- * anything yet, need to read more. */
+ // If the crypt layer is buffering, not producing
+ // anything yet, need to read more.
if (decrypted_size == 0)
continue;
if (linerest == 0)
{
- /* Simple case: reuse returned buffer (may be
- * NULL, checked later). */
+ // Simple case: reuse returned buffer (may be
+ // NULL, checked later).
new_buffer = newptr;
}
else
{
long_u new_size;
- /* Need new buffer to add bytes carried over. */
+ // Need new buffer to add bytes carried over.
new_size = (long_u)(decrypted_size + linerest + 1);
new_buffer = lalloc(new_size, FALSE);
if (new_buffer == NULL)
@@ -1311,7 +1309,7 @@ retry:
if (size <= 0)
{
- if (size < 0) /* read error */
+ if (size < 0) // read error
error = TRUE;
else if (conv_restlen > 0)
{
@@ -1320,7 +1318,7 @@ retry:
* not be converted. Truncated file?
*/
- /* When we did a conversion report an error. */
+ // When we did a conversion report an error.
if (fio_flags != 0
#ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1
@@ -1333,7 +1331,7 @@ retry:
conv_error = curbuf->b_ml.ml_line_count
- linecnt + 1;
}
- /* Remember the first linenr with an illegal byte */
+ // Remember the first linenr with an illegal byte
else if (illegal_byte == 0)
illegal_byte = curbuf->b_ml.ml_line_count
- linecnt + 1;
@@ -1344,10 +1342,10 @@ retry:
}
else
{
- /* Replace the trailing bytes with the replacement
- * character if we were converting; if we weren't,
- * leave the UTF8 checking code to do it, as it
- * works slightly differently. */
+ // Replace the trailing bytes with the replacement
+ // character if we were converting; if we weren't,
+ // leave the UTF8 checking code to do it, as it
+ // works slightly differently.
if (bad_char_behavior != BAD_KEEP && (fio_flags != 0
#ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1
@@ -1360,7 +1358,7 @@ retry:
--conv_restlen;
}
}
- fio_flags = 0; /* don't convert this */
+ fio_flags = 0; // don't convert this
#ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
{
@@ -1395,7 +1393,7 @@ retry:
char_u *ccname;
int blen;
- /* no BOM detection in a short file or in binary mode */
+ // no BOM detection in a short file or in binary mode
if (size < 2 || curbuf->b_p_bin)
ccname = NULL;
else
@@ -1403,7 +1401,7 @@ retry:
fio_flags == FIO_UCSBOM ? FIO_ALL : get_fio_flags(fenc));
if (ccname != NULL)
{
- /* Remove BOM from the text */
+ // Remove BOM from the text
filesize += blen;
size -= blen;
mch_memmove(ptr, ptr + blen, (size_t)size);
@@ -1418,24 +1416,24 @@ retry:
{
if (ccname == NULL)
{
- /* No BOM detected: retry with next encoding. */
+ // No BOM detected: retry with next encoding.
advance_fenc = TRUE;
}
else
{
- /* BOM detected: set "fenc" and jump back */
+ // BOM detected: set "fenc" and jump back
if (fenc_alloced)
vim_free(fenc);
fenc = ccname;
fenc_alloced = FALSE;
}
- /* retry reading without getting new bytes or rewinding */
+ // retry reading without getting new bytes or rewinding
skip_read = TRUE;
goto retry;
}
}
- /* Include not converted bytes. */
+ // Include not converted bytes.
ptr -= conv_restlen;
size += conv_restlen;
conv_restlen = 0;
@@ -1480,7 +1478,7 @@ retry:
conv_error = readfile_linenr(linecnt,
ptr, (char_u *)top);
- /* Deal with a bad byte and continue with the next. */
+ // Deal with a bad byte and continue with the next.
++fromp;
--from_size;
if (bad_char_behavior == BAD_KEEP)
@@ -1497,13 +1495,13 @@ retry:
if (from_size > 0)
{
- /* Some remaining characters, keep them for the next
- * round. */
+ // Some remaining characters, keep them for the next
+ // round.
mch_memmove(conv_rest, (char_u *)fromp, from_size);
conv_restlen = (int)from_size;
}
- /* move the linerest to before the converted characters */
+ // move the linerest to before the converted characters
line_start = ptr - linerest;
mch_memmove(line_start, buffer, (size_t)linerest);
size = (long)((char_u *)top - ptr);
@@ -1533,7 +1531,7 @@ retry:
* character at a time to get it right.
*/
- /* Replacement string for WideCharToMultiByte(). */
+ // Replacement string for WideCharToMultiByte().
if (bad_char_behavior > 0)
replstr[0] = bad_char_behavior;
else
@@ -1556,22 +1554,22 @@ retry:
{
found_bad = FALSE;
-# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
+# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
if (codepage == CP_UTF8)
{
- /* Handle CP_UTF8 input ourselves to be able to handle
- * trailing bytes properly.
- * Get one UTF-8 character from src. */
+ // Handle CP_UTF8 input ourselves to be able to handle
+ // trailing bytes properly.
+ // Get one UTF-8 character from src.
bytelen = (int)utf_ptr2len_len(src, size);
if (bytelen > size)
{
- /* Only got some bytes of a character. Normally
- * it's put in "conv_rest", but if it's too long
- * deal with it as if they were illegal bytes. */
+ // Only got some bytes of a character. Normally
+ // it's put in "conv_rest", but if it's too long
+ // deal with it as if they were illegal bytes.
if (bytelen <= CONV_RESTLEN)
break;
- /* weird overlong byte sequence */
+ // weird overlong byte sequence
bytelen = size;
found_bad = TRUE;
}
@@ -1588,8 +1586,8 @@ retry:
else
# endif
{
- /* We don't know how long the byte sequence is, try
- * from one to three bytes. */
+ // We don't know how long the byte sequence is, try
+ // from one to three bytes.
for (bytelen = 1; bytelen <= size && bytelen <= 3;
++bytelen)
{
@@ -1602,9 +1600,9 @@ retry:
}
if (ucs2len == 0)
{
- /* If we have only one byte then it's probably an
- * incomplete byte sequence. Otherwise discard
- * one byte as a bad character. */
+ // If we have only one byte then it's probably an
+ // incomplete byte sequence. Otherwise discard
+ // one byte as a bad character.
if (size == 1)
break;
found_bad = TRUE;
@@ -1616,10 +1614,10 @@ retry:
{
int i;
- /* Convert "ucs2buf[ucs2len]" to 'enc' in "dst". */
+ // Convert "ucs2buf[ucs2len]" to 'enc' in "dst".
if (enc_utf8)
{
- /* From UCS-2 to UTF-8. Cannot fail. */
+ // From UCS-2 to UTF-8. Cannot fail.
for (i = 0; i < ucs2len; ++i)
dst += utf_char2bytes(ucs2buf[i], dst);
}
@@ -1628,9 +1626,9 @@ retry:
BOOL bad = FALSE;
int dstlen;
- /* From UCS-2 to "enc_codepage". If the
- * conversion uses the default character "?",
- * the data doesn't fit in this encoding. */
+ // From UCS-2 to "enc_codepage". If the
+ // conversion uses the default character "?",
+ // the data doesn't fit in this encoding.
dstlen = WideCharToMultiByte(enc_codepage, 0,
(LPCWSTR)ucs2buf, ucs2len,
(LPSTR)dst, (int)(src - dst),
@@ -1644,7 +1642,7 @@ retry:
if (found_bad)
{
- /* Deal with bytes we can't convert. */
+ // Deal with bytes we can't convert.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1667,12 +1665,12 @@ retry:
if (size > 0)
{
- /* An incomplete byte sequence remaining. */
+ // An incomplete byte sequence remaining.
mch_memmove(conv_rest, src, size);
conv_restlen = size;
}
- /* The new size is equal to how much "dst" was advanced. */
+ // The new size is equal to how much "dst" was advanced.
size = (long)(dst - ptr);
}
else
@@ -1709,7 +1707,7 @@ retry:
p = ptr + size;
if (fio_flags == FIO_UTF8)
{
- /* Check for a trailing incomplete UTF-8 sequence */
+ // Check for a trailing incomplete UTF-8 sequence
tail = ptr + size - 1;
while (tail > ptr && (*tail & 0xc0) == 0x80)
--tail;
@@ -1721,13 +1719,13 @@ retry:
}
else if (fio_flags & (FIO_UCS2 | FIO_UTF16))
{
- /* Check for a trailing byte */
+ // Check for a trailing byte
p = ptr + (size & ~1);
if (size & 1)
tail = p;
if ((fio_flags & FIO_UTF16) && p > ptr)
{
- /* Check for a trailing leading word */
+ // Check for a trailing leading word
if (fio_flags & FIO_ENDIAN_L)
{
u8c = (*--p << 8);
@@ -1744,16 +1742,16 @@ retry:
p += 2;
}
}
- else /* FIO_UCS4 */
+ else // FIO_UCS4
{
- /* Check for trailing 1, 2 or 3 bytes */
+ // Check for trailing 1, 2 or 3 bytes
p = ptr + (size & ~3);
if (size & 3)
tail = p;
}
- /* If there is a trailing incomplete sequence move it to
- * conv_rest[]. */
+ // If there is a trailing incomplete sequence move it to
+ // conv_rest[].
if (tail != NULL)
{
conv_restlen = (int)((ptr + size) - tail);
@@ -1785,7 +1783,7 @@ retry:
if (p == ptr)
{
- /* Missing leading word. */
+ // Missing leading word.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1797,8 +1795,8 @@ retry:
u8c = bad_char_behavior;
}
- /* found second word of double-word, get the first
- * word and compute the resulting character */
+ // found second word of double-word, get the first
+ // word and compute the resulting character
if (fio_flags & FIO_ENDIAN_L)
{
u16c = (*--p << 8);
@@ -1812,7 +1810,7 @@ retry:
u8c = 0x10000 + ((u16c & 0x3ff) << 10)
+ (u8c & 0x3ff);
- /* Check if the word is indeed a leading word. */
+ // Check if the word is indeed a leading word.
if (u16c < 0xd800 || u16c > 0xdbff)
{
if (can_retry)
@@ -1836,7 +1834,7 @@ retry:
u8c += (unsigned)*--p << 8;
u8c += *--p;
}
- else /* big endian */
+ else // big endian
{
u8c = *--p;
u8c += (unsigned)*--p << 8;
@@ -1844,7 +1842,7 @@ retry:
u8c += (unsigned)*--p << 24;
}
}
- else /* UTF-8 */
+ else // UTF-8
{
if (*--p < 0x80)
u8c = *p;
@@ -1855,9 +1853,9 @@ retry:
u8c = utf_ptr2char(p);
if (len == 0)
{
- /* Not a valid UTF-8 character, retry with
- * another fenc when possible, otherwise just
- * report the error. */
+ // Not a valid UTF-8 character, retry with
+ // another fenc when possible, otherwise just
+ // report the error.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1870,19 +1868,19 @@ retry:
}
}
}
- if (enc_utf8) /* produce UTF-8 */
+ if (enc_utf8) // produce UTF-8
{
dest -= utf_char2len(u8c);
(void)utf_char2bytes(u8c, dest);
}
- else /* produce Latin1 */
+ else // produce Latin1
{
--dest;
if (u8c >= 0x100)
{
- /* character doesn't fit in latin1, retry with
- * another fenc when possible, otherwise just
- * report the error. */
+ // character doesn't fit in latin1, retry with
+ // another fenc when possible, otherwise just
+ // report the error.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1901,7 +1899,7 @@ retry:
}
}
- /* move the linerest to before the converted characters */
+ // move the linerest to before the converted characters
line_start = dest - linerest;
mch_memmove(line_start, buffer, (size_t)linerest);
size = (long)((ptr + real_size) - dest);
@@ -1911,7 +1909,7 @@ retry:
{
int incomplete_tail = FALSE;
- /* Reading UTF-8: Check if the bytes are valid UTF-8. */
+ // Reading UTF-8: Check if the bytes are valid UTF-8.
for (p = ptr; ; ++p)
{
int todo = (int)((ptr + size) - p);
@@ -1921,22 +1919,22 @@ retry:
break;
if (*p >= 0x80)
{
- /* A length of 1 means it's an illegal byte. Accept
- * an incomplete character at the end though, the next
- * read() will get the next bytes, we'll check it
- * then. */
+ // A length of 1 means it's an illegal byte. Accept
+ // an incomplete character at the end though, the next
+ // read() will get the next bytes, we'll check it
+ // then.
l = utf_ptr2len_len(p, todo);
if (l > todo && !incomplete_tail)
{
- /* Avoid retrying with a different encoding when
- * a truncated file is more likely, or attempting
- * to read the rest of an incomplete sequence when
- * we have already done so. */
+ // Avoid retrying with a different encoding when
+ // a truncated file is more likely, or attempting
+ // to read the rest of an incomplete sequence when
+ // we have already done so.
if (p > ptr || filesize > 0)
incomplete_tail = TRUE;
- /* Incomplete byte sequence, move it to conv_rest[]
- * and try to read the rest of it, unless we've
- * already done so. */
+ // Incomplete byte sequence, move it to conv_rest[]
+ // and try to read the rest of it, unless we've
+ // already done so.
if (p > ptr)
{
conv_restlen = todo;
@@ -1947,21 +1945,21 @@ retry:
}
if (l == 1 || l > todo)
{
- /* Illegal byte. If we can try another encoding
- * do that, unless at EOF where a truncated
- * file is more likely than a conversion error. */
+ // Illegal byte. If we can try another encoding
+ // do that, unless at EOF where a truncated
+ // file is more likely than a conversion error.
if (can_retry && !incomplete_tail)
break;
#ifdef USE_ICONV
- /* When we did a conversion report an error. */
+ // When we did a conversion report an error.
if (iconv_fd != (iconv_t)-1 && conv_error == 0)
conv_error = readfile_linenr(linecnt, ptr, p);
#endif
- /* Remember the first linenr with an illegal byte */
+ // Remember the first linenr with an illegal byte
if (conv_error == 0 && illegal_byte == 0)
illegal_byte = readfile_linenr(linecnt, ptr, p);
- /* Drop, keep or replace the bad byte. */
+ // Drop, keep or replace the bad byte.
if (bad_char_behavior == BAD_DROP)
{
mch_memmove(p, p + 1, todo - 1);
@@ -1977,23 +1975,23 @@ retry:
}
if (p < ptr + size && !incomplete_tail)
{
- /* Detected a UTF-8 error. */
+ // Detected a UTF-8 error.
rewind_retry:
- /* Retry reading with another conversion. */
+ // Retry reading with another conversion.
#if defined(FEAT_EVAL) && defined(USE_ICONV)
if (*p_ccv != NUL && iconv_fd != (iconv_t)-1)
- /* iconv() failed, try 'charconvert' */
+ // iconv() failed, try 'charconvert'
did_iconv = TRUE;
else
#endif
- /* use next item from 'fileencodings' */
+ // use next item from 'fileencodings'
advance_fenc = TRUE;
file_rewind = TRUE;
goto retry;
}
}
- /* count the number of characters (after conversion!) */
+ // count the number of characters (after conversion!)
filesize += size;
/*
@@ -2001,10 +1999,10 @@ rewind_retry:
*/
if (fileformat == EOL_UNKNOWN)
{
- /* First try finding a NL, for Dos and Unix */
+ // First try finding a NL, for Dos and Unix
if (try_dos || try_unix)
{
- /* Reset the carriage return counter. */
+ // Reset the carriage return counter.
if (try_mac)
try_mac = 1;
@@ -2023,10 +2021,10 @@ rewind_retry:
try_mac++;
}
- /* Don't give in to EOL_UNIX if EOL_MAC is more likely */
+ // Don't give in to EOL_UNIX if EOL_MAC is more likely
if (fileformat == EOL_UNIX && try_mac)
{
- /* Need to reset the counters when retrying fenc. */
+ // Need to reset the counters when retrying fenc.
try_mac = 1;
try_unix = 1;
for (; p >= ptr && *p != CAR; p--)
@@ -2045,20 +2043,20 @@ rewind_retry:
}
}
else if (fileformat == EOL_UNKNOWN && try_mac == 1)
- /* Looking for CR but found no end-of-line markers at
- * all: use the default format. */
+ // Looking for CR but found no end-of-line markers at
+ // all: use the default format.
fileformat = default_fileformat();
}
- /* No NL found: may use Mac format */
+ // No NL found: may use Mac format
if (fileformat == EOL_UNKNOWN && try_mac)
fileformat = EOL_MAC;
- /* Still nothing found? Use first format in 'ffs' */
+ // Still nothing found? Use first format in 'ffs'
if (fileformat == EOL_UNKNOWN)
fileformat = default_fileformat();
- /* if editing a new file: may set p_tx and p_ff */
+ // if editing a new file: may set p_tx and p_ff
if (set_options)
set_fileformat(fileformat, OPT_LOCAL);
}
@@ -2073,18 +2071,18 @@ rewind_retry:
--ptr;
while (++ptr, --size >= 0)
{
- /* catch most common case first */
+ // catch most common case first
if ((c = *ptr) != NUL && c != CAR && c != NL)
continue;
if (c == NUL)
- *ptr = NL; /* NULs are replaced by newlines! */
+ *ptr = NL; // NULs are replaced by newlines!
else if (c == NL)
- *ptr = CAR; /* NLs are replaced by CRs! */
+ *ptr = CAR; // NLs are replaced by CRs!
else
{
if (skip_count == 0)
{
- *ptr = NUL; /* end of line */
+ *ptr = NUL; // end of line
len = (colnr_T) (ptr - line_start + 1);
if (ml_append(lnum, line_start, len, newfile) == FAIL)
{
@@ -2098,8 +2096,8 @@ rewind_retry:
++lnum;
if (--read_count == 0)
{
- error = TRUE; /* break loop */
- line_start = ptr; /* nothing left to write */
+ error = TRUE; // break loop
+ line_start = ptr; // nothing left to write
break;
}
}
@@ -2114,21 +2112,21 @@ rewind_retry:
--ptr;
while (++ptr, --size >= 0)
{
- if ((c = *ptr) != NUL && c != NL) /* catch most common case */
+ if ((c = *ptr) != NUL && c != NL) // catch most common case
continue;
if (c == NUL)
- *ptr = NL; /* NULs are replaced by newlines! */
+ *ptr = NL; // NULs are replaced by newlines!
else
{
if (skip_count == 0)
{
- *ptr = NUL; /* end of line */
+ *ptr = NUL; // end of line
len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS)
{
if (ptr > line_start && ptr[-1] == CAR)
{
- /* remove CR before NL */
+ // remove CR before NL
ptr[-1] = NUL;
--len;
}
@@ -2168,8 +2166,8 @@ rewind_retry:
++lnum;
if (--read_count == 0)
{
- error = TRUE; /* break loop */
- line_start = ptr; /* nothing left to write */
+ error = TRUE; // break loop
+ line_start = ptr; // nothing left to write
break;
}
}
@@ -2184,7 +2182,7 @@ rewind_retry:
}
failed:
- /* not an error, max. number of lines reached */
+ // not an error, max. number of lines reached
if (error && read_count == 0)
error = FALSE;
@@ -2201,7 +2199,7 @@ failed:
&& *line_start == Ctrl_Z
&& ptr == line_start + 1))
{
- /* remember for when writing */
+ // remember for when writing
if (set_options)
curbuf->b_p_eol = FALSE;
*ptr = NUL;
@@ -2219,7 +2217,7 @@ failed:
}
if (set_options)
- save_file_ff(curbuf); /* remember the current file format */
+ save_file_ff(curbuf); // remember the current file format
#ifdef FEAT_CRYPT
if (curbuf->b_cryptstate != NULL)
@@ -2229,12 +2227,12 @@ failed:
}
if (cryptkey != NULL && cryptkey != curbuf->b_p_key)
crypt_free_key(cryptkey);
- /* Don't set cryptkey to NULL, it's used below as a flag that
- * encryption was used. */
+ // Don't set cryptkey to NULL, it's used below as a flag that
+ // encryption was used.
#endif
- /* If editing a new file: set 'fenc' for the current buffer.
- * Also for ":read ++edit file". */
+ // If editing a new file: set 'fenc' for the current buffer.
+ // Also for ":read ++edit file".
if (set_options)
set_string_option_direct((char_u *)"fenc", -1, fenc,
OPT_FREE|OPT_LOCAL, 0);
@@ -2246,7 +2244,7 @@ failed:
#endif
if (!read_buffer && !read_stdin)
- close(fd); /* errors are ignored */
+ close(fd); // errors are ignored
#ifdef HAVE_FD_CLOEXEC
else
{
@@ -2260,7 +2258,7 @@ failed:
#ifdef HAVE_DUP
if (read_stdin)
{
- /* Use stderr for stdin, makes shell commands work. */
+ // Use stderr for stdin, makes shell commands work.
close(0);
vim_ignored = dup(2);
}
@@ -2268,17 +2266,17 @@ failed:
if (tmpname != NULL)
{
- mch_remove(tmpname); /* delete converted file */
+ mch_remove(tmpname); // delete converted file
vim_free(tmpname);
}
- --no_wait_return; /* may wait for return now */
+ --no_wait_return; // may wait for return now
/*
* In recovery mode everything but autocommands is skipped.
*/
if (!recoverymode)
{
- /* need to delete the last line, which comes from the empty buffer */
+ // need to delete the last line, which comes from the empty buffer
if (newfile && wasempty && !(curbuf->b_ml.ml_flags & ML_EMPTY))
{
#ifdef FEAT_NETBEANS_INTG
@@ -2297,17 +2295,17 @@ failed:
{
redraw_curbuf_later(NOT_VALID);
#ifdef FEAT_DIFF
- /* After reading the text into the buffer the diff info needs to
- * be updated. */
+ // After reading the text into the buffer the diff info needs to
+ // be updated.
diff_invalidate(curbuf);
#endif
#ifdef FEAT_FOLDING
- /* All folds in the window are invalid now. Mark them for update
- * before triggering autocommands. */
+ // All folds in the window are invalid now. Mark them for update
+ // before triggering autocommands.
foldUpdateAll(curwin);
#endif
}
- else if (linecnt) /* appended at least one line */
+ else if (linecnt) // appended at least one line
appended_lines_mark(from, linecnt);
#ifndef ALWAYS_USE_GUI
@@ -2318,7 +2316,7 @@ failed:
*/
if (read_stdin)
{
- settmode(TMODE_RAW); /* set to raw mode */
+ settmode(TMODE_RAW); // set to raw mode
starttermcap();
screenclear();
}
@@ -2330,33 +2328,33 @@ failed:
{
filemess(curbuf, sfname, (char_u *)_(e_interr), 0);
if (newfile)
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
}
msg_scroll = msg_save;
#ifdef FEAT_VIMINFO
check_marks_read();
#endif
- return OK; /* an interrupt isn't really an error */
+ return OK; // an interrupt isn't really an error
}
if (!filtering && !(flags & READ_DUMMY))
{
- msg_add_fname(curbuf, sfname); /* fname in IObuff with quotes */
+ msg_add_fname(curbuf, sfname); // fname in IObuff with quotes
c = FALSE;
#ifdef UNIX
- if (S_ISFIFO(perm)) /* fifo */
+ if (S_ISFIFO(perm)) // fifo
{
STRCAT(IObuff, _("[fifo]"));
c = TRUE;
}
- if (S_ISSOCK(perm)) /* or socket */
+ if (S_ISSOCK(perm)) // or socket
{
STRCAT(IObuff, _("[socket]"));
c = TRUE;
}
# ifdef OPEN_CHR_FILES
- if (S_ISCHR(perm)) /* or character special */
+ if (S_ISCHR(perm)) // or character special
{
STRCAT(IObuff, _("[character special]"));
c = TRUE;
@@ -2430,8 +2428,8 @@ failed:
VIM_CLEAR(keep_msg);
msg_scrolled_ign = TRUE;
#ifdef ALWAYS_USE_GUI
- /* Don't show the message when reading stdin, it would end up in a
- * message box (which might be shown when exiting!) */
+ // Don't show the message when reading stdin, it would end up in a
+ // message box (which might be shown when exiting!)
if (read_stdin || read_buffer)
p = msg_may_trunc(FALSE, IObuff);
else
@@ -2443,23 +2441,23 @@ failed:
}
if (read_stdin || read_buffer || restart_edit != 0
|| (msg_scrolled != 0 && !need_wait_return))
- /* Need to repeat the message after redrawing when:
- * - When reading from stdin (the screen will be cleared next).
- * - When restart_edit is set (otherwise there will be a delay
- * before redrawing).
- * - When the screen was scrolled but there is no wait-return
- * prompt. */
+ // Need to repeat the message after redrawing when:
+ // - When reading from stdin (the screen will be cleared next).
+ // - When restart_edit is set (otherwise there will be a delay
+ // before redrawing).
+ // - When the screen was scrolled but there is no wait-return
+ // prompt.
set_keep_msg(p, 0);
msg_scrolled_ign = FALSE;
}
- /* with errors writing the file requires ":w!" */
+ // with errors writing the file requires ":w!"
if (newfile && (error
|| conv_error != 0
|| (illegal_byte > 0 && bad_char_behavior != BAD_KEEP)))
curbuf->b_p_ro = TRUE;
- u_clearline(); /* cannot use "U" command after adding lines */
+ u_clearline(); // cannot use "U" command after adding lines
/*
* In Ex mode: cursor at last new line.
@@ -2470,7 +2468,7 @@ failed:
else
curwin->w_cursor.lnum = from + 1;
check_cursor_lnum();
- beginline(BL_WHITE | BL_FIX); /* on first non-blank */
+ beginline(BL_WHITE | BL_FIX); // on first non-blank
if (!cmdmod.lockmarks)
{
@@ -2514,8 +2512,8 @@ failed:
*/
curbuf->b_no_eol_lnum = read_no_eol_lnum;
- /* When reloading a buffer put the cursor at the first line that is
- * different. */
+ // When reloading a buffer put the cursor at the first line that is
+ // different.
if (flags & READ_KEEP_UNDO)
u_find_first_changed();
@@ -2537,8 +2535,8 @@ failed:
int m = msg_scroll;
int n = msg_scrolled;
- /* Save the fileformat now, otherwise the buffer will be considered
- * modified if the format/encoding was automatically detected. */
+ // Save the fileformat now, otherwise the buffer will be considered
+ // modified if the format/encoding was automatically detected.
if (set_options)
save_file_ff(curbuf);
@@ -2569,7 +2567,7 @@ failed:
if (msg_scrolled == n)
msg_scroll = m;
# ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
# endif
}
@@ -2604,9 +2602,9 @@ is_dev_fd_file(char_u *fname)
*/
static linenr_T
readfile_linenr(
- linenr_T linecnt, /* line count before reading more bytes */
- char_u *p, /* start of more bytes read */
- char_u *endp) /* end of more bytes read */
+ linenr_T linecnt, // line count before reading more bytes
+ char_u *p, // start of more bytes read
+ char_u *endp) // end of more bytes read
{
char_u *s;
linenr_T lnum;
@@ -2647,7 +2645,7 @@ prep_exarg(exarg_T *eap, buf_T *buf)
void
set_file_options(int set_options, exarg_T *eap)
{
- /* set default 'fileformat' */
+ // set default 'fileformat'
if (set_options)
{
if (eap != NULL && eap->force_ff != 0)
@@ -2656,7 +2654,7 @@ set_file_options(int set_options, exarg_T *eap)
set_fileformat(default_fileformat(), OPT_LOCAL);
}
- /* set or reset 'binary' */
+ // set or reset 'binary'
if (eap != NULL && eap->force_bin != 0)
{
int oldval = curbuf->b_p_bin;
@@ -2742,9 +2740,9 @@ next_fenc(char_u **pp, int *alloced)
*/
static char_u *
readfile_charconvert(
- char_u *fname, /* name of input file */
- char_u *fenc, /* converted from */
- int *fdp) /* in/out: file descriptor of file */
+ char_u *fname, // name of input file
+ char_u *fenc, // converted from
+ int *fdp) // in/out: file descriptor of file
{
char_u *tmpname;
char *errmsg = NULL;
@@ -2754,7 +2752,7 @@ readfile_charconvert(
errmsg = _("Can't find temp file for conversion");
else
{
- close(*fdp); /* close the input file, ignore errors */
+ close(*fdp); // close the input file, ignore errors
*fdp = -1;
if (eval_charconvert(fenc, enc_utf8 ? (char_u *)"utf-8" : p_enc,
fname, tmpname) == FAIL)
@@ -2766,17 +2764,17 @@ readfile_charconvert(
if (errmsg != NULL)
{
- /* Don't use emsg(), it breaks mappings, the retry with
- * another type of conversion might still work. */
+ // Don't use emsg(), it breaks mappings, the retry with
+ // another type of conversion might still work.
msg(errmsg);
if (tmpname != NULL)
{
- mch_remove(tmpname); /* delete converted file */
+ mch_remove(tmpname); // delete converted file
VIM_CLEAR(tmpname);
}
}
- /* If the input file is closed, open it (caller should check for error). */
+ // If the input file is closed, open it (caller should check for error).
if (*fdp < 0)
*fdp = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0);
@@ -2793,24 +2791,24 @@ readfile_charconvert(
*/
static char_u *
check_for_cryptkey(
- char_u *cryptkey, /* previous encryption key or NULL */
- char_u *ptr, /* pointer to read bytes */
- long *sizep, /* length of read bytes */
- off_T *filesizep, /* nr of bytes used from file */
- int newfile, /* editing a new buffer */
- char_u *fname, /* file name to display */
- int *did_ask) /* flag: whether already asked for key */
+ char_u *cryptkey, // previous encryption key or NULL
+ char_u *ptr, // pointer to read bytes
+ long *sizep, // length of read bytes
+ off_T *filesizep, // nr of bytes used from file
+ int newfile, // editing a new buffer
+ char_u *fname, // file name to display
+ int *did_ask) // flag: whether already asked for key
{
int method = crypt_method_nr_from_magic((char *)ptr, *sizep);
int b_p_ro = curbuf->b_p_ro;
if (method >= 0)
{
- /* Mark the buffer as read-only until the decryption has taken place.
- * Avoids accidentally overwriting the file with garbage. */
+ // Mark the buffer as read-only until the decryption has taken place.
+ // Avoids accidentally overwriting the file with garbage.
curbuf->b_p_ro = TRUE;
- /* Set the cryptmethod local to the buffer. */
+ // Set the cryptmethod local to the buffer.
crypt_set_cm_option(curbuf, method);
if (cryptkey == NULL && !*did_ask)
{
@@ -2818,17 +2816,17 @@ check_for_cryptkey(
cryptkey = curbuf->b_p_key;
else
{
- /* When newfile is TRUE, store the typed key in the 'key'
- * option and don't free it. bf needs hash of the key saved.
- * Don't ask for the key again when first time Enter was hit.
- * Happens when retrying to detect encoding. */
+ // When newfile is TRUE, store the typed key in the 'key'
+ // option and don't free it. bf needs hash of the key saved.
+ // Don't ask for the key again when first time Enter was hit.
+ // Happens when retrying to detect encoding.
smsg(_(need_key_msg), fname);
msg_scroll = TRUE;
crypt_check_method(method);
cryptkey = crypt_get_key(newfile, FALSE);
*did_ask = TRUE;
- /* check if empty key entered */
+ // check if empty key entered
if (cryptkey != NULL && *cryptkey == NUL)
{
if (cryptkey != curbuf->b_p_key)
@@ -2846,30 +2844,30 @@ check_for_cryptkey(
method, cryptkey, ptr);
crypt_set_cm_option(curbuf, method);
- /* Remove cryptmethod specific header from the text. */
+ // Remove cryptmethod specific header from the text.
header_len = crypt_get_header_len(method);
if (*sizep <= header_len)
- /* invalid header, buffer can't be encrypted */
+ // invalid header, buffer can't be encrypted
return NULL;
*filesizep += header_len;
*sizep -= header_len;
mch_memmove(ptr, ptr + header_len, (size_t)*sizep);
- /* Restore the read-only flag. */
+ // Restore the read-only flag.
curbuf->b_p_ro = b_p_ro;
}
}
- /* When starting to edit a new file which does not have encryption, clear
- * the 'key' option, except when starting up (called with -x argument) */
+ // When starting to edit a new file which does not have encryption, clear
+ // the 'key' option, except when starting up (called with -x argument)
else if (newfile && *curbuf->b_p_key != NUL && !starting)
set_option_value((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL);
return cryptkey;
}
-#endif /* FEAT_CRYPT */
+#endif // FEAT_CRYPT
#if defined(VMS) && !defined(MIN)
-/* Older DECC compiler for VAX doesn't define MIN() */
+// Older DECC compiler for VAX doesn't define MIN()
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
@@ -2878,8 +2876,8 @@ check_for_cryptkey(
*/
int
check_file_readonly(
- char_u *fname, /* full path to file */
- int perm UNUSED) /* known permissions on file */
+ char_u *fname, // full path to file
+ int perm UNUSED) // known permissions on file
{
#ifndef USE_MCH_ACCESS
int fd = 0;
@@ -2926,17 +2924,17 @@ set_rw_fname(char_u *fname, char_u *sfname)
{
buf_T *buf = curbuf;
- /* It's like the unnamed buffer is deleted.... */
+ // It's like the unnamed buffer is deleted....
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
if (curbuf != buf)
{
- /* We are in another buffer now, don't do the renaming. */
+ // We are in another buffer now, don't do the renaming.
emsg(_(e_auchangedbuf));
return FAIL;
}
@@ -2944,16 +2942,16 @@ set_rw_fname(char_u *fname, char_u *sfname)
if (setfname(curbuf, fname, sfname, FALSE) == OK)
curbuf->b_flags |= BF_NOTEDITED;
- /* ....and a new named one is created */
+ // ....and a new named one is created
apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf);
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
- /* Do filetype detection now if 'filetype' is empty. */
+ // Do filetype detection now if 'filetype' is empty.
if (*curbuf->b_p_ft == NUL)
{
if (au_has_group((char_u *)"filetypedetect"))
@@ -3047,9 +3045,9 @@ msg_add_eol(void)
time_differs(long t1, long t2)
{
#if defined(__linux__) || defined(MSWIN)
- /* On a FAT filesystem, esp. under Linux, there are only 5 bits to store
- * the seconds. Since the roundoff is done when flushing the inode, the
- * time may change unexpectedly by one second!!! */
+ // On a FAT filesystem, esp. under Linux, there are only 5 bits to store
+ // the seconds. Since the roundoff is done when flushing the inode, the
+ // time may change unexpectedly by one second!!!
return (t1 - t2 > 1 || t2 - t1 > 1);
#else
return (t1 != t2);
@@ -3074,21 +3072,21 @@ need_conversion(char_u *fenc)
}
else
{
- /* Ignore difference between "ansi" and "latin1", "ucs-4" and
- * "ucs-4be", etc. */
+ // Ignore difference between "ansi" and "latin1", "ucs-4" and
+ // "ucs-4be", etc.
enc_flags = get_fio_flags(p_enc);
fenc_flags = get_fio_flags(fenc);
same_encoding = (enc_flags != 0 && fenc_flags == enc_flags);
}
if (same_encoding)
{
- /* Specified encoding matches with 'encoding'. This requires
- * conversion when 'encoding' is Unicode but not UTF-8. */
+ // Specified encoding matches with 'encoding'. This requires
+ // conversion when 'encoding' is Unicode but not UTF-8.
return enc_unicode != 0;
}
- /* Encodings differ. However, conversion is not needed when 'enc' is any
- * Unicode encoding and the file is UTF-8. */
+ // Encodings differ. However, conversion is not needed when 'enc' is any
+ // Unicode encoding and the file is UTF-8.
return !(enc_utf8 && fenc_flags == FIO_UTF8);
}
@@ -3130,7 +3128,7 @@ get_fio_flags(char_u *ptr)
}
if (prop & ENC_LATIN1)
return FIO_LATIN1;
- /* must be ENC_DBCS, requires iconv() */
+ // must be ENC_DBCS, requires iconv()
return 0;
}
@@ -3145,14 +3143,14 @@ get_win_fio_flags(char_u *ptr)
{
int cp;
- /* Cannot do this when 'encoding' is not utf-8 and not a codepage. */
+ // Cannot do this when 'encoding' is not utf-8 and not a codepage.
if (!enc_utf8 && enc_codepage <= 0)
return 0;
cp = encname2codepage(ptr);
if (cp == 0)
{
-# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
+# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
if (STRCMP(ptr, "utf-8") == 0)
cp = CP_UTF8;
else
@@ -3197,7 +3195,7 @@ check_for_bom(
if (p[0] == 0xef && p[1] == 0xbb && size >= 3 && p[2] == 0xbf
&& (flags == FIO_ALL || flags == FIO_UTF8 || flags == 0))
{
- name = "utf-8"; /* EF BB BF */
+ name = "utf-8"; // EF BB BF
len = 3;
}
else if (p[0] == 0xff && p[1] == 0xfe)
@@ -3205,28 +3203,28 @@ check_for_bom(
if (size >= 4 && p[2] == 0 && p[3] == 0
&& (flags == FIO_ALL || flags == (FIO_UCS4 | FIO_ENDIAN_L)))
{
- name = "ucs-4le"; /* FF FE 00 00 */
+ name = "ucs-4le"; // FF FE 00 00
len = 4;
}
else if (flags == (FIO_UCS2 | FIO_ENDIAN_L))
- name = "ucs-2le"; /* FF FE */
+ name = "ucs-2le"; // FF FE
else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L))
- /* utf-16le is preferred, it also works for ucs-2le text */
- name = "utf-16le"; /* FF FE */
+ // utf-16le is preferred, it also works for ucs-2le text
+ name = "utf-16le"; // FF FE
}
else if (p[0] == 0xfe && p[1] == 0xff
&& (flags == FIO_ALL || flags == FIO_UCS2 || flags == FIO_UTF16))
{
- /* Default to utf-16, it works also for ucs-2 text. */
+ // Default to utf-16, it works also for ucs-2 text.
if (flags == FIO_UCS2)
- name = "ucs-2"; /* FE FF */
+ name = "ucs-2"; // FE FF
else
- name = "utf-16"; /* FE FF */
+ name = "utf-16"; // FE FF
}
else if (size >= 4 && p[0] == 0 && p[1] == 0 && p[2] == 0xfe
&& p[3] == 0xff && (flags == FIO_ALL || flags == FIO_UCS4))
{
- name = "ucs-4"; /* 00 00 FE FF */
+ name = "ucs-4"; // 00 00 FE FF
len = 4;
}
@@ -3287,7 +3285,7 @@ shorten_fname(char_u *full_path, char_u *dir_name)
{
if (vim_ispathsep(*p))
++p;
-#ifndef VMS /* the path separator is always part of the path */
+#ifndef VMS // the path separator is always part of the path
else
p = NULL;
#endif
@@ -3360,8 +3358,8 @@ shorten_fnames(int force)
{
shorten_buf_fname(buf, dirname, force);
- /* Always make the swap file name a full path, a "nofile" buffer may
- * also have a swap file. */
+ // Always make the swap file name a full path, a "nofile" buffer may
+ // also have a swap file.
mf_fullname(buf->b_ml.ml_mfp);
}
status_redraw_all();
@@ -3392,9 +3390,9 @@ shorten_filenames(char_u **fnames, int count)
{
if ((p = shorten_fname(fnames[i], dirname)) != NULL)
{
- /* shorten_fname() returns pointer in given "fnames[i]". If free
- * "fnames[i]" first, "p" becomes invalid. So we need to copy
- * "p" first then free fnames[i]. */
+ // shorten_fname() returns pointer in given "fnames[i]". If free
+ // "fnames[i]" first, "p" becomes invalid. So we need to copy
+ // "p" first then free fnames[i].
p = vim_strsave(p);
vim_free(fnames[i]);
fnames[i] = p;
@@ -3418,7 +3416,7 @@ shorten_filenames(char_u **fnames, int count)
modname(
char_u *fname,
char_u *ext,
- int prepend_dot) /* may prepend a '.' to file name */
+ int prepend_dot) // may prepend a '.' to file name
{
return buf_modname((curbuf->b_p_sn || curbuf->b_shortname),
fname, ext, prepend_dot);
@@ -3426,10 +3424,10 @@ modname(
char_u *
buf_modname(
- int shortname, /* use 8.3 file name */
+ int shortname, // use 8.3 file name
char_u *fname,
char_u *ext,
- int prepend_dot) /* may prepend a '.' to file name */
+ int prepend_dot) // may prepend a '.' to file name
{
char_u *retval;
char_u *s;
@@ -3459,7 +3457,7 @@ buf_modname(
retval[fnamelen++] = PATHSEP;
retval[fnamelen] = NUL;
}
- prepend_dot = FALSE; /* nothing to prepend a dot to */
+ prepend_dot = FALSE; // nothing to prepend a dot to
}
else
{
@@ -3469,7 +3467,7 @@ buf_modname(
return NULL;
STRCPY(retval, fname);
#ifdef VMS
- vms_remove_version(retval); /* we do not need versions here */
+ vms_remove_version(retval); // we do not need versions here
#endif
}
@@ -3482,7 +3480,7 @@ buf_modname(
for (ptr = retval + fnamelen; ptr > retval; MB_PTR_BACK(retval, ptr))
{
if (*ext == '.' && shortname)
- if (*ptr == '.') /* replace '.' by '_' */
+ if (*ptr == '.') // replace '.' by '_'
*ptr = '_';
if (vim_ispathsep(*ptr))
{
@@ -3491,7 +3489,7 @@ buf_modname(
}
}
- /* the file name has at most BASENAMELEN characters. */
+ // the file name has at most BASENAMELEN characters.
if (STRLEN(ptr) > (unsigned)BASENAMELEN)
ptr[BASENAMELEN] = '\0';
@@ -3569,7 +3567,7 @@ buf_modname(
*/
if (fname != NULL && STRCMP(fname, retval) == 0)
{
- /* we search for a character that can be replaced by '_' */
+ // we search for a character that can be replaced by '_'
while (--s >= ptr)
{
if (*s != '_')
@@ -3578,7 +3576,7 @@ buf_modname(
break;
}
}
- if (s < ptr) /* fname was "________.<ext>", how tricky! */
+ if (s < ptr) // fname was "________.<ext>", how tricky!
*ptr = 'v';
}
return retval;
@@ -3600,9 +3598,9 @@ vim_fgets(char_u *buf, int size, FILE *fp)
eof = fgets((char *)buf, size, fp);
if (buf[size - 2] != NUL && buf[size - 2] != '\n')
{
- buf[size - 1] = NUL; /* Truncate the line */
+ buf[size - 1] = NUL; // Truncate the line
- /* Now throw away the rest of the line: */
+ // Now throw away the rest of the line:
do
{
tbuf[FGETS_SIZE - 2] = NUL;
@@ -3631,7 +3629,7 @@ vim_rename(char_u *from, char_u *to)
stat_T st;
long perm;
#ifdef HAVE_ACL
- vim_acl_T acl; /* ACL from original file */
+ vim_acl_T acl; // ACL from original file
#endif
int use_tmp_file = FALSE;
@@ -3658,9 +3656,9 @@ vim_rename(char_u *from, char_u *to)
{
stat_T st_to;
- /* It's possible for the source and destination to be the same file.
- * This happens when "from" and "to" differ in case and are on a FAT32
- * filesystem. In that case go through a temp file name. */
+ // It's possible for the source and destination to be the same file.
+ // This happens when "from" and "to" differ in case and are on a FAT32
+ // filesystem. In that case go through a temp file name.
if (mch_stat((char *)to, &st_to) >= 0
&& st.st_dev == st_to.st_dev
&& st.st_ino == st_to.st_ino)
@@ -3671,9 +3669,9 @@ vim_rename(char_u *from, char_u *to)
{
BY_HANDLE_FILE_INFORMATION info1, info2;
- /* It's possible for the source and destination to be the same file.
- * In that case go through a temp file name. This makes rename("foo",
- * "./foo") a no-op (in a complicated way). */
+ // It's possible for the source and destination to be the same file.
+ // In that case go through a temp file name. This makes rename("foo",
+ // "./foo") a no-op (in a complicated way).
if (win32_fileinfo(from, &info1) == FILEINFO_OK
&& win32_fileinfo(to, &info2) == FILEINFO_OK
&& info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber
@@ -3703,13 +3701,13 @@ vim_rename(char_u *from, char_u *to)
{
if (mch_rename(tempname, (char *)to) == 0)
return 0;
- /* Strange, the second step failed. Try moving the
- * file back and return failure. */
+ // Strange, the second step failed. Try moving the
+ // file back and return failure.
mch_rename(tempname, (char *)from);
return -1;
}
- /* If it fails for one temp name it will most likely fail
- * for any temp name, give up. */
+ // If it fails for one temp name it will most likely fail
+ // for any temp name, give up.
return -1;
}
}
@@ -3755,7 +3753,7 @@ vim_rename(char_u *from, char_u *to)
*/
perm = mch_getperm(from);
#ifdef HAVE_ACL
- /* For systems that support ACL: get the ACL from the original file. */
+ // For systems that support ACL: get the ACL from the original file.
acl = mch_get_acl(from);
#endif
fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
@@ -3767,7 +3765,7 @@ vim_rename(char_u *from, char_u *to)
return -1;
}
- /* Create the new file with same permissions as the original. */
+ // Create the new file with same permissions as the original.
fd_out = mch_open((char *)to,
O_CREAT|O_EXCL|O_WRONLY|O_EXTRA|O_NOFOLLOW, (int)perm);
if (fd_out == -1)
@@ -3806,7 +3804,7 @@ vim_rename(char_u *from, char_u *to)
errmsg = _("E210: Error reading \"%s\"");
to = from;
}
-#ifndef UNIX /* for Unix mch_open() already set the permission */
+#ifndef UNIX // for Unix mch_open() already set the permission
mch_setperm(to, perm);
#endif
#ifdef HAVE_ACL
@@ -3837,20 +3835,20 @@ static int already_warned = FALSE;
*/
int
check_timestamps(
- int focus) /* called for GUI focus event */
+ int focus) // called for GUI focus event
{
buf_T *buf;
int didit = 0;
int n;
- /* Don't check timestamps while system() or another low-level function may
- * cause us to lose and gain focus. */
+ // Don't check timestamps while system() or another low-level function may
+ // cause us to lose and gain focus.
if (no_check_timestamps > 0)
return FALSE;
- /* Avoid doing a check twice. The OK/Reload dialog can cause a focus
- * event and we would keep on checking if the file is steadily growing.
- * Do check again after typing something. */
+ // Avoid doing a check twice. The OK/Reload dialog can cause a focus
+ // event and we would keep on checking if the file is steadily growing.
+ // Do check again after typing something.
if (focus && did_check_timestamps)
{
need_check_timestamps = TRUE;
@@ -3859,7 +3857,7 @@ check_timestamps(
if (!stuff_empty() || global_busy || !typebuf_typed()
|| autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0)
- need_check_timestamps = TRUE; /* check later */
+ need_check_timestamps = TRUE; // check later
else
{
++no_wait_return;
@@ -3867,7 +3865,7 @@ check_timestamps(
already_warned = FALSE;
FOR_ALL_BUFFERS(buf)
{
- /* Only check buffers in a window. */
+ // Only check buffers in a window.
if (buf->b_nwindows > 0)
{
bufref_T bufref;
@@ -3878,8 +3876,8 @@ check_timestamps(
didit = n;
if (n > 0 && !bufref_valid(&bufref))
{
- /* Autocommands have removed the buffer, start at the
- * first one again. */
+ // Autocommands have removed the buffer, start at the
+ // first one again.
buf = firstbuf;
continue;
}
@@ -3889,7 +3887,7 @@ check_timestamps(
need_check_timestamps = FALSE;
if (need_wait_return && didit == 2)
{
- /* make sure msg isn't overwritten */
+ // make sure msg isn't overwritten
msg_puts("\n");
out_flush();
}
@@ -3910,7 +3908,7 @@ move_lines(buf_T *frombuf, buf_T *tobuf)
linenr_T lnum;
char_u *p;
- /* Copy the lines in "frombuf" to "tobuf". */
+ // Copy the lines in "frombuf" to "tobuf".
curbuf = tobuf;
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; ++lnum)
{
@@ -3924,15 +3922,15 @@ move_lines(buf_T *frombuf, buf_T *tobuf)
vim_free(p);
}
- /* Delete all the lines in "frombuf". */
+ // Delete all the lines in "frombuf".
if (retval != FAIL)
{
curbuf = frombuf;
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0; --lnum)
if (ml_delete(lnum, FALSE) == FAIL)
{
- /* Oops! We could try putting back the saved lines, but that
- * might fail again... */
+ // Oops! We could try putting back the saved lines, but that
+ // might fail again...
retval = FAIL;
break;
}
@@ -3952,7 +3950,7 @@ move_lines(buf_T *frombuf, buf_T *tobuf)
int
buf_check_timestamp(
buf_T *buf,
- int focus UNUSED) /* called for GUI focus event */
+ int focus UNUSED) // called for GUI focus event
{
stat_T st;
int stat_res;
@@ -3981,9 +3979,9 @@ buf_check_timestamp(
set_bufref(&bufref, buf);
- /* If there is no file name, the buffer is not loaded, 'buftype' is
- * set, we are in the middle of a save or being called recursively: ignore
- * this buffer. */
+ // If there is no file name, the buffer is not loaded, 'buftype' is
+ // set, we are in the middle of a save or being called recursively: ignore
+ // this buffer.
if (buf->b_ffname == NULL
|| buf->b_ml.ml_mfp == NULL
|| !bt_normal(buf)
@@ -4026,8 +4024,8 @@ buf_check_timestamp(
else
buf_store_time(buf, &st, buf->b_ffname);
- /* Don't do anything for a directory. Might contain the file
- * explorer. */
+ // Don't do anything for a directory. Might contain the file
+ // explorer.
if (mch_isdir(buf->b_fname))
;
@@ -4116,8 +4114,8 @@ buf_check_timestamp(
mesg2 = _("See \":help W16\" for more info.");
}
else
- /* Only timestamp changed, store it to avoid a warning
- * in check_mtime() later. */
+ // Only timestamp changed, store it to avoid a warning
+ // in check_mtime() later.
buf->b_mtime_read = buf->b_mtime;
}
}
@@ -4145,8 +4143,8 @@ buf_check_timestamp(
tbuf = alloc(STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2);
sprintf(tbuf, mesg, path);
#ifdef FEAT_EVAL
- /* Set warningmsg here, before the unimportant and output-specific
- * mesg2 has been appended. */
+ // Set warningmsg here, before the unimportant and output-specific
+ // mesg2 has been appended.
set_vim_var_string(VV_WARNINGMSG, (char_u *)tbuf, -1);
#endif
#if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
@@ -4190,10 +4188,10 @@ buf_check_timestamp(
#ifdef FEAT_GUI
if (!focus)
#endif
- /* give the user some time to think about it */
+ // give the user some time to think about it
ui_delay(1004L, TRUE);
- /* don't redraw and erase the message */
+ // don't redraw and erase the message
redraw_cmdline = FALSE;
}
}
@@ -4207,7 +4205,7 @@ buf_check_timestamp(
if (reload)
{
- /* Reload the buffer. */
+ // Reload the buffer.
buf_reload(buf, orig_mode);
#ifdef FEAT_PERSISTENT_UNDO
if (buf->b_p_udf && buf->b_ffname != NULL)
@@ -4215,7 +4213,7 @@ buf_check_timestamp(
char_u hash[UNDO_HASH_SIZE];
buf_T *save_curbuf = curbuf;
- /* Any existing undo file is unusable, write it now. */
+ // Any existing undo file is unusable, write it now.
curbuf = buf;
u_compute_hash(hash);
u_write_undo(NULL, FALSE, buf, hash);
@@ -4224,13 +4222,13 @@ buf_check_timestamp(
#endif
}
- /* Trigger FileChangedShell when the file was changed in any way. */
+ // Trigger FileChangedShell when the file was changed in any way.
if (bufref_valid(&bufref) && retval != 0)
(void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST,
buf->b_fname, buf->b_fname, FALSE, buf);
#ifdef FEAT_GUI
- /* restore this in case an autocommand has set it; it would break
- * 'mousefocus' */
+ // restore this in case an autocommand has set it; it would break
+ // 'mousefocus'
need_mouse_correct = save_mouse_correct;
#endif
@@ -4256,12 +4254,12 @@ buf_reload(buf_T *buf, int orig_mode)
aco_save_T aco;
int flags = READ_NEW;
- /* set curwin/curbuf for "buf" and save some things */
+ // set curwin/curbuf for "buf" and save some things
aucmd_prepbuf(&aco, buf);
- /* We only want to read the text from the file, not reset the syntax
- * highlighting, clear marks, diff status, etc. Force the fileformat
- * and encoding to be the same. */
+ // We only want to read the text from the file, not reset the syntax
+ // highlighting, clear marks, diff status, etc. Force the fileformat
+ // and encoding to be the same.
if (prep_exarg(&ea, buf) == OK)
{
old_cursor = curwin->w_cursor;
@@ -4269,8 +4267,8 @@ buf_reload(buf_T *buf, int orig_mode)
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);
saved = u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE);
flags |= READ_KEEP_UNDO;
@@ -4287,12 +4285,12 @@ buf_reload(buf_T *buf, int orig_mode)
savebuf = NULL;
else
{
- /* Allocate a buffer without putting it in the buffer list. */
+ // Allocate a buffer without putting it in the buffer list.
savebuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
set_bufref(&bufref, savebuf);
if (savebuf != NULL && buf == curbuf)
{
- /* Open the memline. */
+ // Open the memline.
curbuf = savebuf;
curwin->w_buffer = savebuf;
saved = ml_open(curbuf);
@@ -4310,8 +4308,8 @@ buf_reload(buf_T *buf, int orig_mode)
if (saved == OK)
{
- curbuf->b_flags |= BF_CHECK_RO; /* check for RO again */
- keep_filetype = TRUE; /* don't detect 'filetype' */
+ curbuf->b_flags |= BF_CHECK_RO; // check for RO again
+ keep_filetype = TRUE; // don't detect 'filetype'
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0,
(linenr_T)0,
(linenr_T)MAXLNUM, &ea, flags) != OK)
@@ -4322,17 +4320,17 @@ buf_reload(buf_T *buf, int orig_mode)
semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
if (savebuf != NULL && bufref_valid(&bufref) && buf == curbuf)
{
- /* Put the text back from the save buffer. First
- * delete any lines that readfile() added. */
+ // Put the text back from the save buffer. First
+ // delete any lines that readfile() added.
while (!BUFEMPTY())
if (ml_delete(buf->b_ml.ml_line_count, FALSE) == FAIL)
break;
(void)move_lines(savebuf, buf);
}
}
- else if (buf == curbuf) /* "buf" still valid */
+ else if (buf == curbuf) // "buf" still valid
{
- /* Mark the buffer as unmodified and free undo info. */
+ // Mark the buffer as unmodified and free undo info.
unchanged(buf, TRUE, TRUE);
if ((flags & READ_KEEP_UNDO) == 0)
{
@@ -4341,7 +4339,7 @@ buf_reload(buf_T *buf, int orig_mode)
}
else
{
- /* Mark all undo states as changed. */
+ // Mark all undo states as changed.
u_unchanged(curbuf);
}
}
@@ -4352,12 +4350,12 @@ buf_reload(buf_T *buf, int orig_mode)
wipe_buffer(savebuf, FALSE);
#ifdef FEAT_DIFF
- /* Invalidate diff info if necessary. */
+ // Invalidate diff info if necessary.
diff_invalidate(curbuf);
#endif
- /* Restore the topline and cursor position and check it (lines may
- * have been removed). */
+ // Restore the topline and cursor position and check it (lines may
+ // have been removed).
if (old_topline > curbuf->b_ml.ml_line_count)
curwin->w_topline = curbuf->b_ml.ml_line_count;
else
@@ -4371,26 +4369,26 @@ buf_reload(buf_T *buf, int orig_mode)
win_T *wp;
tabpage_T *tp;
- /* Update folds unless they are defined manually. */
+ // Update folds unless they are defined manually.
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == curwin->w_buffer
&& !foldmethodIsManual(wp))
foldUpdateAll(wp);
}
#endif
- /* If the mode didn't change and 'readonly' was set, keep the old
- * value; the user probably used the ":view" command. But don't
- * reset it, might have had a read error. */
+ // If the mode didn't change and 'readonly' was set, keep the old
+ // value; the user probably used the ":view" command. But don't
+ // reset it, might have had a read error.
if (orig_mode == curbuf->b_orig_mode)
curbuf->b_p_ro |= old_ro;
- /* Modelines must override settings done by autocommands. */
+ // Modelines must override settings done by autocommands.
do_modelines(0);
}
- /* restore curwin/curbuf and a few other things */
+ // restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
- /* Careful: autocommands may have made "buf" invalid! */
+ // Careful: autocommands may have made "buf" invalid!
}
void
@@ -4412,7 +4410,7 @@ buf_store_time(buf_T *buf, stat_T *st, char_u *fname UNUSED)
void
write_lnum_adjust(linenr_T offset)
{
- if (curbuf->b_no_eol_lnum != 0) /* only if there is a missing eol */
+ if (curbuf->b_no_eol_lnum != 0) // only if there is a missing eol
curbuf->b_no_eol_lnum += offset;
}
@@ -4611,7 +4609,7 @@ delete_recursive(char_u *name)
#endif
#if defined(TEMPDIRNAMES) || defined(PROTO)
-static long temp_count = 0; /* Temp filename counter. */
+static long temp_count = 0; // Temp filename counter.
/*
* Delete the temp directory and all files it contains.
@@ -4621,7 +4619,7 @@ vim_deltempdir(void)
{
if (vim_tempdir != NULL)
{
- /* remove the trailing path separator */
+ // remove the trailing path separator
gettail(vim_tempdir)[-1] = NUL;
delete_recursive(vim_tempdir);
VIM_CLEAR(vim_tempdir);
@@ -4661,11 +4659,11 @@ vim_settempdir(char_u *tempdir)
*/
char_u *
vim_tempname(
- int extra_char UNUSED, /* char to use in the name instead of '?' */
+ int extra_char UNUSED, // char to use in the name instead of '?'
int keep UNUSED)
{
#ifdef USE_TMPNAM
- char_u itmp[L_tmpnam]; /* use tmpnam() */
+ char_u itmp[L_tmpnam]; // use tmpnam()
#elif defined(MSWIN)
WCHAR itmp[TEMPNAMELEN];
#else
@@ -4699,22 +4697,22 @@ vim_tempname(
long off;
# endif
- /* Expand $TMP, leave room for "/v1100000/999999999".
- * Skip the directory check if the expansion fails. */
+ // Expand $TMP, leave room for "/v1100000/999999999".
+ // Skip the directory check if the expansion fails.
expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
if (itmp[0] != '$' && mch_isdir(itmp))
{
- /* directory exists */
+ // directory exists
add_pathsep(itmp);
# ifdef HAVE_MKDTEMP
{
# if defined(UNIX) || defined(VMS)
- /* Make sure the umask doesn't remove the executable bit.
- * "repl" has been reported to use "177". */
+ // Make sure the umask doesn't remove the executable bit.
+ // "repl" has been reported to use "177".
mode_t umask_save = umask(077);
# endif
- /* Leave room for filename */
+ // Leave room for filename
STRCAT(itmp, "vXXXXXX");
if (mkdtemp((char *)itmp) != NULL)
vim_settempdir(itmp);
@@ -4723,15 +4721,15 @@ vim_tempname(
# endif
}
# else
- /* Get an arbitrary number of up to 6 digits. When it's
- * unlikely that it already exists it will be faster,
- * otherwise it doesn't matter. The use of mkdir() avoids any
- * security problems because of the predictable number. */
+ // Get an arbitrary number of up to 6 digits. When it's
+ // unlikely that it already exists it will be faster,
+ // otherwise it doesn't matter. The use of mkdir() avoids any
+ // security problems because of the predictable number.
nr = (mch_get_pid() + (long)time(NULL)) % 1000000L;
itmplen = STRLEN(itmp);
- /* Try up to 10000 different values until we find a name that
- * doesn't exist. */
+ // Try up to 10000 different values until we find a name that
+ // doesn't exist.
for (off = 0; off < 10000L; ++off)
{
int r;
@@ -4741,15 +4739,15 @@ vim_tempname(
sprintf((char *)itmp + itmplen, "v%ld", nr + off);
# ifndef EEXIST
- /* If mkdir() does not set errno to EEXIST, check for
- * existing file here. There is a race condition then,
- * although it's fail-safe. */
+ // If mkdir() does not set errno to EEXIST, check for
+ // existing file here. There is a race condition then,
+ // although it's fail-safe.
if (mch_stat((char *)itmp, &st) >= 0)
continue;
# endif
# if defined(UNIX) || defined(VMS)
- /* Make sure the umask doesn't remove the executable bit.
- * "repl" has been reported to use "177". */
+ // Make sure the umask doesn't remove the executable bit.
+ // "repl" has been reported to use "177".
umask_save = umask(077);
# endif
r = vim_mkdir(itmp, 0700);
@@ -4762,14 +4760,14 @@ vim_tempname(
break;
}
# ifdef EEXIST
- /* If the mkdir() didn't fail because the file/dir exists,
- * we probably can't create any dir here, try another
- * place. */
+ // If the mkdir() didn't fail because the file/dir exists,
+ // we probably can't create any dir here, try another
+ // place.
if (errno != EEXIST)
# endif
break;
}
-# endif /* HAVE_MKDTEMP */
+# endif // HAVE_MKDTEMP
if (vim_tempdir != NULL)
break;
}
@@ -4778,15 +4776,15 @@ vim_tempname(
if (vim_tempdir != NULL)
{
- /* There is no need to check if the file exists, because we own the
- * directory and nobody else creates a file in it. */
+ // There is no need to check if the file exists, because we own the
+ // directory and nobody else creates a file in it.
sprintf((char *)itmp, "%s%ld", vim_tempdir, temp_count++);
return vim_strsave(itmp);
}
return NULL;
-#else /* TEMPDIRNAMES */
+#else // TEMPDIRNAMES
# ifdef MSWIN
WCHAR wszTempFile[_MAX_PATH + 1];
@@ -4801,7 +4799,7 @@ vim_tempname(
wszTempFile[1] = NUL;
}
wcscpy(buf4, L"VIM");
- buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */
+ buf4[2] = extra_char; // make it "VIa", "VIb", etc.
if (GetTempFileNameW(wszTempFile, buf4, 0, itmp) == 0)
return NULL;
if (!keep)
@@ -4823,7 +4821,7 @@ vim_tempname(
# ifdef USE_TMPNAM
char_u *p;
- /* tmpnam() will make its own name */
+ // tmpnam() will make its own name
p = tmpnam((char *)itmp);
if (p == NULL || *p == NUL)
return NULL;
@@ -4831,15 +4829,14 @@ vim_tempname(
char_u *p;
# ifdef VMS_TEMPNAM
- /* mktemp() is not working on VMS. It seems to be
- * a do-nothing function. Therefore we use tempnam().
- */
+ // mktemp() is not working on VMS. It seems to be
+ // a do-nothing function. Therefore we use tempnam().
sprintf((char *)itmp, "VIM%c", extra_char);
p = (char_u *)tempnam("tmp:", (char *)itmp);
if (p != NULL)
{
- /* VMS will use '.LIS' if we don't explicitly specify an extension,
- * and VIM will then be unable to find the file later */
+ // VMS will use '.LIS' if we don't explicitly specify an extension,
+ // and VIM will then be unable to find the file later
STRCPY(itmp, p);
STRCAT(itmp, ".txt");
free(p);
@@ -4857,7 +4854,7 @@ vim_tempname(
return vim_strsave(itmp);
# endif // MSWIN
-#endif /* TEMPDIRNAMES */
+#endif // TEMPDIRNAMES
}
#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
@@ -4873,7 +4870,7 @@ forward_slash(char_u *fname)
if (path_with_url(fname))
return;
for (p = fname; *p != NUL; ++p)
- /* The Big5 encoding can have '\' in the trail byte. */
+ // The Big5 encoding can have '\' in the trail byte.
if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
++p;
else if (*p == '\\')
@@ -4890,17 +4887,17 @@ forward_slash(char_u *fname)
*/
int
match_file_pat(
- char_u *pattern, /* pattern to match with */
- regprog_T **prog, /* pre-compiled regprog or NULL */
- char_u *fname, /* full path of file name */
- char_u *sfname, /* short file name or NULL */
- char_u *tail, /* tail of path */
- int allow_dirs) /* allow matching with dir */
+ char_u *pattern, // pattern to match with
+ regprog_T **prog, // pre-compiled regprog or NULL
+ char_u *fname, // full path of file name
+ char_u *sfname, // short file name or NULL
+ char_u *tail, // tail of path
+ int allow_dirs) // allow matching with dir
{
regmatch_T regmatch;
int result = FALSE;
- regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */
+ regmatch.rm_ic = p_fic; // ignore case if 'fileignorecase' is set
if (prog != NULL)
regmatch.regprog = *prog;
else
@@ -4945,7 +4942,7 @@ match_file_list(char_u *list, char_u *sfname, char_u *ffname)
tail = gettail(sfname);
- /* try all patterns in 'wildignore' */
+ // try all patterns in 'wildignore'
p = list;
while (*p)
{
@@ -4975,11 +4972,11 @@ match_file_list(char_u *list, char_u *sfname, char_u *ffname)
char_u *
file_pat_to_reg_pat(
char_u *pat,
- char_u *pat_end, /* first char after pattern or NULL */
- char *allow_dirs, /* Result passed back out in here */
- int no_bslash UNUSED) /* Don't use a backward slash as pathsep */
+ char_u *pat_end, // first char after pattern or NULL
+ char *allow_dirs, // Result passed back out in here
+ int no_bslash UNUSED) // Don't use a backward slash as pathsep
{
- int size = 2; /* '^' at start, '$' at end */
+ int size = 2; // '^' at start, '$' at end
char_u *endp;
char_u *reg_pat;
char_u *p;
@@ -5002,12 +4999,12 @@ file_pat_to_reg_pat(
case '{':
case '}':
case '~':
- size += 2; /* extra backslash */
+ size += 2; // extra backslash
break;
#ifdef BACKSLASH_IN_FILENAME
case '\\':
case '/':
- size += 4; /* could become "[\/]" */
+ size += 4; // could become "[\/]"
break;
#endif
default:
@@ -5045,7 +5042,7 @@ file_pat_to_reg_pat(
case '*':
reg_pat[i++] = '.';
reg_pat[i++] = '*';
- while (p[1] == '*') /* "**" matches like "*" */
+ while (p[1] == '*') // "**" matches like "*"
++p;
break;
case '.':
@@ -5062,12 +5059,11 @@ file_pat_to_reg_pat(
#ifdef BACKSLASH_IN_FILENAME
if (!no_bslash)
{
- /* translate:
- * "\x" to "\\x" e.g., "dir\file"
- * "\*" to "\\.*" e.g., "dir\*.c"
- * "\?" to "\\." e.g., "dir\??.c"
- * "\+" to "\+" e.g., "fileX\+.c"
- */
+ // translate:
+ // "\x" to "\\x" e.g., "dir\file"
+ // "\*" to "\\.*" e.g., "dir\*.c"
+ // "\?" to "\\." e.g., "dir\??.c"
+ // "\+" to "\+" e.g., "fileX\+.c"
if ((vim_isfilec(p[1]) || p[1] == '*' || p[1] == '?')
&& p[1] != '+')
{
@@ -5081,16 +5077,15 @@ file_pat_to_reg_pat(
}
}
#endif
- /* Undo escaping from ExpandEscape():
- * foo\?bar -> foo?bar
- * foo\%bar -> foo%bar
- * foo\,bar -> foo,bar
- * foo\ bar -> foo bar
- * Don't unescape \, * and others that are also special in a
- * regexp.
- * An escaped { must be unescaped since we use magic not
- * verymagic. Use "\\\{n,m\}"" to get "\{n,m}".
- */
+ // Undo escaping from ExpandEscape():
+ // foo\?bar -> foo?bar
+ // foo\%bar -> foo%bar
+ // foo\,bar -> foo,bar
+ // foo\ bar -> foo bar
+ // Don't unescape \, * and others that are also special in a
+ // regexp.
+ // An escaped { must be unescaped since we use magic not
+ // verymagic. Use "\\\{n,m\}"" to get "\{n,m}".
if (*++p == '?'
#ifdef BACKSLASH_IN_FILENAME
&& no_bslash
@@ -5200,8 +5195,8 @@ write_eintr(int fd, void *buf, size_t bufsize)
long ret = 0;
long wlen;
- /* Repeat the write() so long it didn't fail, other than being interrupted
- * by a signal. */
+ // Repeat the write() so long it didn't fail, other than being interrupted
+ // by a signal.
while (ret < (long)bufsize)
{
wlen = vim_write(fd, (char *)buf + ret, bufsize - ret);
diff --git a/src/filepath.c b/src/filepath.c
index 8da6e1772..0fc1a5cad 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -162,7 +162,7 @@ shortpath_for_invalid_fname(
* path with the remaining path at the tail.
*/
- /* Compute the length of the new path. */
+ // Compute the length of the new path.
sfx_len = (int)(save_endp - endp) + 1;
new_len = len + sfx_len;
@@ -2367,7 +2367,7 @@ fullpathcmp(
r2 = mch_stat((char *)s2, &st2);
if (r1 != 0 && r2 != 0)
{
- /* if mch_stat() doesn't work, may compare the names */
+ // if mch_stat() doesn't work, may compare the names
if (checkname)
{
if (fnamecmp(exp1, s2) == 0)
@@ -3689,7 +3689,7 @@ gen_expand_wildcards(
void
addfile(
garray_T *gap,
- char_u *f, /* filename */
+ char_u *f, // filename
int flags)
{
char_u *p;
diff --git a/src/findfile.c b/src/findfile.c
index ddb4d10d2..dba547da1 100644
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -968,7 +968,7 @@ vim_findfile(void *search_ctx_arg)
{
if (!path_with_url(stackp->ffs_filearray[i])
&& !mch_isdir(stackp->ffs_filearray[i]))
- continue; /* not a directory */
+ continue; // not a directory
// prepare the filename to be checked for existence
// below
@@ -2690,7 +2690,7 @@ simplify_filename(char_u *filename)
char_u saved_char;
stat_T st;
- /* Don't strip for an erroneous file name. */
+ // Don't strip for an erroneous file name.
if (!stripping_disabled)
{
// If the preceding component does not exist in the file
@@ -2827,7 +2827,7 @@ f_simplify(typval_T *argvars, typval_T *rettv)
p = tv_get_string(&argvars[0]);
rettv->vval.v_string = vim_strsave(p);
- simplify_filename(rettv->vval.v_string); /* simplify in place */
+ simplify_filename(rettv->vval.v_string); // simplify in place
rettv->v_type = VAR_STRING;
}
#endif // FEAT_EVAL
diff --git a/src/fold.c b/src/fold.c
index 8cadd4327..d91203c75 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -16,8 +16,8 @@
#if defined(FEAT_FOLDING) || defined(PROTO)
-/* local declarations. {{{1 */
-/* typedef fold_T {{{2 */
+// local declarations. {{{1
+// typedef fold_T {{{2
/*
* The toplevel folds for each window are stored in the w_folds growarray.
* Each toplevel fold can contain an array of second level folds in the
@@ -26,23 +26,23 @@
*/
typedef struct
{
- linenr_T fd_top; /* first line of fold; for nested fold
- * relative to parent */
- linenr_T fd_len; /* number of lines in the fold */
- garray_T fd_nested; /* array of nested folds */
- char fd_flags; /* see below */
- char fd_small; /* TRUE, FALSE or MAYBE: fold smaller than
- 'foldminlines'; MAYBE applies to nested
- folds too */
+ linenr_T fd_top; // first line of fold; for nested fold
+ // relative to parent
+ linenr_T fd_len; // number of lines in the fold
+ garray_T fd_nested; // array of nested folds
+ char fd_flags; // see below
+ char fd_small; // TRUE, FALSE or MAYBE: fold smaller than
+ // 'foldminlines'; MAYBE applies to nested
+ // folds too
} fold_T;
-#define FD_OPEN 0 /* fold is open (nested ones can be closed) */
-#define FD_CLOSED 1 /* fold is closed */
-#define FD_LEVEL 2 /* depends on 'foldlevel' (nested folds too) */
+#define FD_OPEN 0 // fold is open (nested ones can be closed)
+#define FD_CLOSED 1 // fold is closed
+#define FD_LEVEL 2 // depends on 'foldlevel' (nested folds too)
-#define MAX_LEVEL 20 /* maximum fold depth */
+#define MAX_LEVEL 20 // maximum fold depth
-/* static functions {{{2 */
+// static functions {{{2
static void newFoldLevelWin(win_T *wp);
static int checkCloseRec(garray_T *gap, linenr_T lnum, int level);
static int foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp);
@@ -84,17 +84,17 @@ static linenr_T invalid_bot = (linenr_T)0;
static linenr_T prev_lnum = 0;
static int prev_lnum_lvl = -1;
-/* Flags used for "done" argument of setManualFold. */
+// Flags used for "done" argument of setManualFold.
#define DONE_NOTHING 0
-#define DONE_ACTION 1 /* did close or open a fold */
-#define DONE_FOLD 2 /* did find a fold */
+#define DONE_ACTION 1 // did close or open a fold
+#define DONE_FOLD 2 // did find a fold
static int foldstartmarkerlen;
static char_u *foldendmarker;
static int foldendmarkerlen;
-/* Exported folding functions. {{{1 */
-/* copyFoldingState() {{{2 */
+// Exported folding functions. {{{1
+// copyFoldingState() {{{2
/*
* Copy that folding state from window "wp_from" to window "wp_to".
@@ -107,19 +107,19 @@ copyFoldingState(win_T *wp_from, win_T *wp_to)
cloneFoldGrowArray(&wp_from->w_folds, &wp_to->w_folds);
}
-/* hasAnyFolding() {{{2 */
+// hasAnyFolding() {{{2
/*
* Return TRUE if there may be folded lines in the current window.
*/
int
hasAnyFolding(win_T *win)
{
- /* very simple now, but can become more complex later */
+ // very simple now, but can become more complex later
return (win->w_p_fen
&& (!foldmethodIsManual(win) || win->w_folds.ga_len > 0));
}
-/* hasFolding() {{{2 */
+// hasFolding() {{{2
/*
* Return TRUE if line "lnum" in the current window is part of a closed
* fold.
@@ -132,15 +132,15 @@ hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
return hasFoldingWin(curwin, lnum, firstp, lastp, TRUE, NULL);
}
-/* hasFoldingWin() {{{2 */
+// hasFoldingWin() {{{2
int
hasFoldingWin(
win_T *win,
linenr_T lnum,
linenr_T *firstp,
linenr_T *lastp,
- int cache, /* when TRUE: use cached values of window */
- foldinfo_T *infop) /* where to store fold info */
+ int cache, // when TRUE: use cached values of window
+ foldinfo_T *infop) // where to store fold info
{
int had_folded = FALSE;
linenr_T first = 0;
@@ -192,25 +192,25 @@ hasFoldingWin(
if (!foldFind(gap, lnum_rel, &fp))
break;
- /* Remember lowest level of fold that starts in "lnum". */
+ // Remember lowest level of fold that starts in "lnum".
if (lnum_rel == fp->fd_top && low_level == 0)
low_level = level + 1;
first += fp->fd_top;
last += fp->fd_top;
- /* is this fold closed? */
+ // is this fold closed?
had_folded = check_closed(win, fp, &use_level, level,
&maybe_small, lnum - lnum_rel);
if (had_folded)
{
- /* Fold closed: Set last and quit loop. */
+ // Fold closed: Set last and quit loop.
last += fp->fd_len - 1;
break;
}
- /* Fold found, but it's open: Check nested folds. Line number is
- * relative to containing fold. */
+ // Fold found, but it's open: Check nested folds. Line number is
+ // relative to containing fold.
gap = &fp->fd_nested;
lnum_rel -= fp->fd_top;
++level;
@@ -243,7 +243,7 @@ hasFoldingWin(
return TRUE;
}
-/* foldLevel() {{{2 */
+// foldLevel() {{{2
#ifdef FEAT_EVAL
/*
* Return fold level at line number "lnum" in the current window.
@@ -251,8 +251,8 @@ hasFoldingWin(
static int
foldLevel(linenr_T lnum)
{
- /* While updating the folds lines between invalid_top and invalid_bot have
- * an undefined fold level. Otherwise update the folds first. */
+ // While updating the folds lines between invalid_top and invalid_bot have
+ // an undefined fold level. Otherwise update the folds first.
if (invalid_top == (linenr_T)0)
checkupdate(curwin);
else if (lnum == prev_lnum && prev_lnum_lvl >= 0)
@@ -260,7 +260,7 @@ foldLevel(linenr_T lnum)
else if (lnum >= invalid_top && lnum <= invalid_bot)
return -1;
- /* Return quickly when there is no folding at all in this window. */
+ // Return quickly when there is no folding at all in this window.
if (!hasAnyFolding(curwin))
return 0;
@@ -268,7 +268,7 @@ foldLevel(linenr_T lnum)
}
#endif
-/* lineFolded() {{{2 */
+// lineFolded() {{{2
/*
* Low level function to check if a line is folded. Doesn't use any caching.
* Return TRUE if line is folded.
@@ -281,7 +281,7 @@ lineFolded(win_T *win, linenr_T lnum)
return foldedCount(win, lnum, NULL) != 0;
}
-/* foldedCount() {{{2 */
+// foldedCount() {{{2
/*
* Count the number of lines that are folded at line number "lnum".
* Normally "lnum" is the first line of a possible fold, and the returned
@@ -300,7 +300,7 @@ foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop)
return 0;
}
-/* foldmethodIsManual() {{{2 */
+// foldmethodIsManual() {{{2
/*
* Return TRUE if 'foldmethod' is "manual"
*/
@@ -310,7 +310,7 @@ foldmethodIsManual(win_T *wp)
return (wp->w_p_fdm[3] == 'u');
}
-/* foldmethodIsIndent() {{{2 */
+// foldmethodIsIndent() {{{2
/*
* Return TRUE if 'foldmethod' is "indent"
*/
@@ -320,7 +320,7 @@ foldmethodIsIndent(win_T *wp)
return (wp->w_p_fdm[0] == 'i');
}
-/* foldmethodIsExpr() {{{2 */
+// foldmethodIsExpr() {{{2
/*
* Return TRUE if 'foldmethod' is "expr"
*/
@@ -330,7 +330,7 @@ foldmethodIsExpr(win_T *wp)
return (wp->w_p_fdm[1] == 'x');
}
-/* foldmethodIsMarker() {{{2 */
+// foldmethodIsMarker() {{{2
/*
* Return TRUE if 'foldmethod' is "marker"
*/
@@ -340,7 +340,7 @@ foldmethodIsMarker(win_T *wp)
return (wp->w_p_fdm[2] == 'r');
}
-/* foldmethodIsSyntax() {{{2 */
+// foldmethodIsSyntax() {{{2
/*
* Return TRUE if 'foldmethod' is "syntax"
*/
@@ -350,7 +350,7 @@ foldmethodIsSyntax(win_T *wp)
return (wp->w_p_fdm[0] == 's');
}
-/* foldmethodIsDiff() {{{2 */
+// foldmethodIsDiff() {{{2
/*
* Return TRUE if 'foldmethod' is "diff"
*/
@@ -360,7 +360,7 @@ foldmethodIsDiff(win_T *wp)
return (wp->w_p_fdm[0] == 'd');
}
-/* closeFold() {{{2 */
+// closeFold() {{{2
/*
* Close fold for current window at line "lnum".
* Repeat "count" times.
@@ -371,7 +371,7 @@ closeFold(linenr_T lnum, long count)
setFoldRepeat(lnum, count, FALSE);
}
-/* closeFoldRecurse() {{{2 */
+// closeFoldRecurse() {{{2
/*
* Close fold for current window at line "lnum" recursively.
*/
@@ -381,7 +381,7 @@ closeFoldRecurse(linenr_T lnum)
(void)setManualFold(lnum, FALSE, TRUE, NULL);
}
-/* opFoldRange() {{{2 */
+// opFoldRange() {{{2
/*
* Open or Close folds for current window in lines "first" to "last".
* Used for "zo", "zO", "zc" and "zC" in Visual mode.
@@ -390,35 +390,35 @@ closeFoldRecurse(linenr_T lnum)
opFoldRange(
linenr_T first,
linenr_T last,
- int opening, /* TRUE to open, FALSE to close */
- int recurse, /* TRUE to do it recursively */
- int had_visual) /* TRUE when Visual selection used */
+ int opening, // TRUE to open, FALSE to close
+ int recurse, // TRUE to do it recursively
+ int had_visual) // TRUE when Visual selection used
{
- int done = DONE_NOTHING; /* avoid error messages */
+ int done = DONE_NOTHING; // avoid error messages
linenr_T lnum;
linenr_T lnum_next;
for (lnum = first; lnum <= last; lnum = lnum_next + 1)
{
lnum_next = lnum;
- /* Opening one level only: next fold to open is after the one going to
- * be opened. */
+ // Opening one level only: next fold to open is after the one going to
+ // be opened.
if (opening && !recurse)
(void)hasFolding(lnum, NULL, &lnum_next);
(void)setManualFold(lnum, opening, recurse, &done);
- /* Closing one level only: next line to close a fold is after just
- * closed fold. */
+ // Closing one level only: next line to close a fold is after just
+ // closed fold.
if (!opening && !recurse)
(void)hasFolding(lnum, NULL, &lnum_next);
}
if (done == DONE_NOTHING)
emsg(_(e_nofold));
- /* Force a redraw to remove the Visual highlighting. */
+ // Force a redraw to remove the Visual highlighting.
if (had_visual)
redraw_curbuf_later(INVERTED);
}
-/* openFold() {{{2 */
+// openFold() {{{2
/*
* Open fold for current window at line "lnum".
* Repeat "count" times.
@@ -429,7 +429,7 @@ openFold(linenr_T lnum, long count)
setFoldRepeat(lnum, count, TRUE);
}
-/* openFoldRecurse() {{{2 */
+// openFoldRecurse() {{{2
/*
* Open fold for current window at line "lnum" recursively.
*/
@@ -439,7 +439,7 @@ openFoldRecurse(linenr_T lnum)
(void)setManualFold(lnum, TRUE, TRUE, NULL);
}
-/* foldOpenCursor() {{{2 */
+// foldOpenCursor() {{{2
/*
* Open folds until the cursor line is not in a closed fold.
*/
@@ -459,7 +459,7 @@ foldOpenCursor(void)
}
}
-/* newFoldLevel() {{{2 */
+// newFoldLevel() {{{2
/*
* Set new foldlevel for current window.
*/
@@ -497,9 +497,9 @@ newFoldLevelWin(win_T *wp)
checkupdate(wp);
if (wp->w_fold_manual)
{
- /* Set all flags for the first level of folds to FD_LEVEL. Following
- * manual open/close will then change the flags to FD_OPEN or
- * FD_CLOSED for those folds that don't use 'foldlevel'. */
+ // Set all flags for the first level of folds to FD_LEVEL. Following
+ // manual open/close will then change the flags to FD_OPEN or
+ // FD_CLOSED for those folds that don't use 'foldlevel'.
fp = (fold_T *)wp->w_folds.ga_data;
for (i = 0; i < wp->w_folds.ga_len; ++i)
fp[i].fd_flags = FD_LEVEL;
@@ -508,14 +508,14 @@ newFoldLevelWin(win_T *wp)
changed_window_setting_win(wp);
}
-/* foldCheckClose() {{{2 */
+// foldCheckClose() {{{2
/*
* Apply 'foldlevel' to all folds that don't contain the cursor.
*/
void
foldCheckClose(void)
{
- if (*p_fcl != NUL) /* can only be "all" right now */
+ if (*p_fcl != NUL) // can only be "all" right now
{
checkupdate(curwin);
if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
@@ -524,7 +524,7 @@ foldCheckClose(void)
}
}
-/* checkCloseRec() {{{2 */
+// checkCloseRec() {{{2
static int
checkCloseRec(garray_T *gap, linenr_T lnum, int level)
{
@@ -535,7 +535,7 @@ checkCloseRec(garray_T *gap, linenr_T lnum, int level)
fp = (fold_T *)gap->ga_data;
for (i = 0; i < gap->ga_len; ++i)
{
- /* Only manually opened folds may need to be closed. */
+ // Only manually opened folds may need to be closed.
if (fp[i].fd_flags == FD_OPEN)
{
if (level <= 0 && (lnum < fp[i].fd_top
@@ -552,7 +552,7 @@ checkCloseRec(garray_T *gap, linenr_T lnum, int level)
return retval;
}
-/* foldCreateAllowed() {{{2 */
+// foldCreateAllowed() {{{2
/*
* Return TRUE if it's allowed to manually create or delete a fold.
* Give an error message and return FALSE if not.
@@ -569,7 +569,7 @@ foldManualAllowed(int create)
return FALSE;
}
-/* foldCreate() {{{2 */
+// foldCreate() {{{2
/*
* Create a fold from line "start" to line "end" (inclusive) in the current
* window.
@@ -590,14 +590,14 @@ foldCreate(linenr_T start, linenr_T end)
if (start > end)
{
- /* reverse the range */
+ // reverse the range
end = start_rel;
start = end_rel;
start_rel = start;
end_rel = end;
}
- /* When 'foldmethod' is "marker" add markers, which creates the folds. */
+ // When 'foldmethod' is "marker" add markers, which creates the folds.
if (foldmethodIsMarker(curwin))
{
foldCreateMarkers(start, end);
@@ -606,7 +606,7 @@ foldCreate(linenr_T start, linenr_T end)
checkupdate(curwin);
- /* Find the place to insert the new fold. */
+ // Find the place to insert the new fold.
gap = &curwin->w_folds;
for (;;)
{
@@ -614,7 +614,7 @@ foldCreate(linenr_T start, linenr_T end)
break;
if (fp->fd_top + fp->fd_len > end_rel)
{
- /* New fold is completely inside this fold: Go one level deeper. */
+ // New fold is completely inside this fold: Go one level deeper.
gap = &fp->fd_nested;
start_rel -= fp->fd_top;
end_rel -= fp->fd_top;
@@ -630,8 +630,8 @@ foldCreate(linenr_T start, linenr_T end)
}
else
{
- /* This fold and new fold overlap: Insert here and move some folds
- * inside the new fold. */
+ // This fold and new fold overlap: Insert here and move some folds
+ // inside the new fold.
break;
}
}
@@ -642,45 +642,44 @@ foldCreate(linenr_T start, linenr_T end)
fp = (fold_T *)gap->ga_data + i;
ga_init2(&fold_ga, (int)sizeof(fold_T), 10);
- /* Count number of folds that will be contained in the new fold. */
+ // Count number of folds that will be contained in the new fold.
for (cont = 0; i + cont < gap->ga_len; ++cont)
if (fp[cont].fd_top > end_rel)
break;
if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
{
- /* If the first fold starts before the new fold, let the new fold
- * start there. Otherwise the existing fold would change. */
+ // If the first fold starts before the new fold, let the new fold
+ // start there. Otherwise the existing fold would change.
if (start_rel > fp->fd_top)
start_rel = fp->fd_top;
- /* When last contained fold isn't completely contained, adjust end
- * of new fold. */
+ // When last contained fold isn't completely contained, adjust end
+ // of new fold.
if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
- /* Move contained folds to inside new fold. */
+ // Move contained folds to inside new fold.
mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
fold_ga.ga_len += cont;
i += cont;
- /* Adjust line numbers in contained folds to be relative to the
- * new fold. */
+ // Adjust line numbers in contained folds to be relative to the
+ // new fold.
for (j = 0; j < cont; ++j)
((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
}
- /* Move remaining entries to after the new fold. */
+ // Move remaining entries to after the new fold.
if (i < gap->ga_len)
mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
sizeof(fold_T) * (gap->ga_len - i));
gap->ga_len = gap->ga_len + 1 - cont;
- /* insert new fold */
+ // insert new fold
fp->fd_nested = fold_ga;
fp->fd_top = start_rel;
fp->fd_len = end_rel - start_rel + 1;
- /* We want the new fold to be closed. If it would remain open because
- * of using 'foldlevel', need to adjust fd_flags of containing folds.
- */
+ // We want the new fold to be closed. If it would remain open because
+ // of using 'foldlevel', need to adjust fd_flags of containing folds.
if (use_level && !closed && level < curwin->w_p_fdl)
closeFold(start, 1L);
if (!use_level)
@@ -688,12 +687,12 @@ foldCreate(linenr_T start, linenr_T end)
fp->fd_flags = FD_CLOSED;
fp->fd_small = MAYBE;
- /* redraw */
+ // redraw
changed_window_setting();
}
}
-/* deleteFold() {{{2 */
+// deleteFold() {{{2
/*
* Delete a fold at line "start" in the current window.
* When "end" is not 0, delete all folds from "start" to "end".
@@ -704,7 +703,7 @@ deleteFold(
linenr_T start,
linenr_T end,
int recursive,
- int had_visual) /* TRUE when Visual selection used */
+ int had_visual) // TRUE when Visual selection used
{
garray_T *gap;
fold_T *fp;
@@ -724,7 +723,7 @@ deleteFold(
while (lnum <= end)
{
- /* Find the deepest fold for "start". */
+ // Find the deepest fold for "start".
gap = &curwin->w_folds;
found_ga = NULL;
lnum_off = 0;
@@ -733,17 +732,17 @@ deleteFold(
{
if (!foldFind(gap, lnum - lnum_off, &fp))
break;
- /* lnum is inside this fold, remember info */
+ // lnum is inside this fold, remember info
found_ga = gap;
found_fp = fp;
found_off = lnum_off;
- /* if "lnum" is folded, don't check nesting */
+ // if "lnum" is folded, don't check nesting
if (check_closed(curwin, fp, &use_level, level,
&maybe_small, lnum_off))
break;
- /* check nested folds */
+ // check nested folds
gap = &fp->fd_nested;
lnum_off += fp->fd_top;
++level;
@@ -771,26 +770,26 @@ deleteFold(
}
did_one = TRUE;
- /* redraw window */
+ // redraw window
changed_window_setting();
}
}
if (!did_one)
{
emsg(_(e_nofold));
- /* Force a redraw to remove the Visual highlighting. */
+ // Force a redraw to remove the Visual highlighting.
if (had_visual)
redraw_curbuf_later(INVERTED);
}
else
- /* Deleting markers may make cursor column invalid. */
+ // Deleting markers may make cursor column invalid.
check_cursor_col();
if (last_lnum > 0)
changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L);
}
-/* clearFolding() {{{2 */
+// clearFolding() {{{2
/*
* Remove all folding for window "win".
*/
@@ -801,7 +800,7 @@ clearFolding(win_T *win)
win->w_foldinvalid = FALSE;
}
-/* foldUpdate() {{{2 */
+// foldUpdate() {{{2
/*
* Update folds for changes in the buffer of a window.
* Note that inserted/deleted lines must have already been taken care of by
@@ -821,7 +820,7 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
return;
#endif
- /* Mark all folds from top to bot as maybe-small. */
+ // Mark all folds from top to bot as maybe-small.
(void)foldFind(&wp->w_folds, top, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top < bot)
@@ -840,14 +839,14 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
{
int save_got_int = got_int;
- /* reset got_int here, otherwise it won't work */
+ // reset got_int here, otherwise it won't work
got_int = FALSE;
foldUpdateIEMS(wp, top, bot);
got_int |= save_got_int;
}
}
-/* foldUpdateAll() {{{2 */
+// foldUpdateAll() {{{2
/*
* Update all lines in a window for folding.
* Used when a fold setting changes or after reloading the buffer.
@@ -861,7 +860,7 @@ foldUpdateAll(win_T *win)
redraw_win_later(win, NOT_VALID);
}
-/* foldMoveTo() {{{2 */
+// foldMoveTo() {{{2
/*
* If "updown" is FALSE: Move to the start or end of the fold.
* If "updown" is TRUE: move to fold at the same level.
@@ -870,7 +869,7 @@ foldUpdateAll(win_T *win)
int
foldMoveTo(
int updown,
- int dir, /* FORWARD or BACKWARD */
+ int dir, // FORWARD or BACKWARD
long count)
{
long n;
@@ -887,11 +886,11 @@ foldMoveTo(
checkupdate(curwin);
- /* Repeat "count" times. */
+ // Repeat "count" times.
for (n = 0; n < count; ++n)
{
- /* Find nested folds. Stop when a fold is closed. The deepest fold
- * that moves the cursor is used. */
+ // Find nested folds. Stop when a fold is closed. The deepest fold
+ // that moves the cursor is used.
lnum_off = 0;
gap = &curwin->w_folds;
use_level = FALSE;
@@ -906,8 +905,8 @@ foldMoveTo(
if (!updown)
break;
- /* When moving up, consider a fold above the cursor; when
- * moving down consider a fold below the cursor. */
+ // When moving up, consider a fold above the cursor; when
+ // moving down consider a fold below the cursor.
if (dir == FORWARD)
{
if (fp - (fold_T *)gap->ga_data >= gap->ga_len)
@@ -919,19 +918,19 @@ foldMoveTo(
if (fp == (fold_T *)gap->ga_data)
break;
}
- /* don't look for contained folds, they will always move
- * the cursor too far. */
+ // don't look for contained folds, they will always move
+ // the cursor too far.
last = TRUE;
}
if (!last)
{
- /* Check if this fold is closed. */
+ // Check if this fold is closed.
if (check_closed(curwin, fp, &use_level, level,
&maybe_small, lnum_off))
last = TRUE;
- /* "[z" and "]z" stop at closed fold */
+ // "[z" and "]z" stop at closed fold
if (last && !updown)
break;
}
@@ -940,7 +939,7 @@ foldMoveTo(
{
if (dir == FORWARD)
{
- /* to start of next fold if there is one */
+ // to start of next fold if there is one
if (fp + 1 - (fold_T *)gap->ga_data < gap->ga_len)
{
lnum = fp[1].fd_top + lnum_off;
@@ -950,7 +949,7 @@ foldMoveTo(
}
else
{
- /* to end of previous fold if there is one */
+ // to end of previous fold if there is one
if (fp > (fold_T *)gap->ga_data)
{
lnum = fp[-1].fd_top + lnum_off + fp[-1].fd_len - 1;
@@ -961,8 +960,8 @@ foldMoveTo(
}
else
{
- /* Open fold found, set cursor to its start/end and then check
- * nested folds. */
+ // Open fold found, set cursor to its start/end and then check
+ // nested folds.
if (dir == FORWARD)
{
lnum = fp->fd_top + lnum_off + fp->fd_len - 1;
@@ -980,7 +979,7 @@ foldMoveTo(
if (last)
break;
- /* Check nested folds (if any). */
+ // Check nested folds (if any).
gap = &fp->fd_nested;
lnum_off += fp->fd_top;
++level;
@@ -1000,7 +999,7 @@ foldMoveTo(
return retval;
}
-/* foldInitWin() {{{2 */
+// foldInitWin() {{{2
/*
* Init the fold info in a new window.
*/
@@ -1010,7 +1009,7 @@ foldInitWin(win_T *new_win)
ga_init2(&new_win->w_folds, (int)sizeof(fold_T), 10);
}
-/* find_wl_entry() {{{2 */
+// find_wl_entry() {{{2
/*
* Find an entry in the win->w_lines[] array for buffer line "lnum".
* Only valid entries are considered (for entries where wl_valid is FALSE the
@@ -1033,7 +1032,7 @@ find_wl_entry(win_T *win, linenr_T lnum)
return -1;
}
-/* foldAdjustVisual() {{{2 */
+// foldAdjustVisual() {{{2
/*
* Adjust the Visual area to include any fold at the start or end completely.
*/
@@ -1064,13 +1063,13 @@ foldAdjustVisual(void)
end->col = (colnr_T)STRLEN(ptr);
if (end->col > 0 && *p_sel == 'o')
--end->col;
- /* prevent cursor from moving on the trail byte */
+ // prevent cursor from moving on the trail byte
if (has_mbyte)
mb_adjust_cursor();
}
}
-/* cursor_foldstart() {{{2 */
+// cursor_foldstart() {{{2
/*
* Move the cursor to the first line of a closed fold.
*/
@@ -1080,8 +1079,8 @@ foldAdjustCursor(void)
(void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL);
}
-/* Internal functions for "fold_T" {{{1 */
-/* cloneFoldGrowArray() {{{2 */
+// Internal functions for "fold_T" {{{1
+// cloneFoldGrowArray() {{{2
/*
* Will "clone" (i.e deep copy) a garray_T of folds.
*
@@ -1114,7 +1113,7 @@ cloneFoldGrowArray(garray_T *from, garray_T *to)
}
}
-/* foldFind() {{{2 */
+// foldFind() {{{2
/*
* Search for line "lnum" in folds of growarray "gap".
* Set *fpp to the fold struct for the fold that contains "lnum" or
@@ -1140,14 +1139,14 @@ foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp)
{
i = (low + high) / 2;
if (fp[i].fd_top > lnum)
- /* fold below lnum, adjust high */
+ // fold below lnum, adjust high
high = i - 1;
else if (fp[i].fd_top + fp[i].fd_len <= lnum)
- /* fold above lnum, adjust low */
+ // fold above lnum, adjust low
low = i + 1;
else
{
- /* lnum is inside this fold */
+ // lnum is inside this fold
*fpp = fp + i;
return TRUE;
}
@@ -1156,7 +1155,7 @@ foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp)
return FALSE;
}
-/* foldLevelWin() {{{2 */
+// foldLevelWin() {{{2
/*
* Return fold level at line number "lnum" in window "wp".
*/
@@ -1168,13 +1167,13 @@ foldLevelWin(win_T *wp, linenr_T lnum)
int level = 0;
garray_T *gap;
- /* Recursively search for a fold that contains "lnum". */
+ // Recursively search for a fold that contains "lnum".
gap = &wp->w_folds;
for (;;)
{
if (!foldFind(gap, lnum_rel, &fp))
break;
- /* Check nested folds. Line number is relative to containing fold. */
+ // Check nested folds. Line number is relative to containing fold.
gap = &fp->fd_nested;
lnum_rel -= fp->fd_top;
++level;
@@ -1183,7 +1182,7 @@ foldLevelWin(win_T *wp, linenr_T lnum)
return level;
}
-/* checkupdate() {{{2 */
+// checkupdate() {{{2
/*
* Check if the folds in window "wp" are invalid and update them if needed.
*/
@@ -1192,12 +1191,12 @@ checkupdate(win_T *wp)
{
if (wp->w_foldinvalid)
{
- foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); /* will update all */
+ foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all
wp->w_foldinvalid = FALSE;
}
}
-/* setFoldRepeat() {{{2 */
+// setFoldRepeat() {{{2
/*
* Open or close fold for current window at line "lnum".
* Repeat "count" times.
@@ -1214,7 +1213,7 @@ setFoldRepeat(linenr_T lnum, long count, int do_open)
(void)setManualFold(lnum, do_open, FALSE, &done);
if (!(done & DONE_ACTION))
{
- /* Only give an error message when no fold could be opened. */
+ // Only give an error message when no fold could be opened.
if (n == 0 && !(done & DONE_FOLD))
emsg(_(e_nofold));
break;
@@ -1222,7 +1221,7 @@ setFoldRepeat(linenr_T lnum, long count, int do_open)
}
}
-/* setManualFold() {{{2 */
+// setManualFold() {{{2
/*
* Open or close the fold in the current window which contains "lnum".
* Also does this for other windows in diff mode when needed.
@@ -1230,8 +1229,8 @@ setFoldRepeat(linenr_T lnum, long count, int do_open)
static linenr_T
setManualFold(
linenr_T lnum,
- int opening, /* TRUE when opening, FALSE when closing */
- int recurse, /* TRUE when closing/opening recursive */
+ int opening, // TRUE when opening, FALSE when closing
+ int recurse, // TRUE when closing/opening recursive
int *donep)
{
#ifdef FEAT_DIFF
@@ -1259,7 +1258,7 @@ setManualFold(
return setManualFoldWin(curwin, lnum, opening, recurse, donep);
}
-/* setManualFoldWin() {{{2 */
+// setManualFoldWin() {{{2
/*
* Open or close the fold in window "wp" which contains "lnum".
* "donep", when not NULL, points to flag that is set to DONE_FOLD when some
@@ -1273,8 +1272,8 @@ setManualFold(
setManualFoldWin(
win_T *wp,
linenr_T lnum,
- int opening, /* TRUE when opening, FALSE when closing */
- int recurse, /* TRUE when closing/opening recursive */
+ int opening, // TRUE when opening, FALSE when closing
+ int recurse, // TRUE when closing/opening recursive
int *donep)
{
fold_T *fp;
@@ -1299,20 +1298,20 @@ setManualFoldWin(
{
if (!foldFind(gap, lnum, &fp))
{
- /* If there is a following fold, continue there next time. */
+ // If there is a following fold, continue there next time.
if (fp < (fold_T *)gap->ga_data + gap->ga_len)
next = fp->fd_top + off;
break;
}
- /* lnum is inside this fold */
+ // lnum is inside this fold
found_fold = TRUE;
- /* If there is a following fold, continue there next time. */
+ // If there is a following fold, continue there next time.
if (fp + 1 < (fold_T *)gap->ga_data + gap->ga_len)
next = fp[1].fd_top + off;
- /* Change from level-dependent folding to manual. */
+ // Change from level-dependent folding to manual.
if (use_level || fp->fd_flags == FD_LEVEL)
{
use_level = TRUE;
@@ -1325,7 +1324,7 @@ setManualFoldWin(
fp2[j].fd_flags = FD_LEVEL;
}
- /* Simple case: Close recursively means closing the fold. */
+ // Simple case: Close recursively means closing the fold.
if (!opening && recurse)
{
if (fp->fd_flags != FD_CLOSED)
@@ -1336,7 +1335,7 @@ setManualFoldWin(
}
else if (fp->fd_flags == FD_CLOSED)
{
- /* When opening, open topmost closed fold. */
+ // When opening, open topmost closed fold.
if (opening)
{
fp->fd_flags = FD_OPEN;
@@ -1347,7 +1346,7 @@ setManualFoldWin(
break;
}
- /* fold is open, check nested folds */
+ // fold is open, check nested folds
found = fp;
gap = &fp->fd_nested;
lnum -= fp->fd_top;
@@ -1356,7 +1355,7 @@ setManualFoldWin(
}
if (found_fold)
{
- /* When closing and not recurse, close deepest open fold. */
+ // When closing and not recurse, close deepest open fold.
if (!opening && found != NULL)
{
found->fd_flags = FD_CLOSED;
@@ -1376,7 +1375,7 @@ setManualFoldWin(
return next;
}
-/* foldOpenNested() {{{2 */
+// foldOpenNested() {{{2
/*
* Open all nested folds in fold "fpr" recursively.
*/
@@ -1394,7 +1393,7 @@ foldOpenNested(fold_T *fpr)
}
}
-/* deleteFoldEntry() {{{2 */
+// deleteFoldEntry() {{{2
/*
* Delete fold "idx" from growarray "gap".
* When "recursive" is TRUE also delete all the folds contained in it.
@@ -1411,7 +1410,7 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive)
fp = (fold_T *)gap->ga_data + idx;
if (recursive || fp->fd_nested.ga_len == 0)
{
- /* recursively delete the contained folds */
+ // recursively delete the contained folds
deleteFoldRecurse(&fp->fd_nested);
--gap->ga_len;
if (idx < gap->ga_len)
@@ -1419,15 +1418,15 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive)
}
else
{
- /* Move nested folds one level up, to overwrite the fold that is
- * deleted. */
+ // Move nested folds one level up, to overwrite the fold that is
+ // deleted.
moved = fp->fd_nested.ga_len;
if (ga_grow(gap, (int)(moved - 1)) == OK)
{
- /* Get "fp" again, the array may have been reallocated. */
+ // Get "fp" again, the array may have been reallocated.
fp = (fold_T *)gap->ga_data + idx;
- /* adjust fd_top and fd_flags for the moved folds */
+ // adjust fd_top and fd_flags for the moved folds
nfp = (fold_T *)fp->fd_nested.ga_data;
for (i = 0; i < moved; ++i)
{
@@ -1438,11 +1437,11 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive)
nfp[i].fd_small = MAYBE;
}
- /* move the existing folds down to make room */
+ // move the existing folds down to make room
if (idx + 1 < gap->ga_len)
mch_memmove(fp + moved, fp + 1,
sizeof(fold_T) * (gap->ga_len - (idx + 1)));
- /* move the contained folds one level up */
+ // move the contained folds one level up
mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved));
vim_free(nfp);
gap->ga_len += moved - 1;
@@ -1450,7 +1449,7 @@ deleteFoldEntry(garray_T *gap, int idx, int recursive)
}
}
-/* deleteFoldRecurse() {{{2 */
+// deleteFoldRecurse() {{{2
/*
* Delete nested folds in a fold.
*/
@@ -1464,7 +1463,7 @@ deleteFoldRecurse(garray_T *gap)
ga_clear(gap);
}
-/* foldMarkAdjust() {{{2 */
+// foldMarkAdjust() {{{2
/*
* Update line numbers of folds for inserted/deleted lines.
*/
@@ -1476,18 +1475,18 @@ foldMarkAdjust(
long amount,
long amount_after)
{
- /* If deleting marks from line1 to line2, but not deleting all those
- * lines, set line2 so that only deleted lines have their folds removed. */
+ // If deleting marks from line1 to line2, but not deleting all those
+ // lines, set line2 so that only deleted lines have their folds removed.
if (amount == MAXLNUM && line2 >= line1 && line2 - line1 >= -amount_after)
line2 = line1 - amount_after - 1;
- /* If appending a line in Insert mode, it should be included in the fold
- * just above the line. */
+ // If appending a line in Insert mode, it should be included in the fold
+ // just above the line.
if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM)
--line1;
foldMarkAdjustRecurse(&wp->w_folds, line1, line2, amount, amount_after);
}
-/* foldMarkAdjustRecurse() {{{2 */
+// foldMarkAdjustRecurse() {{{2
static void
foldMarkAdjustRecurse(
garray_T *gap,
@@ -1501,14 +1500,14 @@ foldMarkAdjustRecurse(
linenr_T last;
linenr_T top;
- /* In Insert mode an inserted line at the top of a fold is considered part
- * of the fold, otherwise it isn't. */
+ // In Insert mode an inserted line at the top of a fold is considered part
+ // of the fold, otherwise it isn't.
if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM)
top = line1 + 1;
else
top = line1;
- /* Find the fold containing or just below "line1". */
+ // Find the fold containing or just below "line1".
(void)foldFind(gap, line1, &fp);
/*
@@ -1528,13 +1527,13 @@ foldMarkAdjustRecurse(
* 3 5 6
*/
- last = fp->fd_top + fp->fd_len - 1; /* last line of fold */
+ last = fp->fd_top + fp->fd_len - 1; // last line of fold
- /* 1. fold completely above line1: nothing to do */
+ // 1. fold completely above line1: nothing to do
if (last < line1)
continue;
- /* 6. fold below line2: only adjust for amount_after */
+ // 6. fold below line2: only adjust for amount_after
if (fp->fd_top > line2)
{
if (amount_after == 0)
@@ -1545,12 +1544,12 @@ foldMarkAdjustRecurse(
{
if (fp->fd_top >= top && last <= line2)
{
- /* 4. fold completely contained in range */
+ // 4. fold completely contained in range
if (amount == MAXLNUM)
{
- /* Deleting lines: delete the fold completely */
+ // Deleting lines: delete the fold completely
deleteFoldEntry(gap, i, TRUE);
- --i; /* adjust index for deletion */
+ --i; // adjust index for deletion
--fp;
}
else
@@ -1560,12 +1559,12 @@ foldMarkAdjustRecurse(
{
if (fp->fd_top < top)
{
- /* 2 or 3: need to correct nested folds too */
+ // 2 or 3: need to correct nested folds too
foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
line2 - fp->fd_top, amount, amount_after);
if (last <= line2)
{
- /* 2. fold contains line1, line2 is below fold */
+ // 2. fold contains line1, line2 is below fold
if (amount == MAXLNUM)
fp->fd_len = line1 - fp->fd_top;
else
@@ -1573,14 +1572,14 @@ foldMarkAdjustRecurse(
}
else
{
- /* 3. fold contains line1 and line2 */
+ // 3. fold contains line1 and line2
fp->fd_len += amount_after;
}
}
else
{
- /* 5. fold is below line1 and contains line2; need to
- * correct nested folds too */
+ // 5. fold is below line1 and contains line2; need to
+ // correct nested folds too
if (amount == MAXLNUM)
{
foldMarkAdjustRecurse(&fp->fd_nested,
@@ -1607,7 +1606,7 @@ foldMarkAdjustRecurse(
}
}
-/* getDeepestNesting() {{{2 */
+// getDeepestNesting() {{{2
/*
* Get the lowest 'foldlevel' value that makes the deepest nested fold in the
* current window open.
@@ -1638,7 +1637,7 @@ getDeepestNestingRecurse(garray_T *gap)
return maxlevel;
}
-/* check_closed() {{{2 */
+// check_closed() {{{2
/*
* Check if a fold is closed and update the info needed to check nested folds.
*/
@@ -1646,15 +1645,15 @@ getDeepestNestingRecurse(garray_T *gap)
check_closed(
win_T *win,
fold_T *fp,
- int *use_levelp, /* TRUE: outer fold had FD_LEVEL */
- int level, /* folding depth */
- int *maybe_smallp, /* TRUE: outer this had fd_small == MAYBE */
- linenr_T lnum_off) /* line number offset for fp->fd_top */
+ int *use_levelp, // TRUE: outer fold had FD_LEVEL
+ int level, // folding depth
+ int *maybe_smallp, // TRUE: outer this had fd_small == MAYBE
+ linenr_T lnum_off) // line number offset for fp->fd_top
{
int closed = FALSE;
- /* Check if this fold is closed. If the flag is FD_LEVEL this
- * fold and all folds it contains depend on 'foldlevel'. */
+ // Check if this fold is closed. If the flag is FD_LEVEL this
+ // fold and all folds it contains depend on 'foldlevel'.
if (*use_levelp || fp->fd_flags == FD_LEVEL)
{
*use_levelp = TRUE;
@@ -1664,7 +1663,7 @@ check_closed(
else if (fp->fd_flags == FD_CLOSED)
closed = TRUE;
- /* Small fold isn't closed anyway. */
+ // Small fold isn't closed anyway.
if (fp->fd_small == MAYBE)
*maybe_smallp = TRUE;
if (closed)
@@ -1678,7 +1677,7 @@ check_closed(
return closed;
}
-/* checkSmall() {{{2 */
+// checkSmall() {{{2
/*
* Update fd_small field of fold "fp".
*/
@@ -1686,14 +1685,14 @@ check_closed(
checkSmall(
win_T *wp,
fold_T *fp,
- linenr_T lnum_off) /* offset for fp->fd_top */
+ linenr_T lnum_off) // offset for fp->fd_top
{
int count;
int n;
if (fp->fd_small == MAYBE)
{
- /* Mark any nested folds to maybe-small */
+ // Mark any nested folds to maybe-small
setSmallMaybe(&fp->fd_nested);
if (fp->fd_len > curwin->w_p_fml)
@@ -1715,7 +1714,7 @@ checkSmall(
}
}
-/* setSmallMaybe() {{{2 */
+// setSmallMaybe() {{{2
/*
* Set small flags in "gap" to MAYBE.
*/
@@ -1730,7 +1729,7 @@ setSmallMaybe(garray_T *gap)
fp[i].fd_small = MAYBE;
}
-/* foldCreateMarkers() {{{2 */
+// foldCreateMarkers() {{{2
/*
* Create a fold from line "start" to line "end" (inclusive) in the current
* window by adding markers.
@@ -1748,12 +1747,12 @@ foldCreateMarkers(linenr_T start, linenr_T end)
foldAddMarker(start, curwin->w_p_fmr, foldstartmarkerlen);
foldAddMarker(end, foldendmarker, foldendmarkerlen);
- /* Update both changes here, to avoid all folds after the start are
- * changed when the start marker is inserted and the end isn't. */
+ // Update both changes here, to avoid all folds after the start are
+ // changed when the start marker is inserted and the end isn't.
changed_lines(start, (colnr_T)0, end, 0L);
}
-/* foldAddMarker() {{{2 */
+// foldAddMarker() {{{2
/*
* Add "marker[markerlen]" in 'commentstring' to line "lnum".
*/
@@ -1767,19 +1766,19 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
char_u *p = (char_u *)strstr((char *)curbuf->b_p_cms, "%s");
int line_is_comment = FALSE;
- /* Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end */
+ // Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
line = ml_get(lnum);
line_len = (int)STRLEN(line);
if (u_save(lnum - 1, lnum + 1) == OK)
{
- /* Check if the line ends with an unclosed comment */
+ // Check if the line ends with an unclosed comment
(void)skip_comment(line, FALSE, FALSE, &line_is_comment);
newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
if (newline == NULL)
return;
STRCPY(newline, line);
- /* Append the marker to the end of the line */
+ // Append the marker to the end of the line
if (p == NULL || line_is_comment)
vim_strncpy(newline + line_len, marker, markerlen);
else
@@ -1793,7 +1792,7 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
}
}
-/* deleteFoldMarkers() {{{2 */
+// deleteFoldMarkers() {{{2
/*
* Delete the markers for a fold, causing it to be deleted.
*/
@@ -1801,7 +1800,7 @@ foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
deleteFoldMarkers(
fold_T *fp,
int recursive,
- linenr_T lnum_off) /* offset for fp->fd_top */
+ linenr_T lnum_off) // offset for fp->fd_top
{
int i;
@@ -1814,7 +1813,7 @@ deleteFoldMarkers(
foldendmarker, foldendmarkerlen);
}
-/* foldDelMarker() {{{2 */
+// foldDelMarker() {{{2
/*
* Delete marker "marker[markerlen]" at the end of line "lnum".
* Delete 'commentstring' if it matches.
@@ -1838,13 +1837,13 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
for (p = line; *p != NUL; ++p)
if (STRNCMP(p, marker, markerlen) == 0)
{
- /* Found the marker, include a digit if it's there. */
+ // Found the marker, include a digit if it's there.
len = markerlen;
if (VIM_ISDIGIT(p[len]))
++len;
if (*cms != NUL)
{
- /* Also delete 'commentstring' if it matches. */
+ // Also delete 'commentstring' if it matches.
cms2 = (char_u *)strstr((char *)cms, "%s");
if (p - line >= cms2 - cms
&& STRNCMP(p - (cms2 - cms), cms, cms2 - cms) == 0
@@ -1856,7 +1855,7 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
}
if (u_save(lnum - 1, lnum + 1) == OK)
{
- /* Make new line: text-before-marker + text-after-marker */
+ // Make new line: text-before-marker + text-after-marker
newline = alloc(STRLEN(line) - len + 1);
if (newline != NULL)
{
@@ -1869,7 +1868,7 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
}
}
-/* get_foldtext() {{{2 */
+// get_foldtext() {{{2
/*
* Return the text for a closed fold at line "lnum", with last line "lnume".
* When 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]".
@@ -1885,7 +1884,7 @@ get_foldtext(
{
char_u *text = NULL;
#ifdef FEAT_EVAL
- /* an error occurred when evaluating 'fdt' setting */
+ // an error occurred when evaluating 'fdt' setting
static int got_fdt_error = FALSE;
int save_did_emsg = did_emsg;
static win_T *last_wp = NULL;
@@ -1893,11 +1892,11 @@ get_foldtext(
if (last_wp != wp || last_wp == NULL
|| last_lnum > lnum || last_lnum == 0)
- /* window changed, try evaluating foldtext setting once again */
+ // window changed, try evaluating foldtext setting once again
got_fdt_error = FALSE;
if (!got_fdt_error)
- /* a previous error should not abort evaluating 'foldexpr' */
+ // a previous error should not abort evaluating 'foldexpr'
did_emsg = FALSE;
if (*wp->w_p_fdt != NUL)
@@ -1907,12 +1906,12 @@ get_foldtext(
int level;
char_u *p;
- /* Set "v:foldstart" and "v:foldend". */
+ // Set "v:foldstart" and "v:foldend".
set_vim_var_nr(VV_FOLDSTART, lnum);
set_vim_var_nr(VV_FOLDEND, lnume);
- /* Set "v:folddashes" to a string of "level" dashes. */
- /* Set "v:foldlevel" to "level". */
+ // Set "v:folddashes" to a string of "level" dashes.
+ // Set "v:foldlevel" to "level".
level = foldinfo->fi_level;
if (level > (int)sizeof(dashes) - 1)
level = (int)sizeof(dashes) - 1;
@@ -1921,14 +1920,14 @@ get_foldtext(
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
set_vim_var_nr(VV_FOLDLEVEL, (long)level);
- /* skip evaluating foldtext on errors */
+ // skip evaluating foldtext on errors
if (!got_fdt_error)
{
save_curwin = curwin;
curwin = wp;
curbuf = wp->w_buffer;
- ++emsg_silent; /* handle exceptions, but don't display errors */
+ ++emsg_silent; // handle exceptions, but don't display errors
text = eval_to_string_safe(wp->w_p_fdt, NULL,
was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
--emsg_silent;
@@ -1948,8 +1947,8 @@ get_foldtext(
if (text != NULL)
{
- /* Replace unprintable characters, if there are any. But
- * replace a TAB with a space. */
+ // Replace unprintable characters, if there are any. But
+ // replace a TAB with a space.
for (p = text; *p != NUL; ++p)
{
int len;
@@ -1988,7 +1987,7 @@ get_foldtext(
return text;
}
-/* foldtext_cleanup() {{{2 */
+// foldtext_cleanup() {{{2
#ifdef FEAT_EVAL
/*
* Remove 'foldmarker' and 'commentstring' from "str" (in-place).
@@ -1996,34 +1995,34 @@ get_foldtext(
static void
foldtext_cleanup(char_u *str)
{
- char_u *cms_start; /* first part or the whole comment */
- int cms_slen = 0; /* length of cms_start */
- char_u *cms_end; /* last part of the comment or NULL */
- int cms_elen = 0; /* length of cms_end */
+ char_u *cms_start; // first part or the whole comment
+ int cms_slen = 0; // length of cms_start
+ char_u *cms_end; // last part of the comment or NULL
+ int cms_elen = 0; // length of cms_end
char_u *s;
char_u *p;
int len;
int did1 = FALSE;
int did2 = FALSE;
- /* Ignore leading and trailing white space in 'commentstring'. */
+ // Ignore leading and trailing white space in 'commentstring'.
cms_start = skipwhite(curbuf->b_p_cms);
cms_slen = (int)STRLEN(cms_start);
while (cms_slen > 0 && VIM_ISWHITE(cms_start[cms_slen - 1]))
--cms_slen;
- /* locate "%s" in 'commentstring', use the part before and after it. */
+ // locate "%s" in 'commentstring', use the part before and after it.
cms_end = (char_u *)strstr((char *)cms_start, "%s");
if (cms_end != NULL)
{
cms_elen = cms_slen - (int)(cms_end - cms_start);
cms_slen = (int)(cms_end - cms_start);
- /* exclude white space before "%s" */
+ // exclude white space before "%s"
while (cms_slen > 0 && VIM_ISWHITE(cms_start[cms_slen - 1]))
--cms_slen;
- /* skip "%s" and white space after it */
+ // skip "%s" and white space after it
s = skipwhite(cms_end + 2);
cms_elen -= (int)(s - cms_end);
cms_end = s;
@@ -2042,8 +2041,8 @@ foldtext_cleanup(char_u *str)
if (VIM_ISDIGIT(s[len]))
++len;
- /* May remove 'commentstring' start. Useful when it's a double
- * quote and we already removed a double quote. */
+ // May remove 'commentstring' start. Useful when it's a double
+ // quote and we already removed a double quote.
for (p = s; p > str && VIM_ISWHITE(p[-1]); --p)
;
if (p >= str + cms_slen
@@ -2081,28 +2080,28 @@ foldtext_cleanup(char_u *str)
}
#endif
-/* Folding by indent, expr, marker and syntax. {{{1 */
-/* Define "fline_T", passed to get fold level for a line. {{{2 */
+// Folding by indent, expr, marker and syntax. {{{1
+// Define "fline_T", passed to get fold level for a line. {{{2
typedef struct
{
- win_T *wp; /* window */
- linenr_T lnum; /* current line number */
- linenr_T off; /* offset between lnum and real line number */
- linenr_T lnum_save; /* line nr used by foldUpdateIEMSRecurse() */
- int lvl; /* current level (-1 for undefined) */
- int lvl_next; /* level used for next line */
- int start; /* number of folds that are forced to start at
- this line. */
- int end; /* level of fold that is forced to end below
- this line */
- int had_end; /* level of fold that is forced to end above
- this line (copy of "end" of prev. line) */
+ win_T *wp; // window
+ linenr_T lnum; // current line number
+ linenr_T off; // offset between lnum and real line number
+ linenr_T lnum_save; // line nr used by foldUpdateIEMSRecurse()
+ int lvl; // current level (-1 for undefined)
+ int lvl_next; // level used for next line
+ int start; // number of folds that are forced to start at
+ // this line.
+ int end; // level of fold that is forced to end below
+ // this line
+ int had_end; // level of fold that is forced to end above
+ // this line (copy of "end" of prev. line)
} fline_T;
-/* Flag is set when redrawing is needed. */
+// Flag is set when redrawing is needed.
static int fold_changed;
-/* Function declarations. {{{2 */
+// Function declarations. {{{2
static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level, linenr_T startlnum, fline_T *flp, void (*getlevel)(fline_T *), linenr_T bot, int topflags);
static int foldInsert(garray_T *gap, int i);
static void foldSplit(garray_T *gap, int i, linenr_T top, linenr_T bot);
@@ -2116,7 +2115,7 @@ static void foldlevelExpr(fline_T *flp);
static void foldlevelMarker(fline_T *flp);
static void foldlevelSyntax(fline_T *flp);
-/* foldUpdateIEMS() {{{2 */
+// foldUpdateIEMS() {{{2
/*
* Update the folding for window "wp", at least from lines "top" to "bot".
* Return TRUE if any folds did change.
@@ -2131,23 +2130,23 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
int level;
fold_T *fp;
- /* Avoid problems when being called recursively. */
+ // Avoid problems when being called recursively.
if (invalid_top != (linenr_T)0)
return;
if (wp->w_foldinvalid)
{
- /* Need to update all folds. */
+ // Need to update all folds.
top = 1;
bot = wp->w_buffer->b_ml.ml_line_count;
wp->w_foldinvalid = FALSE;
- /* Mark all folds a maybe-small. */
+ // Mark all folds a maybe-small.
setSmallMaybe(&wp->w_folds);
}
#ifdef FEAT_DIFF
- /* add the context for "diff" folding */
+ // add the context for "diff" folding
if (foldmethodIsDiff(wp))
{
if (top > diff_context)
@@ -2158,8 +2157,8 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
}
#endif
- /* When deleting lines at the end of the buffer "top" can be past the end
- * of the buffer. */
+ // When deleting lines at the end of the buffer "top" can be past the end
+ // of the buffer.
if (top > wp->w_buffer->b_ml.ml_line_count)
top = wp->w_buffer->b_ml.ml_line_count;
@@ -2179,24 +2178,24 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
{
getlevel = foldlevelMarker;
- /* Init marker variables to speed up foldlevelMarker(). */
+ // Init marker variables to speed up foldlevelMarker().
parseMarker(wp);
- /* Need to get the level of the line above top, it is used if there is
- * no marker at the top. */
+ // Need to get the level of the line above top, it is used if there is
+ // no marker at the top.
if (top > 1)
{
- /* Get the fold level at top - 1. */
+ // Get the fold level at top - 1.
level = foldLevelWin(wp, top - 1);
- /* The fold may end just above the top, check for that. */
+ // The fold may end just above the top, check for that.
fline.lnum = top - 1;
fline.lvl = level;
getlevel(&fline);
- /* If a fold started here, we already had the level, if it stops
- * here, we need to use lvl_next. Could also start and end a fold
- * in the same line. */
+ // If a fold started here, we already had the level, if it stops
+ // here, we need to use lvl_next. Could also start and end a fold
+ // in the same line.
if (fline.lvl > level)
fline.lvl = level - (fline.lvl - fline.lvl_next);
else
@@ -2211,8 +2210,8 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
if (foldmethodIsExpr(wp))
{
getlevel = foldlevelExpr;
- /* start one line back, because a "<1" may indicate the end of a
- * fold in the topline */
+ // start one line back, because a "<1" may indicate the end of a
+ // fold in the topline
if (top > 1)
--fline.lnum;
}
@@ -2225,13 +2224,13 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
else
getlevel = foldlevelIndent;
- /* Backup to a line for which the fold level is defined. Since it's
- * always defined for line one, we will stop there. */
+ // Backup to a line for which the fold level is defined. Since it's
+ // always defined for line one, we will stop there.
fline.lvl = -1;
for ( ; !got_int; --fline.lnum)
{
- /* Reset lvl_next each time, because it will be set to a value for
- * the next line, but we search backwards here. */
+ // Reset lvl_next each time, because it will be set to a value for
+ // the next line, but we search backwards here.
fline.lvl_next = -1;
getlevel(&fline);
if (fline.lvl >= 0)
@@ -2275,20 +2274,20 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
start = fline.lnum;
end = bot;
- /* Do at least one line. */
+ // Do at least one line.
if (start > end && end < wp->w_buffer->b_ml.ml_line_count)
end = start;
while (!got_int)
{
- /* Always stop at the end of the file ("end" can be past the end of
- * the file). */
+ // Always stop at the end of the file ("end" can be past the end of
+ // the file).
if (fline.lnum > wp->w_buffer->b_ml.ml_line_count)
break;
if (fline.lnum > end)
{
- /* For "marker", "expr" and "syntax" methods: If a change caused
- * a fold to be removed, we need to continue at least until where
- * it ended. */
+ // For "marker", "expr" and "syntax" methods: If a change caused
+ // a fold to be removed, we need to continue at least until where
+ // it ended.
if (getlevel != foldlevelMarker
&& getlevel != foldlevelSyntax
&& getlevel != foldlevelExpr)
@@ -2302,15 +2301,15 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
end = fp->fd_top + fp->fd_len - 1;
else if (getlevel == foldlevelSyntax
&& foldLevelWin(wp, fline.lnum) != fline.lvl)
- /* For "syntax" method: Compare the foldlevel that the syntax
- * tells us to the foldlevel from the existing folds. If they
- * don't match continue updating folds. */
+ // For "syntax" method: Compare the foldlevel that the syntax
+ // tells us to the foldlevel from the existing folds. If they
+ // don't match continue updating folds.
end = fline.lnum;
else
break;
}
- /* A level 1 fold starts at a line with foldlevel > 0. */
+ // A level 1 fold starts at a line with foldlevel > 0.
if (fline.lvl > 0)
{
invalid_top = fline.lnum;
@@ -2329,16 +2328,16 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
}
}
- /* There can't be any folds from start until end now. */
+ // There can't be any folds from start until end now.
foldRemove(&wp->w_folds, start, end);
- /* If some fold changed, need to redraw and position cursor. */
+ // If some fold changed, need to redraw and position cursor.
if (fold_changed && wp->w_p_fen)
changed_window_setting_win(wp);
- /* If we updated folds past "bot", need to redraw more lines. Don't do
- * this in other situations, the changed lines will be redrawn anyway and
- * this method can cause the whole window to be updated. */
+ // If we updated folds past "bot", need to redraw more lines. Don't do
+ // this in other situations, the changed lines will be redrawn anyway and
+ // this method can cause the whole window to be updated.
if (end != bot)
{
if (wp->w_redraw_top == 0 || wp->w_redraw_top > top)
@@ -2350,7 +2349,7 @@ foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
invalid_top = (linenr_T)0;
}
-/* foldUpdateIEMSRecurse() {{{2 */
+// foldUpdateIEMSRecurse() {{{2
/*
* Update a fold that starts at "flp->lnum". At this line there is always a
* valid foldlevel, and its level >= "level".
@@ -2382,14 +2381,14 @@ foldUpdateIEMSRecurse(
fline_T *flp,
void (*getlevel)(fline_T *),
linenr_T bot,
- int topflags) /* flags used by containing fold */
+ int topflags) // flags used by containing fold
{
linenr_T ll;
fold_T *fp = NULL;
fold_T *fp2;
int lvl = level;
linenr_T startlnum2 = startlnum;
- linenr_T firstlnum = flp->lnum; /* first lnum we got */
+ linenr_T firstlnum = flp->lnum; // first lnum we got
int i;
int finish = FALSE;
linenr_T linecount = flp->wp->w_buffer->b_ml.ml_line_count - flp->off;
@@ -2424,13 +2423,13 @@ foldUpdateIEMSRecurse(
flp->lnum_save = flp->lnum;
while (!got_int)
{
- /* Updating folds can be slow, check for CTRL-C. */
+ // Updating folds can be slow, check for CTRL-C.
line_breakcheck();
- /* Set "lvl" to the level of line "flp->lnum". When flp->start is set
- * and after the first line of the fold, set the level to zero to
- * force the fold to end. Do the same when had_end is set: Previous
- * line was marked as end of a fold. */
+ // Set "lvl" to the level of line "flp->lnum". When flp->start is set
+ // and after the first line of the fold, set the level to zero to
+ // force the fold to end. Do the same when had_end is set: Previous
+ // line was marked as end of a fold.
lvl = flp->lvl;
if (lvl > MAX_LEVEL)
lvl = MAX_LEVEL;
@@ -2440,12 +2439,11 @@ foldUpdateIEMSRecurse(
if (flp->lnum > bot && !finish && fp != NULL)
{
- /* For "marker" and "syntax" methods:
- * - If a change caused a nested fold to be removed, we need to
- * delete it and continue at least until where it ended.
- * - If a change caused a nested fold to be created, or this fold
- * to continue below its original end, need to finish this fold.
- */
+ // For "marker" and "syntax" methods:
+ // - If a change caused a nested fold to be removed, we need to
+ // delete it and continue at least until where it ended.
+ // - If a change caused a nested fold to be created, or this fold
+ // to continue below its original end, need to finish this fold.
if (getlevel != foldlevelMarker
&& getlevel != foldlevelExpr
&& getlevel != foldlevelSyntax)
@@ -2454,9 +2452,9 @@ foldUpdateIEMSRecurse(
fp2 = fp;
if (lvl >= level)
{
- /* Compute how deep the folds currently are, if it's deeper
- * than "lvl" then some must be deleted, need to update
- * at least one nested fold. */
+ // Compute how deep the folds currently are, if it's deeper
+ // than "lvl" then some must be deleted, need to update
+ // at least one nested fold.
ll = flp->lnum - fp->fd_top;
while (foldFind(&fp2->fd_nested, ll, &fp2))
{
@@ -2476,9 +2474,9 @@ foldUpdateIEMSRecurse(
break;
}
- /* At the start of the first nested fold and at the end of the current
- * fold: check if existing folds at this level, before the current
- * one, need to be deleted or truncated. */
+ // At the start of the first nested fold and at the end of the current
+ // fold: check if existing folds at this level, before the current
+ // one, need to be deleted or truncated.
if (fp == NULL
&& (lvl != level
|| flp->lnum_save >= bot
@@ -2492,16 +2490,16 @@ foldUpdateIEMSRecurse(
*/
while (!got_int)
{
- /* set concat to 1 if it's allowed to concatenated this fold
- * with a previous one that touches it. */
+ // set concat to 1 if it's allowed to concatenated this fold
+ // with a previous one that touches it.
if (flp->start != 0 || flp->had_end <= MAX_LEVEL)
concat = 0;
else
concat = 1;
- /* Find an existing fold to re-use. Preferably one that
- * includes startlnum, otherwise one that ends just before
- * startlnum or starts after it. */
+ // Find an existing fold to re-use. Preferably one that
+ // includes startlnum, otherwise one that ends just before
+ // startlnum or starts after it.
if (foldFind(gap, startlnum, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& fp->fd_top <= firstlnum)
@@ -2513,23 +2511,23 @@ foldUpdateIEMSRecurse(
{
if (fp->fd_top + fp->fd_len + concat > firstlnum)
{
- /* Use existing fold for the new fold. If it starts
- * before where we started looking, extend it. If it
- * starts at another line, update nested folds to keep
- * their position, compensating for the new fd_top. */
+ // Use existing fold for the new fold. If it starts
+ // before where we started looking, extend it. If it
+ // starts at another line, update nested folds to keep
+ // their position, compensating for the new fd_top.
if (fp->fd_top == firstlnum)
{
- /* have found a fold beginning where we want */
+ // have found a fold beginning where we want
}
else if (fp->fd_top >= startlnum)
{
if (fp->fd_top > firstlnum)
- /* like lines are inserted */
+ // like lines are inserted
foldMarkAdjustRecurse(&fp->fd_nested,
(linenr_T)0, (linenr_T)MAXLNUM,
(long)(fp->fd_top - firstlnum), 0L);
else
- /* like lines are deleted */
+ // like lines are deleted
foldMarkAdjustRecurse(&fp->fd_nested,
(linenr_T)0,
(long)(firstlnum - fp->fd_top - 1),
@@ -2577,9 +2575,9 @@ foldUpdateIEMSRecurse(
foldSplit(gap, i, breakstart, breakend - 1);
fp = (fold_T *)gap->ga_data + i + 1;
- /* If using the "marker" or "syntax" method, we
- * need to continue until the end of the fold is
- * found. */
+ // If using the "marker" or "syntax" method, we
+ // need to continue until the end of the fold is
+ // found.
if (getlevel == foldlevelMarker
|| getlevel == foldlevelExpr
|| getlevel == foldlevelSyntax)
@@ -2603,16 +2601,16 @@ foldUpdateIEMSRecurse(
}
if (fp->fd_top >= startlnum)
{
- /* A fold that starts at or after startlnum and stops
- * before the new fold must be deleted. Continue
- * looking for the next one. */
+ // A fold that starts at or after startlnum and stops
+ // before the new fold must be deleted. Continue
+ // looking for the next one.
deleteFoldEntry(gap,
(int)(fp - (fold_T *)gap->ga_data), TRUE);
}
else
{
- /* A fold has some lines above startlnum, truncate it
- * to stop just above startlnum. */
+ // A fold has some lines above startlnum, truncate it
+ // to stop just above startlnum.
fp->fd_len = startlnum - fp->fd_top;
foldMarkAdjustRecurse(&fp->fd_nested,
(linenr_T)fp->fd_len, (linenr_T)MAXLNUM,
@@ -2622,19 +2620,19 @@ foldUpdateIEMSRecurse(
}
else
{
- /* Insert new fold. Careful: ga_data may be NULL and it
- * may change! */
+ // Insert new fold. Careful: ga_data may be NULL and it
+ // may change!
i = (int)(fp - (fold_T *)gap->ga_data);
if (foldInsert(gap, i) != OK)
return bot;
fp = (fold_T *)gap->ga_data + i;
- /* The new fold continues until bot, unless we find the
- * end earlier. */
+ // The new fold continues until bot, unless we find the
+ // end earlier.
fp->fd_top = firstlnum;
fp->fd_len = bot - firstlnum + 1;
- /* When the containing fold is open, the new fold is open.
- * The new fold is closed if the fold above it is closed.
- * The first fold depends on the containing fold. */
+ // When the containing fold is open, the new fold is open.
+ // The new fold is closed if the fold above it is closed.
+ // The first fold depends on the containing fold.
if (topflags == FD_OPEN)
{
flp->wp->w_fold_manual = TRUE;
@@ -2649,8 +2647,8 @@ foldUpdateIEMSRecurse(
else
fp->fd_flags = (fp - 1)->fd_flags;
fp->fd_small = MAYBE;
- /* If using the "marker", "expr" or "syntax" method, we
- * need to continue until the end of the fold is found. */
+ // If using the "marker", "expr" or "syntax" method, we
+ // need to continue until the end of the fold is found.
if (getlevel == foldlevelMarker
|| getlevel == foldlevelExpr
|| getlevel == foldlevelSyntax)
@@ -2679,12 +2677,12 @@ foldUpdateIEMSRecurse(
/*
* There is a nested fold, handle it recursively.
*/
- /* At least do one line (can happen when finish is TRUE). */
+ // At least do one line (can happen when finish is TRUE).
if (bot < flp->lnum)
bot = flp->lnum;
- /* Line numbers in the nested fold are relative to the start of
- * this fold. */
+ // Line numbers in the nested fold are relative to the start of
+ // this fold.
flp->lnum = flp->lnum_save - fp->fd_top;
flp->off += fp->fd_top;
i = (int)(fp - (fold_T *)gap->ga_data);
@@ -2698,7 +2696,7 @@ foldUpdateIEMSRecurse(
bot += fp->fd_top;
startlnum2 = flp->lnum;
- /* This fold may end at the same line, don't incr. flp->lnum. */
+ // This fold may end at the same line, don't incr. flp->lnum.
}
else
{
@@ -2712,7 +2710,7 @@ foldUpdateIEMSRecurse(
ll = flp->lnum + 1;
while (!got_int)
{
- /* Make the previous level available to foldlevel(). */
+ // Make the previous level available to foldlevel().
prev_lnum = flp->lnum;
prev_lnum_lvl = flp->lvl;
@@ -2727,14 +2725,14 @@ foldUpdateIEMSRecurse(
if (flp->lnum > linecount)
break;
- /* leave flp->lnum_save to lnum of the line that was used to get
- * the level, flp->lnum to the lnum of the next line. */
+ // leave flp->lnum_save to lnum of the line that was used to get
+ // the level, flp->lnum to the lnum of the next line.
flp->lnum_save = flp->lnum;
flp->lnum = ll;
}
}
- if (fp == NULL) /* only happens when got_int is set */
+ if (fp == NULL) // only happens when got_int is set
return bot;
/*
@@ -2761,25 +2759,25 @@ foldUpdateIEMSRecurse(
if (lvl < level)
{
- /* End of fold found, update the length when it got shorter. */
+ // End of fold found, update the length when it got shorter.
if (fp->fd_len != flp->lnum - fp->fd_top)
{
if (fp->fd_top + fp->fd_len - 1 > bot)
{
- /* fold continued below bot */
+ // fold continued below bot
if (getlevel == foldlevelMarker
|| getlevel == foldlevelExpr
|| getlevel == foldlevelSyntax)
{
- /* marker method: truncate the fold and make sure the
- * previously included lines are processed again */
+ // marker method: truncate the fold and make sure the
+ // previously included lines are processed again
bot = fp->fd_top + fp->fd_len - 1;
fp->fd_len = flp->lnum - fp->fd_top;
}
else
{
- /* indent or expr method: split fold to create a new one
- * below bot */
+ // indent or expr method: split fold to create a new one
+ // below bot
i = (int)(fp - (fold_T *)gap->ga_data);
foldSplit(gap, i, flp->lnum, bot);
fp = (fold_T *)gap->ga_data + i;
@@ -2791,7 +2789,7 @@ foldUpdateIEMSRecurse(
}
}
- /* delete following folds that end before the current line */
+ // delete following folds that end before the current line
for (;;)
{
fp2 = fp + 1;
@@ -2802,7 +2800,7 @@ foldUpdateIEMSRecurse(
{
if (fp2->fd_top < flp->lnum)
{
- /* Make fold that includes lnum start at lnum. */
+ // Make fold that includes lnum start at lnum.
foldMarkAdjustRecurse(&fp2->fd_nested,
(linenr_T)0, (long)(flp->lnum - fp2->fd_top - 1),
(linenr_T)MAXLNUM, (long)(fp2->fd_top - flp->lnum));
@@ -2813,7 +2811,7 @@ foldUpdateIEMSRecurse(
if (lvl >= level)
{
- /* merge new fold with existing fold that follows */
+ // merge new fold with existing fold that follows
foldMerge(fp, gap, fp2);
}
break;
@@ -2822,15 +2820,15 @@ foldUpdateIEMSRecurse(
deleteFoldEntry(gap, (int)(fp2 - (fold_T *)gap->ga_data), TRUE);
}
- /* Need to redraw the lines we inspected, which might be further down than
- * was asked for. */
+ // Need to redraw the lines we inspected, which might be further down than
+ // was asked for.
if (bot < flp->lnum - 1)
bot = flp->lnum - 1;
return bot;
}
-/* foldInsert() {{{2 */
+// foldInsert() {{{2
/*
* Insert a new fold in "gap" at position "i".
* Returns OK for success, FAIL for failure.
@@ -2850,7 +2848,7 @@ foldInsert(garray_T *gap, int i)
return OK;
}
-/* foldSplit() {{{2 */
+// foldSplit() {{{2
/*
* Split the "i"th fold in "gap", which starts before "top" and ends below
* "bot" in two pieces, one ending above "top" and the other starting below
@@ -2872,7 +2870,7 @@ foldSplit(
int idx;
int len;
- /* The fold continues below bot, need to split it. */
+ // The fold continues below bot, need to split it.
if (foldInsert(gap, i + 1) == FAIL)
return;
fp = (fold_T *)gap->ga_data + i;
@@ -2882,8 +2880,8 @@ foldSplit(
fp[1].fd_small = MAYBE;
fp->fd_small = MAYBE;
- /* Move nested folds below bot to new fold. There can't be
- * any between top and bot, they have been removed by the caller. */
+ // Move nested folds below bot to new fold. There can't be
+ // any between top and bot, they have been removed by the caller.
gap1 = &fp->fd_nested;
gap2 = &fp[1].fd_nested;
(void)(foldFind(gap1, bot + 1 - fp->fd_top, &fp2));
@@ -2903,7 +2901,7 @@ foldSplit(
fold_changed = TRUE;
}
-/* foldRemove() {{{2 */
+// foldRemove() {{{2
/*
* Remove folds within the range "top" to and including "bot".
* Check for these situations:
@@ -2928,23 +2926,23 @@ foldRemove(garray_T *gap, linenr_T top, linenr_T bot)
fold_T *fp = NULL;
if (bot < top)
- return; /* nothing to do */
+ return; // nothing to do
for (;;)
{
- /* Find fold that includes top or a following one. */
+ // Find fold that includes top or a following one.
if (foldFind(gap, top, &fp) && fp->fd_top < top)
{
- /* 2: or 3: need to delete nested folds */
+ // 2: or 3: need to delete nested folds
foldRemove(&fp->fd_nested, top - fp->fd_top, bot - fp->fd_top);
if (fp->fd_top + fp->fd_len - 1 > bot)
{
- /* 3: need to split it. */
+ // 3: need to split it.
foldSplit(gap, (int)(fp - (fold_T *)gap->ga_data), top, bot);
}
else
{
- /* 2: truncate fold at "top". */
+ // 2: truncate fold at "top".
fp->fd_len = top - fp->fd_top;
}
fold_changed = TRUE;
@@ -2953,16 +2951,16 @@ foldRemove(garray_T *gap, linenr_T top, linenr_T bot)
if (fp >= (fold_T *)(gap->ga_data) + gap->ga_len
|| fp->fd_top > bot)
{
- /* 6: Found a fold below bot, can stop looking. */
+ // 6: Found a fold below bot, can stop looking.
break;
}
if (fp->fd_top >= top)
{
- /* Found an entry below top. */
+ // Found an entry below top.
fold_changed = TRUE;
if (fp->fd_top + fp->fd_len - 1 > bot)
{
- /* 5: Make fold that includes bot start below bot. */
+ // 5: Make fold that includes bot start below bot.
foldMarkAdjustRecurse(&fp->fd_nested,
(linenr_T)0, (long)(bot - fp->fd_top),
(linenr_T)MAXLNUM, (long)(fp->fd_top - bot - 1));
@@ -2971,13 +2969,13 @@ foldRemove(garray_T *gap, linenr_T top, linenr_T bot)
break;
}
- /* 4: Delete completely contained fold. */
+ // 4: Delete completely contained fold.
deleteFoldEntry(gap, (int)(fp - (fold_T *)gap->ga_data), TRUE);
}
}
}
-/* foldReverseOrder() {{{2 */
+// foldReverseOrder() {{{2
static void
foldReverseOrder(garray_T *gap, linenr_T start_arg, linenr_T end_arg)
{
@@ -2996,7 +2994,7 @@ foldReverseOrder(garray_T *gap, linenr_T start_arg, linenr_T end_arg)
}
}
-/* foldMoveRange() {{{2 */
+// foldMoveRange() {{{2
/*
* Move folds within the inclusive range "line1" to "line2" to after "dest"
* requires "line1" <= "line2" <= "dest"
@@ -3054,49 +3052,46 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
{
if (fold_end(fp) > dest)
{
- /* Case 4
- * don't have to change this fold, but have to move nested folds.
- */
+ // Case 4
+ // don't have to change this fold, but have to move nested folds.
foldMoveRange(&fp->fd_nested, line1 - fp->fd_top, line2 -
fp->fd_top, dest - fp->fd_top);
return;
}
else if (fold_end(fp) > line2)
{
- /* Case 3
- * Remove nested folds between line1 and line2 & reduce the
- * length of fold by "range_len".
- * Folds after this one must be dealt with.
- */
+ // Case 3
+ // Remove nested folds between line1 and line2 & reduce the
+ // length of fold by "range_len".
+ // Folds after this one must be dealt with.
foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top, line2 -
fp->fd_top, MAXLNUM, -range_len);
fp->fd_len -= range_len;
}
else
- /* Case 2 truncate fold, folds after this one must be dealt with. */
+ // Case 2 truncate fold, folds after this one must be dealt with.
truncate_fold(fp, line1 - 1);
- /* Look at the next fold, and treat that one as if it were the first
- * after "line1" (because now it is). */
+ // Look at the next fold, and treat that one as if it were the first
+ // after "line1" (because now it is).
fp = fp + 1;
}
if (!valid_fold(fp, gap) || fp->fd_top > dest)
{
- /* Case 10
- * No folds after "line1" and before "dest"
- */
+ // Case 10
+ // No folds after "line1" and before "dest"
return;
}
else if (fp->fd_top > line2)
{
for (; valid_fold(fp, gap) && fold_end(fp) <= dest; fp++)
- /* Case 9. (for all case 9's) -- shift up. */
+ // Case 9. (for all case 9's) -- shift up.
fp->fd_top -= range_len;
if (valid_fold(fp, gap) && fp->fd_top <= dest)
{
- /* Case 8. -- ensure truncated at dest, shift up */
+ // Case 8. -- ensure truncated at dest, shift up
truncate_fold(fp, dest);
fp->fd_top -= range_len;
}
@@ -3104,7 +3099,7 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
}
else if (fold_end(fp) > dest)
{
- /* Case 7 -- remove nested folds and shrink */
+ // Case 7 -- remove nested folds and shrink
foldMarkAdjustRecurse(&fp->fd_nested, line2 + 1 - fp->fd_top, dest -
fp->fd_top, MAXLNUM, -move_len);
fp->fd_len -= move_len;
@@ -3112,26 +3107,25 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
return;
}
- /* Case 5 or 6
- * changes rely on whether there are folds between the end of
- * this fold and "dest".
- */
+ // Case 5 or 6
+ // changes rely on whether there are folds between the end of
+ // this fold and "dest".
move_start = fold_index(fp, gap);
for (; valid_fold(fp, gap) && fp->fd_top <= dest; fp++)
{
if (fp->fd_top <= line2)
{
- /* 1. 2. or 3. */
+ // 1. 2. or 3.
if (fold_end(fp) > line2)
- /* 2. or 3., truncate before moving */
+ // 2. or 3., truncate before moving
truncate_fold(fp, line2);
fp->fd_top += move_len;
continue;
}
- /* Record index of the first fold after the moved range. */
+ // Record index of the first fold after the moved range.
if (move_end == 0)
move_end = fold_index(fp, gap);
@@ -3149,8 +3143,8 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
* range [move_start, move_end).
*/
if (move_end == 0)
- /* There are no folds after those moved, hence no folds have been moved
- * out of order. */
+ // There are no folds after those moved, hence no folds have been moved
+ // out of order.
return;
foldReverseOrder(gap, (linenr_T)move_start, (linenr_T)dest_index - 1);
foldReverseOrder(gap, (linenr_T)move_start,
@@ -3162,7 +3156,7 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
#undef valid_fold
#undef fold_index
-/* foldMerge() {{{2 */
+// foldMerge() {{{2
/*
* Merge two adjacent folds (and the nested ones in them).
* This only works correctly when the folds are really adjacent! Thus "fp1"
@@ -3179,12 +3173,12 @@ foldMerge(fold_T *fp1, garray_T *gap, fold_T *fp2)
garray_T *gap1 = &fp1->fd_nested;
garray_T *gap2 = &fp2->fd_nested;
- /* If the last nested fold in fp1 touches the first nested fold in fp2,
- * merge them recursively. */
+ // If the last nested fold in fp1 touches the first nested fold in fp2,
+ // merge them recursively.
if (foldFind(gap1, fp1->fd_len - 1L, &fp3) && foldFind(gap2, 0L, &fp4))
foldMerge(fp3, gap2, fp4);
- /* Move nested folds in fp2 to the end of fp1. */
+ // Move nested folds in fp2 to the end of fp1.
if (gap2->ga_len > 0 && ga_grow(gap1, gap2->ga_len) == OK)
{
for (idx = 0; idx < gap2->ga_len; ++idx)
@@ -3202,7 +3196,7 @@ foldMerge(fold_T *fp1, garray_T *gap, fold_T *fp2)
fold_changed = TRUE;
}
-/* foldlevelIndent() {{{2 */
+// foldlevelIndent() {{{2
/*
* Low level function to get the foldlevel for the "indent" method.
* Doesn't use any caching.
@@ -3218,11 +3212,11 @@ foldlevelIndent(fline_T *flp)
buf = flp->wp->w_buffer;
s = skipwhite(ml_get_buf(buf, lnum, FALSE));
- /* empty line or lines starting with a character in 'foldignore': level
- * depends on surrounding lines */
+ // empty line or lines starting with a character in 'foldignore': level
+ // depends on surrounding lines
if (*s == NUL || vim_strchr(flp->wp->w_p_fdi, *s) != NULL)
{
- /* first and last line can't be undefined, use level 0 */
+ // first and last line can't be undefined, use level 0
if (lnum == 1 || lnum == buf->b_ml.ml_line_count)
flp->lvl = 0;
else
@@ -3238,7 +3232,7 @@ foldlevelIndent(fline_T *flp)
}
}
-/* foldlevelDiff() {{{2 */
+// foldlevelDiff() {{{2
#ifdef FEAT_DIFF
/*
* Low level function to get the foldlevel for the "diff" method.
@@ -3254,7 +3248,7 @@ foldlevelDiff(fline_T *flp)
}
#endif
-/* foldlevelExpr() {{{2 */
+// foldlevelExpr() {{{2
/*
* Low level function to get the foldlevel for the "expr" method.
* Doesn't use any caching.
@@ -3284,15 +3278,15 @@ foldlevelExpr(fline_T *flp)
if (lnum <= 1)
flp->lvl = 0;
- /* KeyTyped may be reset to 0 when calling a function which invokes
- * do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. */
+ // KeyTyped may be reset to 0 when calling a function which invokes
+ // do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
save_keytyped = KeyTyped;
n = (int)eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped;
switch (c)
{
- /* "a1", "a2", .. : add to the fold level */
+ // "a1", "a2", .. : add to the fold level
case 'a': if (flp->lvl >= 0)
{
flp->lvl += n;
@@ -3301,7 +3295,7 @@ foldlevelExpr(fline_T *flp)
flp->start = n;
break;
- /* "s1", "s2", .. : subtract from the fold level */
+ // "s1", "s2", .. : subtract from the fold level
case 's': if (flp->lvl >= 0)
{
if (n > flp->lvl)
@@ -3312,25 +3306,25 @@ foldlevelExpr(fline_T *flp)
}
break;
- /* ">1", ">2", .. : start a fold with a certain level */
+ // ">1", ">2", .. : start a fold with a certain level
case '>': flp->lvl = n;
flp->lvl_next = n;
flp->start = 1;
break;
- /* "<1", "<2", .. : end a fold with a certain level */
+ // "<1", "<2", .. : end a fold with a certain level
case '<': flp->lvl_next = n - 1;
flp->end = n;
break;
- /* "=": No change in level */
+ // "=": No change in level
case '=': flp->lvl_next = flp->lvl;
break;
- /* "-1", "0", "1", ..: set fold level */
+ // "-1", "0", "1", ..: set fold level
default: if (n < 0)
- /* Use the current level for the next line, so that "a1"
- * will work there. */
+ // Use the current level for the next line, so that "a1"
+ // will work there.
flp->lvl_next = flp->lvl;
else
flp->lvl_next = n;
@@ -3338,8 +3332,8 @@ foldlevelExpr(fline_T *flp)
break;
}
- /* If the level is unknown for the first or the last line in the file, use
- * level 0. */
+ // If the level is unknown for the first or the last line in the file, use
+ // level 0.
if (flp->lvl < 0)
{
if (lnum <= 1)
@@ -3356,7 +3350,7 @@ foldlevelExpr(fline_T *flp)
#endif
}
-/* parseMarker() {{{2 */
+// parseMarker() {{{2
/*
* Parse 'foldmarker' and set "foldendmarker", "foldstartmarkerlen" and
* "foldendmarkerlen".
@@ -3370,7 +3364,7 @@ parseMarker(win_T *wp)
foldendmarkerlen = (int)STRLEN(foldendmarker);
}
-/* foldlevelMarker() {{{2 */
+// foldlevelMarker() {{{2
/*
* Low level function to get the foldlevel for the "marker" method.
* "foldendmarker", "foldstartmarkerlen" and "foldendmarkerlen" must have been
@@ -3390,13 +3384,13 @@ foldlevelMarker(fline_T *flp)
char_u *s;
int n;
- /* cache a few values for speed */
+ // cache a few values for speed
startmarker = flp->wp->w_p_fmr;
cstart = *startmarker;
++startmarker;
cend = *foldendmarker;
- /* Default: no start found, next level is same as current level */
+ // Default: no start found, next level is same as current level
flp->start = 0;
flp->lvl_next = flp->lvl;
@@ -3406,7 +3400,7 @@ foldlevelMarker(fline_T *flp)
if (*s == cstart
&& STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0)
{
- /* found startmarker: set flp->lvl */
+ // found startmarker: set flp->lvl
s += foldstartmarkerlen;
if (VIM_ISDIGIT(*s))
{
@@ -3431,7 +3425,7 @@ foldlevelMarker(fline_T *flp)
else if (*s == cend
&& STRNCMP(s + 1, foldendmarker + 1, foldendmarkerlen - 1) == 0)
{
- /* found endmarker: set flp->lvl_next */
+ // found endmarker: set flp->lvl_next
s += foldendmarkerlen;
if (VIM_ISDIGIT(*s))
{
@@ -3440,7 +3434,7 @@ foldlevelMarker(fline_T *flp)
{
flp->lvl = n;
flp->lvl_next = n - 1;
- /* never start a fold with an end marker */
+ // never start a fold with an end marker
if (flp->lvl_next > start_lvl)
flp->lvl_next = start_lvl;
}
@@ -3452,12 +3446,12 @@ foldlevelMarker(fline_T *flp)
MB_PTR_ADV(s);
}
- /* The level can't go negative, must be missing a start marker. */
+ // The level can't go negative, must be missing a start marker.
if (flp->lvl_next < 0)
flp->lvl_next = 0;
}
-/* foldlevelSyntax() {{{2 */
+// foldlevelSyntax() {{{2
/*
* Low level function to get the foldlevel for the "syntax" method.
* Doesn't use any caching.
@@ -3472,7 +3466,7 @@ foldlevelSyntax(fline_T *flp)
linenr_T lnum = flp->lnum + flp->off;
int n;
- /* Use the maximum fold level at the start of this line and the next. */
+ // Use the maximum fold level at the start of this line and the next.
flp->lvl = syn_get_foldlevel(flp->wp, lnum);
flp->start = 0;
if (lnum < flp->wp->w_buffer->b_ml.ml_line_count)
@@ -3480,15 +3474,15 @@ foldlevelSyntax(fline_T *flp)
n = syn_get_foldlevel(flp->wp, lnum + 1);
if (n > flp->lvl)
{
- flp->start = n - flp->lvl; /* fold(s) start here */
+ flp->start = n - flp->lvl; // fold(s) start here
flp->lvl = n;
}
}
#endif
}
-/* functions for storing the fold state in a View {{{1 */
-/* put_folds() {{{2 */
+// functions for storing the fold state in a View {{{1
+// put_folds() {{{2
#if defined(FEAT_SESSION) || defined(PROTO)
static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off);
static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off);
@@ -3508,14 +3502,14 @@ put_folds(FILE *fd, win_T *wp)
return FAIL;
}
- /* If some folds are manually opened/closed, need to restore that. */
+ // If some folds are manually opened/closed, need to restore that.
if (wp->w_fold_manual)
return put_foldopen_recurse(fd, wp, &wp->w_folds, (linenr_T)0);
return OK;
}
-/* put_folds_recurse() {{{2 */
+// put_folds_recurse() {{{2
/*
* Write commands to "fd" to recreate manually created folds.
* Returns FAIL when writing failed.
@@ -3529,7 +3523,7 @@ put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
fp = (fold_T *)gap->ga_data;
for (i = 0; i < gap->ga_len; i++)
{
- /* Do nested folds first, they will be created closed. */
+ // Do nested folds first, they will be created closed.
if (put_folds_recurse(fd, &fp->fd_nested, off + fp->fd_top) == FAIL)
return FAIL;
if (fprintf(fd, "%ld,%ldfold", fp->fd_top + off,
@@ -3541,7 +3535,7 @@ put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
return OK;
}
-/* put_foldopen_recurse() {{{2 */
+// put_foldopen_recurse() {{{2
/*
* Write commands to "fd" to open and close manually opened/closed folds.
* Returns FAIL when writing failed.
@@ -3564,7 +3558,7 @@ put_foldopen_recurse(
{
if (fp->fd_nested.ga_len > 0)
{
- /* open nested folds while this fold is open */
+ // open nested folds while this fold is open
if (fprintf(fd, "%ld", fp->fd_top + off) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "normal! zo") == FAIL)
@@ -3573,7 +3567,7 @@ put_foldopen_recurse(
off + fp->fd_top)
== FAIL)
return FAIL;
- /* close the parent when needed */
+ // close the parent when needed
if (fp->fd_flags == FD_CLOSED)
{
if (put_fold_open_close(fd, fp, off) == FAIL)
@@ -3582,9 +3576,9 @@ put_foldopen_recurse(
}
else
{
- /* Open or close the leaf according to the window foldlevel.
- * Do not close a leaf that is already closed, as it will close
- * the parent. */
+ // Open or close the leaf according to the window foldlevel.
+ // Do not close a leaf that is already closed, as it will close
+ // the parent.
level = foldLevelWin(wp, off + fp->fd_top);
if ((fp->fd_flags == FD_CLOSED && wp->w_p_fdl >= level)
|| (fp->fd_flags != FD_CLOSED && wp->w_p_fdl < level))
@@ -3598,7 +3592,7 @@ put_foldopen_recurse(
return OK;
}
-/* put_fold_open_close() {{{2 */
+// put_fold_open_close() {{{2
/*
* Write the open or close command to "fd".
* Returns FAIL when writing failed.
@@ -3615,9 +3609,9 @@ put_fold_open_close(FILE *fd, fold_T *fp, linenr_T off)
return OK;
}
-#endif /* FEAT_SESSION */
+#endif // FEAT_SESSION
-/* }}}1 */
+// }}}1
#endif // defined(FEAT_FOLDING) || defined(PROTO)
#if defined(FEAT_EVAL) || defined(PROTO)
diff --git a/src/version.c b/src/version.c
index cc5b4b99d..4d03ce88a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2379,
+/**/
2378,
/**/
2377,