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

@ -128,7 +128,7 @@ struct argnod
extern struct dolnod *sh_argcreate(char*[]);
extern char *sh_argdolminus(void*);
extern int sh_argopts(int,char*[],void*);
extern int sh_argopts(int,char*[]);
extern const char e_heading[];

View file

@ -33,33 +33,33 @@
* IMPORTANT: The offsets on these macros must be synchronous
* with the order of shtab_builtins[] in data/builtins.c!
*/
#define SYSEXEC (shgd->bltin_cmds) /* exec */
#define SYSREDIR (shgd->bltin_cmds+1) /* redirect */
#define SYSSET (shgd->bltin_cmds+2) /* set */
#define SYSEXEC (sh.bltin_cmds) /* exec */
#define SYSREDIR (sh.bltin_cmds+1) /* redirect */
#define SYSSET (sh.bltin_cmds+2) /* set */
/* : */
#define SYSTRUE (shgd->bltin_cmds+4) /* true */
#define SYSCOMMAND (shgd->bltin_cmds+5) /* command */
#define SYSCD (shgd->bltin_cmds+6) /* cd */
#define SYSBREAK (shgd->bltin_cmds+7) /* break */
#define SYSCONT (shgd->bltin_cmds+8) /* continue */
#define SYSTRUE (sh.bltin_cmds+4) /* true */
#define SYSCOMMAND (sh.bltin_cmds+5) /* command */
#define SYSCD (sh.bltin_cmds+6) /* cd */
#define SYSBREAK (sh.bltin_cmds+7) /* break */
#define SYSCONT (sh.bltin_cmds+8) /* continue */
#define SYSTYPESET (shgd->bltin_cmds+9) /* typeset \ */
#define SYSTYPESET (sh.bltin_cmds+9) /* typeset \ */
/* autoload | */
#define SYSCOMPOUND (shgd->bltin_cmds+11) /* compound | */
#define SYSCOMPOUND (sh.bltin_cmds+11) /* compound | */
/* float >typeset range */
/* functions | */
/* integer | */
#define SYSNAMEREF (shgd->bltin_cmds+15) /* nameref | */
#define SYSTYPESET_END (shgd->bltin_cmds+15) /* / */
#define SYSNAMEREF (sh.bltin_cmds+15) /* nameref | */
#define SYSTYPESET_END (sh.bltin_cmds+15) /* / */
#define SYSTEST (shgd->bltin_cmds+16) /* test */
#define SYSBRACKET (shgd->bltin_cmds+17) /* [ */
#define SYSLET (shgd->bltin_cmds+18) /* let */
#define SYSEXPORT (shgd->bltin_cmds+19) /* export */
#define SYSDOT (shgd->bltin_cmds+20) /* . */
#define SYSSOURCE (shgd->bltin_cmds+21) /* source */
#define SYSRETURN (shgd->bltin_cmds+22) /* return */
#define SYSENUM (shgd->bltin_cmds+23) /* enum */
#define SYSTEST (sh.bltin_cmds+16) /* test */
#define SYSBRACKET (sh.bltin_cmds+17) /* [ */
#define SYSLET (sh.bltin_cmds+18) /* let */
#define SYSEXPORT (sh.bltin_cmds+19) /* export */
#define SYSDOT (sh.bltin_cmds+20) /* . */
#define SYSSOURCE (sh.bltin_cmds+21) /* source */
#define SYSRETURN (sh.bltin_cmds+22) /* return */
#define SYSENUM (sh.bltin_cmds+23) /* enum */
/* entry point for shell special builtins */

View file

