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
This commit is contained in:
ac-stef
2015-03-06 19:36:29 +01:00
parent 1c402a7d93
commit 5619fb2e7e
+11 -3
View File
@@ -11,6 +11,7 @@ vector<int> 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;