search for: evalskip

Displaying 20 results from an estimated 30 matches for "evalskip".

2019 Jan 25
0
[klibc:update-dash] [EVAL] Move common skipcount logic into skiploop
...----- 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; +} + + STATIC void evalloop(union node *n, int flags) { + int skip; int status; loopne...
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Move common skipcount logic into skiploop
...----- 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; +} + + STATIC void evalloop(union node *n, int flags) { + int skip; int status; loopne...
2019 Jan 25
0
[klibc:update-dash] [TRAP] Make sure evalskip is zero before running traps
...klibc/klibc.git;a=commit;h=e6ebc6f4137090ec4ce858bdb0fe674774173e57 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 2 Oct 2014 19:49:48 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [TRAP] Make sure evalskip is zero before running traps As it is if dotrap is called with evalskip set to a nonzero value, it'll try to execute any set traps. The result is that the first command in the first set trap will be executed while the rest of the trap will be silently ignored due to evalskip. This is highly...
2020 Mar 28
0
[klibc:update-dash] dash: [TRAP] Make sure evalskip is zero before running traps
...klibc.git;a=commit;h=9d16e7c25d87057eae0b8bbbd512dd768f409e01 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 2 Oct 2014 19:49:48 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [TRAP] Make sure evalskip is zero before running traps [ dash commit d28c13e7119a605ef152a4310e9415dc7ae9b8f3 ] As it is if dotrap is called with evalskip set to a nonzero value, it'll try to execute any set traps. The result is that the first command in the first set trap will be executed while the rest of the trap...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Return without arguments in a trap should use status outside traps
...2 +- usr/dash/trap.c | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 57db825b..db7639a4 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -967,7 +967,7 @@ funcdone: shellparam = saveparam; handler = savehandler; INTON; - evalskip &= ~SKIPFUNC; + evalskip &= ~(SKIPFUNC | SKIPFUNCDEF); return e; } @@ -1047,12 +1047,23 @@ breakcmd(int argc, char **argv) int returncmd(int argc, char **argv) { + int skip; + int status; + /* * If called outside a function, do what ksh does; * skip the rest of the file....
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Return without arguments in a trap should use status outside traps
...2 +- usr/dash/trap.c | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index bb9fc260..3325cb62 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -967,7 +967,7 @@ funcdone: shellparam = saveparam; handler = savehandler; INTON; - evalskip &= ~SKIPFUNC; + evalskip &= ~(SKIPFUNC | SKIPFUNCDEF); return e; } @@ -1047,12 +1047,23 @@ breakcmd(int argc, char **argv) int returncmd(int argc, char **argv) { + int skip; + int status; + /* * If called outside a function, do what ksh does; * skip the rest of the file....
2012 Jul 02
0
[klibc:master] [BUILTIN] Merge SKIPFUNC/ SKIPFILE and only clear SKIPFUNC when leaving dotcmd
...t;herbert at gondor.apana.org.au> AuthorDate: Sat, 9 Jul 2011 22:05:22 +0800 Committer: maximilian attems <max at stro.at> CommitDate: Mon, 2 Jul 2012 10:45:36 +0200 [klibc] [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving dotcmd Currently upon leaving a dotcmd the evalskip state is reset so if a continue/break statement is used within a dot script it would have no effect outside of the dot script. This is inconsistent with other shells. This patch is based on one by Jilles Tjoelker and only clears SKIPFUNC when leaving a dot script. As a result continue/break will...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Only restore exit status on exit/return
...shell */ +#define EXEXIT 4 /* exit the shell via exitcmd */ /* diff --git a/usr/dash/eval.c b/usr/dash/eval.c index bba0e7f8..1aad31a0 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -114,12 +114,13 @@ STATIC const struct builtincmd bltin = { INCLUDE "eval.h" EXITRESET { - evalskip = 0; - loopnest = 0; if (savestatus >= 0) { - exitstatus = savestatus; + if (exception == EXEXIT || evalskip == SKIPFUNCDEF) + exitstatus = savestatus; savestatus = -1; } + evalskip = 0; + loopnest = 0; } #endif @@ -318,7 +319,7 @@ out: if (flags & EV_EXIT) { exexit: - e...
2019 Jan 25
0
[klibc:update-dash] eval: Return status in eval functions
...) != NEOF) { - evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); + for (; (n = parsecmd(0)) != NEOF; popstackmark(&smark)) { + int i; + + i = evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); if (n) - status = exitstatus; - popstackmark(&smark); + status = i; + if (evalskip) break; } @@ -192,13 +194,13 @@ evalstring(char *s, int flags) * exitstatus. */ -void +int evaltree(union node *n, int flags) { int checkexit = 0; - void (*evalfn)(union node *, int); + int (*evalfn)(union node *, int); unsigned isor; - int status; + int status = 0; if (n == NUL...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Return status in eval functions
...) != NEOF) { - evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); + for (; (n = parsecmd(0)) != NEOF; popstackmark(&smark)) { + int i; + + i = evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); if (n) - status = exitstatus; - popstackmark(&smark); + status = i; + if (evalskip) break; } @@ -192,13 +194,13 @@ evalstring(char *s, int flags) * exitstatus. */ -void +int evaltree(union node *n, int flags) { int checkexit = 0; - void (*evalfn)(union node *, int); + int (*evalfn)(union node *, int); unsigned isor; - int status; + int status = 0; if (n == NUL...
2019 Jan 25
0
[klibc:update-dash] [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) ^~~~~~~ ( ) ----------------------------------------------------------------------- Add the parentheses to silence the warning. Si...
2020 Mar 28
0
[klibc:update-dash] dash: 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) ^~~~~~~ ( ) ----------------------------------------------------------------------- Add the parentheses to silence the warning. Si...
2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...otherwise, it shall return the exit > status of the command defined by the string of concatenated > arguments separated by <space>s. > > Hi Herbert, please see http://bugs.debian.org/347232 Changed evalstring to return the exit status instead of evalskip. This allows us to return zero if the string is empty. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: maximilian attems <max at stro.at> diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 44ba850..23b9608 100644 --- a/usr/dash/eval.c +++ b...
2020 Jun 18
1
[PATCH] fix warnings with GCC 10
...eval.c b/usr/dash/eval.c index dd144948a9fa..6b2b01e19a47 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -274,7 +274,7 @@ checkexit: n->nbinary.ch1, (flags | ((isor >> 1) - 1)) & EV_TESTED ); - if (!exitstatus == isor) + if ((!exitstatus) == isor) break; if (!evalskip) { n = n->nbinary.ch2; diff --git a/usr/klibc/zlib/infback.c b/usr/klibc/zlib/infback.c index 455dbc9ee843..be5eace3ad1a 100644 --- a/usr/klibc/zlib/infback.c +++ b/usr/klibc/zlib/infback.c @@ -460,7 +460,7 @@ void FAR *out_desc; } Tracev((stderr, "inflate:...
2019 Jan 25
0
[klibc:update-dash] [SHELL] Optimize dash -c "command" to avoid a fork
...h/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 */ @@ -169,7 +165,7 @@ evalstring(char *s, int flags) status = 0; while ((n = parsecmd(0)) != NEOF) { - evaltree(n, flags); + evaltree(n, flag...
2020 Mar 28
0
[klibc:update-dash] dash: [SHELL] Optimize dash -c "command" to avoid a fork
...h/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 */ @@ -169,7 +165,7 @@ evalstring(char *s, int flags) status = 0; while ((n = parsecmd(0)) != NEOF) { - evaltree(n, flags); + evaltree(n, flag...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Fix use-after-free in dotrap/evalstring
...l.c index da39136d..755136e2 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -160,6 +160,7 @@ evalstring(char *s, int flags) struct stackmark smark; int status; + s = sstrdup(s); setinputstring(s); setstackmark(&smark); @@ -171,7 +172,9 @@ evalstring(char *s, int flags) if (evalskip) break; } + popstackmark(&smark); popfile(); + stunalloc(s); return status; } diff --git a/usr/dash/histedit.c b/usr/dash/histedit.c index b27d6294..94465d78 100644 --- a/usr/dash/histedit.c +++ b/usr/dash/histedit.c @@ -372,8 +372,7 @@ histcmd(int argc, char **argv) out2str(...
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Fix use-after-free in dotrap/evalstring
...l.c index e6f6cd5c..adf05fde 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -160,6 +160,7 @@ evalstring(char *s, int flags) struct stackmark smark; int status; + s = sstrdup(s); setinputstring(s); setstackmark(&smark); @@ -171,7 +172,9 @@ evalstring(char *s, int flags) if (evalskip) break; } + popstackmark(&smark); popfile(); + stunalloc(s); return status; } diff --git a/usr/dash/histedit.c b/usr/dash/histedit.c index b27d6294..94465d78 100644 --- a/usr/dash/histedit.c +++ b/usr/dash/histedit.c @@ -372,8 +372,7 @@ histcmd(int argc, char **argv) out2str(...
2019 Jan 25
0
[klibc:update-dash] trap: Globally rename pendingsigs to pending_sig
...sig) return; status = savestatus; @@ -322,7 +322,7 @@ void dotrap(void) status = exitstatus; savestatus = status; } - pendingsigs = 0; + pending_sig = 0; barrier(); for (i = 0, q = gotsig; i < NSIG - 1; i++, q++) { @@ -330,7 +330,7 @@ void dotrap(void) continue; if (evalskip) { - pendingsigs = i + 1; + pending_sig = i + 1; break; } diff --git a/usr/dash/trap.h b/usr/dash/trap.h index 6590be12..a095b0e1 100644 --- a/usr/dash/trap.h +++ b/usr/dash/trap.h @@ -38,7 +38,7 @@ extern int trapcnt; extern char sigmode[]; -extern volatile sig_atomic_t pendingsig...
2020 Mar 28
0
[klibc:update-dash] dash: trap: Globally rename pendingsigs to pending_sig
...sig) return; status = savestatus; @@ -322,7 +322,7 @@ void dotrap(void) status = exitstatus; savestatus = status; } - pendingsigs = 0; + pending_sig = 0; barrier(); for (i = 0, q = gotsig; i < NSIG - 1; i++, q++) { @@ -330,7 +330,7 @@ void dotrap(void) continue; if (evalskip) { - pendingsigs = i + 1; + pending_sig = i + 1; break; } diff --git a/usr/dash/trap.h b/usr/dash/trap.h index 6590be12..a095b0e1 100644 --- a/usr/dash/trap.h +++ b/usr/dash/trap.h @@ -38,7 +38,7 @@ extern int trapcnt; extern char sigmode[]; -extern volatile sig_atomic_t pendingsig...