@ -124,59 +124,56 @@ extern char* sh_setenviron(const char*);
#define SH_READEVAL 0x4000 /* for sh_eval */
#define SH_FUNEVAL 0x10000 /* for sh_eval for function load */
extern void sh_applyopts(Shell_t*,Shopt_t);
extern char **sh_argbuild(Shell_t*,int*,const struct comnod*,int);
extern struct dolnod *sh_argfree(Shell_t *, struct dolnod*,int);
extern struct dolnod *sh_argnew(Shell_t*,char*[],struct dolnod**);
extern void *sh_argopen(Shell_t*);
extern struct argnod *sh_argprocsub(Shell_t*,struct argnod*);
extern void sh_argreset(Shell_t*,struct dolnod*,struct dolnod*);
extern char **sh_argbuild(int*,const struct comnod*,int);
extern struct dolnod *sh_argfree(struct dolnod*,int);
extern struct dolnod *sh_argnew(char*[],struct dolnod**);
extern void *sh_argopen(void);
extern struct argnod *sh_argprocsub(struct argnod*);
extern void sh_argreset(struct dolnod*,struct dolnod*);
extern Namval_t *sh_assignok(Namval_t*,int);
extern struct dolnod *sh_arguse(Shell_t*);
extern struct dolnod *sh_arguse(void);
extern char *sh_checkid(char*,char*);
extern void sh_chktrap(Shell_t*);
extern void sh_chktrap(void);
extern void sh_deparse(Sfio_t*,const Shnode_t*,int);
extern int sh_debug(Shell_t *shp,const char*,const char*,const char*,char *const[],int);
extern int sh_echolist(Shell_t*,Sfio_t*, int, char**);
extern struct argnod *sh_endword(Shell_t*,int);
extern int sh_debug(const char*,const char*,const char*,char *const[],int);
extern char **sh_envgen(void);
extern void sh_envnolocal(Namval_t*,void*);
extern Sfdouble_t sh_arith(Shell_t*,const char*);
extern void *sh_arithcomp(Shell_t *,char*);
extern pid_t sh_fork(Shell_t*,int,int*);
extern pid_t _sh_fork(Shell_t*,pid_t, int ,int*);
extern char *sh_mactrim(Shell_t*,char*,int);
extern int sh_macexpand(Shell_t*,struct argnod*,struct argnod**,int);
extern int sh_macfun(Shell_t*,const char*,int);
extern void sh_machere(Shell_t*,Sfio_t*, Sfio_t*, char*);
extern void *sh_macopen(Shell_t*);
extern char *sh_macpat(Shell_t*,struct argnod*,int);
extern Sfdouble_t sh_mathfun(Shell_t*, void*, int, Sfdouble_t*);
extern int sh_outtype(Shell_t*, Sfio_t*);
extern char *sh_mactry(Shell_t*,char*);
extern Sfdouble_t sh_arith(const char*);
extern void *sh_arithcomp(char*);
extern pid_t sh_fork(int,int*);
extern pid_t _sh_fork(pid_t, int ,int*);
extern char *sh_mactrim(char*,int);
extern int sh_macexpand(struct argnod*,struct argnod**,int);
extern int sh_macfun(const char*,int);
extern void sh_machere(Sfio_t*, Sfio_t*, char*);
extern void *sh_macopen(void);
extern char *sh_macpat(struct argnod*,int);
extern Sfdouble_t sh_mathfun(void*, int, Sfdouble_t*);
extern int sh_outtype(Sfio_t*);
extern char *sh_mactry(char*);
extern int sh_mathstd(const char*);
extern void sh_printopts(Shopt_t,int,Shopt_t*);
extern int sh_readline(Shell_t*,char**,volatile int,int,ssize_t,long);
extern int sh_readline(char**,volatile int,int,ssize_t,long);
extern Sfio_t *sh_sfeval(char*[]);
extern void sh_setmatch(Shell_t*,const char*,int,int,int[],int);
extern void sh_scope(Shell_t*, struct argnod*, int);
extern Namval_t *sh_scoped(Shell_t*, Namval_t*);
extern void sh_setmatch(const char*,int,int,int[],int);
extern void sh_scope(struct argnod*, int);
extern Namval_t *sh_scoped(Namval_t*);
extern Dt_t *sh_subtracktree(int);
extern Dt_t *sh_subfuntree(int);
extern void sh_subjobcheck(pid_t);
extern int sh_subsavefd(int);
extern void sh_subtmpfile(Shell_t*);
extern void sh_subtmpfile(void);
extern char *sh_substitute(const char*,const char*,char*);
extern void sh_timetraps(Shell_t*);
extern void sh_timetraps(void);
extern const char *_sh_translate(const char*);
extern int sh_trace(Shell_t*,char*[],int);
extern int sh_trace(char*[],int);
extern void sh_trim(char*);
extern int sh_type(const char*);
extern void sh_unscope(Shell_t*);
extern void sh_unscope(void);
extern void sh_utol(const char*, char*);
extern int sh_whence(char**,int);
#if SHOPT_NAMESPACE
extern Namval_t *sh_fsearch(Shell_t*,const char *,int);
extern Namval_t *sh_fsearch(const char *,int);
#endif /* SHOPT_NAMESPACE */
/* malloc related wrappers */
@ -214,7 +211,7 @@ extern char *sh_getcwd(void);
#define sh_getstate() (sh.st.states)
#define sh_setstate(x) (sh.st.states = (x))
#define sh_sigcheck(shp) do{if((shp)->trapnote&SH_SIGSET)sh_exit(SH_EXITSIG);} while(0)
#define sh_sigcheck() do { if(sh.trapnote & SH_SIGSET) sh_exit(SH_EXITSIG); } while(0)
extern int32_t sh_mailchk;
extern const char e_dict[];
@ -243,7 +240,7 @@ extern const char e_dict[];
# define STAT_SPAWN 12
# define STAT_SUBSHELL 13
extern const Shtable_t shtab_stats[];
# define sh_stats(x) (shgd->stats[(x)]++)
# define sh_stats(x) (sh.stats[(x)]++)
#else
# define sh_stats(x)
#endif /* SHOPT_STATS */

