diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-30 21:18:36 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-30 21:18:36 +0200 |
commit | 37c837119579ff70b005a4e54c2e26ca42b74022 (patch) | |
tree | ce12731cb7af5cbd9d64a579fffa94438b790552 /src/eval.c | |
parent | 006ad48b8a15c3bace741d8caaf3195e592fbe78 (diff) | |
download | vim-git-37c837119579ff70b005a4e54c2e26ca42b74022.tar.gz |
patch 8.2.1099: Vim9: cannot use line break in :cexpr argumentv8.2.1099
Problem: Vim9: cannot use line break in :cexpr argument.
Solution: Check for line break.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/eval.c b/src/eval.c index a98eea34b..060fd0c7d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -153,6 +153,18 @@ eval_clear(void) } #endif + static void +fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip) +{ + CLEAR_FIELD(*evalarg); + evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE; + if (eap != NULL && getline_equal(eap->getline, eap->cookie, getsourceline)) + { + evalarg->eval_getline = eap->getline; + evalarg->eval_cookie = eap->cookie; + } +} + /* * Top level evaluation function, returning a boolean. * Sets "error" to TRUE if there was an error. @@ -169,13 +181,7 @@ eval_to_bool( varnumber_T retval = FALSE; evalarg_T evalarg; - CLEAR_FIELD(evalarg); - evalarg.eval_flags = skip ? 0 : EVAL_EVALUATE; - if (eap != NULL && getline_equal(eap->getline, eap->cookie, getsourceline)) - { - evalarg.eval_getline = eap->getline; - evalarg.eval_cookie = eap->cookie; - } + fill_evalarg_from_eap(&evalarg, eap, skip); if (skip) ++emsg_skip; @@ -335,13 +341,7 @@ eval_to_string_skip( char_u *retval; evalarg_T evalarg; - CLEAR_FIELD(evalarg); - evalarg.eval_flags = skip ? 0 : EVAL_EVALUATE; - if (eap != NULL && getline_equal(eap->getline, eap->cookie, getsourceline)) - { - evalarg.eval_getline = eap->getline; - evalarg.eval_cookie = eap->cookie; - } + fill_evalarg_from_eap(&evalarg, eap, skip); if (skip) ++emsg_skip; if (eval0(arg, &tv, eap, &evalarg) == FAIL || skip) @@ -535,12 +535,15 @@ eval_to_number(char_u *expr) eval_expr(char_u *arg, exarg_T *eap) { typval_T *tv; + evalarg_T evalarg; + + fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip); tv = ALLOC_ONE(typval_T); - if (tv != NULL && eval0(arg, tv, eap, &EVALARG_EVALUATE) == FAIL) + if (tv != NULL && eval0(arg, tv, eap, &evalarg) == FAIL) VIM_CLEAR(tv); - clear_evalarg(&EVALARG_EVALUATE, eap); + clear_evalarg(&evalarg, eap); return tv; } @@ -5239,13 +5242,7 @@ ex_echo(exarg_T *eap) int called_emsg_before = called_emsg; evalarg_T evalarg; - CLEAR_FIELD(evalarg); - evalarg.eval_flags = eap->skip ? 0 : EVAL_EVALUATE; - if (getline_equal(eap->getline, eap->cookie, getsourceline)) - { - evalarg.eval_getline = eap->getline; - evalarg.eval_cookie = eap->cookie; - } + fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip); if (eap->skip) ++emsg_skip; |