[klibc] [klibc:update-dash] [BUILTIN] Do not allow break to break across function calls
klibc-bot for Herbert Xu
herbert at gondor.apana.org.au
Thu Jan 24 19:15:18 PST 2019
Commit-ID: 2c5f70d5fee9a0d51c7fc9a45df99ab735462c62
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=2c5f70d5fee9a0d51c7fc9a45df99ab735462c62
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Mon, 6 Oct 2014 19:45:58 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] [BUILTIN] Do not allow break to break across function calls
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 at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/eval.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/usr/dash/eval.c b/usr/dash/eval.c
index ccd5e0c0..204f1e57 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);
More information about the klibc
mailing list