mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Streamline some shell state flaggery
src/cmd/ksh93/sh/args.c: sh_argprocsub(): - Save and restore state more efficiently by just saving and restoring all the state bits in one go using the sh_{get,set}state() macros, which are defined in defs.h as: #define sh_getstate() (sh.st.states) #define sh_setstate(x) (sh.st.states = (x)) (and there is yet more evidence that it doesn't matter whether we use a 'shp->' pointer or 'sh.' direct access). src/cmd/ksh93/sh/main.c: exfile(): - Remove a no-op 'sh_offstate(SH_INTERACTIVE);'. It was in the 'else' clause of 'if(sh_isstate(SH_INTERACTIVE))' so if we get there, it is known that this flag is already off. - To properly disable job control, we also have to save and restore the job.jobcontrol variable. src/cmd/ksh93/sh/xec.c: sh_exec(): - Remove some no-op flaggery from this highly performance-sensitive point in the code. Given the immediately preceding: volatile int was_errexit = sh_isstate(SH_ERREXIT); volatile int was_monitor = sh_isstate(SH_MONITOR); the following: sh_offstate(SH_ERREXIT); if(was_errexit&flags) sh_onstate(SH_ERREXIT); can be reformulated as: if(!(flags & sh_state(SH_ERREXIT))) sh_offstate(SH_ERREXIT); (IOW, if it was already on, don't turn it off and then on again) ...and the following: if(was_monitor&flags) sh_onstate(SH_MONITOR); can be removed; it's a no-op because it wasn't preceded by an sh_offstate() and if 'was_monitor' is true, this option is known to be on. (I considered they may have forgotten an 'sh_offstate' there like in the SH_ERREXIT case, but adding that causes several regressions in a shtests run.) src/cmd/ksh93/include/defs.h: - Remove comment that is evidently long outdated; there is not (or no longer) a Shscoped_t type defined anywhere, nor are these struct fields replicated in any other type definition. - Add comment to clarify what the 'states' int in 'struct sh_scoped' is for.
This commit is contained in:
parent
48ba6964ad
commit
79d1945813
4 changed files with 15 additions and 33 deletions
|
@ -402,7 +402,6 @@ static void exfile(register Shell_t *shp, register Sfio_t *iop,register int fno)
|
|||
buff.mode = SH_JMPEXIT;
|
||||
sh_onoption(SH_TRACKALL);
|
||||
}
|
||||
sh_offstate(SH_INTERACTIVE);
|
||||
if(sh_isoption(SH_MONITOR))
|
||||
sh_onstate(SH_MONITOR);
|
||||
sh_offstate(SH_HISTORY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue