summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-01 17:28:33 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-01 17:28:33 +0200
commite6b5324e3a3d354363f3c48e784c42ce3e77453f (patch)
tree7e4ddd66d330a898256b3ea8060768a761aa2cc2 /src/eval.c
parent086eb18ba16164ca5258068cff9c4b2db742f2ef (diff)
patch 8.2.1110: Vim9: line continuation does not work in function argumentsv8.2.1110
Problem: Vim9: line continuation does not work in function arguments. Solution: Pass "evalarg" to get_func_tv(). Fix seeing double quoted string as comment.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/eval.c b/src/eval.c
index 5a0aef2c27..ce255e2b96 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -153,7 +153,7 @@ eval_clear(void)
}
#endif
- static void
+ void
fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip)
{
CLEAR_FIELD(*evalarg);
@@ -1804,6 +1804,7 @@ pattern_match(char_u *pat, char_u *text, int ic)
static int
eval_func(
char_u **arg, // points to "(", will be advanced
+ evalarg_T *evalarg,
char_u *name,
int name_len,
typval_T *rettv,
@@ -1839,7 +1840,7 @@ eval_func(
funcexe.evaluate = evaluate;
funcexe.partial = partial;
funcexe.basetv = basetv;
- ret = get_func_tv(s, len, rettv, arg, &funcexe);
+ ret = get_func_tv(s, len, rettv, arg, evalarg, &funcexe);
}
vim_free(s);
@@ -1917,6 +1918,9 @@ eval_next_line(evalarg_T *evalarg)
return skipwhite(line);
}
+/*
+ * Call eval_next_non_blank() and get the next line if needed.
+ */
char_u *
skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg)
{
@@ -1930,6 +1934,20 @@ skipwhite_and_linebreak(char_u *arg, evalarg_T *evalarg)
}
/*
+ * Call eval_next_non_blank() and get the next line if needed, but not when a
+ * double quote follows. Used inside an expression.
+ */
+ char_u *
+skipwhite_and_linebreak_keep_string(char_u *arg, evalarg_T *evalarg)
+{
+ char_u *p = skipwhite(arg);
+
+ if (*p == '"')
+ return p;
+ return skipwhite_and_linebreak(arg, evalarg);
+}
+
+/*
* After using "evalarg" filled from "eap" free the memory.
*/
void
@@ -2995,7 +3013,7 @@ eval7(
else
{
if (**arg == '(') // recursive!
- ret = eval_func(arg, s, len, rettv, flags, NULL);
+ ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
else if (flags & EVAL_CONSTANT)
ret = FAIL;
else if (evaluate)
@@ -3106,6 +3124,7 @@ eval7_leader(
static int
call_func_rettv(
char_u **arg,
+ evalarg_T *evalarg,
typval_T *rettv,
int evaluate,
dict_T *selfdict,
@@ -3142,7 +3161,7 @@ call_func_rettv(
funcexe.partial = pt;
funcexe.selfdict = selfdict;
funcexe.basetv = basetv;
- ret = get_func_tv(s, -1, rettv, arg, &funcexe);
+ ret = get_func_tv(s, -1, rettv, arg, evalarg, &funcexe);
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
@@ -3189,7 +3208,7 @@ eval_lambda(
ret = FAIL;
}
else
- ret = call_func_rettv(arg, rettv, evaluate, NULL, &base);
+ ret = call_func_rettv(arg, evalarg, rettv, evaluate, NULL, &base);
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
@@ -3208,7 +3227,7 @@ eval_lambda(
eval_method(
char_u **arg,
typval_T *rettv,
- int evaluate,
+ evalarg_T *evalarg,
int verbose) // give error messages
{
char_u *name;
@@ -3216,6 +3235,8 @@ eval_method(
char_u *alias;
typval_T base = *rettv;
int ret;
+ int evaluate = evalarg != NULL
+ && (evalarg->eval_flags & EVAL_EVALUATE);
// Skip over the ->.
*arg += 2;
@@ -3247,7 +3268,7 @@ eval_method(
ret = FAIL;
}
else
- ret = eval_func(arg, name, len, rettv,
+ ret = eval_func(arg, evalarg, name, len, rettv,
evaluate ? EVAL_EVALUATE : 0, &base);
}
@@ -5035,7 +5056,8 @@ handle_subscript(
{
if (**arg == '(')
{
- ret = call_func_rettv(arg, rettv, evaluate, selfdict, NULL);
+ ret = call_func_rettv(arg, evalarg, rettv, evaluate,
+ selfdict, NULL);
// Stop the expression evaluation when immediately aborting on
// error, or when an interrupt occurred or an exception was thrown
@@ -5058,7 +5080,7 @@ handle_subscript(
ret = eval_lambda(arg, rettv, evalarg, verbose);
else
// expr->name()
- ret = eval_method(arg, rettv, evaluate, verbose);
+ ret = eval_method(arg, rettv, evalarg, verbose);
}
}
else // **arg == '[' || **arg == '.'