1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

[shp cleanup 01..20] all the rest (re: 2d3ec8b6)

This combines 20 cleanup commits from the dev branch.

All changed files:
- Clean up pointer defererences to sh.
- Remove shp arguments from functions.

Other notable changes:

src/cmd/ksh93/include/shell.h,
src/cmd/ksh93/sh/init.c:
- On second thought, get rid of the function version of
  sh_getinterp() as libshell ABI compatibility is moot. We've
  already been breaking that by reordering the sh struct, so there
  is no way it's going to work without recompiling.

src/cmd/ksh93/sh/name.c:
- De-obfuscate the relationship between nv_scan() and scanfilter().
  The former just calls the latter as a static function, there's no
  need to do that via a function pointer and void* type conversions.

src/cmd/ksh93/bltins/typeset.c,
src/cmd/ksh93/sh/name.c,
src/cmd/ksh93/sh/nvdisc.c:
- 'struct adata' and 'struct tdata', defined as local struct types
  in these files, need to have their first three fields in common,
  the first being a pointer to sh. This is because scanfilter() in
  name.c accesses these fields via a type conversion. So the sh
  field needed to be removed in all three at the same time.
  TODO: de-obfuscate: good practice definition via a header file.

src/cmd/ksh93/sh/path.c:
- Naming consistency: reserve the path_ function name prefix for
  externs and rename statics with that prefix.
- The default path was sometimes referred to as the standard path.
  To use one term, rename std_path to defpath and onstdpath() to
  ondefpath().
- De-obfuscate SHOPT_PFSH conditional code by only calling
  pf_execve() (was path_pfexecve()) if that is compiled in.

src/cmd/ksh93/include/streval.h,
src/cmd/ksh93/sh/streval.c:
- Rename extern strval() to arith_strval() for consistency.

src/cmd/ksh93/sh/string.c:
- Remove outdated/incorrect isxdigit() fallback; '#ifnded isxdigit'
  is not a correct test as isxdigit() is specified as a function.
  Plus, it's part of C89/C90 which we now require. (re: ac8991e5)

src/cmd/ksh93/sh/suid_exec.c:
- Replace an incorrect reference to shgd->current_pid with
  getpid(); it cannot work as (contrary to its misleading directory
  placement) suid_exec is an independent libast program with no
  link to ksh or libshell at all. However, no one noticed because
  this was in fallback code for ancient systems without
  setreuid(2). Since that standard function was specified in POSIX
  Issue 4 Version 2 from 1994, we should remove that fallback code
  sometime as part of another obsolete code cleanup operation to
  avoid further bit rot. (re: 843b546c)

src/cmd/ksh93/bltins/print.c: genformat():
- Remove preformat[] which was always empty and had no effect.

src/cmd/ksh93/shell.3:
- Minor copy-edit.
- Remove documentation for nonexistent sh.infile_name. A search
  through ast-open-archive[*] reveals this never existed at all.
- Document sh.savexit (== $?).

src/cmd/ksh93/shell.3,
src/cmd/ksh93/include/shell.h,
src/cmd/ksh93/sh/init.c:
- Remove sh.gd/shgd; this is now unused and was never documented
  or exposed in the shell.h public interface.
- sh_sigcheck() was documented in shell.3 as taking no arguments
  whereas in the actual code it took a shp argument. I decided to
  go with the documentation.
- That leaves sh_parse() as the only documented function that still
  takes an shp argument. I'm just going to go ahead and remove it
  for consistency, reverting sh_parse() to its pre-2003 spec.
- Remove undocumented/unused sh_bltin_tree() function which simply
  returned sh.bltin_tree.
- Bump SH_VERSION to 20220106.
This commit is contained in:
Martijn Dekker 2022-01-07 16:16:31 +00:00
parent 01da863154
commit b590a9f155
68 changed files with 3674 additions and 3935 deletions

View file

