From f3433a696ace68c3ad4a9d4e59be94800b434e02 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 25 Nov 2021 10:13:06 +0100 Subject: [PATCH] Reset sh.arithrecursion in sh_exit() instead (re: d50d3d7c) Since the arithmetic recursion level only becomes incorrect when an error interrupts the arithmetic subsystem, and all such error messages call sh_exit(), it should be good enough to reset it there, so we don't need to do that for nearly every sh_exec() run. --- src/cmd/ksh93/sh/fault.c | 1 + src/cmd/ksh93/sh/xec.c | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cmd/ksh93/sh/fault.c b/src/cmd/ksh93/sh/fault.c index 972bcfd77..502c7661e 100644 --- a/src/cmd/ksh93/sh/fault.c +++ b/src/cmd/ksh93/sh/fault.c @@ -580,6 +580,7 @@ void sh_exit(register int xno) sfclrlock(sfstdin); if(!pp) sh_done(shp,sig); + shp->arithrecursion = 0; shp->prefix = 0; #if SHOPT_TYPEDEF shp->mktype = 0; diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 3578b67e8..87525fc9c 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -978,7 +978,6 @@ int sh_exec(register const Shnode_t *t, int flags) error_info.line = t->com.comline-shp->st.firstline; com = sh_argbuild(shp,&argn,&(t->com),OPTIMIZE); echeck = 1; - shp->arithrecursion = 0; if(t->tre.tretyp&COMSCAN) { argp = t->com.comarg; @@ -1890,7 +1889,6 @@ int sh_exec(register const Shnode_t *t, int flags) case TPAR: echeck = 1; - shp->arithrecursion = 0; flags &= ~OPTIMIZE_FLAG; if(!shp->subshell && !shp->st.trapcom[0] && !shp->st.trap[SH_ERRTRAP] && (flags&sh_state(SH_NOFORK))) { @@ -1960,7 +1958,6 @@ int sh_exec(register const Shnode_t *t, int flags) int *exitval=0,*saveexitval = job.exitval; pid_t savepgid = job.curpgid; echeck = 1; - shp->arithrecursion = 0; job.exitval = 0; job.curjobid = 0; if(shp->subshell) @@ -2643,7 +2640,6 @@ int sh_exec(register const Shnode_t *t, int flags) skipexitset++; error_info.line = t->tst.tstline-shp->st.firstline; echeck = 1; - shp->arithrecursion = 0; if((type&TPAREN)==TPAREN) { sh_exec(t->lst.lstlef,OPTIMIZE);