*.usedby
*.uses
.xify
+ansify.log
bin/adb/adb
bin/adb/instrs.adb
bin/ar
LIBES=
SCCS= sccs
-OBJS= malloc.o doprnt.o printf.o vprintf.o sh.o sh.char.o sh.data.o \
- sh.dir.o sh.dol.o sh.err.o sh.exec.o sh.exp.o sh.file.o sh.func.o \
- sh.glob.o sh.hist.o sh.init.o sh.lex.o sh.misc.o sh.parse.o \
- sh.print.o sh.proc.o sh.sem.o sh.set.o sh.time.o sh.end.o
+OBJS= doprnt.o malloc.o printf.o sh.char.o sh.data.o sh.dir.o sh.dol.o \
+ sh.err.o sh.exec.o sh.exp.o sh.file.o sh.func.o sh.glob.o sh.hist.o \
+ sh.init.o sh.lex.o sh.misc.o sh.o sh.parse.o sh.print.o sh.proc.o \
+ sh.sem.o sh.set.o sh.time.o vprintf.o
# do things the standard way for Linux hosted version, fix this properly later
csh: ${OBJS}
/*extern gid_t getegid(), getgid();*/
/*extern uid_t geteuid(), getuid();*/
+/* end of data segment, formerly done by linker using dummy array "end" */
+char *end;
+
void main(c, av) int c; char **av; {
register char **v, *cp;
register int f;
struct sigvec osv;
+ end = (char *)sbrk(0);
settimes(); /* Immed. estab. timing base */
v = av;
if (eq(v[0], "a.out")) /* A.out's are quittable */
+++ /dev/null
-char end[0];
* In lines for frequently called functions
*/
#define XFREE(cp) { \
- extern char end[]; \
char stack; \
if ((cp) >= end && (cp) < &stack) \
free(cp); \
char *pname; /* print name */
} mesg[];
+/* end of data segment, formerly done by linker using dummy array "end" */
+extern char *end;
+
#ifndef NORETURN
#ifdef __GNUC__
#define NORETURN __attribute__ ((__noreturn__))
}
int onlyread(cp) char *cp; {
- extern char end[];
-
return (cp < end);
}
void xfree(cp) char *cp; {
- extern char end[];
-
if (cp >= end && cp < (char *) &cp)
free(cp);
}
# Makefile 4.5 83/07/01
#
+OBJS= args.o blok.o builtin.o cmd.o ctype.o error.o expand.o fault.o io.o \
+ macro.o main.o msg.o name.o print.o service.o setbrk.o stak.o \
+ string.o word.o xec.o
CFLAGS = -O -w
all: sh
cmp sh /bin/sh
rm sh *.o
-sh: setbrk.o
-sh: builtin.o blok.o stak.o
-sh: cmd.o fault.o main.o
-sh: word.o string.o name.o args.o
-sh: xec.o service.o error.o io.o
-sh: print.o macro.o expand.o
-sh: ctype.o msg.o
blok.o: brkincr.h
fault.o: brkincr.h
main.o: brkincr.h
stak.o: brkincr.h
-sh:
- cc -o sh *.o
+sh: ${OBJS}
+ ${CC} -o sh ${OBJS}
install:
install -s sh $(DESTDIR)/bin
/* ctype.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*
#define _IDCH (T_IDC|T_DIG)
#define _META (T_SPC|T_DIP|T_MET|T_EOR)
-char _ctype1[];
+extern char _ctype1[];
/* nb these args are not call by value !!!! */
#define space(c) (((c)&0200)==0 && _ctype1[c]&(T_SPC))
#define subchar(c) (((c)&0200)==0 && _ctype1[c]&(T_SUB|T_QOT))
#define escchar(c) (((c)&0200)==0 && _ctype1[c]&(T_ESC))
-char _ctype2[];
+extern char _ctype2[];
#define digit(c) (((c)&0200)==0 && _ctype2[c]&(T_DIG))
#define fngchar(c) (((c)&0200)==0 && _ctype2[c]&(T_FNG))
static char sccsid[] = "@(#)args.c 4.4 7/31/85";
#endif
-#
/*
* UNIX shell
*
#include "defs.h"
-extern char **copyargs();
+static struct dolnod *copyargs();
static struct dolnod *dolh;
char flagadr[10];
char flagchar[] = {
'x', 'n', 'v', 't', 's', 'i', 'e', 'r', 'k', 'u', 0
-}
+};
int flagval[] = {
execpr, noexec, readpr, oneflg, stdflg, intflg, errflg, rshflg, keyflg, setflg, 0
-}
+};
/* ======== option handling ======== */
return(argr);
}
-static char ** copyargs(from, n)
+static struct dolnod *copyargs(from, n)
char *from[];
{
- register char ** np=alloc(sizeof(char **)*n+3*BYTESPERWORD);
+ register struct dolnod *pp = (struct dolnod *)alloc(sizeof(struct dolnod)+n*sizeof(char **));
+ register char ** np=pp->dolarg;
register char ** fp=from;
- register char ** pp=np;
- np->doluse=1; /* use count */
- np=np->dolarg;
+ pp->doluse=1; /* use count */
dolv=np;
while (n--) { *np++ = make(*fp++); }
static char sccsid[] = "@(#)blok.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
unsigned brkincr=BRKINCR;
struct blk *blokp; /*current search pointer*/
-struct blk *bloktop=(struct blk *)(end); /*top of arena (last blok)*/
+struct blk *bloktop/*=(struct blk *)(end)*/; /*top of arena (last blok)*/
do {
if (!busy(p)) {
while (!busy(q = p->word)) { p->word = q->word; }
- if ((void *)(q)-(void *)(p) >= rbytes) {
- blokp = (struct blk *)((void *)(p)+rbytes);
+ if ((char *)(q)-(char *)(p) >= rbytes) {
+ blokp = (struct blk *)((char *)(p)+rbytes);
if (q > blokp) {
blokp->word = p->word;
}
}
void free(ap)
- struct blk *ap;
+ void *ap;
{
- register struct blk *p;
-
- if ((p=ap) && p<bloktop) {
- Lcheat((--p)->word) &= ~BUSY;
+#define p ((struct blk *)ap)
+ if (p && p<bloktop) {
+ Lcheat(p[-1].word) &= ~BUSY;
}
+#undef p
}
#ifdef DEBUG
static char sccsid[] = "@(#)builtin.c 4.2 8/11/83";
#endif
-builtin()
+builtin(argn, com)
+int argn;
+char **com;
{return(0);}
static char sccsid[] = "@(#)cmd.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
#include "sym.h"
extern struct ionod *inout();
-extern void chkword();
-extern void chksym();
+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 void skipnl();
-extern void prsym();
-extern void synbad();
+extern int skipnl();
+extern void prsym();
+extern void synbad();
/* ======== command line decoding ========*/
int flgs;
struct trenod *i;
{
- register struct trenod *t;
+ register struct forknod *t;
- t=getstak(sizeof(struct forknod));
+ t=(struct forknod *)getstak(sizeof(struct forknod));
t->forktyp=flgs|TFORK; t->forktre=i; t->forkio=0;
- return(t);
+ return((struct trenod *)t);
}
static struct trenod *makelist(type,i,r)
int type;
struct trenod *i, *r;
{
- register struct trenod *t;
+ register struct lstnod *t;
if (i==0 || r==0) {
synbad();
}
else {
- t = getstak(sizeof(struct lstnod));
+ t = (struct lstnod *)getstak(sizeof(struct lstnod));
t->lsttyp = type;
t->lstlef = i; t->lstrit = r;
}
- return(t);
+ return((struct trenod *)t);
}
/*
return(0);
}
else {
- register struct regnod *r=getstak(sizeof(struct regnod));
+ register struct regnod *r=(struct regnod *)getstak(sizeof(struct regnod));
r->regptr=0;
for(;;) {
wdarg->argnxt=r->regptr;
static struct trenod *item(flag)
bool flag;
{
- register struct trenod *t;
+ struct trenod *_t;
register struct ionod *io;
if (flag) {
case CASYM:
{
-
- t=getstak(sizeof(struct swnod));
+#define t (*(struct swnod **)&_t)
+ t=(struct swnod *)getstak(sizeof(struct swnod));
chkword();
t->swarg=wdarg->argval;
skipnl(); chksym(INSYM|BRSYM);
t->swlst=syncase(wdval==INSYM?ESSYM:KTSYM);
t->swtyp=TSW;
break;
+#undef t
}
case IFSYM:
{
-
+#define t (*(struct ifnod **)&_t)
register int w;
- t=getstak(sizeof(struct ifnod));
+ t=(struct ifnod *)getstak(sizeof(struct ifnod));
t->iftyp=TIF;
t->iftre=cmd(THSYM,NLFLG);
t->thtre=cmd(ELSYM|FISYM|EFSYM,NLFLG);
t->eltre=((w=wdval)==ELSYM ? cmd(FISYM,NLFLG) : (w==EFSYM ? (wdval=IFSYM, item(0)) : 0));
if (w==EFSYM) { return(t); }
break;
+#undef t
}
case FORSYM:
{
-
- t=getstak(sizeof(struct fornod));
+#define t (*(struct fornod **)&_t)
+ t=(struct fornod *)getstak(sizeof(struct fornod));
t->fortyp=TFOR;
t->forlst=0;
chkword();
chksym(DOSYM|BRSYM);
t->fortre=cmd(wdval==DOSYM?ODSYM:KTSYM,NLFLG);
break;
+#undef t
}
case WHSYM:
case UNSYM:
{
-
- t=getstak(sizeof(struct whnod));
+#define t (*(struct whnod **)&_t)
+ t=(struct whnod *)getstak(sizeof(struct whnod));
t->whtyp=(wdval==WHSYM ? TWH : TUN);
t->whtre = cmd(DOSYM,NLFLG);
t->dotre = cmd(ODSYM,NLFLG);
break;
+#undef t
}
case BRSYM:
- t=cmd(KTSYM,NLFLG);
+ _t=cmd(KTSYM,NLFLG);
break;
case '(':
{
-
register struct parnod *p;
- p=getstak(sizeof(struct parnod));
+ p=(struct parnod *)getstak(sizeof(struct parnod));
p->partre=cmd(')',NLFLG);
p->partyp=TPAR;
- t=makefork(0,p);
+ _t=makefork(0,p);
break;
}
case 0:
{
-
+#define t (*(struct comnod **)&_t)
register struct argnod *argp;
register struct argnod **argtail;
register struct argnod **argset=0;
int keywd=1;
- t=getstak(sizeof(struct comnod));
+ t=(struct comnod *)getstak(sizeof(struct comnod));
t->comio=io; /*initial io chain*/
argtail = &(t->comarg);
while (wdval==0) {
t->comtyp=TCOM; t->comset=argset; *argtail=0;
return(t);
+#undef t
}
}
reserv++; word();
if (io=inout(io)) {
- t=makefork(0,t); t->treio=io;
+ _t=makefork(0,_t); _t->treio=io;
}
- return(t);
+ return(_t);
}
-static void skipnl()
+static int skipnl()
{
while ((reserv++, word()=='\n')) { chkpr('\n'); }
return(wdval);
}
chkword();
- iop=getstak(sizeof(struct ionod)); iop->ioname=wdarg->argval; iop->iofile=iof;
+ iop=(struct ionod *)getstak(sizeof(struct ionod)); iop->ioname=wdarg->argval; iop->iofile=iof;
if (iof&IODOC) {
iop->iolst=iopend; iopend=iop;
}
--- /dev/null
+defs.h arpa/ftp.h
+defs.h arpa/tftp.h
+defs.h assert.h
+defs.h stdio.h
+error.c arpa/ftp.h
+error.c arpa/tftp.h
+error.c stdio.h
+io.c stdio.h
+mode.h stdio.h
+stak.c assert.h
+word.c stdio.h
static char sccsid[] = "@(#)ctype.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
#include "defs.h"
-char _ctype1[] {
+char _ctype1[] = {
/* 000 001 002 003 004 005 006 007 */
_EOF, 0, 0, 0, 0, 0, 0, 0,
/* x y z { | } ~ del */
0, 0, 0, 0, _BAR, 0, 0, 0
-}
+};
-char _ctype2[] {
+char _ctype2[] = {
/* 000 001 002 003 004 005 006 007 */
0, 0, 0, 0, 0, 0, 0, 0,
/* x y z { | } ~ del */
_LPC, _LPC, _LPC, _CBR, 0, _CKT, 0, 0
-}
-
+};
/* defs.h 4.4 85/03/19 */
-#
/*
* UNIX shell
*/
/* result type declarations */
-#define alloc malloc
void *alloc();
void addblok();
char *make();
char *movstr();
-struct trenod *cmd();
-struct trenod *makefork();
-struct namnod *lookup();
+struct trenod *cmd();
+struct trenod *makefork();
+struct namnod *lookup();
void setname();
void setargs();
-struct dolnod *useargs();
+struct dolnod *useargs();
float expr();
char *catpath();
char *getpath();
#define assert(x) ;
/* temp files and io */
-int output;
-int ioset;
-struct ionod *iotemp; /* files to be deleted sometime */
-struct ionod *iopend; /* documents waiting to be read at '\n' */
+extern int output;
+extern int ioset;
+extern struct ionod *iotemp; /* files to be deleted sometime */
+extern struct ionod *iopend; /* documents waiting to be read at '\n' */
/* substitution */
-int dolc;
-char **dolv;
-struct dolnod *argfor;
-struct argnod *gchain;
+extern int dolc;
+extern char **dolv;
+extern struct dolnod *argfor;
+extern struct argnod *gchain;
/* stak stuff */
#include "stak.h"
/* string constants */
-char atline[];
-char readmsg[];
-char colon[];
-char minus[];
-char nullstr[];
-char sptbnl[];
-char unexpected[];
-char endoffile[];
-char synmsg[];
+extern char atline[];
+extern char readmsg[];
+extern char colon[];
+extern char minus[];
+extern char nullstr[];
+extern char sptbnl[];
+extern char unexpected[];
+extern char endoffile[];
+extern char synmsg[];
/* name tree and words */
-struct sysnod reserved[];
-int wdval;
-int wdnum;
-struct argnod *wdarg;
-int wdset;
-bool reserv;
+extern struct sysnod reserved[];
+extern int wdval;
+extern int wdnum;
+extern struct argnod *wdarg;
+extern int wdset;
+extern bool reserv;
/* prompting */
-char stdprompt[];
-char supprompt[];
-char profile[];
+extern char stdprompt[];
+extern char supprompt[];
+extern char profile[];
/* built in names */
-struct namnod fngnod;
-struct namnod ifsnod;
-struct namnod homenod;
-struct namnod mailnod;
-struct namnod pathnod;
-struct namnod ps1nod;
-struct namnod ps2nod;
+extern struct namnod fngnod;
+extern struct namnod ifsnod;
+extern struct namnod homenod;
+extern struct namnod mailnod;
+extern struct namnod pathnod;
+extern struct namnod ps1nod;
+extern struct namnod ps2nod;
/* special names */
-char flagadr[];
-char *cmdadr;
-char *exitadr;
-char *dolladr;
-char *pcsadr;
-char *pidadr;
+extern char flagadr[];
+extern char *cmdadr;
+extern char *exitadr;
+extern char *dolladr;
+extern char *pcsadr;
+extern char *pidadr;
-char defpath[];
+extern char defpath[];
/* names always present */
-char mailname[];
-char homename[];
-char pathname[];
-char fngname[];
-char ifsname[];
-char ps1name[];
-char ps2name[];
+extern char mailname[];
+extern char homename[];
+extern char pathname[];
+extern char fngname[];
+extern char ifsname[];
+extern char ps1name[];
+extern char ps2name[];
/* transput */
-char tmpout[];
-char *tmpnam;
-int serial;
+extern char tmpout[];
+extern char *tmpnam;
+extern int serial;
#define TMPNAM 7
-struct fileblk *standin;
+extern struct fileblk *standin;
#define input (standin->fdes)
#define eof (standin->feof)
-int peekc;
-char *comdiv;
-char devnull[];
+extern int peekc;
+extern char *comdiv;
+extern char devnull[];
/* flags */
#define noexec 01
#define readpr 010000
#define keyflg 020000
#define batchflg 040000
-int flags;
+extern int flags;
/* error exits from various parts of shell */
#include <setjmp.h>
-jmp_buf subshell;
-jmp_buf errshell;
-jmp_buf INTbuf;
+extern jmp_buf subshell;
+extern jmp_buf errshell;
+extern jmp_buf INTbuf;
/* fault handling */
#include "brkincr.h"
-unsigned brkincr;
+extern unsigned brkincr;
+extern struct blk *blokp; /*current search pointer*/
+extern struct blk *bloktop; /*top of arena (last blok)*/
#define MINTRAP 0
#define MAXTRAP 32
#define SIGMOD 8
void fault();
-bool trapnote;
-char *trapcom[];
-bool trapflg[];
-bool trapjmp[];
+extern bool trapnote;
+extern char *trapcom[];
+extern bool trapflg[];
+extern bool trapjmp[];
/* name tree and words */
-char **environ;
-char numbuf[];
-char export[];
-char readonly[];
+extern char **environ;
+extern char numbuf[];
+extern char export[];
+extern char readonly[];
/* execflgs */
-int exitval;
-bool execbrk;
-int loopcnt;
-int breakcnt;
+extern int exitval;
+extern bool execbrk;
+extern int loopcnt;
+extern int breakcnt;
/* messages */
-char mailmsg[];
-char coredump[];
-char badopt[];
-char badparam[];
-char badsub[];
-char nospace[];
-char notfound[];
-char badtrap[];
-char baddir[];
-char badshift[];
-char illegal[];
-char restricted[];
-char execpmsg[];
-char notid[];
-char wtfailed[];
-char badcreate[];
-char piperr[];
-char badopen[];
-char badnum[];
-char arglist[];
-char txtbsy[];
-char toobig[];
-char badexec[];
-char notfound[];
-char badfile[];
-
-address end[];
-
-#include "ctype.h"
-
+extern char mailmsg[];
+extern char coredump[];
+extern char badopt[];
+extern char badparam[];
+extern char badsub[];
+extern char nospace[];
+extern char notfound[];
+extern char badtrap[];
+extern char baddir[];
+extern char badshift[];
+extern char illegal[];
+extern char restricted[];
+extern char execpmsg[];
+extern char notid[];
+extern char wtfailed[];
+extern char badcreate[];
+extern char piperr[];
+extern char badopen[];
+extern char badnum[];
+extern char arglist[];
+extern char txtbsy[];
+extern char toobig[];
+extern char badexec[];
+extern char notfound[];
+extern char badfile[];
+
+/* end of data segment, formerly done by linker using dummy array "end" */
+extern struct blk *end;
+
+#include "_ctype.h"
s/@SYSNOD@/@struct sysnod@/g
s/@SYSPTR@/@struct sysnod*CHECKME@/g
s/@SYSTAB@/@struct sysnod[]CHECKME@/g
+s/@NIL@/@NULL@/g
s/@FORKTYPE@/@sizeof(struct forknod)@/g
s/@COMTYPE@/@sizeof(struct comnod)@/g
/* dup.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*
static char sccsid[] = "@(#)error.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
error(s)
char *s;
{
- failed(s,NIL);
+ failed(s,NULL);
}
exitsh(xno)
execexp(t,0);
}
rmtemp(0);
- exit(exitval);
+ /* formerly exit(), may have been an oversight as we do not use stdio */
+ _exit(exitval);
}
rmtemp(base)
static char sccsid[] = "@(#)expand.c 4.5 8/11/83";
#endif
-#
/*
* UNIX shell
*
}
makearg(args)
- register char *args;
+ register struct argnod *args;
{
args->argnxt=gchain;
gchain=args;
}
-
static char sccsid[] = "@(#)fault.c 4.3 8/11/83";
#endif
-#
/*
* UNIX shell
*
getsig(ALARM);
}
-ignsig(n)
+void
+(*ignsig(n))()
{
- register int s, i;
+ register void (*s)();
+ register int i;
- if ((s=signal(i=n,1)&01)==0) {
+ if ((s=signal(i=n,SIG_IGN))!=SIG_IGN) {
trapflg[i] |= SIGMOD;
}
return(s);
{
register int i;
- if (trapflg[i=n]&SIGMOD || ignsig(i)==0) {
+ if (trapflg[i=n]&SIGMOD || ignsig(i)==SIG_DFL) {
signal(i,fault);
}
}
--- /dev/null
+args.c defs.h
+blok.c defs.h
+builtin.c defs.h
+cmd.c defs.h
+ctype.c defs.h
+error.c defs.h
+expand.c defs.h
+fault.c defs.h
+io.c defs.h
+macro.c defs.h
+main.c defs.h
+msg.c defs.h
+name.c defs.h
+print.c defs.h
+service.c defs.h
+setbrk.c defs.h
+stak.c stak.h
+string.c defs.h
+word.c defs.h
+xec.c defs.h
static char sccsid[] = "@(#)io.c 4.3 3/19/85";
#endif
-#
/*
* UNIX shell
*
static char sccsid[] = "@(#)macro.c 4.3 8/11/83";
#endif
-#
/*
* UNIX shell
*
if (d==DOLLAR) {
register int c;
if ((c=readc(), dolchar(c))) {
- struct namnod *n=NIL;
+ struct namnod *n=NULL;
int dolg=0;
bool bra;
register char *argp, *v;
static char sccsid[] = "@(#)main.c 4.3 3/19/85";
#endif
-#
/*
* UNIX shell
*
#include <sgtty.h>
#include <signal.h>
+/* moved here from defs.h, which now just declares them extern */
+/* temp files and io */
+int output;
+int ioset;
+struct ionod *iotemp; /* files to be deleted sometime */
+struct ionod *iopend; /* documents waiting to be read at '\n' */
+
+/* substitution */
+int dolc;
+char **dolv;
+struct dolnod *argfor;
+struct argnod *gchain;
+
+/* name tree and words */
+int wdval;
+int wdnum;
+struct argnod *wdarg;
+int wdset;
+bool reserv;
+
+/* special names */
+char flagadr[];
+char *cmdadr;
+char *exitadr;
+char *dolladr;
+char *pcsadr;
+char *pidadr;
+
+/* transput */
+char *tmpnam;
+int serial;
+int peekc;
+char *comdiv;
+
+/* flags */
+int flags;
+
+/* error exits from various parts of shell */
+jmp_buf subshell;
+jmp_buf errshell;
+jmp_buf INTbuf;
+
+/* fault handling */
+unsigned brkincr;
+
+bool trapnote;
+
+/* execflgs */
+int exitval;
+bool execbrk;
+int loopcnt;
+int breakcnt;
+
+/* end of data segment, formerly done by linker using dummy array "end" */
+struct blk *end;
+
int output = 2;
static bool beenhere = 0;
char tmpout[20] = "/tmp/sh-";
-struct fileblk stdfile;
-struct fileblk *standin = &stdfile;
-#ifdef stupid
-#include <execargs.h>
-#endif
+struct fileblk stdfile;
+struct fileblk *standin = &stdfile;
extern void exfile();
/* initialise storage allocation */
stdsigs();
- setbrk(BRKINCR);
+ end = (struct blk *)setbrk(BRKINCR);
+ bloktop = end;
addblok((unsigned)0);
/* set names from userenv */
/* mode.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*/
+typedef char bool;
-#define BYTESPERWORD (sizeof(char *))
-
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
/* the following nonsense is required
* because casts turn an Lvalue
* into an Rvalue so two cheats
* are necessary, one for each context.
*/
-union { int _cheat;}
-#define Lcheat(a) ((a)._cheat)
+#define Lcheat(a) (*(int *)&(a))
#define Rcheat(a) ((int)(a))
-
-/* address puns for storage allocation */
-typedef union {
- struct forknod *_forkptr;
- struct comnod *_comptr;
- struct parnod *_parptr;
- struct ifnod *_ifptr;
- struct whnod *_whptr;
- struct fornod *_forptr;
- struct lstnod *_lstptr;
- struct blk *_blkptr;
- struct namnod *_namptr;
- char *_bytptr;
- } address;
-
-
-/* for functions that do not return values */
-/*
-struct void {int vvvvvvvv;}
-*/
-
-
/* heap storage */
struct blk {
struct blk *word;
-}
+};
#define BUFSIZ 64
struct fileblk {
char **feval;
struct fileblk *fstak;
char fbuf[BUFSIZ];
-}
+};
/* for files not used with file descriptors */
struct filehdr {
char **feval;
struct fileblk *fstak;
char _fbuf[1];
-}
+};
struct sysnod {
char *sysnam;
int sysval;
-}
+};
/* this node is a proforma for those that follow */
struct trenod {
int tretyp;
struct ionod *treio;
-}
+};
/* dummy for access only */
struct argnod {
struct argnod *argnxt;
char argval[1];
-}
+};
struct dolnod {
struct dolnod *dolnxt;
int doluse;
char dolarg[1];
-}
+};
struct forknod {
int forktyp;
struct ionod *forkio;
struct trenod *forktre;
-}
+};
struct comnod {
int comtyp;
struct ionod *comio;
struct argnod *comarg;
struct argnod *comset;
-}
+};
struct ifnod {
int iftyp;
struct trenod *iftre;
struct trenod *thtre;
struct trenod *eltre;
-}
+};
struct whnod {
int whtyp;
struct trenod *whtre;
struct trenod *dotre;
-}
+};
struct fornod {
int fortyp;
struct trenod *fortre;
char *fornam;
struct comnod *forlst;
-}
+};
struct swnod {
int swtyp;
char *swarg;
struct regnod *swlst;
-}
+};
struct regnod {
struct argnod *regptr;
struct trenod *regcom;
struct regnod *regnxt;
-}
+};
struct parnod {
int partyp;
struct trenod *partre;
-}
+};
struct lstnod {
int lsttyp;
struct trenod *lstlef;
struct trenod *lstrit;
-}
+};
struct ionod {
int iofile;
char *ioname;
struct ionod *ionxt;
struct ionod *iolst;
-}
+};
static char sccsid[] = "@(#)msg.c 4.4 5/22/85";
#endif
-#
/*
* UNIX shell
*
char version[] = "\nVERSION sys137 DATE 1978 Nov 6 14:29:22\n";
/* error messages */
-char badopt[] = "bad option(s)";
-char mailmsg[] = "you have mail\n";
-char nospace[] = "no space";
-char synmsg[] = "syntax error";
+char badopt[] = "bad option(s)";
+char mailmsg[] = "you have mail\n";
+char nospace[] = "no space";
+char synmsg[] = "syntax error";
-char badnum[] = "bad number";
+char badnum[] = "bad number";
char badparam[] = "parameter not set";
-char badsub[] = "bad substitution";
+char badsub[] = "bad substitution";
char badcreate[] = "cannot create";
-char illegal[] = "illegal io";
+char illegal[] = "illegal io";
char restricted[] = "restricted";
-char piperr[] = "cannot make pipe";
-char badopen[] = "cannot open";
+char piperr[] = "cannot make pipe";
+char badopen[] = "cannot open";
char coredump[] = " - core dumped";
-char arglist[] = "arg list too long";
-char txtbsy[] = "text busy";
-char toobig[] = "too big";
-char badexec[] = "cannot execute";
+char arglist[] = "arg list too long";
+char txtbsy[] = "text busy";
+char toobig[] = "too big";
+char badexec[] = "cannot execute";
char notfound[] = "not found";
-char badfile[] = "bad file number";
+char badfile[] = "bad file number";
char badshift[] = "cannot shift";
-char baddir[] = "bad directory";
-char badtrap[] = "bad trap";
+char baddir[] = "bad directory";
+char badtrap[] = "bad trap";
char wtfailed[] = "is read only";
char notid[] = "is not an identifier";
char pathname[] = "PATH";
char homename[] = "HOME";
char mailname[] = "MAIL";
-char fngname[] = "FILEMATCH";
-char ifsname[] = "IFS";
-char ps1name[] = "PS1";
-char ps2name[] = "PS2";
+char fngname[] = "FILEMATCH";
+char ifsname[] = "IFS";
+char ps1name[] = "PS1";
+char ps2name[] = "PS2";
/* string constants */
-char nullstr[] = "";
-char sptbnl[] = " \t\n";
-char defpath[] = ":/bin:/usr/bin";
+char nullstr[] = "";
+char sptbnl[] = " \t\n";
+char defpath[] = ":/bin:/usr/bin";
char colon[] = ": ";
char minus[] = "-";
char endoffile[] = "end of file";
char unexpected[] = " unexpected";
-char atline[] = " at line ";
-char devnull[] = "/dev/null";
+char atline[] = " at line ";
+char devnull[] = "/dev/null";
char execpmsg[] = "+ ";
-char readmsg[] = "> ";
+char readmsg[] = "> ";
char stdprompt[] = "$ ";
char supprompt[] = "# ";
-char profile[] = ".profile";
-
+char profile[] = ".profile";
/* tables */
-struct sysnod reserved[] {
+struct sysnod reserved[] = {
{"in", INSYM},
{"esac", ESSYM},
{"case", CASYM},
{"elif", EFSYM},
{"fi", FISYM},
{"until", UNSYM},
- { "{", BRSYM},
- { "}", KTSYM},
- {0, 0},
-}
+ {"{", BRSYM},
+ {"}", KTSYM},
+ {0, 0}
+};
-char *sysmsg[] {
+char *sysmsg[] = {
0,
"Hangup",
0, /* Interrupt */
"Signal 29",
"User defined signal 1",
"User defined signal 2",
- "Signal 32",
-}
+ "Signal 32"
+};
int num_sysmsg = (sizeof sysmsg / sizeof sysmsg[0]);
char export[] = "export";
char readonly[] = "readonly";
-struct sysnod commands[] {
+struct sysnod commands[] = {
{"cd", SYSCD},
{"read", SYSREAD},
-/*
- {"[", SYSTST},
-*/
+ /*{"[", SYSTST},*/
{"set", SYSSET},
{":", SYSNULL},
{"trap", SYSTRAP},
{"exec", SYSEXEC},
{"times", SYSTIMES},
{"umask", SYSUMASK},
- {0, 0},
-}
+ {0, 0}
+};
static char sccsid[] = "@(#)name.c 4.4 10/31/85";
#endif
-#
/*
* UNIX shell
*
extern bool chkid();
-struct namnod ps2nod = { NIL, NIL, ps2name},
- fngnod = { NIL, NIL, fngname},
- pathnod = { NIL, NIL, pathname},
- ifsnod = { NIL, NIL, ifsname},
- ps1nod = { &pathnod, &ps2nod, ps1name},
- homenod = { &fngnod, &ifsnod, homename},
- mailnod = { &homenod, &ps1nod, mailname}
+struct namnod ps2nod = { NULL, NULL, ps2name},
+ fngnod = { NULL, NULL, fngname},
+ pathnod = { NULL, NULL, pathname},
+ ifsnod = { NULL, NULL, ifsname},
+ ps1nod = { &pathnod, &ps2nod, ps1name},
+ homenod = { &fngnod, &ifsnod, homename},
+ mailnod = { &homenod, &ps1nod, mailname};
-struct namnod *namep = &mailnod;
+struct namnod *namep = &mailnod;
/* ======== variable and string handling ======== */
/* add name node */
nscan=alloc(sizeof *nscan);
- nscan->namlft=nscan->namrgt=NIL;
+ nscan->namlft=nscan->namrgt=NULL;
nscan->namid=make(nam);
nscan->namval=0; nscan->namflg=N_DEFAULT; nscan->namenv=0;
return(*prev = nscan);
p=movstr(n->namid,staktop);
p=movstr("=",p);
p=movstr(n->namval,p);
- return(getstak(p+1-(void *)(stakbot)));
+ return(getstak(p+1-stakbot));
}
void exname(n)
/* name.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*
char *namval;
char *namenv;
int namflg;
-}
+};
static char sccsid[] = "@(#)print.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
static char sccsid[] = "@(#)service.c 4.4 3/19/85";
#endif
-#
/*
* UNIX shell
*
else if (c==0) {
s--;
}
- if (c=expand((argp=endstak(argp))->argval,0)) {
+ if (c=expand(((struct argnod *)(argp=endstak(argp)))->argval,0)) {
count += c;
}
else {
static char sccsid[] = "@(#)setbrk.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
static char sccsid[] = "@(#)stak.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
#include "defs.h"
+/* moved here from stak.h, which now just declares them extern */
+struct blk *stakbsy;
+char *stakbas;
+char *brkend;
+char *staktop;
+
char *stakbot=nullstr;
/* stak.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*
* have become covered by heap allocation.
* `tdystak' will return them to the heap.
*/
-struct blk *stakbsy;
+extern struct blk *stakbsy;
/* Base of the entire stack */
-char *stakbas;
+extern char *stakbas;
/* Top of entire stack */
-char *brkend;
+extern char *brkend;
/* Base of current item */
-char *stakbot;
+extern char *stakbot;
/* Top of current item */
-char *staktop;
+extern char *staktop;
/* Used with tdystak */
char *savstak();
static char sccsid[] = "@(#)string.c 4.2 8/11/83";
#endif
-#
/*
* UNIX shell
*
/* sym.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*/
/* for peekc */
#define MARK 0100000
-
-/* odd chars */
-#define DQUOTE '"'
-#define SQUOTE '`'
-#define LITERAL '\''
-#define DOLLAR '$'
-#define ESCAPE '\\'
-#define BRACE '{'
/* timeout.h 4.1 82/05/07 */
-#
/*
* UNIX shell
*
--- /dev/null
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+# defs.h
+s/@alloc@/@malloc@/g
+s/@rename@/@_rename@/g
+
+# mode.h
+s/@BYTESPERWORD@/@sizeof(char *)@/g
+
+# sym.h
+s/@DQUOTE@/@'"'@/g
+s/@SQUOTE@/@'`'@/g
+s/@LITERAL@/@'\\''@/g
+s/@DOLLAR@/@'$'@/g
+s/@ESCAPE@/@'\\\\'@/g
+s/@BRACE@/@'{'@/g
+
+s/@//g
+s/ATSIGN/@/g
static char sccsid[] = "@(#)word.c 4.6 10/31/85";
#endif
-#
/*
* UNIX shell
*
}
} while ((c=nextc(0), !eofmeta(c)));
argp=endstak(argp);
- if (!letter(argp->argval[0])) { wdset=0; }
+ if (!letter(((struct argnod *)argp)->argval[0])) { wdset=0; }
peekc=c|MARK;
- if (argp->argval[1]==0 && (d=argp->argval[0], digit(d)) && (c=='>' || c=='<')) {
+ if (((struct argnod *)argp)->argval[1]==0 && (d=((struct argnod *)argp)->argval[0], digit(d)) && (c=='>' || c=='<')) {
word(); wdnum=d-'0';
}
else {
/*check for reserved words*/
- if (reserv==0 || (wdval=syslook(argp->argval,reserved))==0) {
- wdarg=argp; wdval=0;
+ if (reserv==0 || (wdval=syslook(((struct argnod *)argp)->argval,reserved))==0) {
+ wdarg=(struct argnod *)argp; wdval=0;
}
}
static char sccsid[] = "@(#)xec.c 4.3 8/11/83";
#endif
-#
/*
* UNIX shell
*
static int parent;
-struct sysnod commands[];
+extern struct sysnod commands[];
int *pf1, *pf2;
{
/* `stakbot' is preserved by this routine */
- register struct trenod *t;
+ register struct trenod *_t;
char *sav=savstak();
sigchk();
- if ((t=argt) && execbrk==0) {
- register int treeflgs;
+ if ((_t=argt) && execbrk==0) {
+ register int treeflgs;
int oldexit, type;
register char **com;
- treeflgs = t->tretyp; type = treeflgs&COMMSK;
+ treeflgs = _t->tretyp; type = treeflgs&COMMSK;
oldexit=exitval; exitval=0;
switch (type) {
case TCOM:
+#define t ((struct comnod *)_t)
{
-
char *a1;
int argn, internal;
struct argnod *schain=gchain;
- struct ionod *io=t->treio;
+ struct ionod *io=t->comio;
gchain=0;
argn = getarg(t);
com=scan(argn);
case SYSTIMES:
{
- long t[4]; times(t);
- prt(t[2]); blank(); prt(t[3]); newline();
+ long tm[4]; times(tm);
+ prt(tm[2]); blank(); prt(tm[3]); newline();
}
break;
case SYSUMASK:
if (a1) {
- int c, i
+ int c, i;
i = 0;
while ((c = *a1++) >= '0' &&
c <= '7')
break;
}
}
- else if (t->treio==0) {
+ else if (t->comio==0) {
break;
}
}
+ /* fallthru */
case TFORK:
if (execflg && (treeflgs&(FAMP|FPOU))==0) {
/* except for those `lost' by trap */
oldsigs();
if (treeflgs&FINT) {
- signal(INTR,1); signal(QUIT,1);
+ signal(INTR,SIG_IGN); signal(QUIT,SIG_IGN);
}
/* pipe in or out */
}
/* io redirection */
- initio(t->treio);
+ initio(t->comio);
if (type!=TCOM) {
- execute(t->forktre,1);
+ execute(((struct forknod *)t)->forktre,1);
}
else if (com[0]!=ENDARGS) {
setlist(t->comset,N_EXPORT);
}
done();
}
+#undef t
case TPAR:
+#define t ((struct parnod *)_t)
rename(dup(2),output);
execute(t->partre,execflg);
done();
+#undef t
case TFIL:
+#define t ((struct lstnod *)_t)
{
-
int pv[2]; chkpipe(pv);
if (execute(t->lstlef, 0, pf1, pv)==0) {
execute(t->lstrit, execflg, pv, pf2);
}
}
break;
+#undef t
case TLST:
+#define t ((struct lstnod *)_t)
execute(t->lstlef,0);
execute(t->lstrit,execflg);
break;
+#undef t
case TAND:
+#define t ((struct lstnod *)_t)
if (execute(t->lstlef,0)==0) {
execute(t->lstrit,execflg);
}
break;
+#undef t
case TORF:
+#define t ((struct lstnod *)_t)
if (execute(t->lstlef,0)!=0) {
execute(t->lstrit,execflg);
}
break;
+#undef t
case TFOR:
+#define t ((struct fornod *)_t)
{
-
struct namnod *n = lookup(t->fornam);
char **args;
struct dolnod *argsav=0;
argfor=freeargs(argsav);
}
break;
+#undef t
case TWH:
case TUN:
+#define t ((struct whnod *)_t)
{
-
int i=0;
loopcnt++;
execbrk=breakcnt; loopcnt--; exitval=i;
}
break;
+#undef t
case TIF:
+#define t ((struct ifnod *)_t)
if (execute(t->iftre,0)==0) {
execute(t->thtre,execflg);
}
execute(t->eltre,execflg);
}
break;
+#undef t
case TSW:
+#define t ((struct swnod *)_t)
{
-
register char *r = mactrim(t->swarg);
- t=t->swlst;
- while (t) {
- struct argnod *rex=t->regptr;
+ struct regnod *u = t->swlst;
+ while (u) {
+ struct argnod *rex=u->regptr;
while (rex) {
register char *s;
if (gmatch(r,s=macro(rex->argval)) || (trim(s), eq(r,s))) {
- execute(t->regcom,0);
- t=0; break;
+ execute(u->regcom,0);
+ u=0; break;
}
else {
rex=rex->argnxt;
}
}
- if (t) { t=t->regnxt; }
+ if (u) { u=u->regnxt; }
}
}
break;
+#undef t
}
exitset();
}
QUOTE [\"\']
%s CPP1 INIT1 INIT2 CURLY LEXYACC ASM CPP_INLINE
+
+/* Nick has hacked in a start condition check on the newline below, */
+/* so that if CPP1 we can do the same thing but also BEGIN INITIAL */
+
%%
-\n { save_text(); cur_file->line_num++;
+<INITIAL,INIT1,INIT2,CURLY,LEXYACC,ASM,CPP_INLINE>\n { save_text(); cur_file->line_num++;
cur_declarator = NULL; }
"/*" { save_text(); get_comment(); }
finishCpp();
}
+<CPP1>\n { save_text(); cur_file->line_num++;
+ cur_declarator = NULL; BEGIN INITIAL; /* Nick */ }
<CPP1>. { save_text(); get_cpp_directive(NULL, 0); }
<INITIAL>"(" { save_text_offset(); return '('; }
#all_h=`find . -type f -name '*.h' -print |sed -e 's:^\./::' |LC_ALL=C sort`
#all_h=`find $INCLUDE -type f -name '*.h' -print |LC_ALL=C sort`
+rm -f ansify.log
+
if test -z "$1" || test $1 -eq 0
then
echo "===stage 0==="
#mkdir -p $INCLUDE
#(cd $ROOT/include && $SCRIPTS/make.sh SHARED=copies install)
fi
-fi
+fi >>ansify.log
all_c=`echo *.c`
if test "$all_c" = "*.c"
rm $INCLUDE/stdint.h $INCLUDE/stdarg.h
mv $INCLUDE/varargs.h.save $INCLUDE/varargs.h
sed -e 's/^\/\*AAA\(.*\)\*\/$/\1/' -i $std_h
-fi
+fi >>ansify.log
all_h=`echo *.h`
if test "$all_h" = "*.h"
fi
fi
done
-fi
+fi >>ansify.log
if test -z "$1" || test $1 -eq 3
then
) |$SCRIPTS/newline >b
mv b $i
done
-fi
+fi >>ansify.log
if test -z "$1" || test $1 -eq 4
then
done
rm -f $INCLUDE/stdarg.h temp.c
tsort <a >b
-fi
+fi >>ansify.log
#if test -z "$1" || test $1 -eq 5
#then
# echo "i=$i"
# cp $INCLUDE/sys/`basename $i` $ROOT/sys/h
# done
-#fi
+#fi >>ansify.log