Ansified bin/sh
authorNick Downing <downing.nick@gmail.com>
Mon, 30 Jan 2017 05:11:11 +0000 (16:11 +1100)
committerNick Downing <downing.nick@gmail.com>
Mon, 30 Jan 2017 05:11:11 +0000 (16:11 +1100)
29 files changed:
bin/sh/_ctype.h
bin/sh/args.c
bin/sh/blok.c
bin/sh/brkincr.h
bin/sh/builtin.c
bin/sh/cmd.c
bin/sh/ctype.c
bin/sh/defs.h
bin/sh/dup.h
bin/sh/error.c
bin/sh/expand.c
bin/sh/fault.c
bin/sh/io.c
bin/sh/macro.c
bin/sh/main.c
bin/sh/mode.h
bin/sh/msg.c
bin/sh/name.c
bin/sh/name.h
bin/sh/print.c
bin/sh/service.c
bin/sh/setbrk.c
bin/sh/stak.c
bin/sh/stak.h
bin/sh/string.c
bin/sh/sym.h
bin/sh/timeout.h
bin/sh/word.c
bin/sh/xec.c

index 7aa92eb..0ec2d46 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef __CTYPE_H_
+#define __CTYPE_H_
+
 /*     ctype.h 4.1     82/05/07        */
 
 /*
@@ -8,7 +11,6 @@
  *
  */
 
-
 /* table 1 */
 #define T_SUB  01
 #define T_MET  02
@@ -89,3 +91,5 @@ extern char   _ctype2[];
 #define        letter(c)       (((c)&0200)==0 && _ctype2[c]&(T_IDC))
 #define alphanum(c)    (((c)&0200)==0 && _ctype2[c]&(_IDCH))
 #define astchar(c)     (((c)&0200)==0 && _ctype2[c]&(T_AST))
+
+#endif
index 65a246b..31abbc0 100644 (file)
@@ -1,4 +1,8 @@
-#ifndef lint
+#include <gen.h>
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)args.c     4.4 7/31/85";
 #endif
 
@@ -10,9 +14,9 @@ static char sccsid[] = "@(#)args.c    4.4 7/31/85";
  *
  */
 
-#include       "defs.h"
+/*#include     "defs.h"*/
 
-static struct dolnod   *copyargs();
+/*static struct dolnod *copyargs();*/
 static struct dolnod   *dolh;
 
 char   flagadr[10];