View file

@ -131,7 +131,6 @@ typedef struct edit
char e_macro[4]; /* macro buffer */
void *e_vi; /* vi specific data */
void *e_emacs; /* emacs specific data */
Shell_t *sh; /* interpreter pointer */
char *e_stkptr; /* saved stack pointer */
int e_stkoff; /* saved stack offset */
char **e_clist; /* completion list after <ESC>= */
@ -190,7 +189,7 @@ extern int ed_setcursor(Edit_t*, genchar*, int, int, int);
extern int ed_macro(Edit_t*,int);
extern int ed_expand(Edit_t*, char[],int*,int*,int,int);
extern int ed_fulledit(Edit_t*);
extern void *ed_open(Shell_t*);
extern void *ed_open(void);
#if SHOPT_MULTIBYTE
extern int ed_internal(const char*, genchar*);
extern int ed_external(const genchar*, char*);

View file

@ -108,11 +108,11 @@ struct checkpt
)
#define sh_popcontext(shp,bp) ((shp)->jmplist=(bp)->prev, errorpop(&((bp)->err)))
extern noreturn void sh_done(void*,int);
extern noreturn void sh_done(int);
extern void sh_fault(int);
extern void sh_sigclear(int);
extern void sh_sigdone(void);
extern void sh_siginit(void*);
extern void sh_siginit(void);
extern void sh_sigtrap(int);
extern void sh_sigreset(int);
extern void *sh_timeradd(unsigned long,int ,void (*)(void*),void*);

View file

@ -56,7 +56,7 @@ extern int _Hist;
#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
#define hist_max(hp) ((int)((hp)->histind))
/* these are the history interface routines */
extern int sh_histinit(void *);
extern int sh_histinit(void);
extern void hist_cancel(History_t*);
extern void hist_close(History_t*);
extern int hist_copy(char*, int, int, int);

View file

@ -52,29 +52,28 @@
struct ionod;
#endif /* !ARG_RAW */
extern int sh_iocheckfd(Shell_t*,int);
extern void sh_ioinit(Shell_t*);
extern int sh_iocheckfd(int);
extern void sh_ioinit(void);
extern int sh_iomovefd(int);
extern int sh_iorenumber(Shell_t*,int,int);
extern int sh_iorenumber(int,int);
extern void sh_pclose(int[]);
extern int sh_rpipe(int[]);
extern void sh_iorestore(Shell_t*,int,int);
extern void sh_iorestore(int,int);
#if defined(__EXPORT__) && defined(_BLD_DLL)
__EXPORT__
#endif
extern Sfio_t *sh_iostream(Shell_t*,int);
extern int sh_redirect(Shell_t*,struct ionod*,int);
extern void sh_iosave(Shell_t *, int,int,char*);
extern int sh_iovalidfd(Shell_t*, int);
extern int sh_iosafefd(Shell_t*, int);
extern int sh_inuse(Shell_t*, int);
extern void sh_iounsave(Shell_t*);
extern void sh_iounpipe(Shell_t*);
extern Sfio_t *sh_iostream(int);
extern int sh_redirect(struct ionod*,int);
extern void sh_iosave(int,int,char*);
extern int sh_iovalidfd(int);
extern int sh_iosafefd(int);
extern int sh_inuse(int);
extern void sh_iounsave(void);
extern void sh_iounpipe(void);
extern int sh_chkopen(const char*);
extern int sh_ioaccess(int,int);
extern int sh_devtofd(const char*);
extern int sh_isdevfd(const char*);
extern int sh_source(Shell_t*, Sfio_t*, const char*);
/* the following are readonly */
extern const char e_pexists[];

View file

@ -59,7 +59,6 @@ struct process
{
struct process *p_nxtjob; /* next job structure */
struct process *p_nxtproc; /* next process in current job */
Shell_t *p_shp; /* shell that posted the job */
int *p_exitval; /* place to store the exitval */
pid_t p_pid; /* process id */
pid_t p_pgrp; /* process group */
@ -167,23 +166,23 @@ extern void job_bwait(char**);
extern int job_walk(Sfio_t*,int(*)(struct process*,int),int,char*[]);
extern int job_kill(struct process*,int);
extern int job_wait(pid_t);
extern int job_post(Shell_t*,pid_t,pid_t);
extern int job_post(pid_t,pid_t);
extern void *job_subsave(void);
extern void job_subrestore(void*);
#if SHOPT_BGX
extern void job_chldtrap(Shell_t*, const char*,int);
extern void job_chldtrap(const char*,int);
#endif /* SHOPT_BGX */
#ifdef JOBS
extern void job_init(Shell_t*,int);
extern int job_close(Shell_t*);
extern void job_init(int);
extern int job_close(void);
extern int job_list(struct process*,int);
extern int job_hup(struct process *, int);
extern int job_switch(struct process*,int);
extern void job_fork(pid_t);
extern int job_reap(int);
#else
# define job_init(s,flag)
# define job_close(s) (0)
# define job_init(flag)
# define job_close() (0)
# define job_fork(p)
#endif /* JOBS */

View file

@ -63,7 +63,6 @@ typedef struct pathcomp
char *blib;
unsigned short len;
unsigned short flags;
Shell_t *shp;
} Pathcomp_t;
#ifndef ARG_RAW
@ -71,38 +70,42 @@ typedef struct pathcomp
#endif /* !ARG_RAW */
/* pathname handling routines */
extern void path_newdir(Shell_t*,Pathcomp_t*);
extern void path_newdir(Pathcomp_t*);
extern Pathcomp_t *path_dirfind(Pathcomp_t*,const char*,int);
extern Pathcomp_t *path_unsetfpath(Shell_t*);
extern Pathcomp_t *path_addpath(Shell_t*,Pathcomp_t*,const char*,int);
extern Pathcomp_t *path_unsetfpath(void);
extern Pathcomp_t *path_addpath(Pathcomp_t*,const char*,int);
extern Pathcomp_t *path_dup(Pathcomp_t*);
extern void path_delete(Pathcomp_t*);
extern void path_alias(Namval_t*,Pathcomp_t*);
extern Pathcomp_t *path_absolute(Shell_t*, const char*, Pathcomp_t*, int);
extern Pathcomp_t *path_absolute(const char*, Pathcomp_t*, int);
extern char *path_basename(const char*);
extern char *path_fullname(Shell_t*,const char*);
extern int path_expand(Shell_t*,const char*, struct argnod**);
extern noreturn void path_exec(Shell_t*,const char*,char*[],struct argnod*);
extern pid_t path_spawn(Shell_t*,const char*,char*[],char*[],Pathcomp_t*,int);
extern char *path_fullname(const char*);
extern int path_expand(const char*, struct argnod**);
extern noreturn void path_exec(const char*,char*[],struct argnod*);
extern pid_t path_spawn(const char*,char*[],char*[],Pathcomp_t*,int);
#if defined(__EXPORT__) && defined(_BLD_DLL)
# define extern __EXPORT__
#endif
extern int path_open(Shell_t*,const char*,Pathcomp_t*);
extern Pathcomp_t *path_get(Shell_t*,const char*);
extern int path_open(const char*,Pathcomp_t*);
extern Pathcomp_t *path_get(const char*);
#undef extern
extern char *path_pwd(Shell_t*,int);
extern Pathcomp_t *path_nextcomp(Shell_t*,Pathcomp_t*,const char*,Pathcomp_t*);
extern int path_search(Shell_t*,const char*,Pathcomp_t**,int);
extern char *path_relative(Shell_t*,const char*);
extern int path_complete(Shell_t*,const char*, const char*,struct argnod**);
extern char *path_pwd(void);
extern Pathcomp_t *path_nextcomp(Pathcomp_t*,const char*,Pathcomp_t*);
extern int path_search(const char*,Pathcomp_t**,int);
extern char *path_relative(const char*);
extern int path_complete(const char*, const char*,struct argnod**);
#if SHOPT_BRACEPAT
extern int path_generate(Shell_t*,struct argnod*,struct argnod**);
extern int path_generate(struct argnod*,struct argnod**);
#endif /* SHOPT_BRACEPAT */
extern int path_xattr(Shell_t*, const char*, char*);
#if SHOPT_PFSH
extern int path_xattr(const char*, char*);
#endif /* SHOPT_PFSH */
#if SHOPT_DYNAMIC
/* builtin/plugin routines */
extern int sh_addlib(Shell_t*,void*,char*,Pathcomp_t*);
extern Shbltin_f sh_getlib(Shell_t*,char*,Pathcomp_t*);
extern int sh_addlib(void*,char*,Pathcomp_t*);
extern Shbltin_f sh_getlib(char*,Pathcomp_t*);
#endif /* SHOPT_DYNAMIC */
/* constant strings needed for whence */
extern const char e_timeformat[];

