mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.0612: Vim9: no check for space before #comment
Problem: Vim9: no check for space before #comment. Solution: Add space checks.
This commit is contained in:
@@ -451,12 +451,9 @@ ex_sort(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL)
|
else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL)
|
||||||
{
|
{
|
||||||
s = skip_regexp(p + 1, *p, TRUE);
|
s = skip_regexp_err(p + 1, *p, TRUE);
|
||||||
if (*s != *p)
|
if (s == NULL)
|
||||||
{
|
|
||||||
emsg(_(e_invalpat));
|
|
||||||
goto sortend;
|
goto sortend;
|
||||||
}
|
|
||||||
*s = NUL;
|
*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 (s == p + 1)
|
||||||
|
@@ -1021,12 +1021,12 @@ ex_else(exarg_T *eap)
|
|||||||
if (eap->cmdidx == CMD_elseif)
|
if (eap->cmdidx == CMD_elseif)
|
||||||
{
|
{
|
||||||
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
|
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
|
||||||
|
|
||||||
// When throwing error exceptions, we want to throw always the first
|
// When throwing error exceptions, we want to throw always the first
|
||||||
// of several errors in a row. This is what actually happens when
|
// of several errors in a row. This is what actually happens when
|
||||||
// a conditional error was detected above and there is another failure
|
// a conditional error was detected above and there is another failure
|
||||||
// when parsing the expression. Since the skip flag is set in this
|
// when parsing the expression. Since the skip flag is set in this
|
||||||
// case, the parsing error will be ignored by emsg().
|
// case, the parsing error will be ignored by emsg().
|
||||||
|
|
||||||
if (!skip && !error)
|
if (!skip && !error)
|
||||||
{
|
{
|
||||||
if (result)
|
if (result)
|
||||||
@@ -1518,7 +1518,7 @@ ex_catch(exarg_T *eap)
|
|||||||
&cstack->cs_looplevel);
|
&cstack->cs_looplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ends_excmd(*eap->arg)) // no argument, catch all errors
|
if (ends_excmd2(eap->cmd, eap->arg)) // no argument, catch all errors
|
||||||
{
|
{
|
||||||
pat = (char_u *)".*";
|
pat = (char_u *)".*";
|
||||||
end = NULL;
|
end = NULL;
|
||||||
@@ -1527,7 +1527,9 @@ ex_catch(exarg_T *eap)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pat = eap->arg + 1;
|
pat = eap->arg + 1;
|
||||||
end = skip_regexp(pat, *eap->arg, TRUE);
|
end = skip_regexp_err(pat, *eap->arg, TRUE);
|
||||||
|
if (end == NULL)
|
||||||
|
give_up = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!give_up)
|
if (!give_up)
|
||||||
@@ -1548,7 +1550,8 @@ ex_catch(exarg_T *eap)
|
|||||||
if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
|
if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
|
||||||
&& !(cstack->cs_flags[idx] & CSF_CAUGHT))
|
&& !(cstack->cs_flags[idx] & CSF_CAUGHT))
|
||||||
{
|
{
|
||||||
if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1)))
|
if (end != NULL && *end != NUL
|
||||||
|
&& !ends_excmd2(end, skipwhite(end + 1)))
|
||||||
{
|
{
|
||||||
emsg(_(e_trailing));
|
emsg(_(e_trailing));
|
||||||
return;
|
return;
|
||||||
|
@@ -5036,7 +5036,7 @@ ex_gui(exarg_T *eap)
|
|||||||
// of the argument ending up after the shell prompt.
|
// of the argument ending up after the shell prompt.
|
||||||
msg_clr_eos_force();
|
msg_clr_eos_force();
|
||||||
#ifdef GUI_MAY_SPAWN
|
#ifdef GUI_MAY_SPAWN
|
||||||
if (!ends_excmd(*eap->arg))
|
if (!ends_excmd2(eap->cmd, eap->arg))
|
||||||
gui_start(eap->arg);
|
gui_start(eap->arg);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -5045,7 +5045,7 @@ ex_gui(exarg_T *eap)
|
|||||||
channel_gui_register_all();
|
channel_gui_register_all();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (!ends_excmd(*eap->arg))
|
if (!ends_excmd2(eap->cmd, eap->arg))
|
||||||
ex_next(eap);
|
ex_next(eap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -658,7 +658,7 @@ do_highlight(
|
|||||||
/*
|
/*
|
||||||
* If no argument, list current highlighting.
|
* If no argument, list current highlighting.
|
||||||
*/
|
*/
|
||||||
if (ends_excmd(*line))
|
if (!init && ends_excmd2(line - 1, line))
|
||||||
{
|
{
|
||||||
for (i = 1; i <= highlight_ga.ga_len && !got_int; ++i)
|
for (i = 1; i <= highlight_ga.ga_len && !got_int; ++i)
|
||||||
// TODO: only call when the group has attributes set
|
// TODO: only call when the group has attributes set
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* regexp.c */
|
/* regexp.c */
|
||||||
int re_multiline(regprog_T *prog);
|
int re_multiline(regprog_T *prog);
|
||||||
char_u *skip_regexp(char_u *startp, int dirc, int magic);
|
char_u *skip_regexp(char_u *startp, int delim, int magic);
|
||||||
|
char_u *skip_regexp_err(char_u *startp, int delim, int magic);
|
||||||
char_u *skip_regexp_ex(char_u *startp, int dirc, int magic, char_u **newp, int *dropped);
|
char_u *skip_regexp_ex(char_u *startp, int dirc, int magic, char_u **newp, int *dropped);
|
||||||
reg_extmatch_T *ref_extmatch(reg_extmatch_T *em);
|
reg_extmatch_T *ref_extmatch(reg_extmatch_T *em);
|
||||||
void unref_extmatch(reg_extmatch_T *em);
|
void unref_extmatch(reg_extmatch_T *em);
|
||||||
|
26
src/regexp.c
26
src/regexp.c
@@ -534,17 +534,37 @@ skip_anyof(char_u *p)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip past regular expression.
|
* Skip past regular expression.
|
||||||
* Stop at end of "startp" or where "dirc" is found ('/', '?', etc).
|
* Stop at end of "startp" or where "delim" is found ('/', '?', etc).
|
||||||
* Take care of characters with a backslash in front of it.
|
* Take care of characters with a backslash in front of it.
|
||||||
* Skip strings inside [ and ].
|
* Skip strings inside [ and ].
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
skip_regexp(
|
skip_regexp(
|
||||||
char_u *startp,
|
char_u *startp,
|
||||||
int dirc,
|
int delim,
|
||||||
int magic)
|
int magic)
|
||||||
{
|
{
|
||||||
return skip_regexp_ex(startp, dirc, magic, NULL, NULL);
|
return skip_regexp_ex(startp, delim, magic, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call skip_regexp() and when the delimiter does not match give an error and
|
||||||
|
* return NULL.
|
||||||
|
*/
|
||||||
|
char_u *
|
||||||
|
skip_regexp_err(
|
||||||
|
char_u *startp,
|
||||||
|
int delim,
|
||||||
|
int magic)
|
||||||
|
{
|
||||||
|
char_u *p = skip_regexp(startp, delim, magic);
|
||||||
|
|
||||||
|
if (*p != delim)
|
||||||
|
{
|
||||||
|
semsg(_("E654: missing delimiter after search pattern: %s"), startp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1255,7 +1255,7 @@ func Test_sort_cmd()
|
|||||||
call setline(1, ['line1', 'line2'])
|
call setline(1, ['line1', 'line2'])
|
||||||
call assert_fails('sort no', 'E474:')
|
call assert_fails('sort no', 'E474:')
|
||||||
call assert_fails('sort c', 'E475:')
|
call assert_fails('sort c', 'E475:')
|
||||||
call assert_fails('sort #pat%', 'E682:')
|
call assert_fails('sort #pat%', 'E654:')
|
||||||
|
|
||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -1153,22 +1153,76 @@ def Test_vim9_comment()
|
|||||||
|
|
||||||
CheckDefFailure([
|
CheckDefFailure([
|
||||||
'try# comment',
|
'try# comment',
|
||||||
'echo "yes"',
|
' echo "yes"',
|
||||||
'catch',
|
'catch',
|
||||||
'endtry',
|
'endtry',
|
||||||
], 'E488:')
|
], 'E488:')
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'try# comment',
|
||||||
|
'echo "yes"',
|
||||||
|
], 'E488:')
|
||||||
CheckDefFailure([
|
CheckDefFailure([
|
||||||
'try',
|
'try',
|
||||||
'echo "yes"',
|
' echo "yes"',
|
||||||
'catch# comment',
|
'catch# comment',
|
||||||
'endtry',
|
'endtry',
|
||||||
], 'E488:')
|
], 'E488:')
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'try',
|
||||||
|
' echo "yes"',
|
||||||
|
'catch# comment',
|
||||||
|
'endtry',
|
||||||
|
], 'E654:')
|
||||||
|
CheckDefFailure([
|
||||||
|
'try',
|
||||||
|
' echo "yes"',
|
||||||
|
'catch /pat/# comment',
|
||||||
|
'endtry',
|
||||||
|
], 'E488:')
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'try',
|
||||||
|
' throw "pat"',
|
||||||
|
'catch /pat/# comment',
|
||||||
|
'endtry',
|
||||||
|
], 'E605:')
|
||||||
CheckDefFailure([
|
CheckDefFailure([
|
||||||
'try',
|
'try',
|
||||||
'echo "yes"',
|
'echo "yes"',
|
||||||
'catch',
|
'catch',
|
||||||
'endtry# comment',
|
'endtry# comment',
|
||||||
], 'E488:')
|
], 'E488:')
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'try',
|
||||||
|
' echo "yes"',
|
||||||
|
'catch',
|
||||||
|
'endtry# comment',
|
||||||
|
], 'E600:')
|
||||||
|
|
||||||
|
CheckScriptSuccess([
|
||||||
|
'vim9script',
|
||||||
|
'hi # comment',
|
||||||
|
])
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'hi# comment',
|
||||||
|
], 'E416:')
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Test_vim9_comment_gui()
|
||||||
|
CheckCanRunGui
|
||||||
|
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'gui#comment'
|
||||||
|
], 'E499:')
|
||||||
|
CheckScriptFailure([
|
||||||
|
'vim9script',
|
||||||
|
'gui -f#comment'
|
||||||
|
], 'E499:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_vim9_comment_not_compiled()
|
def Test_vim9_comment_not_compiled()
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
612,
|
||||||
/**/
|
/**/
|
||||||
611,
|
611,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user