summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-27 23:07:36 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-27 23:07:36 +0200
commitfaf8626b79e380fe81e7ae2439a535ed7619d27b (patch)
tree6814686cce2bf81a6ccc2c78ef1894cd22d2ba75 /src/eval.c
parent7e8967fdcdf45caf08753bb791dc3779e78b34c8 (diff)
patch 8.2.1076: Vim9: no line break allowed in :if expressionv8.2.1076
Problem: Vim9: no line break allowed in :if expression. Solution: Skip linebreak.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c
index 736023930b..6aaa3a6ef0 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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;
}
@@ -1884,6 +1891,24 @@ skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg)
}
/*
+ * 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
* VAR_UNKNOWN. The function still returns FAIL for a syntax error.
@@ -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;