@@ -26,11 +30,9 @@ int  flagval[]  = {
 
 /* ========    option handling ======== */
 
+static struct dolnod *copyargs __P((char *from[], int n));
 
-int    options(argc,argv)
-       char            **argv;
-       int             argc;
-{
+int options(argc, argv) int argc; char **argv; {
        register char   *cp;
        register char   **argp=argv;
        register char   *flagc;
@@ -71,9 +73,7 @@ int   options(argc,argv)
        return(argc);
 }
 
-void   setargs(argi)
-       char            *argi[];
-{
+void setargs(argi) char *argi[]; {
        /* count args */
        register char   **argp=argi;
        register int            argn=0;
@@ -86,9 +86,7 @@ void  setargs(argi)
        assnum(&dolladr,dolc=argn-1);
 }
 
-freeargs(blk)
-       struct dolnod           *blk;
-{
+int freeargs(blk) struct dolnod *blk; {
        register char   **argp;
        register struct dolnod  *argr=0;
        register struct dolnod  *argblk;
@@ -103,10 +101,8 @@ freeargs(blk)
        return(argr);
 }
 
-static struct dolnod   *copyargs(from, n)
-       char            *from[];
-{
-       register struct dolnod *pp = (struct dolnod *)alloc(sizeof(struct dolnod)+n*sizeof(char **));
+static struct dolnod *copyargs(from, n) char *from[]; int n; {
+       register struct dolnod *pp = (struct dolnod *)malloc(sizeof(struct dolnod)+n*sizeof(char **));
        register char **        np=pp->dolarg;
        register char **        fp=from;
 
@@ -118,8 +114,7 @@ static struct dolnod        *copyargs(from, n)
        return(pp);
 }
 
-clearup()
-{
+int clearup() {
        /* force `for' $* lists to go away */
        while (argfor=freeargs(argfor));
 
@@ -127,8 +122,7 @@ clearup()
        while (pop());
 }
 
-struct dolnod  *useargs()
-{
+struct dolnod *useargs() {
        if (dolh) {
                dolh->doluse++;
                dolh->dolnxt=argfor;
index 53c4e30..ca6d322 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+#include <gen.h>
+/*#include "brkincr.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)blok.c     4.2 8/11/83";
 #endif
 
@@ -10,8 +16,7 @@ static char sccsid[] = "@(#)blok.c    4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
-
+/*#include     "defs.h"*/
 
 /*
  *     storage allocator
@@ -25,12 +30,8 @@ unsigned             brkincr=BRKINCR;
 struct blk             *blokp;                 /*current search pointer*/
 struct blk             *bloktop/*=(struct blk *)(end)*/;       /*top of arena (last blok)*/
 
-
-
-void   *alloc(nbytes)
-       unsigned                nbytes;
-{
-       register unsigned               rbytes = round(nbytes+BYTESPERWORD,BYTESPERWORD);
+void *malloc(nbytes) unsigned nbytes; {
+       register unsigned               rbytes = round(nbytes+sizeof(char *),sizeof(char *));
 
        for(;;) {
                int             c=0;
@@ -54,15 +55,13 @@ void        *alloc(nbytes)
        }
 }
 
-void   addblok(reqd)
-       unsigned                reqd;
-{
+void addblok(reqd) unsigned reqd; {
        if (stakbas!=staktop) {
                register char   *rndstak;
                register struct blk     *blokstak;
 
                pushstak(0);
-               rndstak=round(staktop,BYTESPERWORD);
+               rndstak=round(staktop,sizeof(char *));
                blokstak=(struct blk *)(stakbas)-1;
                blokstak->word=stakbsy; stakbsy=blokstak;
                bloktop->word=(struct blk *)(Rcheat(rndstak)|BUSY);
@@ -71,8 +70,7 @@ void  addblok(reqd)
        reqd += brkincr; reqd &= ~(brkincr-1);
        blokp=bloktop;
        bloktop=bloktop->word=(struct blk *)(Rcheat(bloktop)+reqd);
-       bloktop->word=(struct blk *)((void *)(end)+1);
-       {
+       bloktop->word=(struct blk *)((void *)(end)+1); {
             
           register char *stakadr=(char *)(bloktop+2);
           staktop=movstr(stakbot,stakadr);
@@ -80,9 +78,7 @@ void  addblok(reqd)
        }
 }
 
-void   free(ap)
-       void            *ap;
-{
+void free(ap) void *ap; {
 #define p ((struct blk *)ap)
        if (p && p<bloktop) {
                Lcheat(p[-1].word) &= ~BUSY;
@@ -91,9 +87,7 @@ void  free(ap)
 }
 
 #ifdef DEBUG
-chkbptr(ptr)
-       struct blk      *ptr;
-{
+int chkbptr(ptr) struct blk *ptr; {
        int             exf=0;
        register struct blk     *p = end;
        register struct blk     *q;
index 897bfa9..e4a39d3 100644 (file)
@@ -1,4 +1,9 @@
+#ifndef _BRKINCR_H_
+#define _BRKINCR_H_
+
 /*     brkincr.h       4.1     82/05/07        */
 
 #define BRKINCR 01000
 #define BRKMAX 04000
+
+#endif
index d2f9fde..bd9c4a7 100644 (file)
@@ -1,8 +1,7 @@
-#ifndef lint
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)builtin.c  4.2 8/11/83";
 #endif
 
-builtin(argn, com)
-int argn;
-char **com;
-{return(0);}
+int builtin(argn, com) int argn; char **com; {return(0);}
index 3fbacde..3671434 100644 (file)
@@ -1,4 +1,9 @@
-#ifndef lint
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)cmd.c      4.2 8/11/83";
 #endif
 
@@ -10,31 +15,36 @@ static char sccsid[] = "@(#)cmd.c   4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
-#include       "sym.h"
-
-extern struct ionod    *inout();
-extern void            chkword();
-extern void            chksym();
-extern struct trenod   *term();
-extern struct trenod   *makelist();
-extern struct trenod   *list();
-extern struct regnod   *syncase();
-extern struct trenod   *item();
-extern int             skipnl();
-extern void            prsym();
-extern void            synbad();
-
+/*#include     "defs.h"*/
+/*#include     "sym.h"*/
+
+/*extern struct ionod  *inout();*/
+/*extern void          chkword();*/
+/*extern void          chksym();*/
+/*extern struct trenod *term();*/
+/*extern struct trenod *makelist();*/
+/*extern struct trenod *list();*/
+/*extern struct regnod *syncase();*/
+/*extern struct trenod *item();*/
+/*extern int           skipnl();*/
+/*extern void          prsym();*/
+/*extern void          synbad();*/
 
 /* ========    command line decoding   ========*/
 
-
-
-
-struct trenod  *makefork(flgs, i)
-       int             flgs;
-       struct trenod           *i;
-{
+static struct trenod *makelist __P((int type, struct trenod *i, struct trenod *r));
+static struct trenod *list __P((int flg));
+static struct trenod *term __P((int flg));
+static struct regnod *syncase __P((register int esym));
+static struct trenod *item __P((int flag));
+static int skipnl __P((void));
+static struct ionod *inout __P((struct ionod *lastio));
+static void chkword __P((void));
+static void chksym __P((int sym));
+static void prsym __P((int sym));
+static void synbad __P((void));
+
+struct trenod *makefork(flgs, i) int flgs; struct trenod *i; {
        register struct forknod *t;
 
        t=(struct forknod *)getstak(sizeof(struct forknod));
@@ -42,10 +52,7 @@ struct trenod        *makefork(flgs, i)
        return((struct trenod *)t);
 }
 
-static struct trenod   *makelist(type,i,r)
-       int             type;
-       struct trenod           *i, *r;
-{
+static struct trenod *makelist(type, i, r) int type; struct trenod *i; struct trenod *r; {
        register struct lstnod  *t;
 
        if (i==0 || r==0) {
@@ -67,10 +74,7 @@ static struct trenod *makelist(type,i,r)
  *     list [ ; cmd ]
  */
 
-struct trenod  *cmd(sym,flg)
-       register int            sym;
-       int             flg;
-{
+struct trenod *cmd(sym, flg) register int sym; int flg; {
        register struct trenod  *i, *e;
 
        i = list(flg);
@@ -122,8 +126,7 @@ struct trenod       *cmd(sym,flg)
  *     list || term
  */
 
-static struct trenod   *list(flg)
-{
+static struct trenod *list(flg) int flg; {
        register struct trenod  *r;
        register int            b;
 
@@ -140,8 +143,7 @@ static struct trenod        *list(flg)
  *     item |^ term
  */
 
-static struct trenod   *term(flg)
-{
+static struct trenod *term(flg) int flg; {
        register struct trenod  *t;
 
        reserv++;
@@ -160,9 +162,7 @@ static struct trenod        *term(flg)
        }
 }
 
-static struct regnod   *syncase(esym)
-       register int    esym;
-{
+static struct regnod *syncase(esym) register int esym; {
        skipnl();
        if (wdval==esym) {
                return(0);
@@ -206,9 +206,7 @@ static struct regnod        *syncase(esym)
  *     begin ... end
  */
 
-static struct trenod   *item(flag)
-       bool            flag;
-{
+static struct trenod *item(flag) int flag; {
        struct trenod   *_t;
        register struct ionod   *io;
 
@@ -222,8 +220,7 @@ static struct trenod        *item(flag)
        switch (wdval) {
          
 
-           case CASYM:
-               {
+           case CASYM: {
 #define t (*(struct swnod **)&_t)
                   t=(struct swnod *)getstak(sizeof(struct swnod));
                   chkword();
@@ -235,8 +232,7 @@ static struct trenod        *item(flag)
 #undef t
                }
 
-           case IFSYM:
-               {
+           case IFSYM: {
 #define t (*(struct ifnod **)&_t)
                   register int w;
                   t=(struct ifnod *)getstak(sizeof(struct ifnod));
@@ -249,8 +245,7 @@ static struct trenod        *item(flag)
 #undef t
                }
 
-           case FORSYM:
-               {
+           case FORSYM: {
 #define t (*(struct fornod **)&_t)
                   t=(struct fornod *)getstak(sizeof(struct fornod));
                   t->fortyp=TFOR;
@@ -272,8 +267,7 @@ static struct trenod        *item(flag)
                }
 
            case WHSYM:
-           case UNSYM:
-               {
+           case UNSYM: {
 #define t (*(struct whnod **)&_t)
                   t=(struct whnod *)getstak(sizeof(struct whnod));
                   t->whtyp=(wdval==WHSYM ? TWH : TUN);
@@ -287,8 +281,7 @@ static struct trenod        *item(flag)
                _t=cmd(KTSYM,NLFLG);
                break;
 
-           case '(':
-               {
+           case '(': {
                   register struct parnod        *p;
                   p=(struct parnod *)getstak(sizeof(struct parnod));
                   p->partre=cmd(')',NLFLG);
@@ -302,8 +295,7 @@ static struct trenod        *item(flag)
                        return(0);
                }
 
-           case 0:
-               {
+           case 0: {
 #define t (*(struct comnod **)&_t)
                   register struct argnod       *argp;
                   register struct argnod       **argtail;
@@ -339,16 +331,12 @@ static struct trenod      *item(flag)
        return(_t);
 }
 
-
-static int     skipnl()
-{
+static int skipnl() {
        while ((reserv++, word()=='\n')) { chkpr('\n'); }
        return(wdval);
 }
 
-static struct ionod    *inout(lastio)
-       struct ionod            *lastio;
-{
+static struct ionod *inout(lastio) struct ionod *lastio; {
        register int            iof;
        register struct ionod   *iop;
        register char   c;
@@ -394,23 +382,20 @@ static struct ionod       *inout(lastio)
        return(iop);
 }
 
-static void    chkword()
-{
+static void chkword() {
        if (word()) {
                synbad();
        }
 }
 
-static void    chksym(sym)
-{
+static void chksym(sym) int sym; {
        register int            x = sym&wdval;
        if (((x&SYMFLG) ? x : sym) != wdval) {
                synbad();
        }
 }
 
-static void    prsym(sym)
-{
+static void prsym(sym) int sym; {
        if (sym&SYMFLG) {
                register struct sysnod  *sp=reserved;
                while (sp->sysval
@@ -431,8 +416,7 @@ static void prsym(sym)
        }
 }
 
-static void    synbad()
-{
+static void synbad() {
        prp(); prs(synmsg);
        if ((flags&ttyflg)==0) {
                prs(atline); prn(standin->flin);
index 20ef52f..ddd7b6e 100644 (file)
@@ -1,4 +1,6 @@
-#ifndef lint
+#include "_ctype.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)ctype.c    4.2 8/11/83";
 #endif
 
@@ -10,7 +12,7 @@ static char sccsid[] = "@(#)ctype.c   4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
+/*#include     "defs.h"*/
 
 char   _ctype1[] = {
 /*     000     001     002     003     004     005     006     007     */
@@ -60,7 +62,6 @@ char  _ctype1[] = {
        0,      0,      0,      0,      _BAR,   0,      0,      0
 };
 
-
 char   _ctype2[] = {
 /*     000     001     002     003     004     005     006     007     */
        0,      0,      0,      0,      0,      0,      0,      0,
index 83c8631..31dd5a0 100644 (file)
@@ -1,3 +1,11 @@
+#ifndef _DEFS_H_
+#define _DEFS_H_
+
+#include <setjmp.h>
+#include <sys/file.h>
+#include "mode.h"
+#include "name.h"
+
 /*     defs.h  4.4     85/03/19        */
 
 /*
 /* arg list terminator */
 #define ENDARGS        0
 
-#include       "mode.h"
-#include       "name.h"
-
+/*#include     "mode.h"*/
+/*#include     "name.h"*/
 
 /* result type declarations */
-void           *alloc();
-void           addblok();
-char           *make();
-char           *movstr();
-struct trenod  *cmd();
-struct trenod  *makefork();
-struct namnod  *lookup();
-void           setname();
-void           setargs();
-struct dolnod  *useargs();
-float          expr();
-char           *catpath();
-char           *getpath();
-char           **scan();
-char           *mactrim();
-char           *macro();
-char           *execs();
-void           await();
-void           post();
-char           *copyto();
-void           exname();
-char           *staknam();
-void           printnam();
-void           printflg();
-void           prs();
-void           prc();
-void           setupenv();
-char           **setenv();
+/*void         *malloc();*/
+/*void         addblok();*/
+/*char         *make();*/
+/*char         *movstr();*/
+/*struct trenod        *cmd();*/
+/*struct trenod        *makefork();*/
+/*struct namnod        *lookup();*/
+/*void         setname();*/
+/*void         setargs();*/
+/*struct dolnod        *useargs();*/
+/*float                expr();*/
+/*char         *catpath();*/
+/*char         *getpath();*/
+/*char         **scan();*/
+/*char         *mactrim();*/
+/*char         *macro();*/
+/*char         *execs();*/
+/*void         await();*/
+/*void         post();*/
+/*char         *copyto();*/
+/*void         exname();*/
+/*char         *staknam();*/
+/*void         printnam();*/
+/*void         printflg();*/
+/*void         prs();*/
+/*void         prc();*/
+/*void         setupenv();*/
+/*char         **setenv();*/
 
 #define attrib(n,f)    (n->namflg |= f)
 #define round(a,b)     (((int)(((void *)(a)+b)-1))&~((b)-1))
@@ -211,7 +218,7 @@ extern char         devnull[];
 extern int             flags;
 
 /* error exits from various parts of shell */
-#include       <setjmp.h>
+/*#include     <setjmp.h>*/
 extern jmp_buf         subshell;
 extern jmp_buf         errshell;
 extern jmp_buf         INTbuf;
@@ -234,7 +241,7 @@ extern struct blk   *bloktop;               /*top of arena (last blok)*/
 #define SIGSET 4
 #define SIGMOD 8
 
-void           fault();
+/*void         fault();*/
 extern bool            trapnote;
 extern char            *trapcom[];
 extern bool            trapflg[];
@@ -283,3 +290,142 @@ extern char               badfile[];
 extern struct blk      *end;
 
 #include       "_ctype.h"
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* args.c */
+int options __P((int argc, char **argv));
+void setargs __P((char *argi[]));
+int freeargs __P((struct dolnod *blk));
+int clearup __P((void));
+struct dolnod *useargs __P((void));
+
+/* blok.c */
+void *malloc __P((unsigned nbytes));
+void addblok __P((unsigned reqd));
+void free __P((void *ap));
+int chkbptr __P((struct blk *ptr));
+
+/* builtin.c */
+int builtin __P((int argn, char **com));
+
+/* cmd.c */
+struct trenod *makefork __P((int flgs, struct trenod *i));
+struct trenod *cmd __P((register int sym, int flg));
+
+/* error.c */
+int exitset __P((void));
+int sigchk __P((void));
+int failed __P((char *s1, char *s2));
+int error __P((char *s));
+int exitsh __P((int xno));
+int done __P((void));
+int rmtemp __P((struct ionod *base));
+
+/* expand.c */
+int expand __P((char *as, int rflg));
+int gmatch __P((register char *s, register char *p));
+int makearg __P((register struct argnod *args));
+
+/* fault.c */
+void fault __P((register int sig));
+int stdsigs __P((void));
+void (*ignsig __P((int n))) __P((void));
+int getsig __P((int n));
+int oldsigs __P((void));
+int clrsig __P((int i));
+int chktrap __P((void));
+
+/* io.c */
+int initf __P((int fd));
+int estabf __P((register char *s));
+int push __P((struct fileblk *af));
+int pop __P((void));
+int chkpipe __P((int *pv));
+int chkopen __P((char *idf));
+int _rename __P((register int f1, register int f2));
+int create __P((char *s));
+int tmpfil __P((void));
+int copy __P((struct ionod *ioparg));
+
+/* macro.c */
+char *macro __P((char *as));
+int subst __P((int in, int ot));
+
+/* main.c */
+int main __P((int c, char *v[]));
+int chkpr __P((int eor));
+int settmp __P((void));
+int Ldup __P((register int fa, register int fb));
+
+/* name.c */
+int syslook __P((char *w, struct sysnod syswds[]));
+int setlist __P((register struct argnod *arg, int xp));
+void setname __P((char *argi, int xp));
+int replace __P((register char **a, char *v));
+int dfault __P((struct namnod *n, char *v));
+int assign __P((struct namnod *n, char *v));
+int readvar __P((char **names));
+int assnum __P((char **p, int i));
+char *make __P((char *v));
+struct namnod *lookup __P((register char *nam));
+int namscan __P((void (*fn)(void)));
+void printnam __P((struct namnod *n));
+void exname __P((register struct namnod *n));
+void printflg __P((register struct namnod *n));
+void setupenv __P((void));
+void countnam __P((struct namnod *n));
+void pushnam __P((struct namnod *n));
+char **setenv __P((void));
+
+/* print.c */
+int newline __P((void));
+int blank __P((void));
+int prp __P((void));
+void prs __P((char *as));
+void prc __P((int c));
+int prt __P((long t));
+int prn __P((int n));
+int itos __P((int n));
+int stoi __P((char *icp));
+
+/* service.c */
+void initio __P((struct ionod *iop));
+char *getpath __P((char *s));
+int pathopen __P((register char *path, register char *name));
+char *catpath __P((register char *path, char *name));
+void execa __P((char *at[]));
+int gocsh __P((register char **t, register char *cp, register char **xecenv));
+int postclr __P((void));
+void post __P((int pcsid));
+void await __P((int i));
+int trim __P((char *at));
+char *mactrim __P((char *s));
+char **scan __P((int argn));
+int getarg __P((struct comnod *ac));
+
+/* setbrk.c */
+int setbrk __P((int incr));
+
+/* string.c */
+char *movstr __P((register char *a, register char *b));
+int any __P((int c, char *s));
+int cf __P((register char *s1, register char *s2));
+int length __P((char *as));
+
+/* word.c */
+int word __P((void));
+int nextc __P((int quote));
+int readc __P((void));
+
+/* xec.c */
+int execute __P((struct trenod *argt, int execflg, int *pf1, int *pf2));
+int execexp __P((char *s, int f));
+
+#endif
index 66948c5..6faba22 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _DUP_H_
+#define _DUP_H_
+
 /*     dup.h   4.1     82/05/07        */
 
 /*
@@ -9,3 +12,5 @@
  */
 
 #define DUPFLG 0100
+
+#endif
index a686c6f..50b5725 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/file.h> defs.h*/
+#include <sys/proc.h>
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)error.c    4.2 8/11/83";
 #endif
 
@@ -10,18 +16,15 @@ static char sccsid[] = "@(#)error.c 4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
-
+/*#include     "defs.h"*/
 
 /* ========    error handling  ======== */
 
-exitset()
-{
+int exitset() {
        assnum(&exitadr,exitval);
 }
 
-sigchk()
-{
+int sigchk() {
        /* Find out if it is time to go away.
         * `trapnote' is set to SIGSET when fault is seen and
         * no trap has been set.
@@ -31,9 +34,7 @@ sigchk()
        }
 }
 
-failed(s1,s2)
-       char    *s1, *s2;
-{
+int failed(s1, s2) char *s1; char *s2; {
        prp(); prs(s1); 
        if (s2) {
                prs(colon); prs(s2);
@@ -41,15 +42,11 @@ failed(s1,s2)
        newline(); exitsh(ERROR);
 }
 
-error(s)
-       char    *s;
-{
+int error(s) char *s; {
        failed(s,NULL);
 }
 
-exitsh(xno)
-       int     xno;
-{
+int exitsh(xno) int xno; {
        /* Arrive here from `FATAL' errors
         *  a) exit command,
         *  b) default trap,
@@ -67,8 +64,7 @@ exitsh(xno)
        }
 }
 
-done()
-{
+int done() {
        register char   *t;
        if (t=trapcom[0]) {
                trapcom[0]=0; /*should free but not long */
@@ -79,9 +75,7 @@ done()
        _exit(exitval);
 }
 
-rmtemp(base)
-       struct ionod            *base;
-{
+int rmtemp(base) struct ionod *base; {
        while (iotemp>base) {
            unlink(iotemp->ioname);
            iotemp=iotemp->iolst;
index 3c43609..2cf03a6 100644 (file)
@@ -1,4 +1,12 @@
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+#include <sys/dir.h>
+#include <sys/stat.h>
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)expand.c   4.5 8/11/83";
 #endif
 
@@ -10,12 +18,10 @@ static char sccsid[] = "@(#)expand.c        4.5 8/11/83";
  *
  */
 
-#include       "defs.h"
-#include       <sys/param.h>
-#include       <sys/stat.h>
-#include       <sys/dir.h>
-
-
+/*#include     "defs.h"*/
+/*#include     <sys/param.h>*/
+/*#include     <sys/stat.h>*/
+/*#include     <sys/dir.h>*/
 
 /* globals (file name generation)
  *
@@ -26,12 +32,11 @@ static char sccsid[] = "@(#)expand.c        4.5 8/11/83";
  *
  */
 
-extern void    addg();
+/*extern void  addg();*/
 
+static void addg __P((char *as1, char *as2, char *as3));
 
-int    expand(as,rflg)
-       char            *as;
-{
+int expand(as, rflg) char *as; int rflg; {
        int             count;
        DIR             *dirf;
        bool            dir=0;
@@ -45,8 +50,7 @@ int   expand(as,rflg)
 
        s=cs=as;
 
-       /* check for meta chars */
-       {
+       /* check for meta chars */ {
             
           register bool slash; slash=0;
           while (!fngchar(*cs)) {
@@ -109,8 +113,7 @@ int expand(as,rflg)
                        *rescan='/';
                }
        }
-
-       {
+ {
             
           register char        c;
           s=as;
@@ -119,9 +122,7 @@ int expand(as,rflg)
        return(count);
 }
 
-gmatch(s, p)
-       register char   *s, *p;
-{
+int gmatch(s, p) register char *s; register char *p; {
        register int            scc;
        char            c;
 
@@ -169,13 +170,11 @@ gmatch(s, p)
        }
 }
 
-static void    addg(as1,as2,as3)
-       char            *as1, *as2, *as3;
-{
+static void addg(as1, as2, as3) char *as1; char *as2; char *as3; {
        register char   *s1, *s2;
        register int            c;
 
-       s2 = locstak()+BYTESPERWORD;
+       s2 = locstak()+sizeof(char *);
 
        s1=as1;
        while (c = *s1++) {
@@ -194,9 +193,7 @@ static void addg(as1,as2,as3)
        makearg(endstak(s2));
 }
 
-makearg(args)
-       register struct argnod  *args;
-{
+int makearg(args) register struct argnod *args; {
        args->argnxt=gchain;
        gchain=args;
 }
index 16e715c..73da51d 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+#include <gen.h>
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/signal.h> gen.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)fault.c    4.3 8/11/83";
 #endif
 
@@ -10,8 +16,7 @@ static char sccsid[] = "@(#)fault.c   4.3 8/11/83";
  *
  */
 
-#include       "defs.h"
-
+/*#include     "defs.h"*/
 
 char           *trapcom[MAXTRAP];
 bool           trapflg[MAXTRAP];
@@ -19,10 +24,7 @@ bool         trapjmp[MAXTRAP];
 
 /* ========    fault handling routines    ======== */
 
-
-void   fault(sig)
-       register int            sig;
-{
+void fault(sig) register int sig; {
        register int            flag;
 
        if (sig==MEMF) {
@@ -47,17 +49,14 @@ void        fault(sig)
        }
 }
 
-stdsigs()
-{
+int stdsigs() {
        ignsig(QUIT);
        getsig(INTR);
        getsig(MEMF);
        getsig(ALARM);
 }
 
-void
-(*ignsig(n))()
-{
+void (*ignsig(n))() int n; {
        register void   (*s)();
        register int    i;
 
@@ -67,8 +66,7 @@ void
        return(s);
 }
 
-getsig(n)
-{
+int getsig(n) int n; {
        register int            i;
 
        if (trapflg[i=n]&SIGMOD || ignsig(i)==SIG_DFL) {
@@ -76,8 +74,7 @@ getsig(n)
        }
 }
 
-oldsigs()
-{
+int oldsigs() {
        register int            i;
        register char   *t;
 
@@ -92,9 +89,7 @@ oldsigs()
        trapnote=0;
 }
 
-clrsig(i)
-       int             i;
-{
+int clrsig(i) int i; {
        free(trapcom[i]); trapcom[i]=0;
        if (trapflg[i]&SIGMOD) {
                signal(i,fault);
@@ -102,8 +97,7 @@ clrsig(i)
        }
 }
 
-chktrap()
-{
+int chktrap() {
        /* check for traps */
        register int            i=MAXTRAP;
        register char   *t;
index 19f361b..30fd6e4 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)io.c       4.3 3/19/85";
 #endif
 
@@ -10,14 +16,11 @@ static char sccsid[] = "@(#)io.c    4.3 3/19/85";
  *
  */
 
-#include       "defs.h"
-
+/*#include     "defs.h"*/
 
 /* ========    input output and file copying ======== */
 
-initf(fd)
-       int             fd;
-{
+int initf(fd) int fd; {
        register struct fileblk *f=standin;
 
        f->fdes=fd; f->fsiz=((flags&(oneflg|ttyflg))==0 ? BUFSIZ : 1);
@@ -25,9 +28,7 @@ initf(fd)
        f->feof=0;
 }
 
-estabf(s)
-       register char   *s;
-{
+int estabf(s) register char *s; {
        register struct fileblk *f;
 
        (f=standin)->fdes = -1;
@@ -36,9 +37,7 @@ estabf(s)
        return(f->feof=(s==0));
 }
 
-push(af)
-       struct fileblk          *af;
-{
+int push(af) struct fileblk *af; {
        register struct fileblk *f;
 
        (f=af)->fstak=standin;
@@ -46,8 +45,7 @@ push(af)
        standin=f;
 }
 
-pop()
-{
+int pop() {
        register struct fileblk *f;
 
        if ((f=standin)->fstak) {
@@ -60,17 +58,13 @@ pop()
        }
 }
 
-chkpipe(pv)
-       int             *pv;
-{
+int chkpipe(pv) int *pv; {
        if (pipe(pv)<0 || pv[INPIPE]<0 || pv[OTPIPE]<0) {
                error(piperr);
        }
 }
 
-chkopen(idf)
-       char            *idf;
-{
+int chkopen(idf) char *idf; {
        register int            rc;
 
        if ((rc=open(idf,0))<0) {
@@ -81,9 +75,7 @@ chkopen(idf)
        }
 }
 
-rename(f1,f2)
-       register int            f1, f2;
-{
+int _rename(f1, f2) register int f1; register int f2; {
        if (f1!=f2) {
                dup2(f1, f2);
                close(f1);
@@ -91,9 +83,7 @@ rename(f1,f2)
        }
 }
 
-create(s)
-       char            *s;
-{
+int create(s) char *s; {
        register int            rc;
 
        if ((rc=creat(s,0666))<0) {
@@ -104,8 +94,7 @@ create(s)
        }
 }
 
-tmpfil()
-{
+int tmpfil() {
        itos(serial++); movstr(numbuf,tmpnam);
        return(create(tmpout));
 }
@@ -113,9 +102,7 @@ tmpfil()
 /* set by trim */
 bool           nosubst;
 
-copy(ioparg)
-       struct ionod            *ioparg;
-{
+int copy(ioparg) struct ionod *ioparg; {
        char            c, *ends;
        register char   *cline, *clinep;
        int             fd;
index 73eeedf..cbb4fd7 100644 (file)
@@ -1,4 +1,12 @@
-#ifndef lint
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "name.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)macro.c    4.3 8/11/83";
 #endif
 
@@ -10,17 +18,19 @@ static char sccsid[] = "@(#)macro.c 4.3 8/11/83";
  *
  */
 
-#include       "defs.h"
-#include       "sym.h"
+/*#include     "defs.h"*/
+/*#include     "sym.h"*/
 
 static char    quote;  /* used locally */
 static char    quoted; /* used locally */
 
+static char *copyto __P((int endch));
+static skipto __P((int endch));
+static getch __P((int endch));
+static comsubst __P((void));
+static flush __P((int ot));
 
-
-static char    *copyto(endch)
-       register char   endch;
-{
+static char *copyto(endch) int endch; {
        register char   c;
 
        while ((c=getch(endch))!=endch && c) { pushstak(c|quote); }
@@ -28,29 +38,25 @@ static char *copyto(endch)
        if (c!=endch) { error(badsub); }
 }
 
-static skipto(endch)
-       register char   endch;
-{
+static skipto(endch) int endch; {
        /* skip chars up to } */
        register char   c;
        while ((c=readc()) && c!=endch) {
                switch (c) {
                  
 
-               case SQUOTE:    skipto(SQUOTE); break;
+               case '`':       skipto('`'); break;
 
-               case DQUOTE:    skipto(DQUOTE); break;
+               case '"':       skipto('"'); break;
 
-               case DOLLAR:    if (readc()==BRACE) { skipto('}');
+               case '$':       if (readc()=='{') { skipto('}');
                                }
                }
        }
        if (c!=endch) { error(badsub); }
 }
 
-static getch(endch)
-       char            endch;
-{
+static getch(endch) int endch; {
        register char   d;
 
 retry:
@@ -58,7 +64,7 @@ retry:
        if (!subchar(d)) {
                return(d);
        }
-       if (d==DOLLAR) {
+       if (d=='$') {
                register int    c;
                if ((c=readc(), dolchar(c))) {
                        struct namnod           *n=NULL;
@@ -68,7 +74,7 @@ retry:
                        char            idb[2];
                        char            *id=idb;
 
-                       if (bra=(c==BRACE)) { c=readc(); }
+                       if (bra=(c=='{')) { c=readc(); }
                        if (letter(c)) {
                                argp=relstak();
                                while (alphanum(c)) { pushstak(c); c=readc(); }
@@ -161,18 +167,16 @@ retry:
        else if (d==endch) {
                return(d);
        }
-       else if (d==SQUOTE) {
+       else if (d=='`') {
                comsubst(); goto retry;
        }
-       else if (d==DQUOTE) {
+       else if (d=='"') {
                quoted++; quote^=0200; goto retry;
        }
        return(d);
 }
 
-char   *macro(as)
-       char            *as;
-{
+char *macro(as) char *as; {
        /* Strip "" and do $ substitution
         * Leaves result on top of stack
         */
@@ -190,23 +194,20 @@ char      *macro(as)
        return(fixstak());
 }
 
-static comsubst()
-{
+static comsubst() {
        /* command substn */
        struct fileblk          cb;
        register char   d;
        register char   *savptr = fixstak();
 
        usestak();
-       while ((d=readc())!=SQUOTE && d) { pushstak(d); }
-
-       {
+       while ((d=readc())!='`' && d) { pushstak(d); }
+ {
             
           register char        *argc;
           trim(argc=fixstak());
           push(&cb); estabf(argc);
-       }
-       {
+       } {
             
           register struct trenod       *t = makefork(FPOU,cmd(EOFSYM,MTFLG|NLFLG));
           int          pv[2];
@@ -232,16 +233,14 @@ static    comsubst()
 
 #define CPYSIZ 512
 
-subst(in,ot)
-       int             in, ot;
-{
+int subst(in, ot) int in; int ot; {
        register char   c;
        struct fileblk          fb;
        register int            count=CPYSIZ;
 
        push(&fb); initf(in);
-       /* DQUOTE used to stop it from quoting */
-       while (c=(getch(DQUOTE)&0177)) {
+       /* '"' used to stop it from quoting */
+       while (c=(getch('"')&0177)) {
           pushstak(c);
           if (--count == 0) {
                flush(ot); count=CPYSIZ;
@@ -251,8 +250,7 @@ subst(in,ot)
        pop();
 }
 
-static flush(ot)
-{
+static flush(ot) int ot; {
        write(ot,stakbot,staktop-stakbot);
        if (flags&execpr) { write(output,stakbot,staktop-stakbot); }
        staktop=stakbot;
index 0ee8424..6e27f6e 100644 (file)
@@ -1,4 +1,15 @@
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/file.h> defs.h*/
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/stat.h>
+/*#include "brkincr.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)main.c     4.3 3/19/85";
 #endif
 
@@ -10,13 +21,13 @@ static char sccsid[] = "@(#)main.c  4.3 3/19/85";
  *
  */
 
-#include       "defs.h"
-#include       "sym.h"
-#include       "timeout.h"
-#include       <sys/types.h>
-#include       <sys/stat.h>
-#include       <sgtty.h>
-#include       <signal.h>
+/*#include     "defs.h"*/
+/*#include     "sym.h"*/
+/*#include     "timeout.h"*/
+/*#include     <sys/types.h>*/
+/*#include     <sys/stat.h>*/
+/*#include     <sgtty.h>*/
+/*#include     <signal.h>*/
 
 /* moved here from defs.h, which now just declares them extern */
 /* temp files and io */
@@ -80,15 +91,11 @@ char                tmpout[20] = "/tmp/sh-";
 struct fileblk stdfile;
 struct fileblk *standin = &stdfile;
 
-extern void    exfile();
+/*extern void  exfile();*/
 
+static void exfile __P((int prof));
 
-
-
-main(c, v)
-       int             c;
-       char            *v[];
-{
+int main(c, v) int c; char *v[]; {
        register int            rflag=ttyflg;
 
        /* initialise storage allocation */
@@ -147,16 +154,14 @@ main(c, v)
        }
        else {
                *execargs=dolv; /* for `ps' cmd */
-#endif;
+#endif
        }
 
        exfile(0);
        done();
 }
 
-static void    exfile(prof)
-bool           prof;
-{
+static void exfile(prof) int prof; {
        register long   mailtime = 0;
        register int            userid;
        struct stat     statb;
@@ -180,8 +185,7 @@ bool                prof;
                dfault(&ps1nod, (userid?stdprompt:supprompt));
                dfault(&ps2nod, readmsg);
                flags |= ttyflg|prompt; ignsig(KILL);
-/*
-               {
+/* {
        #include <signal.h>
                signal(SIGTTIN, SIG_IGN);
                signal(SIGTTOU, SIG_IGN);
@@ -226,23 +230,18 @@ bool              prof;
        }
 }
 
-chkpr(eor)
-char eor;
-{
+int chkpr(eor) int eor; {
        if ((flags&prompt) && standin->fstak==0 && eor=='\n') {
                prs(ps2nod.namval);
        }
 }
 
-settmp()
-{
+int settmp() {
        itos(getpid()); serial=0;
        tmpnam=movstr(numbuf,&tmpout[TMPNAM]);
 }
 
-Ldup(fa, fb)
-       register int            fa, fb;
-{
+int Ldup(fa, fb) register int fa; register int fb; {
        dup2(fa, fb);
        close(fa);
        ioctl(fb, FIOCLEX, 0);
index 1983279..0c56433 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _MODE_H_
+#define _MODE_H_
+
 /*     mode.h  4.1     82/05/07        */
 
 /*
@@ -134,3 +137,5 @@ struct ionod {
        struct ionod    *ionxt;
        struct ionod    *iolst;
 };
+
+#endif
index 2fbf5fe..fb228ab 100644 (file)
@@ -1,4 +1,8 @@
-#ifndef lint
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)msg.c      4.4 5/22/85";
 #endif
 
@@ -10,9 +14,8 @@ static char sccsid[] = "@(#)msg.c     4.4 5/22/85";
  *
  */
 
-
-#include       "defs.h"
-#include       "sym.h"
+/*#include     "defs.h"*/
+/*#include     "sym.h"*/
 
 char           version[] = "\nVERSION sys137   DATE 1978 Nov 6 14:29:22\n";
 
index bbaa9a1..ad1a886 100644 (file)
@@ -1,4 +1,14 @@
-#ifndef lint
+#include <gen.h>
+/*#include <strings.h> gen.h*/
+/*#include <sys/file.h> defs.h*/
+/*#include <sys/proc.h> gen.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "name.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)name.c     4.4 10/31/85";
 #endif
 
@@ -10,10 +20,9 @@ static char sccsid[] = "@(#)name.c   4.4 10/31/85";
  *
  */
 
-#include       "defs.h"
-
-extern bool    chkid();
+/*#include     "defs.h"*/
 
+/*extern bool  chkid();*/
 
 struct namnod  ps2nod  = {     NULL,           NULL,           ps2name},
                fngnod  = {     NULL,           NULL,           fngname},
@@ -25,13 +34,13 @@ struct namnod       ps2nod  = {     NULL,           NULL,           ps2name},
 
 struct namnod  *namep = &mailnod;
 
-
 /* ========    variable and string handling    ======== */
 
-syslook(w,syswds)
-       char            *w;
-       struct sysnod           syswds[];
-{
+static bool chkid __P((char *nam));
+static void namwalk __P((register struct namnod *np));
+static char *staknam __P((register struct namnod *n));
+
+int syslook(w, syswds) char *w; struct sysnod syswds[]; {
        register char   first;
        register char   *s;
        register struct sysnod  *syscan;
@@ -48,10 +57,7 @@ syslook(w,syswds)
        return(0);
 }
 
-setlist(arg,xp)
-       register struct argnod  *arg;
-       int             xp;
-{
+int setlist(arg, xp) register struct argnod *arg; int xp; {
        while (arg) {
           register char        *s=mactrim(arg->argval);
           setname(s, xp);
@@ -63,10 +69,7 @@ setlist(arg,xp)
        }
 }
 
-void   setname(argi, xp)
-       char            *argi;
-       int             xp;
-{
+void setname(argi, xp) char *argi; int xp; {
        register char   *argscan=argi;
        register struct namnod  *n;
 
@@ -101,26 +104,17 @@ void      setname(argi, xp)
        failed(argi,notid);
 }
 
-replace(a, v)
-       register char   **a;
-       char            *v;
-{
+int replace(a, v) register char **a; char *v; {
        free(*a); *a=make(v);
 }
 
-dfault(n,v)
-       struct namnod           *n;
-       char            *v;
-{
+int dfault(n, v) struct namnod *n; char *v; {
        if (n->namval==0) {
                assign(n,v);
        }
 }
 
-assign(n,v)
-       struct namnod           *n;
-       char            *v;
-{
+int assign(n, v) struct namnod *n; char *v; {
        if (n->namflg&N_RDONLY) {
                failed(n->namid,wtfailed);
        }
@@ -129,9 +123,7 @@ assign(n,v)
        }
 }
 
-int    readvar(names)
-       char            **names;
-{
+int readvar(names) char **names; {
        struct fileblk          fb;
        register struct fileblk *f = &fb;
        register char   c;
@@ -174,20 +166,15 @@ int       readvar(names)
        return(rc);
 }
 
-assnum(p, i)
-       char            **p;
-       int             i;
-{
+int assnum(p, i) char **p; int i; {
        itos(i); replace(p,numbuf);
 }
 
-char   *make(v)
-       char            *v;
-{
+char *make(v) char *v; {
        register char   *p;
 
        if (v) {
-               movstr(v,p=alloc(length(v)));
+               movstr(v,p=malloc(length(v)));
                return(p);
        }
        else {
@@ -195,10 +182,7 @@ char       *make(v)
        }
 }
 
-
-struct namnod          *lookup(nam)
-       register char   *nam;
-{
+struct namnod *lookup(nam) register char *nam; {
        register struct namnod  *nscan=namep;
        register struct namnod  **prev;
        int             LR;
@@ -220,16 +204,14 @@ struct namnod             *lookup(nam)
        }
 
        /* add name node */
-       nscan=alloc(sizeof *nscan);
+       nscan=malloc(sizeof *nscan);
        nscan->namlft=nscan->namrgt=NULL;
        nscan->namid=make(nam);
        nscan->namval=0; nscan->namflg=N_DEFAULT; nscan->namenv=0;
        return(*prev = nscan);
 }
 
-static bool    chkid(nam)
-       char            *nam;
-{
+static bool chkid(nam) char *nam; {
        register char * cp=nam;
 
        if (!letter(*cp)) {
@@ -246,16 +228,12 @@ static bool       chkid(nam)
 }
 
 static void (*namfn)();
-namscan(fn)
-       void            (*fn)();
-{
+int namscan(fn) void (*fn)(); {
        namfn=fn;
        namwalk(namep);
 }
 
-static void    namwalk(np)
-       register struct namnod  *np;
-{
+static void namwalk(np) register struct namnod *np; {
        if (np) {
                namwalk(np->namlft);
                (*namfn)(np);
@@ -263,9 +241,7 @@ static void namwalk(np)
        }
 }
 
-void   printnam(n)
-       struct namnod           *n;
-{
+void printnam(n) struct namnod *n; {
        register char   *s;
 
        sigchk();
@@ -276,9 +252,7 @@ void        printnam(n)
        }
 }
 
-static char    *staknam(n)
-       register struct namnod  *n;
-{
+static char *staknam(n) register struct namnod *n; {
        register char   *p;
 
        p=movstr(n->namid,staktop);
@@ -287,9 +261,7 @@ static char *staknam(n)
        return(getstak(p+1-stakbot));
 }
 
-void   exname(n)
-       register struct namnod  *n;
-{
+void exname(n) register struct namnod *n; {
        if (n->namflg&N_EXPORT) {
                free(n->namenv);
                n->namenv = make(n->namval);
@@ -300,9 +272,7 @@ void        exname(n)
        }
 }
 
-void   printflg(n)
-       register struct namnod          *n;
-{
+void printflg(n) register struct namnod *n; {
        if (n->namflg&N_EXPORT) {
                prs(export); blank();
        }
@@ -314,8 +284,7 @@ void        printflg(n)
        }
 }
 
-void   setupenv()
-{
+void setupenv() {
        register char   **e=environ;
 
        while (*e) { setname(*e++, N_ENVNAM); }
@@ -323,29 +292,24 @@ void      setupenv()
 
 static int     namec;
 
-void   countnam(n)
-       struct namnod           *n;
-{
+void countnam(n) struct namnod *n; {
        namec++;
 }
 
 static char    **argnam;
 
-void   pushnam(n)
-       struct namnod           *n;
-{
+void pushnam(n) struct namnod *n; {
        if (n->namval) {
                *argnam++ = staknam(n);
        }
 }
 
-char   **setenv()
-{
+char **setenv() {
        register char   **er;
 
        namec=0;
        namscan(countnam);
-       argnam = er = getstak(namec*BYTESPERWORD+BYTESPERWORD);
+       argnam = er = getstak(namec*sizeof(char *)+sizeof(char *));
        namscan(pushnam);
        *argnam++ = 0;
        return(er);
index 42f5ad3..c22608b 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _NAME_H_
+#define _NAME_H_
+
 /*     name.h  4.1     82/05/07        */
 
 /*
@@ -8,7 +11,6 @@
  *
  */
 
-
 #define N_RDONLY 0100000
 #define N_EXPORT 0040000
 #define N_ENVNAM 0020000
@@ -24,3 +26,5 @@ struct namnod {
        char    *namenv;
        int     namflg;
 };
+
+#endif
index fb47b6c..0e51f3b 100644 (file)
@@ -1,4 +1,8 @@
-#ifndef lint
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)print.c    4.2 8/11/83";
 #endif
 
@@ -10,31 +14,25 @@ static char sccsid[] = "@(#)print.c 4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
+/*#include     "defs.h"*/
 
 char           numbuf[6];
 
-
 /* printing and io conversion */
 
-newline()
-{      prc('\n');
+int newline() {        prc('\n');
 }
 
-blank()
-{      prc(' ');
+int blank() {  prc(' ');
 }
 
-prp()
-{
+int prp() {
        if ((flags&prompt)==0 && cmdadr) {
                prs(cmdadr); prs(colon);
        }
 }
 
-void   prs(as)
-       char            *as;
-{
+void prs(as) char *as; {
        register char   *s;
 
        if (s=as) {
@@ -42,17 +40,13 @@ void        prs(as)
        }
 }
 
-void   prc(c)
-       char            c;
-{
+void prc(c) int c; {
        if (c) {
                write(output,&c,1);
        }
 }
 
-prt(t)
-       long            t;
-{
+int prt(t) long t; {
        register int    hr, min, sec;
 
        t += 30; t /= 60;
@@ -65,14 +59,11 @@ prt(t)
        prn(sec); prc('s');
 }
 
-prn(n)
-       int             n;
-{
+int prn(n) int n; {
        itos(n); prs(numbuf);
 }
 
-itos(n)
-{
+int itos(n) int n; {
        register char *abuf; register unsigned a, i; int pr, d;
        abuf=numbuf; pr=0; a=n;
        for (i=10000; i!=1; i/=10) {
@@ -83,9 +74,7 @@ itos(n)
        *abuf++=0;
 }
 
-stoi(icp)
-char   *icp;
-{
+int stoi(icp) char *icp; {
        register char   *cp = icp;
        register int            r = 0;
        register char   c;
@@ -98,4 +87,3 @@ char  *icp;
                return(r);
        }
 }
-
index 1ab342e..b7eb0ad 100644 (file)
@@ -1,4 +1,14 @@
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/errno.h> defs.h*/
+#include <sys/exec.h>
+/*#include <sys/file.h> defs.h*/
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)service.c  4.4 3/19/85";
 #endif
 
@@ -10,10 +20,9 @@ static char sccsid[] = "@(#)service.c        4.4 3/19/85";
  *
  */
 
-#include       "defs.h"
+/*#include     "defs.h"*/
 
-
-extern void    gsort();
+/*extern void  gsort();*/
 
 #define ARGMK  01
 
@@ -28,13 +37,13 @@ int         num_sysmsg;
 #define ENOENT 2
 #define ETXTBSY 26
 
-
-
 /* service routines for `execute' */
 
-void   initio(iop)
-       struct ionod            *iop;
-{
+static char *execs __P((char *ap, register char *t[]));
+static void gsort __P((char *from[], char *to[]));
+static int split __P((register char *s));
+
+void initio(iop) struct ionod *iop; {
        register char   *ion;
        register int            iof, fd;
 
@@ -71,16 +80,14 @@ void        initio(iop)
                                fd=create(ion);
                        }
                        if (fd>=0) {
-                               rename(fd,iof&IOUFD);
+                               _rename(fd,iof&IOUFD);
                        }
                }
                initio(iop->ionxt);
        }
 }
 
-char   *getpath(s)
-       char            *s;
-{
+char *getpath(s) char *s; {
        register char   *path;
        if (any('/',s)) {
                if (flags&rshflg) {
@@ -98,9 +105,7 @@ char *getpath(s)
        }
 }
 
-int    pathopen(path, name)
-       register char   *path, *name;
-{
+int pathopen(path, name) register char *path; register char *name; {
        register int            f;
 
        do {
@@ -109,10 +114,7 @@ int        pathopen(path, name)
        return(f);
 }
 
-char   *catpath(path,name)
-       register char   *path;
-       char            *name;
-{
+char *catpath(path, name) register char *path; char *name; {
        /* leaves result on top of stack */
        register char   *scanp = path,
                        *argp = locstak();
@@ -128,9 +130,7 @@ char        *catpath(path,name)
 static char    *xecmsg;
 static char    **xecenv;
 
-void   execa(at)
-       char            *at[];
-{
+void execa(at) char *at[]; {
        register char   *path;
        register char   **t = at;
 
@@ -143,10 +143,7 @@ void       execa(at)
        }
 }
 
-static char    *execs(ap,t)
-       char            *ap;
-       register char   *t[];
-{
+static char *execs(ap, t) char *ap; register char *t[]; {
        register char   *p, *prefix;
 
        prefix=catpath(ap,t[0]);
@@ -165,8 +162,7 @@ static char *execs(ap,t)
                close(output); output=2;
                input=chkopen(p);
 
-               /* band aid to get csh... 2/26/79 */
-               {
+               /* band aid to get csh... 2/26/79 */ {
                        char c;
                        if (!isatty(input)) {
                                read(input, &c, 1);
@@ -196,9 +192,7 @@ static char *execs(ap,t)
        }
 }
 
-gocsh(t, cp, xecenv)
-       register char **t, *cp, **xecenv;
-{
+int gocsh(t, cp, xecenv) register char **t; register char *cp; register char **xecenv; {
        char **newt[1000];
        register char **p;
        register int i;
@@ -216,17 +210,14 @@ gocsh(t, cp, xecenv)
 static int     pwlist[MAXP];
 static int     pwc;
 
-postclr()
-{
+int postclr() {
        register int            *pw = pwlist;
 
        while (pw <= &pwlist[pwc]) { *pw++ = 0; }
        pwc=0;
 }
 
-void   post(pcsid)
-       int             pcsid;
-{
+void post(pcsid) int pcsid; {
        register int            *pw = pwlist;
 
        if (pcsid) {
@@ -241,9 +232,7 @@ void        post(pcsid)
        }
 }
 
-void   await(i)
-       int             i;
-{
+void await(i) int i; {
        int             rc=0, wx=0;
        int             w;
        int             ipwc = pwc;
@@ -253,8 +242,7 @@ void        await(i)
                register int            p;
                register int            sig;
                int             w_hi;
-
-               {
+ {
                     
                   register int *pw=pwlist;
                   if (setjmp(INTbuf) == 0) {
@@ -307,9 +295,7 @@ void        await(i)
 
 bool           nosubst;
 
-trim(at)
-       char            *at;
-{
+int trim(at) char *at; {
        register char   *p;
        register char   c;
        register char   q=0;
@@ -320,21 +306,17 @@ trim(at)
        nosubst=q&0200;
 }
 
-char   *mactrim(s)
-       char            *s;
-{
+char *mactrim(s) char *s; {
        register char   *t=macro(s);
        trim(t);
        return(t);
 }
 
-char   **scan(argn)
-       int             argn;
-{
+char **scan(argn) int argn; {
        register struct argnod  *argp = Rcheat(gchain)&~ARGMK;
        register char   **comargn, **comargm;
 
-       comargn=getstak(BYTESPERWORD*argn+BYTESPERWORD); comargm = comargn += argn; *comargn = ENDARGS;
+       comargn=getstak(sizeof(char *)*argn+sizeof(char *)); comargm = comargn += argn; *comargn = ENDARGS;
 
        while (argp) {
                *--comargn = argp->argval;
@@ -351,9 +333,7 @@ char        **scan(argn)
        return(comargn);
 }
 
-static void    gsort(from,to)
-       char            *from[], *to[];
-{
+static void gsort(from, to) char *from[]; char *to[]; {
        int             k, m, n;
        register int            i, j;
 
@@ -379,9 +359,7 @@ static void gsort(from,to)
 
 /* Argument list generation */
 
-int    getarg(ac)
-       struct comnod           *ac;
-{
+int getarg(ac) struct comnod *ac; {
        register struct argnod  *argp;
        register int            count=0;
        register struct comnod  *c;
@@ -396,17 +374,15 @@ int       getarg(ac)
        return(count);
 }
 
-static int     split(s)
-       register char   *s;
-{
+static int split(s) register char *s; {
        register char   *argp;
        register int            c;
        int             count=0;
 
        for(;;) {
-               sigchk(); argp=locstak()+BYTESPERWORD;
+               sigchk(); argp=locstak()+sizeof(char *);
                while ((c = *s++, !any(c,ifsnod.namval) && c)) { *argp++ = c; }
-               if (argp==staktop+BYTESPERWORD) {
+               if (argp==staktop+sizeof(char *)) {
                        if (c) {
                                continue;
                        }
index 4636e04..51a5939 100644 (file)
@@ -1,4 +1,7 @@
-#ifndef lint
+#include <sys/proc.h>
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)setbrk.c   4.2 8/11/83";
 #endif
 
@@ -10,10 +13,9 @@ static char sccsid[] = "@(#)setbrk.c 4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
+/*#include     "defs.h"*/
 
-setbrk(incr)
-{
+int setbrk(incr) int incr; {
        register char   *a=sbrk(incr);
        brkend=a+incr;
        return(a);
index a2ae897..a66c09f 100644 (file)
@@ -1,4 +1,10 @@
-#ifndef lint
+#include <gen.h>
+/*#include "brkincr.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)stak.c     4.2 8/11/83";
 #endif
 
@@ -10,7 +16,7 @@ static char sccsid[] = "@(#)stak.c    4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
+/*#include     "defs.h"*/
 
 /* moved here from stak.h, which now just declares them extern */
 struct blk     *stakbsy;
@@ -20,24 +26,19 @@ char                *staktop;
 
 char           *stakbot=nullstr;
 
-
-
 /* ========    storage allocation      ======== */
 
-char   *getstak(asize)
-       int             asize;
-{      /* allocate requested stack */
+char *getstak(asize) int asize; {      /* allocate requested stack */
        register char   *oldstak;
        register int            size;
 
-       size=round(asize,BYTESPERWORD);
+       size=round(asize,sizeof(char *));
        oldstak=stakbot;
        staktop = stakbot += size;
        return(oldstak);
 }
 
-char   *locstak()
-{      /* set up stack for local use
+char *locstak() {      /* set up stack for local use
         * should be followed by `endstak'
         */
        if (brkend-stakbot<BRKINCR) {
@@ -49,24 +50,19 @@ char        *locstak()
        return(stakbot);
 }
 
-char   *savstak()
-{
+char *savstak() {
        assert(staktop==stakbot);
        return(stakbot);
 }
 
-char   *endstak(argp)
-       register char   *argp;
-{      /* tidy up after `locstak' */
+char *endstak(argp) register char *argp; {     /* tidy up after `locstak' */
        register char   *oldstak;
        *argp++=0;
-       oldstak=stakbot; stakbot=staktop=round(argp,BYTESPERWORD);
+       oldstak=stakbot; stakbot=staktop=round(argp,sizeof(char *));
        return(oldstak);
 }
 
-void   tdystak(x)
-       register char   *x;
-{
+void tdystak(x) register char *x; {
        /* try to bring stack back to x */
        while ((void *)(stakbsy)>(void *)(x)) {
           free(stakbsy);
@@ -76,15 +72,12 @@ void        tdystak(x)
        rmtemp(x);
 }
 
-stakchk()
-{
+int stakchk() {
        if ((brkend-stakbas)>BRKINCR+BRKINCR) {
                setbrk(-BRKINCR);
        }
 }
 
-char   *cpystak(x)
-       char            *x;
-{
+char *cpystak(x) char *x; {
        return(endstak(movstr(x,locstak())));
 }
index 92cf15e..1ce6a00 100644 (file)
@@ -1,3 +1,8 @@
+#ifndef _STAK_H_
+#define _STAK_H_
+
+#include "mode.h"
+
 /*     stak.h  4.1     82/05/07        */
 
 /*
@@ -35,7 +40,7 @@
 /* for local use only since it hands
  * out a real address for the stack top
  */
-char           *locstak();
+/*char         *locstak();*/
 
 /* Will allocate the item being used and return its
  * address (safe now).
@@ -45,15 +50,15 @@ char                *locstak();
 /* For use after `locstak' to hand back
  * new stack top and then allocate item
  */
-char           *endstak();
+/*char         *endstak();*/
 
 /* Copy a string onto the stack and
  * allocate the space.
  */
-char           *cpystak();
+/*char         *cpystak();*/
 
 /* Allocate given ammount of stack space */
-char           *getstak();
+/*char         *getstak();*/
 
 /* A chain of ptrs of stack blocks that
  * have become covered by heap allocation.
@@ -74,4 +79,23 @@ extern char          *stakbot;
 extern char            *staktop;
 
 /* Used with tdystak */
-char           *savstak();
+/*char         *savstak();*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* stak.c */
+char *getstak __P((int asize));
+char *locstak __P((void));
+char *savstak __P((void));
+char *endstak __P((register char *argp));
+void tdystak __P((register char *x));
+int stakchk __P((void));
+char *cpystak __P((char *x));
+
+#endif
index 202a3b3..524be73 100644 (file)
@@ -1,4 +1,6 @@
-#ifndef lint
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)string.c   4.2 8/11/83";
 #endif
 
@@ -10,23 +12,16 @@ static char sccsid[] = "@(#)string.c        4.2 8/11/83";
  *
  */
 
-#include       "defs.h"
-
+/*#include     "defs.h"*/
 
 /* ========    general purpose string handling ======== */
 
-
-char   *movstr(a,b)
-       register char   *a, *b;
-{
+char *movstr(a, b) register char *a; register char *b; {
        while (*b++ = *a++);
        return(--b);
 }
 
-int    any(c,s)
-       register char   c;
-       char            *s;
-{
+int any(c, s) int c; char *s; {
        register char d;
 
        while (d = *s++) {
@@ -37,9 +32,7 @@ int   any(c,s)
        return(0);
 }
 
-int    cf(s1, s2)
-       register char *s1, *s2;
-{
+int cf(s1, s2) register char *s1; register char *s2; {
        while (*s1++ == *s2) {
                if (*s2++==0) {
                        return(0);
@@ -48,9 +41,7 @@ int   cf(s1, s2)
        return(*--s1 - *s2);
 }
 
-int    length(as)
-       char *as;
-{
+int length(as) char *as; {
        register char *s;
 
        if (s=as) { while (*s++); }
index 6fb8d5e..554ccfd 100644 (file)
@@ -1,10 +1,12 @@
+#ifndef _SYM_H_
+#define _SYM_H_
+
 /*     sym.h   4.1     82/05/07        */
 
 /*
  *     UNIX shell
  */
 
-
 /* symbols for parsing */
 #define DOSYM  0405
 #define FISYM  0420
@@ -37,3 +39,5 @@
 
 /* for peekc */
 #define MARK   0100000
+
+#endif
index b40606e..e5ac5ec 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _TIMEOUT_H_
+#define _TIMEOUT_H_
+
 /*     timeout.h       4.1     82/05/07        */
 
 /*
@@ -9,3 +12,5 @@
  */
 
 #define TIMEOUT 2400
+
+#endif
index 1ad1007..f4718f8 100644 (file)
@@ -1,4 +1,12 @@
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)word.c     4.6 10/31/85";
 #endif
 
@@ -10,17 +18,16 @@ static char sccsid[] = "@(#)word.c  4.6 10/31/85";
  *
  */
 
-#include       "defs.h"
-#include       "sym.h"
-
+/*#include     "defs.h"*/
+/*#include     "sym.h"*/
 
 /* ========    character handling for command lines    ========*/
 
+static readb __P((void));
 
-word()
-{
+int word() {
        register char   c, d;
-       register char   *argp=locstak()+BYTESPERWORD;
+       register char   *argp=locstak()+sizeof(char *);
        int             alpha=1;
 
        wdnum=0; wdset=0;
@@ -34,10 +41,10 @@ word()
 
        if (!eofmeta(c)) {
                do {
-                       if (c==LITERAL) {
-                               *argp++=(DQUOTE);
-                               while ((c=readc()) && c!=LITERAL) { *argp++=(c|0200); chkpr(c); }
-                               *argp++=(DQUOTE);
+                       if (c=='\'') {
+                               *argp++=('"');
+                               while ((c=readc()) && c!='\'') { *argp++=(c|0200); chkpr(c); }
+                               *argp++=('"');
 
                        }
                        else {
@@ -85,11 +92,9 @@ word()
        return(wdval);
 }
 
-nextc(quote)
-       char            quote;
-{
+int nextc(quote) int quote; {
        register char   c, d;
-       if ((d=readc())==ESCAPE) {
+       if ((d=readc())=='\\') {
                if ((c=readc())=='\n') {
                        chkpr('\n'); d=nextc(quote);
                }
@@ -103,8 +108,7 @@ nextc(quote)
        return(d);
 }
 
-readc()
-{
+int readc() {
        register char   c;
        register int            len;
        register struct fileblk *f;
@@ -143,8 +147,7 @@ retry:
        return(c);
 }
 
-static readb()
-{
+static readb() {
        register struct fileblk *f=standin;
        register int            len;
 
index ec1e445..2565389 100644 (file)
@@ -1,4 +1,18 @@
-#ifndef lint
+#include <compat-4.1.h>
+/*#include <sys/file.h> defs.h*/
+#include <sys/proc.h>
+#include <sys/signal.h>
+#include <sys/stat.h>
+/*#include <sys/time.h> compat-4.1.h*/
+/*#include <sys/times.h> compat-4.1.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "name.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)xec.c      4.3 8/11/83";
 #endif
 
@@ -10,22 +24,16 @@ static char sccsid[] = "@(#)xec.c   4.3 8/11/83";
  *
  */
 
-#include       "defs.h"
-#include       "sym.h"
+/*#include     "defs.h"*/
+/*#include     "sym.h"*/
 
 static int     parent;
 
 extern struct sysnod   commands[];
 
-
-
 /* ========    command execution       ========*/
 
-
-execute(argt, execflg, pf1, pf2)
-       struct trenod           *argt;
-       int             *pf1, *pf2;
-{
+int execute(argt, execflg, pf1, pf2) struct trenod *argt; int execflg; int *pf1; int *pf2; {
        /* `stakbot' is preserved by this routine */
        register struct trenod  *_t;
        char            *sav=savstak();
@@ -83,8 +91,7 @@ execute(argt, execflg, pf1, pf2)
                                        }
                                        break;
        
-                               case SYSTIMES:
-                                       {
+                               case SYSTIMES: {
                                        long    tm[4]; times(tm);
                                        prt(tm[2]); blank(); prt(tm[3]); newline();
                                        }
@@ -282,7 +289,6 @@ execute(argt, execflg, pf1, pf2)
                                chktrap();
                                break;
 
-
                        }
                        else {
                                /* this is the forked branch (child) of execute */
@@ -300,17 +306,17 @@ execute(argt, execflg, pf1, pf2)
 
                                /* pipe in or out */
                                if (treeflgs&FPIN) {
-                                       rename(pf1[INPIPE],0);
+                                       _rename(pf1[INPIPE],0);
                                        close(pf1[OTPIPE]);
                                }
                                if (treeflgs&FPOU) {
-                                       rename(pf2[OTPIPE],1);
+                                       _rename(pf2[OTPIPE],1);
                                        close(pf2[INPIPE]);
                                }
 
                                /* default std input for & */
                                if (treeflgs&FINT && ioset==0) {
-                                       rename(chkopen(devnull),0);
+                                       _rename(chkopen(devnull),0);
                                }
 
                                /* io redirection */
@@ -328,7 +334,7 @@ execute(argt, execflg, pf1, pf2)
 
                case TPAR:
 #define t ((struct parnod *)_t)
-                       rename(dup(2),output);
+                       _rename(dup(2),output);
                        execute(t->partre,execflg);
                        done();
 #undef t
@@ -459,11 +465,7 @@ execute(argt, execflg, pf1, pf2)
        return(exitval);
 }
 
-
-execexp(s,f)
-       char            *s;
-       int             f;
-{
+int execexp(s, f) char *s; int f; {
        struct fileblk          fb;
        push(&fb);
        if (s) {