home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-04-25 | 35.9 KB | 1,449 lines |
- Newsgroups: comp.sources.misc
- From: sjg@zen.void.oz.au (Simon J. Gerraty)
- Subject: v29i086: pdksh - Public Domain Korn Shell, v4, Patch03d/5
- Message-ID: <1992Apr26.041615.22389@sparky.imd.sterling.com>
- X-Md4-Signature: 05de8910a6b1d539c342b4b5ca831059
- Date: Sun, 26 Apr 1992 04:16:15 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: sjg@zen.void.oz.au (Simon J. Gerraty)
- Posting-number: Volume 29, Issue 86
- Archive-name: pdksh/patch03d
- Environment: UNIX
- Patch-To: pdksh: Volume 25, Issue 47-55
-
- *** /dev/null Sat Apr 25 07:00:06 1992
- --- sh/proto.h Sat Apr 25 18:29:12 1992
- ***************
- *** 0 ****
- --- 1,234 ----
- + /*
- + * prototypes for PD-KSH
- + * originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang "
- + * $Id: proto.h,v 1.1 1992/04/25 08:29:02 sjg Exp $
- + */
- + #ifndef ARGS
- + #if defined(__STDC__) || defined(__cplusplus)
- + #define ARGS(s) s
- + #else
- + #define ARGS(s) ()
- + #endif
- + #endif
- +
- + /* alloc.c */
- + Area * ainit ARGS((Area *ap));
- + void afreeall ARGS((Area *ap));
- + void * alloc ARGS((size_t size, Area *ap));
- + void * aresize ARGS((void *ptr, size_t size, Area *ap));
- + void afree ARGS((void *ptr, Area *ap));
- + /* c_ksh.c */
- + int c_hash ARGS((char **wp));
- + int c_cd ARGS((char **wp));
- + int c_print ARGS((char **wp));
- + int c_whence ARGS((char **wp));
- + int c_typeset ARGS((char **wp));
- + int c_alias ARGS((char **wp));
- + int c_unalias ARGS((char **wp));
- + int c_let ARGS((char **wp));
- + int c_jobs ARGS((char **wp));
- + int c_fgbg ARGS((char **wp));
- + int c_kill ARGS((char **wp));
- + int c_bind ARGS((char **wp));
- + /* c_sh.c */
- + int c_label ARGS((char **wp));
- + int c_shift ARGS((char **wp));
- + int c_umask ARGS((char **wp));
- + int c_dot ARGS((char **wp));
- + int c_wait ARGS((char **wp));
- + int c_read ARGS((char **wp));
- + int c_eval ARGS((char **wp));
- + int c_trap ARGS((char **wp));
- + void setsig ARGS((struct trap *p, void (*f)()));
- + int c_return ARGS((char **wp));
- + int c_brkcont ARGS((char **wp));
- + int c_exit ARGS((char **wp));
- + int c_set ARGS((char **wp));
- + int c_unset ARGS((char **wp));
- + int c_ulimit ARGS((char **wp));
- + int c_times ARGS((char **wp));
- + int timex ARGS((struct op *t, int f));
- + int c_exec ARGS((char **wp));
- + int c_builtin ARGS((char **wp));
- + /* c_test.c */
- + int c_test ARGS((char **wp));
- + int oexpr ARGS((int n));
- + int aexpr ARGS((int n));
- + int nexpr ARGS((int n));
- + int primary ARGS((int n));
- + int filstat ARGS((char *nm, int mode));
- + int t_lex ARGS((char *s));
- + int newerf ARGS((char *f1, char *f2));
- + int olderf ARGS((char *f1, char *f2));
- + int equalf ARGS((char *f1, char *f2));
- + /* do_ulimit.c */
- + int do_ulimit ARGS((char *a1, char *a2));
- + /* edit.c */
- + int x_read ARGS((int fd, char *buf, size_t len));
- + int x_getc ARGS((void));
- + void x_flush ARGS((void));
- + void x_adjust ARGS((void));
- + void x_putc ARGS((int c));
- + void x_puts ARGS((char *s));
- + void x_init ARGS((void));
- + bool_t x_mode ARGS((bool_t onoff));
- + int promptlen ARGS((char *cp));
- + int init_editmode ARGS((void));
- + /* emacs.c */
- + int x_emacs ARGS((char *buf, size_t len));
- + void x_redraw ARGS((int limit));
- + void x_bind ARGS((char *a1, char *a2, int macro));
- + void x_init_emacs ARGS((void));
- + void x_emacs_keys ARGS((int erase, int kill, int werase, int intr, int quit));
- + char * x_lastcp ARGS((void));
- + /* eval.c */
- + char * substitute ARGS((char const *cp, int f));
- + char ** eval ARGS((char **ap, int f));
- + char * evalstr ARGS((char *cp, int f));
- + /* exec.c */
- + int execute ARGS((struct op *t, volatile int flags));
- + int shcomexec ARGS((char **wp));
- + int define ARGS((char *name, struct op *t));
- + int builtin ARGS((char *name, int (*func)()));
- + struct tbl * findcom ARGS((char *name, int insert));
- + int flushcom ARGS((int all));
- + char * search ARGS((char *name, char *path, int mode));
- + /* expr.c */
- + void evalerr ARGS((char *err));
- + long evaluate ARGS((const char *expr));
- + /* getopts.c */
- + void resetopts ARGS((void));
- + int c_getopts ARGS((char **wp));
- + /* history.c */
- + int c_fc ARGS((register char **wp));
- + void histbackup ARGS((void));
- + void histsave ARGS((char *cmd));
- + char ** histget ARGS((char *str));
- + char * histrpl ARGS((char *s, char *pat, char *rep, int global));
- + void hist_init ARGS((Source *s));
- + void hist_finish ARGS((void));
- + char ** histpos ARGS((void));
- + int histN ARGS((void));
- + int histnum ARGS((int n));
- + char * findhist ARGS((int start, int fwd, char *str));
- + /* io.c */
- + int errorf ARGS((const char *fmt, ...));
- + int shellf ARGS((const char *fmt, ...));
- + void fopenshf ARGS((int fd));
- + void flushshf ARGS((int fd));
- + int savefd ARGS((int fd));
- + void restfd ARGS((int fd, int ofd));
- + void openpipe ARGS((int *pv));
- + void closepipe ARGS((int *pv));
- + struct temp * maketemp ARGS((Area *ap));
- + /* jobs.c */
- + void j_init ARGS((void));
- + void j_exit ARGS((void));
- + void j_change ARGS((void));
- + int exchild ARGS((struct op *t, int flags));
- + int waitlast ARGS((void));
- + int j_reapchld ARGS((void));
- + int j_reap ARGS((void));
- + int waitfor ARGS((int job));
- + void j_kill ARGS((int job, int sig));
- + int j_resume ARGS((int job, int bg));
- + void j_jobs ARGS((void));
- + void j_notify ARGS((void));
- + int j_lookup ARGS((char *cp));
- + int j_stopped ARGS((void));
- + /* lex.c */
- + int yylex ARGS((int cf));
- + int gethere ARGS((void));
- + void yyerror ARGS((const char *msg));
- + Source * pushs ARGS((int type));
- + int pprompt ARGS((char *cp));
- + /* mail.c */
- + void mcheck ARGS((void));
- + void mbset ARGS((char *p));
- + void mpset ARGS((char *mptoparse));
- + void mprint ARGS((void));
- + /* main.c */
- + int main ARGS((int argc, char **argv, char **envp));
- + int include ARGS((char *name));
- + #if 0
- + int command ARGS((char *comm));
- + #endif
- + int shell ARGS((Source *s));
- + void leave ARGS((int rv));
- + int error ARGS((void));
- + int unwind ARGS((void));
- + int newenv ARGS((int type));
- + int quitenv ARGS((void));
- + void aerror ARGS((Area *ap, const char *msg));
- + /* misc.c */
- + void setctypes ARGS((/* const */ char *s, int t));
- + void initctypes ARGS((void));
- + char * ulton ARGS((unsigned long n, int base));
- + char * strsave ARGS((char *s, Area *ap));
- + int option ARGS((const char *n));
- + char * getoptions ARGS((void));
- + void printoptions ARGS((void));
- + int getn ARGS((char *as));
- + char * strerror ARGS((int i));
- + int gmatch ARGS((char *s, char *p));
- + void qsortp ARGS((void **base, size_t n, int (*f)()));
- + int qsort1 ARGS((void **base, void **lim, int (*f)()));
- + int xstrcmp ARGS((void *p1, void *p2));
- + void cleanpath ARGS((char *pwd, char *dir, char *clean));
- + /* syn.c */
- + int yyparse ARGS((void));
- + int keywords ARGS((void));
- + struct op * compile ARGS((Source *s));
- + /* table.c */
- + unsigned int hash ARGS((char *n));
- + void tinit ARGS((struct table *tp, Area *ap));
- + struct tbl * tsearch ARGS((struct table *tp, char *n, unsigned int h));
- + struct tbl * tenter ARGS((struct table *tp, char *n, unsigned int h));
- + void tdelete ARGS((struct tbl *p));
- + void twalk ARGS((struct table *tp));
- + struct tbl * tnext ARGS((void));
- + struct tbl ** tsort ARGS((struct table *tp));
- + /* trace.c */
- + /* trap.c */
- + Trap * gettrap ARGS((char *name));
- + void trapsig ARGS((int i));
- + int runtraps ARGS((void));
- + int runtrap ARGS((Trap *p));
- + int cleartraps ARGS((void));
- + int ignoresig ARGS((int i));
- + int restoresigs ARGS((void));
- + /* tree.c */
- + void ptree ARGS((struct op *t, FILE *f));
- + int pioact ARGS((FILE *f, struct ioword *iop));
- + int fptreef ARGS((FILE *f, char *fmt, ...));
- + int snptreef ARGS((char *s, int n, char *fmt, ...));
- + struct op * tcopy ARGS((struct op *t, Area *ap));
- + char * wdcopy ARGS((char *wp, Area *ap));
- + char * wdscan ARGS((char *wp, int c));
- + void tfree ARGS((struct op *t, Area *ap));
- + /* var.c */
- + void newblock ARGS((void));
- + void popblock ARGS((void));
- + struct tbl * global ARGS((char *n));
- + struct tbl * local ARGS((char *n));
- + char * strval ARGS((struct tbl *vp));
- + long intval ARGS((struct tbl *vp));
- + void setstr ARGS((struct tbl *vq, char *s));
- + struct tbl * strint ARGS((struct tbl *vq, struct tbl *vp));
- + void setint ARGS((struct tbl *vq, long n));
- + int import ARGS((char *thing));
- + struct tbl * typeset ARGS((char *var, int set, int clr));
- + void unset ARGS((struct tbl *vp));
- + int isassign ARGS((char *s));
- + char ** makenv ARGS((void));
- + /* version.c */
- + /* vi.c */
- + void vi_reset ARGS((char *buf, int len));
- + int vi_hook ARGS((int ch));
- + int save_cbuf ARGS((void));
- + int restore_cbuf ARGS((void));
- + int x_vi ARGS((char *buf, size_t len));
- + int getch ARGS((void));
- + char ** globstr ARGS((char *stuff));
- +
- +
- *** sh/sh.h.old Sat Apr 25 17:44:32 1992
- --- sh/sh.h Sat Apr 25 18:32:35 1992
- ***************
- *** 2,8 ****
- * Public Domain Bourne/Korn shell
- */
-
- ! /* $Id: sh.h,v 3.3 89/03/27 15:46:34 egisin Exp $ */
-
- #include "config.h"
-
- --- 2,8 ----
- * Public Domain Bourne/Korn shell
- */
-
- ! /* $Id: sh.h,v 1.3 1992/04/25 08:29:52 sjg Exp $ */
-
- #include "config.h"
-
- ***************
- *** 16,33 ****
- #endif
-
- /* some people object to this use of __STDC__ */
- ! #ifndef Void
- ! #if __STDC__
- #define ARGS(args) args /* prototype declaration */
- - #define Void void /* generic pointer */
- - #define Const const /* constant data */
- - #define Volatile volatile /* you know */
- #else
- #define ARGS(args) () /* K&R declaration */
- ! #define Void char
- ! #define Const
- ! #define Volatile
- #endif
- #endif
-
- #ifdef _ULTRIX /* Ultrix 2.x gets dup2 wrong */
- --- 16,30 ----
- #endif
-
- /* some people object to this use of __STDC__ */
- ! #ifdef __STDC__
- #define ARGS(args) args /* prototype declaration */
- #else
- #define ARGS(args) () /* K&R declaration */
- ! #ifdef VOID
- ! #define void VOID
- #endif
- + #define const
- + #define volatile
- #endif
-
- #ifdef _ULTRIX /* Ultrix 2.x gets dup2 wrong */
- ***************
- *** 63,69 ****
- --- 60,68 ----
- Extern int kshpid; /* $$, shell pid */
- Extern int exstat; /* exit status */
- Extern int async; /* $!, last &'d pid */
- + Extern volatile int sigchld_caught; /* count of dead children */
-
- +
- /*
- * Area-based allocation built on malloc/free
- */
- ***************
- *** 76,90 ****
- #define APERM &aperm
- #define ATEMP &e.area
-
- - Area *ainit ARGS((Area *ap)); /* initialize Area */
- - void afreeall ARGS((Area *ap)); /* free Area's contents */
- - void ashrink ARGS((Area *ap)); /* unimplimented */
- - void aerror ARGS((Area *ap, const char *msg)); /* error handler */
- -
- - Void *alloc ARGS((size_t size, Area *ap)); /* alloc object from Area */
- - Void *aresize ARGS((Void *ptr, size_t size, Area *ap)); /* shrink object */
- - void afree ARGS((Void *ptr, Area *ap)); /* free ojbect in Area */
- -
- /*
- * parsing & execution environment
- */
- --- 75,80 ----
- ***************
- *** 133,139 ****
- #define FLAG(c) (1 + c - 'a') /* map char to flags index */
- #define FLAGS 32
- Extern char flag [FLAGS];
- ! int option ARGS((Const char *name));
- char *getoptions ARGS((void));
- void printoptions ARGS((void));
-
- --- 123,129 ----
- #define FLAG(c) (1 + c - 'a') /* map char to flags index */
- #define FLAGS 32
- Extern char flag [FLAGS];
- ! int option ARGS((const char *name));
- char *getoptions ARGS((void));
- void printoptions ARGS((void));
-
- ***************
- *** 142,148 ****
- /*
- * other functions
- */
- ! char * substitute ARGS((char Const *, int));
- char *search();
- struct tbl *findcom();
- char *strsave ARGS((char *, Area *));
- --- 132,138 ----
- /*
- * other functions
- */
- ! char * substitute ARGS((char const *, int));
- char *search();
- struct tbl *findcom();
- char *strsave ARGS((char *, Area *));
- ***************
- *** 149,155 ****
- char *ulton ARGS((unsigned long n, int base));
- int xstrcmp();
- void qsortp ARGS((void **base, size_t n, int (*compare)(void *, void *)));
- ! long evaluate ARGS((Const char *expr));
- void resetopts();
- void histsave();
- void histlist();
- --- 139,145 ----
- char *ulton ARGS((unsigned long n, int base));
- int xstrcmp();
- void qsortp ARGS((void **base, size_t n, int (*compare)(void *, void *)));
- ! long evaluate ARGS((const char *expr));
- void resetopts();
- void histsave();
- void histlist();
- ***************
- *** 197,204 ****
- #define stdout shf[1] /* standard output */
- #define shlout shf[2] /* shell output */
-
- ! int shellf ARGS((Const char *fmt, ...)); /* fprintf(shlout, ); */
- ! int errorf ARGS((Const char *fmt, ...)); /* fprintf(shlout, ); error(); */
-
- /*
- * IO control
- --- 187,194 ----
- #define stdout shf[1] /* standard output */
- #define shlout shf[2] /* shell output */
-
- ! int shellf ARGS((const char *fmt, ...)); /* fprintf(shlout, ); */
- ! int errorf ARGS((const char *fmt, ...)); /* fprintf(shlout, ); error(); */
-
- /*
- * IO control
- ***************
- *** 208,214 ****
- int savefd ARGS((int fd)); /* save user fd */
- void restfd ARGS((int fd, int ofd));
- void openpipe ARGS((int [2]));
- ! void closepipe ARGS((int [2]));;
-
- /*
- * trap handlers
- --- 198,204 ----
- int savefd ARGS((int fd)); /* save user fd */
- void restfd ARGS((int fd, int ofd));
- void openpipe ARGS((int [2]));
- ! void closepipe ARGS((int [2]));
-
- /*
- * trap handlers
- ***************
- *** 218,224 ****
- char *name; /* short name */
- char *mess; /* descriptive name */
- char *trap; /* trap command */
- ! int Volatile set; /* trap pending */
- int ourtrap; /* not ignored (?) */
- int sig_dfl; /* originally SIG_DFL */
- } Trap;
- --- 208,214 ----
- char *name; /* short name */
- char *mess; /* descriptive name */
- char *trap; /* trap command */
- ! int volatile set; /* trap pending */
- int ourtrap; /* not ignored (?) */
- int sig_dfl; /* originally SIG_DFL */
- } Trap;
- ***************
- *** 229,238 ****
- #ifdef NSIG
- #define SIGNALS NSIG
- #else
- #define SIGNALS 32
- #endif /* NSIG */
-
- ! Extern int Volatile trap; /* traps pending? */
- extern Trap sigtraps[SIGNALS];
- Trap *gettrap ARGS((char *)); /* search for struct trap by number or name */
- void trapsig ARGS((int sig)); /* trap signal handler */
- --- 219,239 ----
- #ifdef NSIG
- #define SIGNALS NSIG
- #else
- + #ifdef _MINIX
- + #define SIGNALS (_NSIG+1) /* _NSIG is # of signals used, excluding 0. */
- + #else
- #define SIGNALS 32
- + #endif /* _MINIX */
- #endif /* NSIG */
-
- ! #ifdef USE_SIGACT /* always use it? */
- ! #ifndef SA_NOCLDSTOP
- ! # include "sigact.h" /* use sjg's fake sigaction() */
- ! #endif
- ! Extern struct sigaction Sigact, Sigact_dfl, Sigact_ign, Sigact_trap;
- ! #endif
- !
- ! Extern int volatile trap; /* traps pending? */
- extern Trap sigtraps[SIGNALS];
- Trap *gettrap ARGS((char *)); /* search for struct trap by number or name */
- void trapsig ARGS((int sig)); /* trap signal handler */
- ***************
- *** 248,263 ****
- #define C_IFS 0x80 /* $IFS */
-
- extern char ctypes [];
- void initctypes ARGS((void));
- ! void setctypes ARGS((Const char*, int type));
- !
- #define ctype(c, t) !!(ctypes[(unsigned char)(c)]&(t))
- #define letter(c) ctype(c, C_ALPHA)
- #define digit(c) ctype(c, C_DIGIT)
- #define letnum(c) ctype(c, C_ALPHA|C_DIGIT)
-
- /*
- * 91-07-06 <sjg@sun0>
- * use my simple debug tracing...
- */
- #include "trace.h"
- --- 249,274 ----
- #define C_IFS 0x80 /* $IFS */
-
- extern char ctypes [];
- + #if 0
- void initctypes ARGS((void));
- ! void setctypes ARGS((const char*, int type));
- ! #endif
- #define ctype(c, t) !!(ctypes[(unsigned char)(c)]&(t))
- #define letter(c) ctype(c, C_ALPHA)
- #define digit(c) ctype(c, C_DIGIT)
- #define letnum(c) ctype(c, C_ALPHA|C_DIGIT)
-
- + #include "table.h"
- + #include "tree.h"
- + #include "lex.h"
- + #include "proto.h"
- +
- /*
- * 91-07-06 <sjg@sun0>
- * use my simple debug tracing...
- */
- #include "trace.h"
- +
- + #ifndef fileno
- + #define fileno(p) ((p)->_file)
- + #endif
- *** /dev/null Sat Apr 25 07:00:06 1992
- --- sh/sigact.h Sat Apr 25 01:05:25 1992
- ***************
- *** 0 ****
- --- 1,88 ----
- + /* NAME:
- + * sigact.h - sigaction et al
- + *
- + * SYNOPSIS:
- + * #include <signal.h>
- + * #ifndef SA_NOCLDSTOP
- + * # include "sigact.h"
- + * #endif
- + *
- + * DESCRIPTION:
- + * This header is the interface to a fake sigaction(2) implementation.
- + * Do NOT include this header unless your system does not
- + * have a real sigaction(2) implementation.
- + */
- + /*
- + * $Log: sigact.h,v $
- + * Revision 1.2 1992/04/24 15:04:11 sjg
- + * now compiles with cc
- + *
- + * Revision 1.1 1992/04/24 12:01:38 sjg
- + * Initial revision
- + *
- + */
- +
- + #ifndef _SIGACT_H
- + #define _SIGACT_H
- +
- + #ifndef ARGS
- + # if defined(__STDC__)
- + # define ARGS(p) p
- + # else
- + # define ARGS(p) ()
- + # endif
- + #endif
- + #ifndef __STDC__
- + # define volatile /* can change without warning */
- + # define const /* read only */
- + #endif
- +
- + #ifndef SIGKILL
- + # include <signal.h>
- + #endif
- + #ifndef SA_NOCLDSTOP
- + /* sa_flags */
- + #define SA_NOCLDSTOP 0x0001 /* don't send SIGCHLD on child stop */
- + #define SA_RESTART 0x0002 /* re-start I/O */
- +
- + /* sigprocmask flags */
- + #define SIG_BLOCK 0x0001
- + #define SIG_UNBLOCK 0x0002
- + #define SIG_SETMASK 0x0004
- +
- + #ifndef __sys_stdtypes_h
- + typedef int sigset_t;
- + #endif
- +
- + struct sigaction
- + {
- + void (*sa_handler)();
- + sigset_t sa_mask;
- + int sa_flags;
- + };
- +
- +
- + int sigaction ARGS(( int sig, struct sigaction *act, struct sigaction *oact ));
- + int sigaddset ARGS(( sigset_t *mask, int sig ));
- + int sigdelset ARGS(( sigset_t *mask, int sig ));
- + int sigemptyset ARGS(( sigset_t *mask ));
- + int sigfillset ARGS(( sigset_t *mask ));
- + int sigismember ARGS(( sigset_t *mask, int sig ));
- + int sigpending ARGS(( sigset_t *set ));
- + int sigprocmask ARGS(( int how, sigset_t *set, sigset_t *oldset ));
- + int sigsuspend ARGS(( sigset_t *mask ));
- +
- + #ifndef sigmask
- + #define sigmask(m) (1<<((m)-1)) /* convert SIGnum to mask */
- + #endif
- + #if !defined(NSIG) && defined(_NSIG)
- + # define NSIG _NSIG
- + #endif
- + #endif /* ! SA_NOCLDSTOP */
- + #endif /* _SIGACT_H */
- + /*
- + * Local Variables:
- + * version-control:t
- + * comment-column:40
- + * End:
- + */
- *** /dev/null Sat Apr 25 07:00:06 1992
- --- sh/sigact.c Sat Apr 25 01:05:22 1992
- ***************
- *** 0 ****
- --- 1,297 ----
- + /* NAME:
- + * sigact.c - fake sigaction(2)
- + *
- + * SYNOPSIS:
- + * #include <signal.h>
- + * #ifndef SA_NOCLDSTOP
- + * # include "sigact.h"
- + * #endif
- + *
- + * int sigaction(int sig, struct sigaction *act,
- + * struct sigaction *oact);
- + * int sigaddset(sigset_t *mask, int sig);
- + * int sigdelset(sigset_t *mask, int sig);
- + * int sigemptyset(sigset_t *mask);
- + * int sigfillset(sigset_t *mask);
- + * int sigismember(sigset_t *mask, int sig);
- + * int sigpending(sigset_t *set);
- + * int sigprocmask(int how, sigset_t *set, sigset_t *oldset);
- + * int sigsuspend(sigset_t *mask);
- + *
- + * DESCRIPTION:
- + * This is a fake sigaction implementation. It uses
- + * sigset(2) if available, otherwise it just uses
- + * signal(2). If it thinks sigaction(2) really exists it
- + * compiles to almost nothing.
- + *
- + * The need for all this is the problems caused by mixing
- + * signal handling routines in the one process. This
- + * module allows for a consistent POSIX compliant interface
- + * to whatever is available.
- + *
- + * RETURN VALUE:
- + * 0==success, -1==failure
- + *
- + * FILES:
- + * None.
- + *
- + * SEE ALSO:
- + *
- + *
- + * BUGS:
- + * Since we fake most of this, don't expect fancy usage to
- + * work.
- + *
- + * COPYRIGHT:
- + * @(#)Copyright (c) 1992 Simon J. Gerraty
- + *
- + * This is free software. It comes with NO WARRANTY.
- + * Permission to use, modify and distribute this source code
- + * is granted subject to the following conditions.
- + * 1/ that that the above copyright notice and this notice
- + * are preserved in all copies and that due credit be given
- + * to the author.
- + * 2/ that any changes to this code are clearly commented
- + * as such so that the author does get blamed for bugs
- + * other than his own.
- + *
- + * Please send copies of changes and bug-fixes to:
- + * sjg@zen.void.oz.au
- + *
- + */
- + #ifndef lint
- + static char *RCSid = "$Id: sigact.c,v 1.2 1992/04/24 15:04:11 sjg Exp $";
- + #endif
- + /*
- + * $Log: sigact.c,v $
- + * Revision 1.2 1992/04/24 15:04:11 sjg
- + * now compiles with cc
- + *
- + * Revision 1.1 1992/04/24 12:03:58 sjg
- + * Initial revision
- + *
- + */
- +
- + #include <signal.h>
- +
- + #ifndef SA_NOCLDSTOP /* no sigaction() */
- +
- + /*
- + * if we haven't been told,
- + * try and guess what we should implement with.
- + */
- + #if !defined(USE_SIGSET) && !defined(USE_SIGMASK) && !defined(USE_SIGNAL)
- + # if defined(sigmask) || defined(BSD) || defined(_BSD) && !defined(BSD41)
- + # define USE_SIGMASK
- + # else
- + # ifndef NO_SIGSET
- + # define USE_SIGSET
- + # else
- + # define USE_SIGNAL
- + # endif
- + # endif
- + #endif
- + /*
- + * if we still don't know, we're in trouble
- + */
- + #if !defined(USE_SIGSET) && !defined(USE_SIGMASK) && !defined(USE_SIGNAL)
- + #pragma error must know what to implement with
- + #endif
- +
- + #include "sigact.h"
- +
- +
- +
- + int
- + sigaction(sig, act, oact)
- + int sig;
- + struct sigaction *act, *oact;
- + {
- + void (*oldh)();
- +
- + if (act)
- + {
- + #ifdef USE_SIGSET
- + oldh = sigset(sig, act->sa_handler);
- + #else
- + oldh = signal(sig, act->sa_handler);
- + #endif
- + }
- + else
- + {
- + if (oact)
- + {
- + #ifdef USE_SIGSET
- + oldh = sigset(sig, SIG_IGN);
- + #else
- + oldh = signal(sig, SIG_IGN);
- + #endif
- + if (oldh != SIG_IGN)
- + {
- + #ifdef USE_SIGSET
- + (void) sigset(sig, oldh);
- + #else
- + (void) signal(sig, oldh);
- + #endif
- + }
- + }
- + }
- + if (oact)
- + {
- + oact->sa_handler = oldh;
- + }
- + return 0; /* hey we're faking it */
- + }
- +
- + int
- + sigaddset(mask, sig)
- + sigset_t *mask;
- + int sig;
- + {
- + *mask |= sigmask(sig);
- + return 0;
- + }
- +
- +
- + int
- + sigdelset(mask, sig)
- + sigset_t *mask;
- + int sig;
- + {
- + *mask &= ~(sigmask(sig));
- + return 0;
- + }
- +
- +
- + int
- + sigemptyset(mask)
- + sigset_t *mask;
- + {
- + *mask = 0;
- + return 0;
- + }
- +
- +
- + int
- + sigfillset(mask)
- + sigset_t *mask;
- + {
- + register int i;
- +
- + for (i = 1; i < NSIG; i++)
- + *mask |= sigmask(i);
- + return 0;
- + }
- +
- +
- + int
- + sigismember(mask, sig)
- + sigset_t *mask;
- + int sig;
- + {
- + return ((*mask) & sigmask(sig));
- + }
- +
- +
- + int
- + sigpending(set)
- + sigset_t *set;
- + {
- + return 0;
- + }
- +
- +
- + int
- + sigprocmask(how, set, oldset)
- + int how;
- + sigset_t *set, *oldset;
- + {
- + #ifdef USE_SIGSET
- + register int i;
- + #endif
- + sigset_t sm;
- +
- + #ifdef USE_SIGMASK
- + sm = sigblock(0);
- + #else
- + sm = 0;
- + #endif
- +
- + if (oldset)
- + *oldset = sm; /* dangerous ? */
- + if (set)
- + {
- + switch (how)
- + {
- + case SIG_BLOCK:
- + sm |= *set;
- + break;
- + case SIG_UNBLOCK:
- + sm &= ~(*set);
- + break;
- + case SIG_SETMASK:
- + sm = *set;
- + break;
- + }
- + #ifdef USE_SIGMASK
- + (void) sigsetmask(sm);
- + #else
- + # ifdef USE_SIGSET
- + for (i = 1; i < NSIG; i++)
- + {
- + if (how == SIG_UNBLOCK)
- + {
- + if (*set & sigmask(i))
- + sigrelse(i);
- + }
- + else
- + if (sm & sigmask(i))
- + {
- + sighold(i);
- + }
- + }
- + # endif
- + #endif
- + }
- + return 0;
- + }
- +
- +
- + int
- + sigsuspend(mask)
- + sigset_t *mask;
- + {
- + #ifdef USE_SETSIG
- + int sig = SIGCHLD; /* our default */
- +
- + /*
- + * add as many tests as you think sensible, but
- + * SIGALRM, and SIGCHLD are probably the most
- + * common.
- + */
- + if (*mask & sigmask(SIGALRM))
- + sig = SIGALRM;
- + else
- + if (*mask & sigmask(SIGPIPE))
- + sig = SIGPIPE;
- + sigpause(sig);
- + #else
- + # ifdef USE_SIGMASK
- + sigpause(mask);
- + # else
- + pause();
- + # endif
- + #endif
- + return 0;
- + }
- +
- + #endif /* ! SA_NOCLDSTOP */
- +
- +
- + /* This lot (for GNU-Emacs) goes at the end of the file. */
- + /*
- + * Local Variables:
- + * version-control:t
- + * comment-column:40
- + * End:
- + */
- *** sh/stdh.h.old Sat Apr 25 17:44:33 1992
- --- sh/stdh.h Mon Apr 20 22:54:46 1992
- ***************
- *** 23,39 ****
- *
- */
-
- ! #ifndef Void
- ! # if defined(__STDC__) || defined(__GNUC__)
- ! # define ARGS(args) args /* prototype declaration */
- ! # define Void void /* generic pointer */
- ! # define Const const /* constant data */
- ! # define Volatile volatile /* you know */
- # else
- ! # define ARGS(args) () /* K&R declaration */
- ! # define Void char
- ! # define Const
- ! # define Volatile
- # endif
- #endif
-
- --- 23,38 ----
- *
- */
-
- ! #ifndef ARGS
- ! # ifdef __STDC__
- ! # define ARGS(args) args
- # else
- ! # define ARGS(args) ()
- ! # ifdef VOID
- ! # define void VOID
- ! # endif
- ! # define const
- ! # define volatile
- # endif
- #endif
-
- ***************
- *** 54,59 ****
- --- 53,60 ----
- /* just in case they have sys/stdtypes and don't know it
- */
- # ifndef __sys_stdtypes_h
- + #define _PID_T
- + #define _CLOCK_T
- typedef int pid_t;
- typedef long clock_t;
- # endif
- ***************
- *** 67,82 ****
- # endif
- /* just a useful subset of what stdlib.h would have
- */
- ! extern char * getenv ARGS((Const char *));
- ! extern Void * malloc ARGS((size_t));
- ! extern int free ARGS((Void *));
- extern int exit ARGS((int));
- - #endif /* NOSTDHDRS */
-
- /* these _should_ match ANSI */
- ! extern char * strstr ARGS((Const char *, Const char *));
- ! extern Void * memmove ARGS((Void *, Const Void *, size_t));
- ! extern Void * memcpy ARGS((Void *, Const Void *, size_t));
-
-
- #ifndef offsetof
- --- 68,83 ----
- # endif
- /* just a useful subset of what stdlib.h would have
- */
- ! extern char * getenv ARGS((const char *));
- ! extern void * malloc ARGS((size_t));
- ! extern int free ARGS((void *));
- extern int exit ARGS((int));
-
- /* these _should_ match ANSI */
- ! extern char * strstr ARGS((const char *, const char *));
- ! extern void * memmove ARGS((void *, const void *, size_t));
- ! extern void * memcpy ARGS((void *, const void *, size_t));
- ! #endif /* NOSTDHDRS */
-
-
- #ifndef offsetof
- ***************
- *** 83,88 ****
- #define offsetof(type,id) ((size_t)&((type*)NULL)->id)
- #endif
-
- - #if defined(F_SETFD) && !defined(FD_CLEXEC)
- - # define FD_CLEXEC 1
- - #endif
- --- 84,86 ----
- *** sh/syn.c.old Sat Apr 25 17:44:34 1992
- --- sh/syn.c Sat Apr 25 18:37:29 1992
- ***************
- *** 3,10 ****
- */
-
- #ifndef lint
- ! static char *RCSid = "$Id: syn.c,v 3.3 89/03/27 15:51:51 egisin Exp $";
- ! static char *sccs_id = "@(#)syn.c 1.2 91/11/22 22:53:52 (sjg)";
- #endif
-
- #include "stdh.h"
- --- 3,9 ----
- */
-
- #ifndef lint
- ! static char *RCSid = "$Id: syn.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
- #endif
-
- #include "stdh.h"
- ***************
- *** 11,30 ****
- #include <errno.h>
- #include <setjmp.h>
- #include "sh.h"
- - #include "lex.h"
- - #include "tree.h"
- - #include "table.h"
- #include "expand.h"
-
- ! static void zzerr();
- ! static struct op *block(), *newtp();
- ! static struct op *pipeline(), *andor(), *command();
- ! static struct op *nested(), *c_list();
- ! static struct op *dogroup(), *thenpart(), *casepart(), *caselist();
- ! static struct op *elsepart();
- ! static char **wordlist();
- ! static void musthave();
- ! static struct ioword *synio(), *io();
-
- static struct op *outtree; /* yyparse output */
-
- --- 10,33 ----
- #include <errno.h>
- #include <setjmp.h>
- #include "sh.h"
- #include "expand.h"
-
- ! static struct op *pipeline ARGS((int cf));
- ! static struct op *andor ARGS((void));
- ! static struct op *c_list ARGS((void));
- ! static struct ioword *synio ARGS((int cf));
- ! static void musthave ARGS((int c, int cf));
- ! static struct op *nested ARGS((int type, int mark));
- ! static struct op *command ARGS((int cf));
- ! static struct op *dogroup ARGS((int onlydone));
- ! static struct op *thenpart ARGS((void));
- ! static struct op *elsepart ARGS((void));
- ! static struct op *caselist ARGS((void));
- ! static struct op *casepart ARGS((void));
- ! static char ** wordlist ARGS((void));
- ! static struct op *block ARGS((int type, struct op *t1, struct op *t2, char **wp));
- ! static struct op *newtp ARGS((int type));
- ! static void zzerr ARGS((void));
-
- static struct op *outtree; /* yyparse output */
-
- ***************
- *** 102,109 ****
- t = andor();
- if (t != NULL) {
- while ((c = token(0)) == ';' || c == '&' ||
- ! (multiline || source->type == SSTRING
- ! || source->type == SALIAS) && c == '\n') {
- if (c == '&') {
- if (tl)
- tl->right = block(TASYNC, tl->right, NOBLOCK, NOWORDS);
- --- 105,112 ----
- t = andor();
- if (t != NULL) {
- while ((c = token(0)) == ';' || c == '&' ||
- ! ((multiline || source->type == SSTRING
- ! || (source->type == SALIAS)) && c == '\n')) {
- if (c == '&') {
- if (tl)
- tl->right = block(TASYNC, tl->right, NOBLOCK, NOWORDS);
- ***************
- *** 328,338 ****
- }
-
- if (iopn == 0) {
- ! afree((Void*) iops, ATEMP);
- t->ioact = NULL;
- } else {
- iops[iopn++] = NULL;
- ! aresize((Void*) iops, sizeofN(struct ioword *, iopn), ATEMP);
- t->ioact = iops;
- }
-
- --- 331,341 ----
- }
-
- if (iopn == 0) {
- ! afree((void*) iops, ATEMP);
- t->ioact = NULL;
- } else {
- iops[iopn++] = NULL;
- ! aresize((void*) iops, sizeofN(struct ioword *, iopn), ATEMP);
- t->ioact = iops;
- }
-
- ***************
- *** 497,503 ****
- return (t);
- }
-
- ! Const struct res {
- char *name;
- int val;
- } restab[] = {
- --- 500,506 ----
- return (t);
- }
-
- ! const struct res {
- char *name;
- int val;
- } restab[] = {
- ***************
- *** 523,529 ****
-
- keywords()
- {
- ! register struct res Const *rp;
- register struct tbl *p;
-
- for (rp = restab; rp->name; rp++) {
- --- 526,532 ----
-
- keywords()
- {
- ! register struct res const *rp;
- register struct tbl *p;
-
- for (rp = restab; rp->name; rp++) {
- *** sh/table.c.old Sat Apr 25 17:44:34 1992
- --- sh/table.c Sat Apr 25 18:37:32 1992
- ***************
- *** 1,6 ****
- #ifndef lint
- ! static char *RCSid = "$Id: table.c,v 3.2 89/03/27 15:51:58 egisin Exp $";
- ! static char *sccs_id = "@(#)table.c 1.2 91/11/22 22:53:55 (sjg)";
- #endif
-
- /*
- --- 1,5 ----
- #ifndef lint
- ! static char *RCSid = "$Id: table.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
- #endif
-
- /*
- ***************
- *** 11,17 ****
- #include <errno.h>
- #include <setjmp.h>
- #include "sh.h"
- - #include "table.h"
-
- #define INIT_TBLS 8 /* initial table size (power of 2) */
-
- --- 10,15 ----
- ***************
- *** 20,27 ****
- struct tbl **next;
- } tstate;
-
- ! static void texpand();
-
- unsigned int
- hash(n)
- register char * n;
- --- 18,27 ----
- struct tbl **next;
- } tstate;
-
- ! static void texpand ARGS((struct table *tp, int nsize));
- ! static int tnamecmp ARGS((void *p1, void *p2));
-
- +
- unsigned int
- hash(n)
- register char * n;
- ***************
- *** 70,76 ****
- for (i = 0; i < osize; i++)
- if ((tblp = otblp[i]) != NULL)
- if ((tblp->flag&DEFINED)) {
- ! for (p = &ntblp[hash(tblp->name) & tp->size-1];
- *p != NULL; p--)
- if (p == ntblp) /* wrap */
- p += tp->size;
- --- 70,77 ----
- for (i = 0; i < osize; i++)
- if ((tblp = otblp[i]) != NULL)
- if ((tblp->flag&DEFINED)) {
- ! for (p = &ntblp[hash(tblp->name) &
- ! (tp->size-1)];
- *p != NULL; p--)
- if (p == ntblp) /* wrap */
- p += tp->size;
- ***************
- *** 77,85 ****
- *p = tblp;
- tp->free--;
- } else {
- ! afree((Void*)tblp, tp->areap);
- }
- ! afree((Void*)otblp, tp->areap);
- }
-
- struct tbl *
- --- 78,86 ----
- *p = tblp;
- tp->free--;
- } else {
- ! afree((void*)tblp, tp->areap);
- }
- ! afree((void*)otblp, tp->areap);
- }
-
- struct tbl *
- ***************
- *** 94,100 ****
- return NULL;
-
- /* search for name in hashed table */
- ! for (pp = &tp->tbls[h & tp->size-1]; (p = *pp) != NULL; pp--) {
- if (*p->name == *n && strcmp(p->name, n) == 0
- && (p->flag&DEFINED))
- return p;
- --- 95,101 ----
- return NULL;
-
- /* search for name in hashed table */
- ! for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp) != NULL; pp--) {
- if (*p->name == *n && strcmp(p->name, n) == 0
- && (p->flag&DEFINED))
- return p;
- ***************
- *** 118,124 ****
- texpand(tp, INIT_TBLS);
- Search:
- /* search for name in hashed table */
- ! for (pp = &tp->tbls[h & tp->size-1]; (p = *pp) != NULL; pp--) {
- if (*p->name == *n && strcmp(p->name, n) == 0)
- return p; /* found */
- if (pp == tp->tbls) /* wrap */
- --- 119,125 ----
- texpand(tp, INIT_TBLS);
- Search:
- /* search for name in hashed table */
- ! for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp) != NULL; pp--) {
- if (*p->name == *n && strcmp(p->name, n) == 0)
- return p; /* found */
- if (pp == tp->tbls) /* wrap */
- ***************
- *** 174,180 ****
-
- static int
- tnamecmp(p1, p2)
- ! Void *p1, *p2;
- {
- return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name);
- }
- --- 175,181 ----
-
- static int
- tnamecmp(p1, p2)
- ! void *p1, *p2;
- {
- return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name);
- }
- ***************
- *** 193,199 ****
- if ((*dp = *sp++) != NULL && ((*dp)->flag&DEFINED))
- dp++;
- i = dp - p;
- ! qsortp((Void**)p, (size_t)i, tnamecmp);
- p[i] = NULL;
- return p;
- }
- --- 194,200 ----
- if ((*dp = *sp++) != NULL && ((*dp)->flag&DEFINED))
- dp++;
- i = dp - p;
- ! qsortp((void**)p, (size_t)i, tnamecmp);
- p[i] = NULL;
- return p;
- }
- *** sh/table.h.old Sat Apr 25 17:41:37 1992
- --- sh/table.h Sat Apr 25 18:37:35 1992
- ***************
- *** 1,4 ****
- ! /* $Id: table.h,v 3.2 89/03/27 15:46:52 egisin Exp $ */
-
- /*
- * generic hashed associative table for commands and variables.
- --- 1,4 ----
- ! /* $Id: table.h,v 1.2 1992/04/25 08:33:28 sjg Exp $ */
-
- /*
- * generic hashed associative table for commands and variables.
- ***************
- *** 80,86 ****
- char *name;
- int (*func)();
- };
- ! Extern Const struct builtin shbuiltins [], kshbuiltins [];
-
- /* var spec values */
- #define V_NONE 0
- --- 80,89 ----
- char *name;
- int (*func)();
- };
- !
- ! /* these really are externs! Look in table.c for them */
- !
- ! extern const struct builtin shbuiltins [], kshbuiltins [];
-
- /* var spec values */
- #define V_NONE 0
- *** sh/trace.c.old Sat Apr 25 17:44:35 1992
- --- sh/trace.c Sun Apr 19 19:21:42 1992
- ***************
- *** 63,73 ****
- # define TRUE 1
- # define FALSE 0
- #endif
- ! #ifndef _P_
- # if defined(__STDC__) || defined(PROTO)
- ! # define _P_(p) p
- # else
- ! # define _P_(p) ()
- # endif
- #endif
-
- --- 63,73 ----
- # define TRUE 1
- # define FALSE 0
- #endif
- ! #ifndef ARGS
- # if defined(__STDC__) || defined(PROTO)
- ! # define ARGS(p) p
- # else
- ! # define ARGS(p) ()
- # endif
- #endif
-
- ***************
- *** 85,91 ****
- * RETURN VALUE:
- * None
- */
- ! extern char * _CDECL strdup _P_((char *s));
-
- #ifdef __STDC__
- # include <stdarg.h>
- --- 85,91 ----
- * RETURN VALUE:
- * None
- */
- ! extern char * _CDECL strdup ARGS((char *s));
-
- #ifdef __STDC__
- # include <stdarg.h>
- ***************
- *** 109,115 ****
- checkpoint(va_alist)
- va_dcl
- {
- ! extern char *getenv _P_((char *var));
- char *fmt;
- int c;
- va_list arg_ptr;
- --- 109,115 ----
- checkpoint(va_alist)
- va_dcl
- {
- ! extern char *getenv ARGS((char *var));
- char *fmt;
- int c;
- va_list arg_ptr;
- *** sh/trace.h.old Sat Apr 25 17:44:35 1992
- --- sh/trace.h Sun Apr 19 19:21:43 1992
- ***************
- *** 33,43 ****
- # define TRUE 1
- # define FALSE 0
- #endif
- ! #ifndef _P_
- # if defined(__STDC__) || defined(PROTO)
- ! # define _P_(p) p
- # else
- ! # define _P_(p) ()
- # endif
- #endif
-
- --- 33,43 ----
- # define TRUE 1
- # define FALSE 0
- #endif
- ! #ifndef ARGS
- # if defined(__STDC__) || defined(PROTO)
- ! # define ARGS(p) p
- # else
- ! # define ARGS(p) ()
- # endif
- #endif
-
- ***************
- *** 71,77 ****
- EXTERN char * _CDECL Trace_log;
- EXTERN int _CDECL Trace_level;
-
- ! void _CDECL checkpoint _P_((char *fmt, ...));
-
- /*
- * This macro takes a variabel number of args.
- --- 71,77 ----
- EXTERN char * _CDECL Trace_log;
- EXTERN int _CDECL Trace_level;
-
- ! void _CDECL checkpoint ARGS((char *fmt, ...));
-
- /*
- * This macro takes a variabel number of args.
-
- exit 0 # Just in case...
-