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

patch 8.2.1076: Vim9: no line break allowed in :if expression

Problem:    Vim9: no line break allowed in :if expression.
Solution:   Skip linebreak.
This commit is contained in:
Bram Moolenaar
2020-06-27 23:07:36 +02:00
parent 7e8967fdcd
commit faf8626b79
5 changed files with 73 additions and 12 deletions

View File

@@ -166,10 +166,16 @@ eval_to_bool(
{
typval_T tv;
varnumber_T retval = FALSE;
evalarg_T evalarg;
CLEAR_FIELD(evalarg);
evalarg.eval_flags = skip ? 0 : EVAL_EVALUATE;
evalarg.eval_cookie = eap != NULL && eap->getline == getsourceline
? eap->cookie : NULL;
if (skip)
++emsg_skip;
if (eval0(arg, &tv, eap, skip ? NULL : &EVALARG_EVALUATE) == FAIL)
if (eval0(arg, &tv, eap, &evalarg) == FAIL)
*error = TRUE;
else
{
@@ -182,6 +188,7 @@ eval_to_bool(
}
if (skip)
--emsg_skip;
clear_evalarg(&evalarg, eap);
return (int)retval;
}
@@ -1883,6 +1890,24 @@ skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg)
return p;
}
/*
* After using "evalarg" filled from "eap" free the memory.
*/
void
clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
{
if (evalarg != NULL && eap != NULL && evalarg->eval_tofree != NULL)
{
// We may need to keep the original command line, e.g. for
// ":let" it has the variable names. But we may also need the
// new one, "nextcmd" points into it. Keep both.
vim_free(eap->cmdline_tofree);
eap->cmdline_tofree = *eap->cmdlinep;
*eap->cmdlinep = evalarg->eval_tofree;
evalarg->eval_tofree = NULL;
}
}
/*
* The "evaluate" argument: When FALSE, the argument is only parsed but not
* executed. The function may return OK, but the rettv will be of type
@@ -1934,16 +1959,7 @@ eval0(
if (eap != NULL)
eap->nextcmd = check_nextcmd(p);
if (evalarg != NULL && eap != NULL && evalarg->eval_tofree != NULL)
{
// We may need to keep the original command line, e.g. for
// ":let" it has the variable names. But we may also need the
// new one, "nextcmd" points into it. Keep both.
vim_free(eap->cmdline_tofree);
eap->cmdline_tofree = *eap->cmdlinep;
*eap->cmdlinep = evalarg->eval_tofree;
evalarg->eval_tofree = NULL;
}
clear_evalarg(evalarg, eap);
return ret;
}
@@ -5223,6 +5239,7 @@ ex_echo(exarg_T *eap)
arg = skipwhite(arg);
}
eap->nextcmd = check_nextcmd(arg);
clear_evalarg(&evalarg, eap);
if (eap->skip)
--emsg_skip;