search for: evaltree

Displaying 20 results from an estimated 20 matches for "evaltree".

Did you mean: avltree
2019 Jan 25
0
[klibc:update-dash] eval: Return status in eval functions
...nt.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] eval: Return status in eval functions The exit status is currently clobbered too early for case statements and loops. This patch fixes it by making the eval functions return the current exit status and setting them in one place -- evaltree. Harald van Dijk pointed out a number of bugs in the original patch. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eval.c | 139 ++++++++++++++++++++++++++++++-------------------------- usr/dash/eval.h |...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Return status in eval functions
...c] dash: eval: Return status in eval functions [ dash commit da534b740e628512e8e0e62729d6a2ef521e5096 ] The exit status is currently clobbered too early for case statements and loops. This patch fixes it by making the eval functions return the current exit status and setting them in one place -- evaltree. Harald van Dijk pointed out a number of bugs in the original patch. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eval.c | 139 ++++++++++++++++++++++++++++++-------------------------- usr/dash/eval.h |...
2020 Mar 28
0
[klibc:update-dash] dash: eval: avoid leaking memory associated with redirections
...e true; do ( true; ) </dev/null; done For comparison, bash displays static memory usage in both cases. This issue was reported for BusyBox ash which is derived from dash: https://bugs.busybox.net/show_bug.cgi?id=7748 Signed-off-by: Ron Yorston <rmy at frippery.org> I have simplified evaltree so that it simply sets the stack mark unconditionally. This allows us to remove the stack marks in the functions called by evaltree. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eval.c | 16 ++++++------...
2019 Jan 25
0
[klibc:update-dash] [SHELL] Optimize dash -c "command" to avoid a fork
...c65a4 -omitting ee5cbe9fd6bc02f31b4d955606288de36c3d4eab. HOWTO sync branch: 1) Generate patch and fix up their path diff --git a/usr/dash/eval.c b/usr/dash/eval.c index ae83508b..da39136d 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -65,10 +65,6 @@ #endif -/* flags in argument to evaltree */ -#define EV_EXIT 01 /* exit after evaluating tree */ -#define EV_TESTED 02 /* exit status is checked; ignore -e flag */ - int evalskip; /* set if we are skipping commands */ STATIC int skipcount; /* number of levels to skip */ MKINIT int loopnest; /* current loop nesting level */ @@ -16...
2020 Mar 28
0
[klibc:update-dash] dash: [SHELL] Optimize dash -c "command" to avoid a fork
...+It corresponds up to changeset 46abc8c6d8a5e9a5712bdc1312c0b6960eec65a4. Several changes have been made for klibc: diff --git a/usr/dash/eval.c b/usr/dash/eval.c index dd144948..e6f6cd5c 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -65,10 +65,6 @@ #endif -/* flags in argument to evaltree */ -#define EV_EXIT 01 /* exit after evaluating tree */ -#define EV_TESTED 02 /* exit status is checked; ignore -e flag */ - int evalskip; /* set if we are skipping commands */ STATIC int skipcount; /* number of levels to skip */ MKINIT int loopnest; /* current loop nesting level */ @@ -16...
2019 Jan 25
0
[klibc:update-dash] [TRAP] Make sure evalskip is zero before running traps
...will be executed while the rest of the trap will be silently ignored due to evalskip. This is highly counterintuitive, even though both bash and ksh exhibit a similar behaviour. This patch fixes it by skipping trap processing if evalskip is set on entry. It also adds a dotrap call to the top of evaltree to ensure that while continue; do continue; done has a chance of running traps. Finally the pendingsigs check is moved into dotrap for compactness. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eva...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Move common skipcount logic into skiploop
...nt.org.uk> --- usr/dash/eval.c | 56 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 204f1e57..bb106368 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -339,27 +339,45 @@ void evaltreenr(union node *n, int flags) #endif +static int skiploop(void) +{ + int skip = evalskip; + + switch (skip) { + case 0: + break; + + case SKIPBREAK: + case SKIPCONT: + if (likely(--skipcount <= 0)) { + evalskip = 0; + break; + } + + skip = SKIPBREAK; + break; + } + + return skip; +}...
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Move common skipcount logic into skiploop
...nt.org.uk> --- usr/dash/eval.c | 56 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index e0c21f94..6cc92c19 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -339,27 +339,45 @@ void evaltreenr(union node *n, int flags) #endif +static int skiploop(void) +{ + int skip = evalskip; + + switch (skip) { + case 0: + break; + + case SKIPBREAK: + case SKIPCONT: + if (likely(--skipcount <= 0)) { + evalskip = 0; + break; + } + + skip = SKIPBREAK; + break; + } + + return skip; +}...
2020 Mar 28
0
[klibc:update-dash] dash: [TRAP] Make sure evalskip is zero before running traps
...will be executed while the rest of the trap will be silently ignored due to evalskip. This is highly counterintuitive, even though both bash and ksh exhibit a similar behaviour. This patch fixes it by skipping trap processing if evalskip is set on entry. It also adds a dotrap call to the top of evaltree to ensure that while continue; do continue; done has a chance of running traps. Finally the pendingsigs check is moved into dotrap for compactness. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eva...
2019 Jan 22
4
usr/dash/eval.c:277:19: warning: logical not is only applied to the left hand side of comparison
? KLIBCCC usr/dash/eval.o usr/dash/eval.c: In function 'evaltree': usr/dash/eval.c:277:19: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] ?? if (!exitstatus == isor) ?????????????????? ^ Not sure what the fix should be: ?? if (!(exitstatus == isor)) Or ?? if ((!exitstatus) == isor) Any idea...
2019 Jan 25
0
[klibc:update-dash] [PATCH] eval: Silence compiler warning about missing parentheses
...ngs <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [PATCH] eval: Silence compiler warning about missing parentheses Gcc gives a warning about some missing parentheses: ----------------------------------------------------------------------- eval.c: In function ?evaltree?: eval.c:282:15: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] if (!status == isor || evalskip) ^~ eval.c:282:7: note: add parentheses around left hand side expression to silence this warning if (!status == isor || evalskip...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Silence compiler warning about missing parentheses
...ar 2020 21:42:55 +0000 [klibc] dash: eval: Silence compiler warning about missing parentheses [ dash commit f97aaf80dd44e92f2cabc7e6d92d461f4fe6eddd ] Gcc gives a warning about some missing parentheses: ----------------------------------------------------------------------- eval.c: In function ?evaltree?: eval.c:282:15: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] if (!status == isor || evalskip) ^~ eval.c:282:7: note: add parentheses around left hand side expression to silence this warning if (!status == isor || evalskip...
2012 Jul 02
0
[klibc:master] [EVAL] Remove unused EV_BACKCMD flag
...maximilian attems <max at stro.at> CommitDate: Mon, 2 Jul 2012 10:38:03 +0200 [klibc] [EVAL] Remove unused EV_BACKCMD flag The original ash defered forking commands in backquotes so builtins could be run in the same context as the shell. This behavior was controlled using the EV_BACKCMD to evaltree. Unfortunately, as Matthias Scheler noticed in 1999 (NetBSD PR/7814), the result was counterintuitive; for example, echo "`cd /`" would change the cwd. So ash 0.3.5 left out that optimization. The EV_BACKCMD codepath stayed around, unused. Some time between ash 0.3.5-11 and ash 0.3.8-...
2019 Jan 25
0
[klibc:update-dash] eval: Fix exit status when calling eval/dot with no commands
...dash/main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index db7639a4..ef6ec0ef 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -172,7 +172,8 @@ evalstring(char *s, int flags) status = 0; while ((n = parsecmd(0)) != NEOF) { evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); - status = exitstatus; + if (n) + status = exitstatus; popstackmark(&smark); if (evalskip) break; diff --git a/usr/dash/main.c b/usr/dash/main.c index bedb6635..497ac160 100644 --- a/usr/dash/main.c +++ b/usr/dash/main.c @@ -228,7 +22...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Fix exit status when calling eval/dot with no commands
...dash/main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 3325cb62..0380d1d2 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -172,7 +172,8 @@ evalstring(char *s, int flags) status = 0; while ((n = parsecmd(0)) != NEOF) { evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); - status = exitstatus; + if (n) + status = exitstatus; popstackmark(&smark); if (evalskip) break; diff --git a/usr/dash/main.c b/usr/dash/main.c index bedb6635..497ac160 100644 --- a/usr/dash/main.c +++ b/usr/dash/main.c @@ -228,7 +22...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Fix old-style command substitution here-document crash
...> #1 0x574d92 in openredirect /home/jfe/dash/src/redir.c:230:7 > #2 0x5737fe in redirect /home/jfe/dash/src/redir.c:121:11 > #3 0x576017 in redirectsafe /home/jfe/dash/src/redir.c:424:3 > #4 0x522326 in evalcommand /home/jfe/dash/src/eval.c:828:11 > #5 0x520010 in evaltree /home/jfe/dash/src/eval.c:288:12 > #6 0x5270da in evaltreenr /home/jfe/dash/src/eval.c:332:2 > #7 0x526f04 in evalbackcmd /home/jfe/dash/src/eval.c:640:3 > #8 0x539020 in expbackq /home/jfe/dash/src/expand.c:522:2 > #9 0x5332d7 in argstr /home/jfe/dash/src/expand.c:343:4...
2019 Jan 22
0
usr/dash/eval.c:277:19: warning: logical not is only applied to the left hand side of comparison
Hi Christophe. On Tue, Jan 22, 2019 at 04:53:05PM +0000, Christophe Leroy wrote: > ? KLIBCCC usr/dash/eval.o > usr/dash/eval.c: In function 'evaltree': > usr/dash/eval.c:277:19: warning: logical not is only applied to the > left hand side of comparison [-Wlogical-not-parentheses] > ?? if (!exitstatus == isor) > ?????????????????? ^ > > Not sure what the fix should be: > > ?? if (!(exitstatus == isor)) > > &g...
2019 Jan 25
0
[klibc:update-dash] eval: Variable assignments on functions are no longer persistent
...case CMDFUNCTION: - poplocalvars(1); if (evalfun(cmdentry.u.func, argc, argv, flags)) goto raise; break; @@ -971,9 +970,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags) shellparam.p = argv + 1; shellparam.optind = 1; shellparam.optoff = -1; - pushlocalvars(); evaltree(func->n.ndefun.body, flags & EV_TESTED); - poplocalvars(0); funcdone: INTOFF; loopnest = saveloopnest;
2020 Mar 28
0
[klibc:update-dash] dash: eval: Variable assignments on functions are no longer persistent
...case CMDFUNCTION: - poplocalvars(1); if (evalfun(cmdentry.u.func, argc, argv, flags)) goto raise; break; @@ -971,9 +970,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags) shellparam.p = argv + 1; shellparam.optind = 1; shellparam.optoff = -1; - pushlocalvars(); evaltree(func->n.ndefun.body, flags & EV_TESTED); - poplocalvars(0); funcdone: INTOFF; loopnest = saveloopnest;
2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...} - return exitstatus; + return 0; } @@ -166,24 +165,23 @@ evalstring(char *s, int mask) { union node *n; struct stackmark smark; - int skip; + int status; setinputstring(s); setstackmark(&smark); - skip = 0; + status = 0; while ((n = parsecmd(0)) != NEOF) { evaltree(n, 0); + status = exitstatus; popstackmark(&smark); - skip = evalskip; - if (skip) + if (evalskip) break; } popfile(); - skip &= mask; - evalskip = skip; - return skip; + evalskip &= mask; + return status; } diff --git a/usr/dash/trap.c b/usr/dash/trap.c index 51e1...