aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/syntax.c121
-rw-r--r--src/nvim/tag.c73
3 files changed, 95 insertions, 101 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 772275df84..50b12f9dcc 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -2602,7 +2602,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
upp = vim_strsave(items[1]);
} else if (is_aff_rule(items, itemcnt, "REP", 2)
|| is_aff_rule(items, itemcnt, "REPSAL", 2)) {
- /* Ignore REP/REPSAL count */;
+ // Ignore REP/REPSAL count
if (!isdigit(*items[1])) {
smsg(_("Expected REP(SAL) count in %s line %d"),
fname, lnum);
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 49f54dcfe1..ecbfbf8a93 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -230,11 +230,10 @@ struct name_list {
static char *(spo_name_tab[SPO_COUNT]) =
{ "ms=", "me=", "hs=", "he=", "rs=", "re=", "lc=" };
-/* The sp_off_flags are computed like this:
- * offset from the start of the matched text: (1 << SPO_XX_OFF)
- * offset from the end of the matched text: (1 << (SPO_XX_OFF + SPO_COUNT))
- * When both are present, only one is used.
- */
+// The sp_off_flags are computed like this:
+// offset from the start of the matched text: (1 << SPO_XX_OFF)
+// offset from the end of the matched text: (1 << (SPO_XX_OFF + SPO_COUNT))
+// When both are present, only one is used.
#define SPTYPE_MATCH 1 // match keyword with this group ID
#define SPTYPE_START 2 // match a regexp, start of item
@@ -345,7 +344,7 @@ static int next_seqnr = 1; // value to use for si_seqnr
*/
static int next_match_col; // column for start of next match
static lpos_T next_match_m_endpos; // position for end of next match
-static lpos_T next_match_h_startpos; // pos. for highl. start of next match
+static lpos_T next_match_h_startpos; // pos. for highl. start of next match
static lpos_T next_match_h_endpos; // pos. for highl. end of next match
static int next_match_idx; // index of matched item
static long next_match_flags; // flags for next match
@@ -492,8 +491,8 @@ void syntax_start(win_T *wp, linenr_T lnum)
// First line is always valid, no matter "minlines".
first_stored = 1;
} else {
- /* Need to parse "minlines" lines before state can be considered
- * valid to store. */
+ // Need to parse "minlines" lines before state can be considered
+ // valid to store.
first_stored = current_lnum + syn_block->b_syn_sync_minlines;
}
} else {
@@ -514,12 +513,12 @@ void syntax_start(win_T *wp, linenr_T lnum)
(void)syn_finish_line(false);
current_lnum++;
- /* If we parsed at least "minlines" lines or started at a valid
- * state, the current state is considered valid. */
+ // If we parsed at least "minlines" lines or started at a valid
+ // state, the current state is considered valid.
if (current_lnum >= first_stored) {
- /* Check if the saved state entry is for the current line and is
- * equal to the current state. If so, then validate all saved
- * states that depended on a change before the parsed line. */
+ // Check if the saved state entry is for the current line and is
+ // equal to the current state. If so, then validate all saved
+ // states that depended on a change before the parsed line.
if (prev == NULL) {
prev = syn_stack_find_entry(current_lnum - 1);
}
@@ -548,19 +547,18 @@ void syntax_start(win_T *wp, linenr_T lnum)
sp = sp->sst_next;
}
load_current_state(prev);
- }
- /* Store the state at this line when it's the first one, the line
- * where we start parsing, or some distance from the previously
- * saved state. But only when parsed at least 'minlines'. */
- else if (prev == NULL
- || current_lnum == lnum
- || current_lnum >= prev->sst_lnum + dist) {
+ } else if (prev == NULL
+ // Store the state at this line when it's the first one, the line
+ // where we start parsing, or some distance from the previously
+ // saved state. But only when parsed at least 'minlines'.
+ || current_lnum == lnum
+ || current_lnum >= prev->sst_lnum + dist) {
prev = store_current_state();
}
}
- /* This can take a long time: break when CTRL-C pressed. The current
- * state will be wrong then. */
+ // This can take a long time: break when CTRL-C pressed. The current
+ // state will be wrong then.
line_breakcheck();
if (got_int) {
current_lnum = lnum;
@@ -664,8 +662,8 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
* 1. Search backwards for the end of a C-style comment.
*/
if (syn_block->b_syn_sync_flags & SF_CCOMMENT) {
- /* Need to make syn_buf the current buffer for a moment, to be able to
- * use find_start_comment(). */
+ // Need to make syn_buf the current buffer for a moment, to be able to
+ // use find_start_comment().
curwin_save = curwin;
curwin = wp;
curbuf_save = curbuf;
@@ -793,9 +791,9 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
++current_col;
}
- /* syn_current_attr() will have skipped the check for
- * an item that ends here, need to do that now. Be
- * careful not to go past the NUL. */
+ // syn_current_attr() will have skipped the check for
+ // an item that ends here, need to do that now. Be
+ // careful not to go past the NUL.
prev_current_col = current_col;
if (syn_getcurline()[current_col] != NUL) {
++current_col;
@@ -987,9 +985,8 @@ static void syn_update_ends(bool startofline)
check_keepend();
}
-/****************************************
- * Handling of the state stack cache.
- */
+/////////////////////////////////////////
+// Handling of the state stack cache.
/*
* EXPLANATION OF THE SYNTAX STATE STACK CACHE
@@ -1081,8 +1078,8 @@ static void syn_stack_alloc(void)
}
if (syn_block->b_sst_array != NULL) {
- /* When shrinking the array, cleanup the existing stack.
- * Make sure that all valid entries fit in the new array. */
+ // When shrinking the array, cleanup the existing stack.
+ // Make sure that all valid entries fit in the new array.
while (syn_block->b_sst_len - syn_block->b_sst_freecount + 2 > len
&& syn_stack_cleanup()) {
;
@@ -1165,9 +1162,9 @@ static void syn_stack_apply_changes_block(synblock_T *block, buf_T *buf)
p = np;
continue;
}
- /* This state is below the changed area. Remember the line
- * that needs to be parsed before this entry can be made valid
- * again. */
+ // This state is below the changed area. Remember the line
+ // that needs to be parsed before this entry can be made valid
+ // again.
if (p->sst_change_lnum != 0 && p->sst_change_lnum > buf->b_mod_top) {
if (p->sst_change_lnum + buf->b_mod_xlines > buf->b_mod_top) {
p->sst_change_lnum += buf->b_mod_xlines;
@@ -1638,8 +1635,8 @@ int get_syntax_attr(const colnr_T col, bool *const can_spell, const bool keep_st
int attr = 0;
if (can_spell != NULL) {
- /* Default: Only do spelling when there is no @Spell cluster or when
- * ":syn spell toplevel" was used. */
+ // Default: Only do spelling when there is no @Spell cluster or when
+ // ":syn spell toplevel" was used.
*can_spell = syn_block->b_syn_spell == SYNSPL_DEFAULT
? (syn_block->b_spell_cluster_id == 0)
: (syn_block->b_syn_spell == SYNSPL_TOP);
@@ -1901,15 +1898,15 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
syn_add_start_off(&pos, &regmatch,
spp, SPO_MS_OFF, -1);
if (pos.lnum > current_lnum) {
- /* must have used end of match in a next line,
- * we can't handle that */
+ // must have used end of match in a next line,
+ // we can't handle that
spp->sp_startcol = MAXCOL;
continue;
}
startcol = pos.col;
- /* remember the next column where this pattern
- * matches in the current line */
+ // remember the next column where this pattern
+ // matches in the current line
spp->sp_startcol = startcol;
/*
@@ -1999,8 +1996,8 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
/*
* keep the best match so far in next_match_*
*/
- /* Highlighting must start after startpos and end
- * before endpos. */
+ // Highlighting must start after startpos and end
+ // before endpos.
if (hl_startpos.lnum == current_lnum
&& (int)hl_startpos.col < startcol) {
hl_startpos.col = startcol;
@@ -2029,8 +2026,8 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
if (next_match_idx >= 0 && next_match_col == (int)current_col) {
synpat_T *lspp;
- /* When a zero-width item matched which has a nextgroup,
- * don't push the item but set nextgroup. */
+ // When a zero-width item matched which has a nextgroup,
+ // don't push the item but set nextgroup.
lspp = &(SYN_ITEMS(syn_block)[next_match_idx]);
if (next_match_m_endpos.lnum == current_lnum
&& next_match_m_endpos.col == current_col
@@ -2127,8 +2124,8 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
* done in the current item.
*/
if (syn_block->b_spell_cluster_id == 0) {
- /* There is no @Spell cluster: Do spelling for items without
- * @NoSpell cluster. */
+ // There is no @Spell cluster: Do spelling for items without
+ // @NoSpell cluster.
if (syn_block->b_nospell_cluster_id == 0
|| current_trans_id == 0) {
*can_spell = (syn_block->b_syn_spell != SYNSPL_NOTOP);
@@ -2180,8 +2177,8 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
}
}
} else if (can_spell != NULL) {
- /* Default: Only do spelling when there is no @Spell cluster or when
- * ":syn spell toplevel" was used. */
+ // Default: Only do spelling when there is no @Spell cluster or when
+ // ":syn spell toplevel" was used.
*can_spell = syn_block->b_syn_spell == SYNSPL_DEFAULT
? (syn_block->b_spell_cluster_id == 0)
: (syn_block->b_syn_spell == SYNSPL_TOP);
@@ -2365,8 +2362,8 @@ static void check_state_ends(void)
current_next_list = NULL;
}
- /* When the ended item has "extend", another item with
- * "keepend" now needs to check for its end. */
+ // When the ended item has "extend", another item with
+ // "keepend" now needs to check for its end.
had_extend = (cur_si->si_flags & HL_EXTEND);
pop_current_state();
@@ -2541,9 +2538,9 @@ static void update_si_end(stateitem_T *sip, int startcol, bool force)
return;
}
- /* Don't update when it's already done. Can be a match of an end pattern
- * that started in a previous line. Watch out: can also be a "keepend"
- * from a containing item. */
+ // Don't update when it's already done. Can be a match of an end pattern
+ // that started in a previous line. Watch out: can also be a "keepend"
+ // from a containing item.
if (!force && sip->si_m_endpos.lnum >= current_lnum) {
return;
}
@@ -2822,8 +2819,8 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
}
limit_pos(hl_endpos, m_endpos);
- /* now the match ends where the highlighting ends, it is turned
- * into the matchgroup for the end */
+ // now the match ends where the highlighting ends, it is turned
+ // into the matchgroup for the end
*m_endpos = *hl_endpos;
} else {
*end_idx = 0;
@@ -5571,8 +5568,8 @@ static int in_id_list(stateitem_T *cur_si, int16_t *list, struct sp_syn *ssp, in
// If ssp has a "containedin" list and "cur_si" is in it, return TRUE.
if (cur_si != NULL && ssp->cont_in_list != NULL
&& !(cur_si->si_flags & HL_MATCH)) {
- /* Ignore transparent items without a contains argument. Double check
- * that we don't go back past the first one. */
+ // Ignore transparent items without a contains argument. Double check
+ // that we don't go back past the first one.
while ((cur_si->si_flags & HL_TRANS_CONT)
&& cur_si > (stateitem_T *)(current_state.ga_data)) {
--cur_si;
@@ -5636,8 +5633,8 @@ static int in_id_list(stateitem_T *cur_si, int16_t *list, struct sp_syn *ssp, in
}
if (item >= SYNID_CLUSTER) {
scl_list = SYN_CLSTR(syn_block)[item - SYNID_CLUSTER].scl_list;
- /* restrict recursiveness to 30 to avoid an endless loop for a
- * cluster that includes itself (indirectly) */
+ // restrict recursiveness to 30 to avoid an endless loop for a
+ // cluster that includes itself (indirectly)
if (scl_list != NULL && depth < 30) {
++depth;
r = in_id_list(NULL, scl_list, ssp, contained);
@@ -5932,8 +5929,8 @@ int syn_get_sub_char(void)
int syn_get_stack_item(int i)
{
if (i >= current_state.ga_len) {
- /* Need to invalidate the state, because we didn't properly finish it
- * for the last character, "keep_state" was TRUE. */
+ // Need to invalidate the state, because we didn't properly finish it
+ // for the last character, "keep_state" was TRUE.
invalidate_current_state();
current_col = MAXCOL;
return -1;
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 768cca284b..3b29d62191 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -230,8 +230,8 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
if (g_do_tagpreview != 0) {
if (ptag_entry.tagname != NULL
&& STRCMP(ptag_entry.tagname, tag) == 0) {
- /* Jumping to same tag: keep the current match, so that
- * the CursorHold autocommand example works. */
+ // Jumping to same tag: keep the current match, so that
+ // the CursorHold autocommand example works.
cur_match = ptag_entry.cur_match;
cur_fnum = ptag_entry.cur_fnum;
} else {
@@ -407,9 +407,9 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
tagstack[tagstackidx].fmark.fnum = curbuf->b_fnum;
}
- /* Curwin will change in the call to jumpto_tag() if ":stag" was
- * used or an autocommand jumps to another window; store value of
- * tagstackidx now. */
+ // Curwin will change in the call to jumpto_tag() if ":stag" was
+ // used or an autocommand jumps to another window; store value of
+ // tagstackidx now.
curwin->w_tagstackidx = tagstackidx;
if (type != DT_SELECT && type != DT_JUMP) {
curwin->w_tagstack[tagstackidx].cur_match = cur_match;
@@ -418,9 +418,9 @@ int do_tag(char_u *tag, int type, int count, int forceit, int verbose)
}
}
- /* When not using the current buffer get the name of buffer "cur_fnum".
- * Makes sure that the tag order doesn't change when using a remembered
- * position for "cur_match". */
+ // When not using the current buffer get the name of buffer "cur_fnum".
+ // Makes sure that the tag order doesn't change when using a remembered
+ // position for "cur_match".
if (cur_fnum != curbuf->b_fnum) {
buf_T *buf = buflist_findnr(cur_fnum);
@@ -1101,8 +1101,8 @@ static void prepare_pats(pat_T *pats, int has_re)
pats->head = pats->pat;
pats->headlen = pats->len;
if (has_re) {
- /* When the pattern starts with '^' or "\\<", binary searching can be
- * used (much faster). */
+ // When the pattern starts with '^' or "\\<", binary searching can be
+ // used (much faster).
if (pats->pat[0] == '^') {
pats->head = pats->pat + 1;
} else if (pats->pat[0] == '\\' && pats->pat[1] == '<') {
@@ -1500,8 +1500,8 @@ int find_tags(char_u *pat, int *num_matches, char_u ***matchesp, int flags, int
orgpat.len = (int)STRLEN(pat);
if (curbuf->b_help) {
- /* When "@ab" is specified use only the "ab" language, otherwise
- * search all languages. */
+ // When "@ab" is specified use only the "ab" language, otherwise
+ // search all languages.
if (orgpat.len > 3 && pat[orgpat.len - 3] == '@'
&& ASCII_ISALPHA(pat[orgpat.len - 2])
&& ASCII_ISALPHA(pat[orgpat.len - 1])) {
@@ -1613,9 +1613,9 @@ int find_tags(char_u *pat, int *num_matches, char_u ***matchesp, int flags, int
}
}
if (s == NULL || *s == NUL) {
- /* Language not in 'helplang': use last, prefer English,
- * unless found already. */
- ++help_pri;
+ // Language not in 'helplang': use last, prefer English,
+ // unless found already.
+ help_pri++;
if (STRICMP(help_lang, "en") != 0) {
++help_pri;
}
@@ -1654,8 +1654,8 @@ int find_tags(char_u *pat, int *num_matches, char_u ***matchesp, int flags, int
stop_searching = true;
break;
}
- /* When mincount is TAG_MANY, stop when enough matches have been
- * found (for completion). */
+ // When mincount is TAG_MANY, stop when enough matches have been
+ // found (for completion).
if (mincount == TAG_MANY && match_count >= TAG_MANY) {
stop_searching = true;
retval = OK;
@@ -1695,8 +1695,8 @@ int find_tags(char_u *pat, int *num_matches, char_u ***matchesp, int flags, int
vim_fseek(fp, search_info.curr_offset, SEEK_SET);
eof = vim_fgets(lbuf, lbuf_size, fp);
if (!eof && search_info.curr_offset != 0) {
- /* The explicit cast is to work around a bug in gcc 3.4.2
- * (repeated below). */
+ // The explicit cast is to work around a bug in gcc 3.4.2
+ // (repeated below).
search_info.curr_offset = vim_ftell(fp);
if (search_info.curr_offset == search_info.high_offset) {
// oops, gone a bit too far; try from low offset
@@ -1739,9 +1739,9 @@ line_read_in:
char_u *conv_line;
int len;
- /* Convert every line. Converting the pattern from 'enc' to
- * the tags file encoding doesn't work, because characters are
- * not recognized. */
+ // Convert every line. Converting the pattern from 'enc' to
+ // the tags file encoding doesn't work, because characters are
+ // not recognized.
conv_line = string_convert(&vimconv, lbuf, NULL);
if (conv_line != NULL) {
// Copy or swap lbuf and conv_line.
@@ -1764,13 +1764,12 @@ line_read_in:
* format, and for "not sorted" flag.
*/
if (state == TS_START) {
- /* The header ends when the line sorts below "!_TAG_". When
- * case is folded lower case letters sort before "_". */
+ // The header ends when the line sorts below "!_TAG_". When
+ // case is folded lower case letters sort before "_".
if (STRNCMP(lbuf, "!_TAG_", 6) <= 0
|| (lbuf[0] == '!' && ASCII_ISLOWER(lbuf[1]))) {
if (STRNCMP(lbuf, "!_TAG_", 6) != 0) {
- /* Non-header item before the header, e.g. "!" itself.
- */
+ // Non-header item before the header, e.g. "!" itself.
goto parse_line;
}
@@ -1781,10 +1780,9 @@ line_read_in:
tag_file_sorted = lbuf[18];
}
if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) {
- /* Prepare to convert every line from the specified
- * encoding to 'encoding'. */
- for (p = lbuf + 20; *p > ' ' && *p < 127; ++p) {
- ;
+ // Prepare to convert every line from the specified
+ // encoding to 'encoding'.
+ for (p = lbuf + 20; *p > ' ' && *p < 127; p++) {
}
*p = NUL;
convert_setup(&vimconv, lbuf + 20, p_enc);
@@ -1820,9 +1818,9 @@ line_read_in:
}
if (state == TS_BINARY && orgpat.regmatch.rm_ic && !sortic) {
- /* Binary search won't work for ignoring case, use linear
- * search. */
- linear = TRUE;
+ // Binary search won't work for ignoring case, use linear
+ // search.
+ linear = true;
state = TS_LINEAR;
}
@@ -1927,9 +1925,8 @@ parse_line:
}
if (tagcmp == 0) {
- /* We've located the tag, now skip back and search
- * forward until the first matching tag is found.
- */
+ // We've located the tag, now skip back and search
+ // forward until the first matching tag is found.
state = TS_SKIP_BACK;
search_info.match_offset = search_info.curr_offset;
continue;
@@ -1966,8 +1963,8 @@ parse_line:
if (mb_strnicmp(tagp.tagname, orgpat.head, (size_t)cmplen) != 0) {
state = TS_STEP_FORWARD;
} else {
- /* Have to skip back more. Restore the curr_offset
- * used, otherwise we get stuck at a long line. */
+ // Have to skip back more. Restore the curr_offset
+ // used, otherwise we get stuck at a long line.
search_info.curr_offset = search_info.curr_offset_used;
}
continue;