From b58c17f8df95d7626aec57de36781daa277314ee Mon Sep 17 00:00:00 2001 From: dvejmz Date: Sat, 21 Oct 2017 16:48:47 +0100 Subject: [PATCH 1/6] vim-patch:8.0.0198 Problem: Some syntax arguments take effect even after "if 0". (Taylor Venable) Solution: Properly skip the syntax statements. Make "syn case" and "syn conceal" report the current state. Fix that "syn clear" didn't reset the conceal flag. Add tests for :syntax skipping properly. https://github.com/vim/vim/commit/de318c5c35ed0d65fd2a07196cb8acd5ee6d9bf8 --- src/nvim/syntax.c | 75 +++++++++++++----- src/nvim/testdir/test_syntax.vim | 132 ++++++++++++++++++++++++++++++- 2 files changed, 185 insertions(+), 22 deletions(-) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d1a5f0bd1c..2222f41c78 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3019,12 +3019,19 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) + if (*arg == NUL) { + if (curwin->w_s->b_syn_conceal) { + MSG(_("syn conceal on")); + } else { + MSG(_("syn conceal off")); + } + } else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) { curwin->w_s->b_syn_conceal = TRUE; - else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) + } else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) { curwin->w_s->b_syn_conceal = FALSE; - else + } else { EMSG2(_("E390: Illegal argument: %s"), arg); + } } /* @@ -3040,12 +3047,19 @@ static void syn_cmd_case(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) + if (*arg == NUL) { + if (curwin->w_s->b_syn_ic) { + MSG(_("syntax case ignore")); + } else { + MSG(_("syntax case match")); + } + } else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) { curwin->w_s->b_syn_ic = FALSE; - else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) + } else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) { curwin->w_s->b_syn_ic = TRUE; - else + } else { EMSG2(_("E390: Illegal argument: %s"), arg); + } } /* @@ -3061,7 +3075,15 @@ static void syn_cmd_spell(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) { + if (*arg == NUL) { + if (curwin->w_s->b_syn_spell == SYNSPL_TOP) { + MSG(_("syntax spell toplevel")); + } else if (curwin->w_s->b_syn_spell == SYNSPL_NOTOP) { + MSG(_("syntax spell notoplevel")); + } else { + MSG(_("syntax spell default")); + } + } else if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) { curwin->w_s->b_syn_spell = SYNSPL_TOP; } else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) { curwin->w_s->b_syn_spell = SYNSPL_NOTOP; @@ -3125,6 +3147,7 @@ void syntax_clear(synblock_T *block) block->b_syn_ic = FALSE; /* Use case, by default */ block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */ block->b_syn_containedin = FALSE; + block->b_syn_conceal = FALSE; /* free the keywords */ clear_keywtab(&block->b_keywtab); @@ -4004,7 +4027,8 @@ static char_u * get_syn_options ( char_u *arg, /* next argument to be checked */ syn_opt_arg_T *opt, /* various things */ - int *conceal_char + int *conceal_char, + int skip /* TRUE if skipping over command */ ) { char_u *gname_start, *gname; @@ -4080,13 +4104,13 @@ get_syn_options ( EMSG(_("E395: contains argument not accepted here")); return NULL; } - if (get_id_list(&arg, 8, &opt->cont_list) == FAIL) + if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) return NULL; } else if (flagtab[fidx].argtype == 2) { - if (get_id_list(&arg, 11, &opt->cont_in_list) == FAIL) + if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) return NULL; } else if (flagtab[fidx].argtype == 3) { - if (get_id_list(&arg, 9, &opt->next_list) == FAIL) + if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) return NULL; } else if (flagtab[fidx].argtype == 11 && arg[5] == '=') { /* cchar=? */ @@ -4257,7 +4281,11 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) rest = get_group_name(arg, &group_name_end); if (rest != NULL) { - syn_id = syn_check_group(arg, (int)(group_name_end - arg)); + if (eap->skip) { + syn_id = -1; + } else { + syn_id = syn_check_group(arg, (int)(group_name_end - arg)); + } if (syn_id != 0) { // Allocate a buffer, for removing backslashes in the keyword. keyword_copy = xmalloc(STRLEN(rest) + 1); @@ -4276,7 +4304,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) cnt = 0; p = keyword_copy; for (; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) { - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest == NULL || ends_excmd(*rest)) { break; } @@ -4375,7 +4403,7 @@ syn_cmd_match ( syn_opt_arg.cont_list = NULL; syn_opt_arg.cont_in_list = NULL; syn_opt_arg.next_list = NULL; - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); /* get the pattern. */ init_syn_patterns(); @@ -4385,7 +4413,7 @@ syn_cmd_match ( syn_opt_arg.flags |= HL_HAS_EOL; /* Get options after the pattern */ - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest != NULL) { /* all arguments are valid */ /* @@ -4502,7 +4530,7 @@ syn_cmd_region ( */ while (rest != NULL && !ends_excmd(*rest)) { /* Check for option arguments */ - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest == NULL || ends_excmd(*rest)) break; @@ -4926,12 +4954,14 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing) break; clstr_list = NULL; - if (get_id_list(&rest, opt_len, &clstr_list) == FAIL) { + if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL) { EMSG2(_(e_invarg2), rest); break; } - syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, - &clstr_list, list_op); + if (scl_id >= 0) { + syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, + &clstr_list, list_op); + } got_clstr = TRUE; } @@ -5181,8 +5211,9 @@ static int get_id_list ( char_u **arg, int keylen, /* length of keyword */ - short **list /* where to store the resulting list, if not + short **list, /* where to store the resulting list, if not NULL, the list is silently skipped! */ + int skip ) { char_u *p = NULL; @@ -5251,7 +5282,9 @@ get_id_list ( id = SYNID_CONTAINED; id += current_syn_inc_tag; } else if (name[1] == '@') { - id = syn_check_cluster(name + 2, (int)(end - p - 1)); + if (!skip) { + id = syn_check_cluster(name + 2, (int)(end - p - 1)); + } } else { /* * Handle full group name. diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 6c084dd2a7..64b3c14d73 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -157,4 +157,134 @@ func Test_syntax_completion() call feedkeys(":syn match \\\"\", 'tx') call assert_match('^"syn match Boolean Character ', @:) -endfunc \ No newline at end of file +endfunc + +func Test_syntax_arg_skipped() + syn clear + syntax case ignore + if 0 + syntax case match + endif + call assert_match('case ignore', execute('syntax case')) + + syn keyword Foo foo + call assert_match('Foo', execute('syntax')) + syn clear + call assert_match('case match', execute('syntax case')) + call assert_notmatch('Foo', execute('syntax')) + + if has('conceal') + syn clear + syntax conceal on + if 0 + syntax conceal off + endif + call assert_match('conceal on', execute('syntax conceal')) + syn clear + call assert_match('conceal off', execute('syntax conceal')) + endif + + syntax region Tar start=// + if 0 + syntax region NotTest start=// contains=@Spell + endif + call assert_match('Tar', execute('syntax')) + call assert_notmatch('NotTest', execute('syntax')) + call assert_notmatch('Spell', execute('syntax')) + + hi Foo ctermfg=blue + let a = execute('hi Foo') + if 0 + syntax rest + endif + call assert_equal(a, execute('hi Foo')) + + set ft=tags + syn off + if 0 + syntax enable + endif + call assert_match('No Syntax items defined', execute('syntax')) + syntax enable + call assert_match('tagComment', execute('syntax')) + set ft= + + syn clear + if 0 + syntax include @Spell nothing + endif + call assert_notmatch('Spell', execute('syntax')) + + syn clear + syn iskeyword 48-57,$,_ + call assert_match('48-57,$,_', execute('syntax iskeyword')) + if 0 + syn clear + syn iskeyword clear + endif + call assert_match('48-57,$,_', execute('syntax iskeyword')) + syn iskeyword clear + call assert_match('not set', execute('syntax iskeyword')) + syn iskeyword 48-57,$,_ + syn clear + call assert_match('not set', execute('syntax iskeyword')) + + syn clear + syn keyword Foo foo + if 0 + syn keyword NotAdded bar + endif + call assert_match('Foo', execute('syntax')) + call assert_notmatch('NotAdded', execute('highlight')) + + syn clear + syn keyword Foo foo + call assert_match('Foo', execute('syntax')) + call assert_match('Foo', execute('syntax list')) + call assert_notmatch('Foo', execute('if 0 | syntax | endif')) + call assert_notmatch('Foo', execute('if 0 | syntax list | endif')) + + syn clear + syn match Fopi /asdf/ + if 0 + syn match Fopx /asdf/ + endif + call assert_match('Fopi', execute('syntax')) + call assert_notmatch('Fopx', execute('syntax')) + + syn clear + syn spell toplevel + call assert_match('spell toplevel', execute('syntax spell')) + if 0 + syn spell notoplevel + endif + call assert_match('spell toplevel', execute('syntax spell')) + syn spell notoplevel + call assert_match('spell notoplevel', execute('syntax spell')) + syn spell default + call assert_match('spell default', execute('syntax spell')) + + syn clear + if 0 + syntax cluster Spell + endif + call assert_notmatch('Spell', execute('syntax')) + + syn clear + syn keyword Foo foo + syn sync ccomment + syn sync maxlines=5 + if 0 + syn sync maxlines=11 + endif + call assert_match('on C-style comments', execute('syntax sync')) + call assert_match('maximal 5 lines', execute('syntax sync')) + syn clear + syn keyword Foo foo + if 0 + syn sync ccomment + endif + call assert_notmatch('on C-style comments', execute('syntax sync')) + + syn clear +endfunc From 889bc3c20cf308b2bda43358639b739fe987e1ec Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 19:37:24 +0000 Subject: [PATCH 2/6] vim-patch:8.0.0200: some syntax arguments are not tested Problem: Some syntax arguments are not tested. Solution: Add more syntax command tests. https://github.com/vim/vim/commit/58f60ca2fcd2858faac84e386b3ccf5ced75084d --- src/nvim/testdir/test_syntax.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 64b3c14d73..636bdb8a4d 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -184,6 +184,10 @@ func Test_syntax_arg_skipped() call assert_match('conceal off', execute('syntax conceal')) endif + syntax conceal on + syntax conceal off + call assert_match('conceal off', execute('syntax conceal')) + syntax region Tar start=// if 0 syntax region NotTest start=// contains=@Spell From 7f70c5f7b7fd0c0241613f1cc189b5e26a7642dc Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 21:37:12 +0000 Subject: [PATCH 3/6] vim-patch:8.0.0201: completion of highlight groups includes cleared names Problem: When completing a group name for a highlight or syntax command cleared groups are included. Solution: Skip groups that have been cleared. https://github.com/vim/vim/commit/d61e8aaae57bd66279def479462bf11c22ec2f1c --- src/nvim/syntax.c | 19 ++++++++++++-- src/nvim/testdir/test_syntax.vim | 45 +++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2222f41c78..b274e22caa 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -52,6 +52,7 @@ static bool did_syntax_onoff = false; struct hl_group { char_u *sg_name; ///< highlight group name char_u *sg_name_u; ///< uppercase of sg_name + int sg_cleared; ///< "hi clear" was used int sg_attr; ///< Screen attr @see ATTR_ENTRY int sg_link; ///< link to this highlight group ID int sg_set; ///< combination of flags in \ref SG_SET @@ -6490,6 +6491,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; HL_TABLE()[from_id - 1].sg_link = to_id; HL_TABLE()[from_id - 1].sg_scriptID = current_SID; + HL_TABLE()[from_id - 1].sg_cleared = false; redraw_all_later(SOME_VALID); } } @@ -6872,6 +6874,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) error = true; break; } + HL_TABLE()[idx].sg_cleared = false; // When highlighting has been given for a group, don't link it. if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) { @@ -6953,6 +6956,8 @@ static int hl_has_settings(int idx, int check_link) */ static void highlight_clear(int idx) { + HL_TABLE()[idx].sg_cleared = true; + HL_TABLE()[idx].sg_attr = 0; HL_TABLE()[idx].sg_cterm = 0; HL_TABLE()[idx].sg_cterm_bold = FALSE; @@ -7763,10 +7768,20 @@ const char *get_highlight_name(expand_T *const xp, const int idx) } else if (idx == highlight_ga.ga_len + include_none + include_default + 1 && include_link != 0) { return "clear"; - } else if (idx < 0 || idx >= highlight_ga.ga_len) { + } else if (idx < 0) { return NULL; } - return (const char *)HL_TABLE()[idx].sg_name; + + /* Items are never removed from the table, skip the ones that were cleared. + */ + int current_idx = idx; + while (current_idx < highlight_ga.ga_len && HL_TABLE()[current_idx].sg_cleared) { + ++current_idx; + } + if (current_idx >= highlight_ga.ga_len) { + return NULL; + } + return (const char *)HL_TABLE()[current_idx].sg_name; } color_name_table_T color_name_table[] = { diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 636bdb8a4d..39259fe680 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -152,6 +152,12 @@ func Test_syntax_completion() call feedkeys(":syn sync \\\"\", 'tx') call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:) + " Check that clearing "Aap" avoids it showing up before Boolean. + hi Aap ctermfg=blue + call feedkeys(":syn list \\\"\", 'tx') + call assert_match('^"syn list Aap Boolean Character ', @:) + hi clear Aap + call feedkeys(":syn list \\\"\", 'tx') call assert_match('^"syn list Boolean Character ', @:) @@ -188,11 +194,11 @@ func Test_syntax_arg_skipped() syntax conceal off call assert_match('conceal off', execute('syntax conceal')) - syntax region Tar start=// + syntax region Bar start=// if 0 syntax region NotTest start=// contains=@Spell endif - call assert_match('Tar', execute('syntax')) + call assert_match('Bar', execute('syntax')) call assert_notmatch('NotTest', execute('syntax')) call assert_notmatch('Spell', execute('syntax')) @@ -202,6 +208,8 @@ func Test_syntax_arg_skipped() syntax rest endif call assert_equal(a, execute('hi Foo')) + hi clear Bar + hi clear Foo set ft=tags syn off @@ -283,8 +291,7 @@ func Test_syntax_arg_skipped() endif call assert_match('on C-style comments', execute('syntax sync')) call assert_match('maximal 5 lines', execute('syntax sync')) - syn clear - syn keyword Foo foo + syn sync clear if 0 syn sync ccomment endif @@ -292,3 +299,33 @@ func Test_syntax_arg_skipped() syn clear endfunc + +func Test_invalid_arg() + call assert_fails('syntax case asdf', 'E390:') + call assert_fails('syntax conceal asdf', 'E390:') + call assert_fails('syntax spell asdf', 'E390:') +endfunc + +func Test_syn_sync() + syntax region HereGroup start=/this/ end=/that/ + syntax sync match SyncHere grouphere HereGroup "pattern" + call assert_match('SyncHere', execute('syntax sync')) + syn sync clear + call assert_notmatch('SyncHere', execute('syntax sync')) + syn clear +endfunc + +func Test_syn_clear() + syntax keyword Foo foo + syntax keyword Bar tar + call assert_match('Foo', execute('syntax')) + call assert_match('Bar', execute('syntax')) + syn clear Foo + call assert_notmatch('Foo', execute('syntax')) + call assert_match('Bar', execute('syntax')) + syn clear Foo Bar + call assert_notmatch('Foo', execute('syntax')) + call assert_notmatch('Bar', execute('syntax')) + hi clear Foo + hi clear Bar +endfunc From e888439f5589d00f2ac545e38a29924f91dad38e Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 22:36:05 +0000 Subject: [PATCH 4/6] vim-patch:8.0.0202: no test for invalid syntax group name Problem: No test for invalid syntax group name. Solution: Add a test for group name error and warning. https://github.com/vim/vim/commit/4007ed4a5e8c34197078e9d5718bd1d4a429dd23 --- src/nvim/testdir/test_syntax.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 39259fe680..6456ca2b23 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -329,3 +329,14 @@ func Test_syn_clear() hi clear Foo hi clear Bar endfunc + +func Test_invalid_name() + syn clear + syn keyword Nop yes + call assert_fails("syntax keyword Wr\x17ong bar", 'E669:') + syntax keyword @Wrong bar + call assert_match('W18:', execute('1messages')) + syn clear + hi clear Nop + hi clear @Wrong +endfunc From b23fc444b52a7ea10ffce4eca01d9429859147c9 Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 22:40:21 +0000 Subject: [PATCH 5/6] vim-patch:8.0.0204: compiler warns for uninitialized variable Problem: Compiler warns for uninitialized variable. (Tony Mechelynck) Solution: When skipping set "id" to -1. https://github.com/vim/vim/commit/eb46f8fa14a586779f55b1c7f1648f559618322e --- src/nvim/syntax.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index b274e22caa..cf68971f76 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5283,7 +5283,9 @@ get_id_list ( id = SYNID_CONTAINED; id += current_syn_inc_tag; } else if (name[1] == '@') { - if (!skip) { + if (skip) { + id = -1; + } else { id = syn_check_cluster(name + 2, (int)(end - p - 1)); } } else { From 34de6d33c9e4ea7b2c67319eafe8345db7fe0151 Mon Sep 17 00:00:00 2001 From: dvejmz Date: Tue, 9 Jan 2018 22:58:24 +0000 Subject: [PATCH 6/6] lint --- src/nvim/syntax.c | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index cf68971f76..01d2728f3d 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -52,7 +52,7 @@ static bool did_syntax_onoff = false; struct hl_group { char_u *sg_name; ///< highlight group name char_u *sg_name_u; ///< uppercase of sg_name - int sg_cleared; ///< "hi clear" was used + int sg_cleared; ///< "hi clear" was used int sg_attr; ///< Screen attr @see ATTR_ENTRY int sg_link; ///< link to this highlight group ID int sg_set; ///< combination of flags in \ref SG_SET @@ -3027,9 +3027,9 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing) MSG(_("syn conceal off")); } } else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) { - curwin->w_s->b_syn_conceal = TRUE; + curwin->w_s->b_syn_conceal = true; } else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) { - curwin->w_s->b_syn_conceal = FALSE; + curwin->w_s->b_syn_conceal = false; } else { EMSG2(_("E390: Illegal argument: %s"), arg); } @@ -3055,9 +3055,9 @@ static void syn_cmd_case(exarg_T *eap, int syncing) MSG(_("syntax case match")); } } else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) { - curwin->w_s->b_syn_ic = FALSE; + curwin->w_s->b_syn_ic = false; } else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) { - curwin->w_s->b_syn_ic = TRUE; + curwin->w_s->b_syn_ic = true; } else { EMSG2(_("E390: Illegal argument: %s"), arg); } @@ -3144,11 +3144,11 @@ static void syn_cmd_iskeyword(exarg_T *eap, int syncing) */ void syntax_clear(synblock_T *block) { - block->b_syn_error = FALSE; /* clear previous error */ - block->b_syn_ic = FALSE; /* Use case, by default */ - block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */ - block->b_syn_containedin = FALSE; - block->b_syn_conceal = FALSE; + block->b_syn_error = false; // clear previous error + block->b_syn_ic = false; // Use case, by default + block->b_syn_spell = SYNSPL_DEFAULT; // default spell checking + block->b_syn_containedin = false; + block->b_syn_conceal = false; /* free the keywords */ clear_keywtab(&block->b_keywtab); @@ -4025,11 +4025,11 @@ get_group_name ( * Return NULL for any error; */ static char_u * -get_syn_options ( - char_u *arg, /* next argument to be checked */ - syn_opt_arg_T *opt, /* various things */ +get_syn_options( + char_u *arg, // next argument to be checked + syn_opt_arg_T *opt, // various things int *conceal_char, - int skip /* TRUE if skipping over command */ + int skip // TRUE if skipping over command ) { char_u *gname_start, *gname; @@ -4105,14 +4105,17 @@ get_syn_options ( EMSG(_("E395: contains argument not accepted here")); return NULL; } - if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) + if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) { return NULL; + } } else if (flagtab[fidx].argtype == 2) { - if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) + if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) { return NULL; + } } else if (flagtab[fidx].argtype == 3) { - if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) + if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) { return NULL; + } } else if (flagtab[fidx].argtype == 11 && arg[5] == '=') { /* cchar=? */ if (has_mbyte) { @@ -4410,10 +4413,11 @@ syn_cmd_match ( init_syn_patterns(); memset(&item, 0, sizeof(item)); rest = get_syn_pattern(rest, &item); - if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) + if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) { syn_opt_arg.flags |= HL_HAS_EOL; + } - /* Get options after the pattern */ + // Get options after the pattern rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest != NULL) { /* all arguments are valid */ @@ -4526,14 +4530,13 @@ syn_cmd_region ( syn_opt_arg.cont_in_list = NULL; syn_opt_arg.next_list = NULL; - /* - * get the options, patterns and matchgroup. - */ + // get the options, patterns and matchgroup. while (rest != NULL && !ends_excmd(*rest)) { - /* Check for option arguments */ + // Check for option arguments rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); - if (rest == NULL || ends_excmd(*rest)) + if (rest == NULL || ends_excmd(*rest)) { break; + } /* must be a pattern or matchgroup then */ key_end = rest; @@ -4963,7 +4966,7 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing) syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, &clstr_list, list_op); } - got_clstr = TRUE; + got_clstr = true; } if (got_clstr) { @@ -5211,9 +5214,9 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) static int get_id_list ( char_u **arg, - int keylen, /* length of keyword */ - short **list, /* where to store the resulting list, if not - NULL, the list is silently skipped! */ + int keylen, // length of keyword + int16_t **list, // where to store the resulting list, if not + // NULL, the list is silently skipped! int skip ) { @@ -6493,7 +6496,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; HL_TABLE()[from_id - 1].sg_link = to_id; HL_TABLE()[from_id - 1].sg_scriptID = current_SID; - HL_TABLE()[from_id - 1].sg_cleared = false; + HL_TABLE()[from_id - 1].sg_cleared = false; redraw_all_later(SOME_VALID); } } @@ -7774,14 +7777,14 @@ const char *get_highlight_name(expand_T *const xp, const int idx) return NULL; } - /* Items are never removed from the table, skip the ones that were cleared. - */ - int current_idx = idx; - while (current_idx < highlight_ga.ga_len && HL_TABLE()[current_idx].sg_cleared) { - ++current_idx; + // Items are never removed from the table, skip the ones that were cleared. + int current_idx = idx; + while (current_idx < highlight_ga.ga_len + && HL_TABLE()[current_idx].sg_cleared) { + current_idx++; } if (current_idx >= highlight_ga.ga_len) { - return NULL; + return NULL; } return (const char *)HL_TABLE()[current_idx].sg_name; }