aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/regexp.c12
-rw-r--r--src/nvim/regexp_nfa.c79
-rw-r--r--src/nvim/screen.c8
-rw-r--r--src/nvim/search.c87
4 files changed, 92 insertions, 94 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 98a46cf781..eca6739f5c 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -3003,8 +3003,8 @@ static void ungetchr(void)
at_start = prev_at_start;
prev_at_start = false;
- /* Backup regparse, so that it's at the same position as before the
- * getchr(). */
+ // Backup regparse, so that it's at the same position as before the
+ // getchr().
regparse -= prevchr_len;
}
@@ -6412,8 +6412,8 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n)
int c1, c2, c11, c12;
int junk;
- /* we have to handle the strcmp ourselves, since it is necessary to
- * deal with the composing characters by ignoring them: */
+ // we have to handle the strcmp ourselves, since it is necessary to
+ // deal with the composing characters by ignoring them:
str1 = s1;
str2 = s2;
c1 = c2 = 0;
@@ -7184,8 +7184,8 @@ static regengine_T nfa_regengine =
(char_u *)""
};
-/* Which regexp engine to use? Needed for vim_regcomp().
- * Must match with 'regexpengine'. */
+// Which regexp engine to use? Needed for vim_regcomp().
+// Must match with 'regexpengine'.
static int regexp_engine = 0;
#ifdef REGEXP_DEBUG
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 039f9b4675..7550ff64ef 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -372,8 +372,8 @@ nfa_regcomp_start (
/* A reasonable estimation for maximum size */
nstate_max = (STRLEN(expr) + 1) * 25;
- /* Some items blow up in size, such as [A-z]. Add more space for that.
- * When it is still not enough realloc_post_list() will be used. */
+ // Some items blow up in size, such as [A-z]. Add more space for that.
+ // When it is still not enough realloc_post_list() will be used.
nstate_max += 1000;
/* Size for postfix representation of expr. */
@@ -1424,8 +1424,8 @@ static int nfa_regatom(void)
}
break;
- /* Catch \%^ and \%$ regardless of where they appear in the
- * pattern -- regardless of whether or not it makes sense. */
+ // Catch \%^ and \%$ regardless of where they appear in the
+ // pattern -- regardless of whether or not it makes sense.
case '^':
EMIT(NFA_BOF);
break;
@@ -1466,13 +1466,13 @@ static int nfa_regatom(void)
EMIT(NFA_OPT_CHARS);
EMIT(n);
- /* Emit as "\%(\%[abc]\)" to be able to handle
- * "\%[abc]*" which would cause the empty string to be
- * matched an unlimited number of times. NFA_NOPEN is
- * added only once at a position, while NFA_SPLIT is
- * added multiple times. This is more efficient than
- * not allowing NFA_SPLIT multiple times, it is used
- * a lot. */
+ // Emit as "\%(\%[abc]\)" to be able to handle
+ // "\%[abc]*" which would cause the empty string to be
+ // matched an unlimited number of times. NFA_NOPEN is
+ // added only once at a position, while NFA_SPLIT is
+ // added multiple times. This is more efficient than
+ // not allowing NFA_SPLIT multiple times, it is used
+ // a lot.
EMIT(NFA_NOPEN);
break;
}
@@ -1882,8 +1882,8 @@ static int nfa_regpiece(void)
int my_post_start;
int quest;
- /* Save the current parse state, so that we can use it if <atom>{m,n} is
- * next. */
+ // Save the current parse state, so that we can use it if <atom>{m,n} is
+ // next.
save_parse_state(&old_state);
/* store current pos in the postfix form, for \{m,n} involving 0s */
@@ -1967,12 +1967,11 @@ static int nfa_regpiece(void)
break;
case Magic('{'):
- /* a{2,5} will expand to 'aaa?a?a?'
- * a{-1,3} will expand to 'aa??a??', where ?? is the nongreedy
- * version of '?'
- * \v(ab){2,3} will expand to '(ab)(ab)(ab)?', where all the
- * parenthesis have the same id
- */
+ // a{2,5} will expand to 'aaa?a?a?'
+ // a{-1,3} will expand to 'aa??a??', where ?? is the nongreedy
+ // version of '?'
+ // \v(ab){2,3} will expand to '(ab)(ab)(ab)?', where all the
+ // parenthesis have the same id
greedy = true;
c2 = peekchr();
@@ -1983,8 +1982,8 @@ static int nfa_regpiece(void)
if (!read_limits(&minval, &maxval))
EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits"));
- /* <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to
- * <atom>* */
+ // <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to
+ // <atom>*
if (minval == 0 && maxval == MAX_LIMIT) {
if (greedy)
/* \{}, \{0,} */
@@ -3327,10 +3326,10 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
break;
}
- /* Allow "NFA_MOPEN" as a valid postfix representation for
- * the empty regexp "". In this case, the NFA will be
- * NFA_MOPEN -> NFA_MCLOSE. Note that this also allows
- * empty groups of parenthesis, and empty mbyte chars */
+ // Allow "NFA_MOPEN" as a valid postfix representation for
+ // the empty regexp "". In this case, the NFA will be
+ // NFA_MOPEN -> NFA_MCLOSE. Note that this also allows
+ // empty groups of parenthesis, and empty mbyte chars
if (stackp == stack) {
s = alloc_state(mopen, NULL, NULL);
if (s == NULL)
@@ -3343,8 +3342,8 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size)
break;
}
- /* At least one node was emitted before NFA_MOPEN, so
- * at least one node will be between NFA_MOPEN and NFA_MCLOSE */
+ // At least one node was emitted before NFA_MOPEN, so
+ // at least one node will be between NFA_MOPEN and NFA_MCLOSE
e = POP();
s = alloc_state(mopen, e.start, NULL); /* `(' */
if (s == NULL)
@@ -3501,14 +3500,14 @@ static void nfa_postprocess(nfa_regprog_T *prog)
int ch_invisible = failure_chance(prog->state[i].out, 0);
int ch_follows = failure_chance(prog->state[i].out1->out, 0);
- /* Postpone when the invisible match is expensive or has a
- * lower chance of failing. */
+ // Postpone when the invisible match is expensive or has a
+ // lower chance of failing.
if (c == NFA_START_INVISIBLE_BEFORE
|| c == NFA_START_INVISIBLE_BEFORE_NEG) {
- /* "before" matches are very expensive when
- * unbounded, always prefer what follows then,
- * unless what follows will always match.
- * Otherwise strongly prefer what follows. */
+ // "before" matches are very expensive when
+ // unbounded, always prefer what follows then,
+ // unless what follows will always match.
+ // Otherwise strongly prefer what follows.
if (prog->state[i].val <= 0 && ch_follows > 0) {
directly = false;
} else {
@@ -3527,9 +3526,9 @@ static void nfa_postprocess(nfa_regprog_T *prog)
}
}
-/****************************************************************
-* NFA execution code.
-****************************************************************/
+/////////////////////////////////////////////////////////////////
+// NFA execution code.
+/////////////////////////////////////////////////////////////////
/* Values for done in nfa_pim_T. */
#define NFA_PIM_UNUSED 0 /* pim not used */
@@ -4195,8 +4194,8 @@ skip_add:
save_ptr = NULL;
memset(&save_multipos, 0, sizeof(save_multipos));
- /* Set the position (with "off" added) in the subexpression. Save
- * and restore it when it was in use. Otherwise fill any gap. */
+ // Set the position (with "off" added) in the subexpression. Save
+ // and restore it when it was in use. Otherwise fill any gap.
if (REG_MULTI) {
if (subidx < sub->in_use) {
save_multipos = sub->list.multi[subidx];
@@ -4295,8 +4294,8 @@ skip_add:
sub = &subs->norm;
}
- /* We don't fill in gaps here, there must have been an MOPEN that
- * has done that. */
+ // We don't fill in gaps here, there must have been an MOPEN that
+ // has done that.
save_in_use = sub->in_use;
if (sub->in_use <= subidx)
sub->in_use = subidx + 1;
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index fcd8fb1118..a1d03b363d 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -5164,8 +5164,8 @@ void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, in
if (row >= 0) {
if (wild_menu_showing == 0 || wild_menu_showing == WM_LIST) {
if (msg_scrolled > 0) {
- /* Put the wildmenu just above the command line. If there is
- * no room, scroll the screen one line up. */
+ // Put the wildmenu just above the command line. If there is
+ // no room, scroll the screen one line up.
if (cmdline_row == Rows - 1) {
msg_scroll_up(false);
msg_scrolled++;
@@ -7032,8 +7032,8 @@ int showmode(void)
if (VIsual_active) {
char *p;
- /* Don't concatenate separate words to avoid translation
- * problems. */
+ // Don't concatenate separate words to avoid translation
+ // problems.
switch ((VIsual_select ? 4 : 0)
+ (VIsual_mode == Ctrl_V) * 2
+ (VIsual_mode == 'V')) {
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 3d30932d69..1b54d12042 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -839,14 +839,14 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir,
}
}
- /* With the SEARCH_END option move to the last character
- * of the match. Don't do it for an empty match, end
- * should be same as start then. */
+ // With the SEARCH_END option move to the last character
+ // of the match. Don't do it for an empty match, end
+ // should be same as start then.
if ((options & SEARCH_END) && !(options & SEARCH_NOOF)
&& !(matchpos.lnum == endpos.lnum
&& matchpos.col == endpos.col)) {
- /* For a match in the first column, set the position
- * on the NUL in the previous line. */
+ // For a match in the first column, set the position
+ // on the NUL in the previous line.
pos->lnum = lnum + endpos.lnum;
pos->col = endpos.col;
if (endpos.col == 0) {
@@ -1498,8 +1498,8 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char_u *pat)
p = skipwhite(ptr);
pos->col = (colnr_T)(p - ptr);
- /* when adding lines the matching line may be empty but it is not
- * ignored because we are interested in the next line -- Acevedo */
+ // when adding lines the matching line may be empty but it is not
+ // ignored because we are interested in the next line -- Acevedo
if ((compl_cont_status & CONT_ADDING)
&& !(compl_cont_status & CONT_SOL)) {
if (mb_strcmp_ic((bool)p_ic, (const char *)p, (const char *)pat) == 0) {
@@ -1566,9 +1566,9 @@ int searchc(cmdarg_T *cap, int t_cmd)
c = *lastc;
// For multi-byte re-use last lastc_bytes[] and lastc_bytelen.
- /* Force a move of at least one char, so ";" and "," will move the
- * cursor, even if the cursor is right in front of char we are looking
- * at. */
+ // Force a move of at least one char, so ";" and "," will move the
+ // cursor, even if the cursor is right in front of char we are looking
+ // at.
if (vim_strchr(p_cpo, CPO_SCOLON) == NULL && count == 1 && t_cmd) {
stop = false;
}
@@ -2084,10 +2084,10 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
if (linep[pos.col - 1] == 'R'
&& linep[pos.col] == '"'
&& vim_strchr(linep + pos.col + 1, '(') != NULL) {
- /* Possible start of raw string. Now that we have the
- * delimiter we can check if it ends before where we
- * started searching, or before the previously found
- * raw string start. */
+ // Possible start of raw string. Now that we have the
+ // delimiter we can check if it ends before where we
+ // started searching, or before the previously found
+ // raw string start.
if (!find_rawstring_end(linep, &pos,
count > 0 ? &match_pos : &curwin->w_cursor)) {
count++;
@@ -2208,8 +2208,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
break;
case '"':
- /* a quote that is preceded with an odd number of backslashes is
- * ignored */
+ // a quote that is preceded with an odd number of backslashes is
+ // ignored
if (do_quotes) {
int col;
@@ -2282,8 +2282,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
bslcnt++;
}
}
- /* Only accept a match when 'M' is in 'cpo' or when escaping
- * is what we expect. */
+ // Only accept a match when 'M' is in 'cpo' or when escaping
+ // is what we expect.
if (cpo_bsl || (bslcnt & 1) == match_escaped) {
if (c == initc) {
count++;
@@ -3505,8 +3505,8 @@ int current_block(oparg_T *oap, long count, int include, int what, int other)
// Include the character under the cursor.
oap->inclusive = true;
} else {
- /* End is before the start (no text in between <>, [], etc.): don't
- * operate on any text. */
+ // End is before the start (no text in between <>, [], etc.): don't
+ // operate on any text.
curwin->w_cursor = start_pos;
}
}
@@ -4044,8 +4044,8 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
}
if (!vis_empty) {
- /* Check if the existing selection exactly spans the text inside
- * quotes. */
+ // Check if the existing selection exactly spans the text inside
+ // quotes.
if (vis_bef_curs) {
inside_quotes = VIsual.col > 0
&& line[VIsual.col - 1] == quotechar
@@ -4072,11 +4072,11 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
}
if (!vis_empty && line[col_start] == quotechar) {
- /* Already selecting something and on a quote character. Find the
- * next quoted string. */
+ // Already selecting something and on a quote character. Find the
+ // next quoted string.
if (vis_bef_curs) {
- /* Assume we are on a closing quote: move to after the next
- * opening quote. */
+ // Assume we are on a closing quote: move to after the next
+ // opening quote.
col_start = find_next_quote(line, col_start + 1, quotechar, NULL);
if (col_start < 0) {
goto abort_search;
@@ -4800,8 +4800,8 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
file_line = xmalloc(LSIZE);
if (type != CHECK_PATH && type != FIND_DEFINE
- /* when CONT_SOL is set compare "ptr" with the beginning of the line
- * is faster than quote_meta/regcomp/regexec "ptr" -- Acevedo */
+ // when CONT_SOL is set compare "ptr" with the beginning of the line
+ // is faster than quote_meta/regcomp/regexec "ptr" -- Acevedo
&& !(compl_cont_status & CONT_SOL)) {
pat = xmalloc(len + 5);
assert(len <= INT_MAX);
@@ -4946,10 +4946,9 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
// Nothing found, use the rest of the line.
p = incl_regmatch.endp[0];
i = (int)STRLEN(p);
- }
- /* Avoid checking before the start of the line, can
- * happen if \zs appears in the regexp. */
- else if (p > line) {
+ } else if (p > line) {
+ // Avoid checking before the start of the line, can
+ // happen if \zs appears in the regexp.
if (p[-1] == '"' || p[-1] == '<') {
--p;
++i;
@@ -5129,9 +5128,9 @@ search_line:
// IOSIZE > compl_length, so the STRNCPY works
STRNCPY(IObuff, aux, i);
- /* Get the next line: when "depth" < 0 from the current
- * buffer, otherwise from the included file. Jump to
- * exit_matched when past the last line. */
+ // Get the next line: when "depth" < 0 from the current
+ // buffer, otherwise from the included file. Jump to
+ // exit_matched when past the last line.
if (depth < 0) {
if (lnum >= end_lnum) {
goto exit_matched;
@@ -5142,9 +5141,9 @@ search_line:
goto exit_matched;
}
- /* we read a line, set "already" to check this "line" later
- * if depth >= 0 we'll increase files[depth].lnum far
- * bellow -- Acevedo */
+ // we read a line, set "already" to check this "line" later
+ // if depth >= 0 we'll increase files[depth].lnum far
+ // bellow -- Acevedo
already = aux = p = skipwhite(line);
p = find_word_start(p);
p = find_word_end(p);
@@ -5195,8 +5194,8 @@ search_line:
if (did_show) {
msg_putchar('\n'); // cursor below last one
}
- if (!got_int) { /* don't display if 'q' typed
- at "--more--" message */
+ if (!got_int) { // don't display if 'q' typed
+ // at "--more--" message
msg_home_replace_hl(curr_fname);
}
prev_fname = curr_fname;
@@ -5209,10 +5208,10 @@ search_line:
match_count++);
}
- /* Set matched flag for this file and all the ones that
- * include it */
- for (i = 0; i <= depth; ++i) {
- files[i].matched = TRUE;
+ // Set matched flag for this file and all the ones that
+ // include it
+ for (i = 0; i <= depth; i++) {
+ files[i].matched = true;
}
} else if (--count <= 0) {
found = true;