diff options
author | Harald van Dijk <harald@gigawatt.nl> | 2011-03-15 15:44:47 +0800 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2011-06-03 18:44:14 +0200 |
commit | fe205dd103518dfc9e990b5bf8026bce2002dad8 (patch) | |
tree | c1f22ecc1ac8afa2bc26ed68c53798972e1b67e9 | |
parent | d790802dfa92ea145ef0da18f790609db2fccaeb (diff) | |
download | klibc-fe205dd103518dfc9e990b5bf8026bce2002dad8.tar.gz |
[klibc] [EVAL] Let funcnode refer to a function definition, not its
first command
It is not unrelated: I changed the meaning of struct funcnode's field n
to refer to the function definition, rather than the list of the
function's commands, because I needed to refer to the function
definition node from evalfun, which only gets passed a funcnode. But it
is something that could be applied independently (without being useful
by itself), so I've attached it as a separate patch for easier review.
Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/dash/eval.c | 4 | ||||
-rw-r--r-- | usr/dash/exec.c | 4 | ||||
-rw-r--r-- | usr/dash/exec.h | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 2fd326da711dc..0ff430b624650 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -296,7 +296,7 @@ calleval: } goto success; case NDEFUN: - defun(n->narg.text, n->narg.next); + defun(n); success: status = 0; setstatus: @@ -954,7 +954,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags) shellparam.optind = 1; shellparam.optoff = -1; pushlocalvars(); - evaltree(&func->n, flags & EV_TESTED); + evaltree(func->n.narg.next, flags & EV_TESTED); poplocalvars(0); funcdone: INTOFF; diff --git a/usr/dash/exec.c b/usr/dash/exec.c index 194088bd5f333..a13ad67d80966 100644 --- a/usr/dash/exec.c +++ b/usr/dash/exec.c @@ -690,14 +690,14 @@ addcmdentry(char *name, struct cmdentry *entry) */ void -defun(char *name, union node *func) +defun(union node *func) { struct cmdentry entry; INTOFF; entry.cmdtype = CMDFUNCTION; entry.u.func = copyfunc(func); - addcmdentry(name, &entry); + addcmdentry(func->narg.text, &entry); INTON; } diff --git a/usr/dash/exec.h b/usr/dash/exec.h index daa6f100e3a25..9ccb305fef806 100644 --- a/usr/dash/exec.h +++ b/usr/dash/exec.h @@ -71,7 +71,7 @@ void changepath(const char *); #ifdef notdef void getcmdentry(char *, struct cmdentry *); #endif -void defun(char *, union node *); +void defun(union node *); void unsetfunc(const char *); int typecmd(int, char **); int commandcmd(int, char **); |