View file

@ -52,7 +52,7 @@ typedef struct Regress_s
#define SHOPT_P_SUID sh_regress_p_suid(__LINE__, __FILE__)
extern int b___regress__(int, char**, Shbltin_t*);
extern void sh_regress_init(Shell_t*);
extern void sh_regress_init(void);
extern void sh_regress(unsigned int, const char*, const char*, unsigned int, const char*);
extern uid_t sh_regress_p_suid(unsigned int, const char*);
extern char* sh_regress_etc(const char*, unsigned int, const char*);

View file

@ -28,7 +28,7 @@
*
*/
#define SH_VERSION 20211229
#define SH_VERSION 20220106
#include <ast.h>
#include <cdt.h>
@ -226,13 +226,11 @@ struct Shell_s
Dt_t *fun_tree; /* for shell functions */
Dt_t *alias_tree; /* for alias names */
Dt_t *bltin_tree; /* for builtin commands */
Dt_t *track_tree; /* for tracked aliases */
Shscope_t *topscope; /* pointer to top-level scope */
int inlineno; /* line number of current input file */
int exitval; /* exit status of the command currently being run */
int savexit; /* $? == exit status of the last command executed */
unsigned char trapnote; /* set when trap/signal is pending */
char shcomp; /* set when running shcomp */
unsigned int subshell; /* set for virtual subshell */
/* These are the former 'struct shared' (shgd) members. */
struct limits lim;
@ -243,7 +241,6 @@ struct Shell_s
pid_t pid; /* $$, the main shell's PID (invariable) */
pid_t ppid; /* $PPID, the main shell's parent's PID */
pid_t current_pid; /* ${.sh.pid}, PID of current ksh process (updates when subshell forks) */
int realsubshell; /* ${.sh.subshell}, actual subshell level (including virtual and forked) */
unsigned char sigruntime[2];
Namval_t *bltin_nodes;
Namval_t *bltin_cmds;
@ -253,13 +250,18 @@ struct Shell_s
char **sigmsg;
char **login_files;
void *ed_context;
int *stats;
int sigmax;
Shwait_f waitevent;
#if SHOPT_STATS
int *stats;
#endif
/* These are the members formerly defined via the _SH_PRIVATE macro.
/* The following members are not considered to be part of the documented API.
* Programs using libshell should not rely on them as they may change. */
Shell_t *gd; /* pointer to self for backwards compatibility (was: global data) */
int subshell; /* set for virtual subshell */
int realsubshell; /* ${.sh.subshell}, actual subshell level (including virtual and forked) */
char shcomp; /* set when running shcomp */
unsigned char trapnote; /* set when trap/signal is pending */
struct sh_scoped st; /* scoped information */
Stk_t *stk; /* stack pointer */
Sfio_t *heredocs; /* current here-doc temp file */
@ -268,7 +270,6 @@ struct Shell_s
char *lastarg;
char *lastpath; /* last absolute path found */
int path_err; /* last error on path search */
Dt_t *track_tree; /* for tracked aliases */
Dt_t *var_base; /* global level variables */
Dt_t *fun_base; /* global level functions */
Dt_t *openmatch;
@ -414,13 +415,12 @@ extern Libcomp_t *liblist;
# define extern __EXPORT__
#endif /* _DLL */
extern Dt_t *sh_bltin_tree(void);
extern void sh_subfork(void);
extern Shell_t *sh_init(int,char*[],Shinit_f);
extern int sh_reinit(char*[]);
extern int sh_eval(Sfio_t*,int);
extern void sh_delay(double,int);
extern void *sh_parse(Shell_t*, Sfio_t*,int);
extern void *sh_parse(Sfio_t*,int);
extern int sh_trap(const char*,int);
extern int sh_fun(Namval_t*,Namval_t*, char*[]);
extern int sh_funscope(int,char*[],int(*)(void*),void*,int);
@ -452,7 +452,7 @@ extern mode_t sh_umask(mode_t);
extern void *sh_waitnotify(Shwait_f);
extern Shscope_t *sh_getscope(int,int);
extern Shscope_t *sh_setscope(Shscope_t*);
extern void sh_sigcheck(Shell_t*);
extern void sh_sigcheck(void);
extern unsigned long sh_isoption(int);
extern unsigned long sh_onoption(int);
extern unsigned long sh_offoption(int);
@ -462,12 +462,10 @@ extern int sh_exec(const Shnode_t*,int);
/*
* As of 93u+m, direct access to sh is no longer obsolete, and
* shgd ("global data") is no longer a separately allocated struct;
* sh_getinterp() and shgd are provided here for compatibility.
* sh_getinterp() is here for compatibility with the documented interface.
*/
extern Shell_t sh;
extern Shell_t *sh_getinterp(void); /* for libshell ABI compatibility */
#define sh_getinterp() (&sh)
#define shgd (&sh)
#ifdef _DLL
# undef extern

View file

@ -75,7 +75,6 @@ struct _shlex_pvt_lexdata_
*/
typedef struct _shlex_
{
Shell_t *sh; /* pointer to the interpreter */
struct argnod *arg; /* current word */
struct ionod *heredoc; /* pending here document list */
int token; /* current token number */
@ -187,7 +186,7 @@ extern const char e_newline[];
extern int sh_lex(Lex_t*);
extern Shnode_t *sh_dolparen(Lex_t*);
extern Lex_t *sh_lexopen(Lex_t*, Shell_t*, int);
extern Lex_t *sh_lexopen(Lex_t*, int);
extern void sh_lexskip(Lex_t*,int,int,int);
extern noreturn void sh_syntax(Lex_t*);
#if SHOPT_KIA

View file

@ -209,13 +209,13 @@ union Shnode_u
struct arithnod ar;
};
extern void sh_freeup(Shell_t*);
extern void sh_freeup(void);
extern void sh_funstaks(struct slnod*,int);
extern Sfio_t *sh_subshell(Shell_t*,Shnode_t*, volatile int, int);
extern Sfio_t *sh_subshell(Shnode_t*, volatile int, int);
#if defined(__EXPORT__) && defined(_BLD_DLL)
__EXPORT__
#endif
extern int sh_tdump(Sfio_t*, const Shnode_t*);
extern Shnode_t *sh_trestore(Shell_t*, Sfio_t*);
extern Shnode_t *sh_trestore(Sfio_t*);
#endif /* _SHNODES_H */

View file

@ -61,6 +61,6 @@ extern const struct shtable3 shtab_builtins[];
extern const Shtable_t shtab_reserved[];
extern const Shtable_t *sh_locate(const char*, const Shtable_t*, int);
extern int sh_lookopt(const char*, int*);
extern Dt_t *sh_inittree(Shell_t*, const struct shtable2*);
extern Dt_t *sh_inittree(const struct shtable2*);
#endif /* SH_TABLE_H */

View file

@ -68,7 +68,6 @@
struct lval
{
Shell_t *shp;
char *value;
char *ovalue;
Sfdouble_t (*fun)(Sfdouble_t,...);
@ -93,7 +92,6 @@ struct mathtab
typedef struct _arith_
{
Shell_t *shp;
unsigned char *code;
const char *expr;
Sfdouble_t (*fun)(const char**,struct lval*,int,Sfdouble_t);
@ -199,7 +197,7 @@ extern const struct mathtab shtab_math[];
#define VALUE 2
#define MESSAGE 3
extern Sfdouble_t strval(Shell_t*,const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
extern Arith_t *arith_compile(Shell_t *,const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
extern Sfdouble_t arith_strval(const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
extern Arith_t *arith_compile(const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
extern Sfdouble_t arith_exec(Arith_t*);
#endif /* !SEQPOINT */

View file

@ -57,9 +57,9 @@
#define TEST_SGT 17
#define TEST_REP 20
extern int test_unop(Shell_t*,int, const char*);
extern int test_unop(int, const char*);
extern int test_inode(const char*, const char*);
extern int test_binop(Shell_t*,int, const char*, const char*);
extern int test_binop(int, const char*, const char*);
extern const char sh_opttest[];
extern const char test_opchars[];

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 */