From 5619fb2e7efec9d28e067d509af57530d0b689cf Mon Sep 17 00:00:00 2001 From: ac-stef Date: Fri, 6 Mar 2015 19:36:29 +0100 Subject: [PATCH] allow multiple arguments for "pop" instead of "pop var_a ; pop var_b" you can write "pop var_a var_b" Also, "pop" will now give back the removed value of the first alias from the argument list. This allows using the pop'd value one last time. DOCREF pop --- source/src/command.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index 10b9b596..4f05b12a 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -11,6 +11,7 @@ vector contextstack; bool contextsealed = false; bool contextisolated[IEXC_NUM] = { false }; int execcontext; +char *commandret = NULL; bool loop_break = false, loop_skip = false; // break or continue (skip) current loop int loop_level = 0; // avoid bad calls of break & continue @@ -102,7 +103,16 @@ void pop(const char *name) } COMMAND(push, "ss"); -COMMAND(pop, "s"); +COMMANDF(pop, "v", (char **args, int numargs) +{ + if(numargs > 0) + { + const char *beforepopval = getalias(args[0]); + if(beforepopval) commandret = newstring(beforepopval); + } + loopi(numargs) pop(args[i]); +}); + void delalias(const char *name) { ident *id = idents->access(name); @@ -468,8 +478,6 @@ char *conc(const char **w, int n, bool space) VARN(numargs, _numargs, 25, 0, 0); -char *commandret = NULL; - void intret(int v) { string t;