mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
cleanup: remove redundant sh.st.execbrk flag
The 'break' and 'continue' flow control commands use three int variables in the scoped sh.st struct: sh.st.execbrk: nonzero if 'break' or 'continue' are used sh.st.breakcnt: number of levels to 'break'/'continue' (negative if 'continue') sh.st.loopcnt: loop level counter for 'break'/'continue' Reading the code that sets and uses these (in bltins/cflow.c and sh/xec.c) makes it fairly obvious that the sh.st.execbrk flag is redundant; it is zero if no 'break' or 'continue' should happen, but the same is true for sh.st.breakcnt. This commit simplifies the code by removing sh.st.execbrk. It also adds some comments clarifying the use of the other two. Trivia: the ancient "Version 06/03/86a" ksh source code was recently discovered. It uses global execbrk, breakcnt and loopcnt variables with the same redundancy. More evidence that the AT&T team always lacked a question-everything department... https://minnie.tuhs.org/pipermail/tuhs/2020-December/022640.html https://github.com/weiss/original-bsd/blob/master/local/toolchest/ksh/sh/builtin.c https://github.com/weiss/original-bsd/blob/master/local/toolchest/ksh/sh/xec.c
This commit is contained in:
parent
400806afa6
commit
24c3d77e3c
4 changed files with 17 additions and 14 deletions
|
@ -437,7 +437,7 @@ static void exfile(register Sfio_t *iop,register int fno)
|
|||
sh_iorestore(0,jmpval);
|
||||
hist_flush(sh.hist_ptr);
|
||||
sfsync(sh.outpool);
|
||||
sh.st.execbrk = sh.st.breakcnt = 0;
|
||||
sh.st.breakcnt = 0;
|
||||
/* check for return from profile or env file */
|
||||
if(sh_isstate(SH_PROFILE) && (jmpval==SH_JMPFUN || jmpval==SH_JMPEXIT))
|
||||
{
|
||||
|
@ -604,7 +604,7 @@ static void exfile(register Sfio_t *iop,register int fno)
|
|||
{
|
||||
execflags |= sh_state(SH_NOFORK);
|
||||
}
|
||||
sh.st.execbrk = 0;
|
||||
sh.st.breakcnt = 0;
|
||||
sh_exec(t,execflags);
|
||||
if(sh.forked)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue