0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.0613: Vim9: no check for space before #comment

Problem:    Vim9: no check for space before #comment.
Solution:   Add space checks.
This commit is contained in:
Bram Moolenaar
2020-04-20 22:42:32 +02:00
parent 2c7f8c574f
commit 1966c24881
6 changed files with 210 additions and 32 deletions

View File

@@ -3632,7 +3632,7 @@ syn_cmd_clear(exarg_T *eap, int syncing)
if (curwin->w_s->b_syn_topgrp != 0)
return;
if (ends_excmd(*arg))
if (ends_excmd2(eap->cmd, arg))
{
/*
* No argument: Clear all syntax items.
@@ -3652,7 +3652,7 @@ syn_cmd_clear(exarg_T *eap, int syncing)
/*
* Clear the group IDs that are in the argument.
*/
while (!ends_excmd(*arg))
while (!ends_excmd2(eap->cmd, arg))
{
arg_end = skiptowhite(arg);
if (*arg == '@')
@@ -3843,7 +3843,7 @@ syn_cmd_list(
}
else
msg_puts_title(_("\n--- Syntax items ---"));
if (ends_excmd(*arg))
if (ends_excmd2(eap->cmd, arg))
{
/*
* No argument: List all group IDs and all syntax clusters.
@@ -3858,7 +3858,7 @@ syn_cmd_list(
/*
* List the group IDs and syntax clusters that are in the argument.
*/
while (!ends_excmd(*arg) && !got_int)
while (!ends_excmd2(eap->cmd, arg) && !got_int)
{
arg_end = skiptowhite(arg);
if (*arg == '@')
@@ -4463,11 +4463,12 @@ get_group_name(
*/
static char_u *
get_syn_options(
char_u *arg, // next argument to be checked
char_u *start, // next argument to be checked
syn_opt_arg_T *opt, // various things
int *conceal_char UNUSED,
int skip) // TRUE if skipping over command
{
char_u *arg = start;
char_u *gname_start, *gname;
int syn_id;
int len;
@@ -4528,7 +4529,7 @@ get_syn_options(
if (p[i] == NUL && (VIM_ISWHITE(arg[len])
|| (flagtab[fidx].argtype > 0
? arg[len] == '='
: ends_excmd(arg[len]))))
: ends_excmd2(start, arg + len))))
{
if (opt->keyword
&& (flagtab[fidx].flags == HL_DISPLAY
@@ -4790,11 +4791,12 @@ syn_cmd_keyword(exarg_T *eap, int syncing UNUSED)
*/
cnt = 0;
p = keyword_copy;
for ( ; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest))
for ( ; rest != NULL && !ends_excmd2(eap->arg, rest);
rest = skipwhite(rest))
{
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char,
eap->skip);
if (rest == NULL || ends_excmd(*rest))
if (rest == NULL || ends_excmd2(eap->arg, rest))
break;
// Copy the keyword, removing backslashes, and add a NUL.
while (*rest != NUL && !VIM_ISWHITE(*rest))
@@ -4892,6 +4894,7 @@ syn_cmd_match(
syn_opt_arg_T syn_opt_arg;
int sync_idx = 0;
int conceal_char = NUL;
int orig_called_emsg = called_emsg;
// Isolate the group name, check for validity
rest = get_group_name(arg, &group_name_end);
@@ -4922,7 +4925,7 @@ syn_cmd_match(
* Check for trailing command and illegal trailing arguments.
*/
eap->nextcmd = check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip)
if (!ends_excmd2(eap->cmd, rest) || eap->skip)
rest = NULL;
else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
&& (syn_id = syn_check_group(arg,
@@ -4974,7 +4977,7 @@ syn_cmd_match(
vim_free(syn_opt_arg.cont_in_list);
vim_free(syn_opt_arg.next_list);
if (rest == NULL)
if (rest == NULL && called_emsg == orig_called_emsg)
semsg(_(e_invarg2), arg);
}
@@ -5037,11 +5040,11 @@ syn_cmd_region(
/*
* get the options, patterns and matchgroup.
*/
while (rest != NULL && !ends_excmd(*rest))
while (rest != NULL && !ends_excmd2(eap->cmd, rest))
{
// 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_excmd2(eap->cmd, rest))
break;
// must be a pattern or matchgroup then
@@ -5570,7 +5573,7 @@ syn_cmd_cluster(exarg_T *eap, int syncing UNUSED)
if (!got_clstr)
emsg(_("E400: No cluster specified"));
if (rest == NULL || !ends_excmd(*rest))
if (rest == NULL || !ends_excmd2(eap->cmd, rest))
semsg(_(e_invarg2), arg);
}
@@ -5680,7 +5683,7 @@ get_syn_pattern(char_u *arg, synpat_T *ci)
}
} while (idx >= 0);
if (!ends_excmd(*end) && !VIM_ISWHITE(*end))
if (!ends_excmd2(arg, end) && !VIM_ISWHITE(*end))
{
semsg(_("E402: Garbage after pattern: %s"), arg);
return NULL;
@@ -5703,13 +5706,13 @@ syn_cmd_sync(exarg_T *eap, int syncing UNUSED)
long n;
char_u *cpo_save;
if (ends_excmd(*arg_start))
if (ends_excmd2(eap->cmd, arg_start))
{
syn_cmd_list(eap, TRUE);
return;
}
while (!ends_excmd(*arg_start))
while (!ends_excmd2(eap->cmd, arg_start))
{
arg_end = skiptowhite(arg_start);
next_arg = skipwhite(arg_end);
@@ -5719,7 +5722,7 @@ syn_cmd_sync(exarg_T *eap, int syncing UNUSED)
{
if (!eap->skip)
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
if (!ends_excmd(*next_arg))
if (!ends_excmd2(eap->cmd, next_arg))
{
arg_end = skiptowhite(next_arg);
if (!eap->skip)
@@ -5888,7 +5891,7 @@ get_id_list(
break;
}
p = skipwhite(p + 1);
if (ends_excmd(*p))
if (ends_excmd2(*arg, p))
{
semsg(_("E406: Empty argument: %s"), *arg);
break;
@@ -5898,7 +5901,7 @@ get_id_list(
* parse the arguments after "contains"
*/
count = 0;
while (!ends_excmd(*p))
while (!ends_excmd2(*arg, p))
{
for (end = p; *end && !VIM_ISWHITE(*end) && *end != ','; ++end)
;