summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/list.c b/src/list.c
index cf0c99f13..611171d1d 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1156,19 +1156,19 @@ f_join(typval_T *argvars, typval_T *rettv)
/*
* Allocate a variable for a List and fill it from "*arg".
+ * "*arg" points to the "[".
* Return OK or FAIL.
*/
int
-get_list_tv(char_u **arg, typval_T *rettv, int flags, int do_error)
+get_list_tv(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
{
- int evaluate = flags & EVAL_EVALUATE;
+ int evaluate = evalarg == NULL ? FALSE
+ : evalarg->eval_flags & EVAL_EVALUATE;
+ int getnext;
list_T *l = NULL;
typval_T tv;
listitem_T *item;
- evalarg_T evalarg;
-
- CLEAR_FIELD(evalarg);
- evalarg.eval_flags = flags;
+ int had_comma;
if (evaluate)
{
@@ -1178,9 +1178,12 @@ get_list_tv(char_u **arg, typval_T *rettv, int flags, int do_error)
}
*arg = skipwhite(*arg + 1);
+ eval_next_non_blank(*arg, evalarg, &getnext);
+ if (getnext)
+ *arg = eval_next_line(evalarg);
while (**arg != ']' && **arg != NUL)
{
- if (eval1(arg, &tv, &evalarg) == FAIL) // recursive!
+ if (eval1(arg, &tv, evalarg) == FAIL) // recursive!
goto failret;
if (evaluate)
{
@@ -1195,15 +1198,24 @@ get_list_tv(char_u **arg, typval_T *rettv, int flags, int do_error)
clear_tv(&tv);
}
+ // the comma must comma after the value
+ had_comma = **arg == ',';
+ if (had_comma)
+ *arg = skipwhite(*arg + 1);
+
+ // the "]" can be on the next line
+ eval_next_non_blank(*arg, evalarg, &getnext);
+ if (getnext)
+ *arg = eval_next_line(evalarg);
if (**arg == ']')
break;
- if (**arg != ',')
+
+ if (!had_comma)
{
if (do_error)
semsg(_("E696: Missing comma in List: %s"), *arg);
goto failret;
}
- *arg = skipwhite(*arg + 1);
}
if (**arg != ']')