mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:8.2.1076: Vim9: no line break allowed in :if expression
Problem: Vim9: no line break allowed in :if expression.
Solution: Skip linebreak.
faf8626b79
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
64a91f5ea2
commit
e99f28e57d
@ -703,10 +703,15 @@ int eval_to_bool(char *arg, bool *error, exarg_T *eap, int skip)
|
||||
typval_T tv;
|
||||
bool retval = false;
|
||||
|
||||
evalarg_T evalarg = {
|
||||
.eval_flags = skip ? 0 : EVAL_EVALUATE,
|
||||
.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 {
|
||||
*error = false;
|
||||
@ -718,6 +723,7 @@ int eval_to_bool(char *arg, bool *error, exarg_T *eap, int skip)
|
||||
if (skip) {
|
||||
emsg_skip--;
|
||||
}
|
||||
clear_evalarg(&evalarg, eap);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -2228,6 +2234,20 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// 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.
|
||||
xfree(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.
|
||||
@ -2278,15 +2298,7 @@ int eval0(char *arg, typval_T *rettv, exarg_T *eap, evalarg_T *const evalarg)
|
||||
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.
|
||||
xfree(eap->cmdline_tofree);
|
||||
eap->cmdline_tofree = *eap->cmdlinep;
|
||||
*eap->cmdlinep = evalarg->eval_tofree;
|
||||
evalarg->eval_tofree = NULL;
|
||||
}
|
||||
clear_evalarg(evalarg, eap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -7502,6 +7514,7 @@ void ex_echo(exarg_T *eap)
|
||||
arg = skipwhite(arg);
|
||||
}
|
||||
eap->nextcmd = check_nextcmd(arg);
|
||||
clear_evalarg(&evalarg, eap);
|
||||
|
||||
if (eap->skip) {
|
||||
emsg_skip--;
|
||||
|
@ -267,7 +267,7 @@ void ex_let(exarg_T *eap)
|
||||
if (eap->skip) {
|
||||
emsg_skip--;
|
||||
}
|
||||
xfree(evalarg.eval_tofree);
|
||||
clear_evalarg(&evalarg, eap);
|
||||
|
||||
if (!eap->skip && eval_res != FAIL) {
|
||||
(void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
|
||||
|
Loading…
Reference in New Issue
Block a user