extend-for-key-in-array-syntax: update to key=val syntax
[nedit-bw.git] / arrayReplacesArglist3-unpackArray-fix.patch
blob45767cd23e361d57418d867879b022d57db5d8f4
1 ---
3 source/interpret.c | 14 +++++++++++---
4 1 files changed, 11 insertions(+), 3 deletions(-)
6 diff --quilt old/source/interpret.c new/source/interpret.c
7 --- old/source/interpret.c
8 +++ new/source/interpret.c
9 @@ -2619,27 +2619,35 @@ int OverlayRoutineFromProg(Program *prog
10 ** After: Prog-> next, ...
11 ** Stack-> -(nArgs+1), argArray, argN-arg1, next, ...
13 static int unpackArrayToArgs(void)
15 - int nArgs;
16 + int nArgs, res;
18 DataValue dvEntry, dvArray;
20 DISASM_RT(PC-1, 1);
21 STACKDUMP(1, 3);
23 - POP(dvArray)
24 + POP(dvEntry)
26 if (dvArray.tag != ARRAY_TAG) {
27 return execError("argument array call made with non-array value", NULL);
30 + res = ArrayCopy(&dvArray, &dvEntry);
31 + if (res != STAT_OK) {
32 + return execError("cannot copy array in array call", NULL);
33 + }
35 /* push positional argument entries in the array on the stack */
36 for (nArgs = 1; ; ++nArgs) {
37 - if (!ArrayGet(&dvArray, (char *)longAsStr(nArgs), &dvEntry))
38 + char *key = (char *)longAsStr(nArgs);
39 + if (!ArrayGet(&dvArray, key, &dvEntry))
40 break;
41 + /* remove them from remaining array */
42 + ArrayDelete(&dvArray, key);
43 PUSH(dvEntry)
45 PUSH(dvArray)
46 PUSH_INT(-nArgs)
47 return STAT_OK;