@ -38,72 +38,72 @@ extern void sh_save_rand_seed(struct rand *, int);
/* The following defines must be kept synchronous with shtab_variables[] in data/variables.c */
#define PATHNOD (shgd->bltin_nodes)
#define PS1NOD (shgd->bltin_nodes+1)
#define PS2NOD (shgd->bltin_nodes+2)
#define IFSNOD (shgd->bltin_nodes+3)
#define PWDNOD (shgd->bltin_nodes+4)
#define HOME (shgd->bltin_nodes+5)
#define MAILNOD (shgd->bltin_nodes+6)
#define REPLYNOD (shgd->bltin_nodes+7)
#define SHELLNOD (shgd->bltin_nodes+8)
#define EDITNOD (shgd->bltin_nodes+9)
#define MCHKNOD (shgd->bltin_nodes+10)
#define RANDNOD (shgd->bltin_nodes+11)
#define ENVNOD (shgd->bltin_nodes+12)
#define HISTFILE (shgd->bltin_nodes+13)
#define HISTSIZE (shgd->bltin_nodes+14)
#define HISTEDIT (shgd->bltin_nodes+15)
#define HISTCUR (shgd->bltin_nodes+16)
#define FCEDNOD (shgd->bltin_nodes+17)
#define CDPNOD (shgd->bltin_nodes+18)
#define MAILPNOD (shgd->bltin_nodes+19)
#define PS3NOD (shgd->bltin_nodes+20)
#define OLDPWDNOD (shgd->bltin_nodes+21)
#define VISINOD (shgd->bltin_nodes+22)
#define COLUMNS (shgd->bltin_nodes+23)
#define LINES (shgd->bltin_nodes+24)
#define PPIDNOD (shgd->bltin_nodes+25)
#define L_ARGNOD (shgd->bltin_nodes+26)
#define TMOUTNOD (shgd->bltin_nodes+27)
#define SECONDS (shgd->bltin_nodes+28)
#define LINENO (shgd->bltin_nodes+29)
#define OPTARGNOD (shgd->bltin_nodes+30)
#define OPTINDNOD (shgd->bltin_nodes+31)
#define PS4NOD (shgd->bltin_nodes+32)
#define FPATHNOD (shgd->bltin_nodes+33)
#define LANGNOD (shgd->bltin_nodes+34)
#define LCALLNOD (shgd->bltin_nodes+35)
#define LCCOLLNOD (shgd->bltin_nodes+36)
#define LCTYPENOD (shgd->bltin_nodes+37)
#define LCMSGNOD (shgd->bltin_nodes+38)
#define LCNUMNOD (shgd->bltin_nodes+39)
#define LCTIMENOD (shgd->bltin_nodes+40)
#define FIGNORENOD (shgd->bltin_nodes+41)
#define VERSIONNOD (shgd->bltin_nodes+42)
#define JOBMAXNOD (shgd->bltin_nodes+43)
#define DOTSHNOD (shgd->bltin_nodes+44)
#define ED_CHRNOD (shgd->bltin_nodes+45)
#define ED_COLNOD (shgd->bltin_nodes+46)
#define ED_TXTNOD (shgd->bltin_nodes+47)
#define ED_MODENOD (shgd->bltin_nodes+48)
#define SH_NAMENOD (shgd->bltin_nodes+49)
#define SH_SUBSCRNOD (shgd->bltin_nodes+50)
#define SH_VALNOD (shgd->bltin_nodes+51)
#define SH_VERSIONNOD (shgd->bltin_nodes+52)
#define SH_DOLLARNOD (shgd->bltin_nodes+53)
#define SH_MATCHNOD (shgd->bltin_nodes+54)
#define SH_COMMANDNOD (shgd->bltin_nodes+55)
#define SH_PATHNAMENOD (shgd->bltin_nodes+56)
#define SH_FUNNAMENOD (shgd->bltin_nodes+57)
#define SH_SUBSHELLNOD (shgd->bltin_nodes+58)
#define SH_LEVELNOD (shgd->bltin_nodes+59)
#define SH_LINENO (shgd->bltin_nodes+60)
#define SH_STATS (shgd->bltin_nodes+61)
#define SH_MATHNOD (shgd->bltin_nodes+62)
#define SH_JOBPOOL (shgd->bltin_nodes+63)
#define SH_PIDNOD (shgd->bltin_nodes+64)
#define SH_TILDENOD (shgd->bltin_nodes+65)
#define SHLVL (shgd->bltin_nodes+66)
#define PATHNOD (sh.bltin_nodes)
#define PS1NOD (sh.bltin_nodes+1)
#define PS2NOD (sh.bltin_nodes+2)
#define IFSNOD (sh.bltin_nodes+3)
#define PWDNOD (sh.bltin_nodes+4)
#define HOME (sh.bltin_nodes+5)
#define MAILNOD (sh.bltin_nodes+6)
#define REPLYNOD (sh.bltin_nodes+7)
#define SHELLNOD (sh.bltin_nodes+8)
#define EDITNOD (sh.bltin_nodes+9)
#define MCHKNOD (sh.bltin_nodes+10)
#define RANDNOD (sh.bltin_nodes+11)
#define ENVNOD (sh.bltin_nodes+12)
#define HISTFILE (sh.bltin_nodes+13)
#define HISTSIZE (sh.bltin_nodes+14)
#define HISTEDIT (sh.bltin_nodes+15)
#define HISTCUR (sh.bltin_nodes+16)
#define FCEDNOD (sh.bltin_nodes+17)
#define CDPNOD (sh.bltin_nodes+18)
#define MAILPNOD (sh.bltin_nodes+19)
#define PS3NOD (sh.bltin_nodes+20)
#define OLDPWDNOD (sh.bltin_nodes+21)
#define VISINOD (sh.bltin_nodes+22)
#define COLUMNS (sh.bltin_nodes+23)
#define LINES (sh.bltin_nodes+24)
#define PPIDNOD (sh.bltin_nodes+25)
#define L_ARGNOD (sh.bltin_nodes+26)
#define TMOUTNOD (sh.bltin_nodes+27)
#define SECONDS (sh.bltin_nodes+28)
#define LINENO (sh.bltin_nodes+29)
#define OPTARGNOD (sh.bltin_nodes+30)
#define OPTINDNOD (sh.bltin_nodes+31)
#define PS4NOD (sh.bltin_nodes+32)
#define FPATHNOD (sh.bltin_nodes+33)
#define LANGNOD (sh.bltin_nodes+34)
#define LCALLNOD (sh.bltin_nodes+35)
#define LCCOLLNOD (sh.bltin_nodes+36)
#define LCTYPENOD (sh.bltin_nodes+37)
#define LCMSGNOD (sh.bltin_nodes+38)
#define LCNUMNOD (sh.bltin_nodes+39)
#define LCTIMENOD (sh.bltin_nodes+40)
#define FIGNORENOD (sh.bltin_nodes+41)
#define VERSIONNOD (sh.bltin_nodes+42)
#define JOBMAXNOD (sh.bltin_nodes+43)
#define DOTSHNOD (sh.bltin_nodes+44)
#define ED_CHRNOD (sh.bltin_nodes+45)
#define ED_COLNOD (sh.bltin_nodes+46)
#define ED_TXTNOD (sh.bltin_nodes+47)
#define ED_MODENOD (sh.bltin_nodes+48)
#define SH_NAMENOD (sh.bltin_nodes+49)
#define SH_SUBSCRNOD (sh.bltin_nodes+50)
#define SH_VALNOD (sh.bltin_nodes+51)
#define SH_VERSIONNOD (sh.bltin_nodes+52)
#define SH_DOLLARNOD (sh.bltin_nodes+53)
#define SH_MATCHNOD (sh.bltin_nodes+54)
#define SH_COMMANDNOD (sh.bltin_nodes+55)
#define SH_PATHNAMENOD (sh.bltin_nodes+56)
#define SH_FUNNAMENOD (sh.bltin_nodes+57)
#define SH_SUBSHELLNOD (sh.bltin_nodes+58)
#define SH_LEVELNOD (sh.bltin_nodes+59)
#define SH_LINENO (sh.bltin_nodes+60)
#define SH_STATS (sh.bltin_nodes+61)
#define SH_MATHNOD (sh.bltin_nodes+62)
#define SH_JOBPOOL (sh.bltin_nodes+63)
#define SH_PIDNOD (sh.bltin_nodes+64)
#define SH_TILDENOD (sh.bltin_nodes+65)
#define SHLVL (sh.bltin_nodes+66)
#endif /* SH_VALNOD */