diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2014-10-06 19:45:58 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 76fe43c4a495381c5e5600f127bb03f3b26b0d94 (patch) | |
tree | 42065389842e26ab0bf441e73cacf72fc77079de | |
parent | 85a5a4a9d96c0c680597432f1e4454718e7ad101 (diff) | |
download | klibc-76fe43c4a495381c5e5600f127bb03f3b26b0d94.tar.gz |
[klibc] dash: [BUILTIN] Do not allow break to break across function calls
[ dash commit ebfdd97a10e34a5e70eadfc21ebfc033ef93a563 ]
As it is if you do a multi-level break inside a function it'll
actually include loops outside of the function call. This is
counterintuitive.
This patch changes this by saving and resetting loopnest when
entering a function.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/eval.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 1c76d4c519956..e0c21f94e0b4f 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -928,9 +928,11 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags) struct jmploc jmploc; int e; int savefuncline; + int saveloopnest; saveparam = shellparam; savefuncline = funcline; + saveloopnest = loopnest; savehandler = handler; if ((e = setjmp(jmploc.loc))) { goto funcdone; @@ -940,6 +942,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags) shellparam.malloc = 0; func->count++; funcline = func->n.ndefun.linno; + loopnest = 0; INTON; shellparam.nparam = argc - 1; shellparam.p = argv + 1; @@ -950,6 +953,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags) poplocalvars(0); funcdone: INTOFF; + loopnest = saveloopnest; funcline = savefuncline; freefunc(func); freeparam(&shellparam); |