STRING *argv;
INT argc;
{
- REG STRING cp;
- REG STRING *argp=argv;
- REG STRING flagc;
+ register STRING cp;
+ register STRING *argp=argv;
+ register STRING flagc;
STRING flagp;
if (argc>1 && *argp[1]=='-'
STRING argi[];
{
/* count args */
- REG STRING *argp=argi;
- REG INT argn=0;
+ register STRING *argp=argi;
+ register INT argn=0;
while(Rcheat(*argp++)!=ENDARGS ){argn++ ;}
freeargs(blk)
DOLPTR blk;
{
- REG STRING *argp;
- REG DOLPTR argr=0;
- REG DOLPTR argblk;
+ register STRING *argp;
+ register DOLPTR argr=0;
+ register DOLPTR argblk;
if (argblk=blk
) { argr = argblk->dolnxt;
static STRING * copyargs(from, n)
STRING from[];
{
- REG STRING * np=(STRING *)alloc(sizeof(STRING*)*n+3*BYTESPERWORD);
- REG STRING * fp=from;
- REG STRING * pp=np;
+ register STRING * np=(STRING *)alloc(sizeof(STRING*)*n+3*BYTESPERWORD);
+ register STRING * fp=from;
+ register STRING * pp=np;
((DOLPTR)np)->doluse=1; /* use count */
np=(STRING *)((DOLPTR)np)->dolarg;
ADDRESS alloc(nbytes)
POS nbytes;
{
- REG POS rbytes = round(nbytes+BYTESPERWORD,BYTESPERWORD);
+ register POS rbytes = round(nbytes+BYTESPERWORD,BYTESPERWORD);
for (;;) { INT c=0;
- REG BLKPTR p = blokp;
- REG BLKPTR q;
+ register BLKPTR p = blokp;
+ register BLKPTR q;
do { if(!busy(p)
) { while(!busy(q = p->word) ){p->word = q->word ;}
if(ADR(q)-ADR(p) >= rbytes
POS reqd;
{
if(stakbas!=staktop
- ) { REG STKPTR rndstak;
- REG BLKPTR blokstak;
+ ) { register STKPTR rndstak;
+ register BLKPTR blokstak;
pushstak(0);
rndstak=(STKPTR)round(staktop,BYTESPERWORD);
bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd);
bloktop->word=BLK(ADR(end)+1);
{
- REG STKPTR stakadr=STK(bloktop+2);
+ register STKPTR stakadr=STK(bloktop+2);
staktop=movstr(stakbot,stakadr);
stakbas=stakbot=stakadr;
}
BLKPTR ptr;
{
INT exf=0;
- REG BLKPTR p = end;
- REG BLKPTR q;
+ register BLKPTR p = end;
+ register BLKPTR q;
INT us=0, un=0;
for (;;) {
INT flgs;
TREPTR i;
{
- REG FORKPTR t;
+ register FORKPTR t;
t=(FORKPTR)getstak(FORKTYPE);
t->forktyp=flgs|TFORK;
INT type;
TREPTR i, r;
{
- REG LSTPTR t;
+ register LSTPTR t;
if (i==0 || r==0
) { synbad();
*/
TREPTR cmd(sym,flg)
- REG INT sym;
+ register INT sym;
INT flg;
{
- REG TREPTR i, e;
+ register TREPTR i, e;
i = list(flg);
static TREPTR list(flg)
{
- REG TREPTR r;
- REG INT b;
+ register TREPTR r;
+ register INT b;
r = term(flg);
while(r && ((b=(wdval==ANDFSYM)) || wdval==ORFSYM)
static TREPTR term(flg)
{
- REG TREPTR t;
+ register TREPTR t;
reserv++;
if (flg&NLFLG
}
static REGPTR syncase(esym)
- REG INT esym;
+ register INT esym;
{
skipnl();
if (wdval==esym
) { return(0);
- } else { REG REGPTR r=(REGPTR)getstak(REGTYPE);
+ } else { register REGPTR r=(REGPTR)getstak(REGTYPE);
r->regptr=0;
for(;;) {
wdarg->argnxt=r->regptr;
static TREPTR item(flag)
BOOL flag;
{
- REG TREPTR t;
- REG IOPTR io;
+ register TREPTR t;
+ register IOPTR io;
if (flag
) { io=inout((IOPTR)0);
case IFSYM:
{
- REG INT w;
+ register INT w;
t=(TREPTR)getstak(IFTYPE);
((IFPTR)t)->iftyp=TIF;
((IFPTR)t)->iftre=cmd(THSYM,NLFLG);
case '(':
{
- REG PARPTR p;
+ register PARPTR p;
p=(PARPTR)getstak(PARTYPE);
p->partre=cmd(')',NLFLG);
p->partyp=TPAR;
case 0:
{
- REG ARGPTR argp;
- REG ARGPTR *argtail;
- REG ARGPTR *argset=0;
+ register ARGPTR argp;
+ register ARGPTR *argtail;
+ register ARGPTR *argset=0;
INT keywd=1;
t=(TREPTR)getstak(COMTYPE);
((COMPTR)t)->comio=io; /*initial io chain*/
static IOPTR inout(lastio)
IOPTR lastio;
{
- REG INT iof;
- REG IOPTR iop;
- REG CHAR c;
+ register INT iof;
+ register IOPTR iop;
+ register CHAR c;
iof=wdnum;
static void chksym(sym)
{
- REG INT x = sym&wdval;
+ register INT x = sym&wdval;
if (((x&SYMFLG) ? x : sym) != wdval
) { synbad();
;}
static void prsym(sym)
{
if (sym&SYMFLG
- ) { REG SYSPTR sp=reserved;
+ ) { register SYSPTR sp=reserved;
while(sp->sysval
&& sp->sysval!=sym
){sp++ ;}
done()
{
- REG STRING t;
+ register STRING t;
if (t=trapcom[0]
) { trapcom[0]=0; /*should free but not long */
execexp(t,0);
INT count, dirf;
BOOL dir=0;
STRING rescan = 0;
- REG STRING s, cs;
+ register STRING s, cs;
ARGPTR schain = gchain;
struct dirent entry;
STATBUF statb;
/* check for meta chars */
{
- REG BOOL slash; slash=0;
+ register BOOL slash; slash=0;
while(!fngchar(*cs)
){if (*cs++==0
) { if (rflg && slash ) { break; } else { return(0) ;}
if (*cs==0 ) { *cs++=0200 ;}
if (dir
) { /* check for rescan */
- REG STRING rs; rs=cs;
+ register STRING rs; rs=cs;
do { if (*rs=='/' ) { rescan=rs; *rs=0; gchain=0 ;}
} while(*rs++ );
close(dirf);
if (rescan
- ) { REG ARGPTR rchain;
+ ) { register ARGPTR rchain;
rchain=gchain; gchain=schain;
if (count
) { count=0;
;}
{
- REG CHAR c;
+ register CHAR c;
s=as;
while(c = *s
){*s++=(c&STRIP?c:'/') ;}
}
gmatch(s, p)
- REG STRING s, p;
+ register STRING s, p;
{
- REG INT scc;
+ register INT scc;
CHAR c;
if (scc = *s++
static void addg(as1,as2,as3)
STRING as1, as2, as3;
{
- REG STRING s1, s2;
- REG INT c;
+ register STRING s1, s2;
+ register INT c;
s2 = locstak()+BYTESPERWORD;
}
makearg(args)
- REG STRING args;
+ register STRING args;
{
((ARGPTR)args)->argnxt=gchain;
gchain=(ARGPTR)args;
void fault(sig)
- REG INT sig;
+ register INT sig;
{
- REG INT flag;
+ register INT flag;
signal(sig,fault);
if(sig==MEMF
ignsig(n)
{
- REG INT s, i;
+ register INT s, i;
#if 0
// FIXME: need to do proper SIG_IGN checks/handling
if((s=signal(i=n,1)&01)==0
getsig(n)
{
- REG INT i;
+ register INT i;
if(trapflg[i=n]&SIGMOD || ignsig(i)==0
) { signal(i,fault);
oldsigs()
{
- REG INT i;
- REG STRING t;
+ register INT i;
+ register STRING t;
i=MAXTRAP;
while(i--
chktrap()
{
/* check for traps */
- REG INT i=MAXTRAP;
- REG STRING t;
+ register INT i=MAXTRAP;
+ register STRING t;
trapnote &= ~TRAPSET;
while(--i
initf(fd)
UFD fd;
{
- REG FILE f=standin;
+ register FILE f=standin;
f->fdes=fd; f->fsiz=((flags&(oneflg|ttyflg))==0 ? BUFSIZ : 1);
f->fnxt=f->fend=f->fbuf; f->feval=0; f->flin=1;
}
estabf(s)
- REG STRING s;
+ register STRING s;
{
- REG FILE f;
+ register FILE f;
(f=standin)->fdes = -1;
f->fend=length(s)+(f->fnxt=s);
push(af)
FILE af;
{
- REG FILE f;
+ register FILE f;
(f=af)->fstak=standin;
f->feof=0; f->feval=0;
pop()
{
- REG FILE f;
+ register FILE f;
if((f=standin)->fstak
) { if(f->fdes>=0 ) { close(f->fdes) ;}
chkopen(idf)
STRING idf;
{
- REG INT rc;
+ register INT rc;
if((rc=open(idf,0))<0
) { failed(idf,badopen);
}
sh_rename(f1,f2)
- REG INT f1, f2;
+ register INT f1, f2;
{
if(f1!=f2
) { dup2(f1, f2);
create(s)
STRING s;
{
- REG INT rc;
+ register INT rc;
if((rc=creat(s,0666))<0
) { failed(s,badcreate);
IOPTR ioparg;
{
CHAR c, *ends;
- REG CHAR *cline, *clinep;
+ register CHAR *cline, *clinep;
INT fd;
- REG IOPTR iop;
+ register IOPTR iop;
if(iop=ioparg
) { copy(iop->iolst);
#define TYPE typedef
#define STRUCT TYPE struct
#define UNION TYPE union
-#define REG register
#define TRUE (-1)
static STRING copyto(endch)
- REG CHAR endch;
+ register CHAR endch;
{
- REG CHAR c;
+ register CHAR c;
while((c=getch(endch))!=endch && c
){pushstak(c|quote) ;}
}
static skipto(endch)
- REG CHAR endch;
+ register CHAR endch;
{
/* skip chars up to } */
- REG CHAR c;
+ register CHAR c;
while((c=readc()) && c!=endch
){ switch(c) {
static getch(endch)
CHAR endch;
{
- REG CHAR d;
+ register CHAR d;
retry:
d=readc();
) { return(d);
;}
if(d==DOLLAR
- ) { REG INT c;
+ ) { register INT c;
if((c=readc(), dolchar(c))
) { NAMPTR n=(NAMPTR)NIL;
INT dolg=0;
BOOL bra;
- REG STRING argp, v;
+ register STRING argp, v;
CHAR idb[2];
STRING id=idb;
/* Strip "" and do $ substitution
* Leaves result on top of stack
*/
- REG BOOL savqu =quoted;
- REG CHAR savq = quote;
+ register BOOL savqu =quoted;
+ register CHAR savq = quote;
FILEHDR fb;
push(&fb); estabf(as);
{
/* command substn */
FILEBLK cb;
- REG CHAR d;
- REG STKPTR savptr = fixstak();
+ register CHAR d;
+ register STKPTR savptr = fixstak();
usestak();
while((d=readc())!=SQUOTE && d
){pushstak(d) ;}
{
- REG STRING argc;
+ register STRING argc;
trim(argc=fixstak());
push(&cb); estabf(argc);
}
{
- REG TREPTR t = makefork(FPOU,cmd(EOFSYM,MTFLG|NLFLG));
+ register TREPTR t = makefork(FPOU,cmd(EOFSYM,MTFLG|NLFLG));
INT pv[2];
/* this is done like this so that the pipe
subst(in,ot)
INT in, ot;
{
- REG CHAR c;
+ register CHAR c;
FILEBLK fb;
- REG INT count=CPYSIZ;
+ register INT count=CPYSIZ;
push(&fb); initf(in);
/* DQUOTE used to stop it from quoting */
INT c;
STRING v[];
{
- REG INT rflag=ttyflg;
+ register INT rflag=ttyflg;
/* initialise storage allocation */
stdsigs();
static void exfile(prof)
BOOL prof;
{
- REG L_INT mailtime = 0;
- REG INT userid;
+ register L_INT mailtime = 0;
+ register INT userid;
struct stat statb;
/* move input */
}
Ldup(fa, fb)
- REG INT fa, fb;
+ register INT fa, fb;
{
dup2(fa, fb);
close(fa);
STRING w;
SYSTAB syswds;
{
- REG CHAR first;
- REG STRING s;
- REG SYSPTR syscan;
+ register CHAR first;
+ register STRING s;
+ register SYSPTR syscan;
syscan=syswds; first = *w;
}
setlist(arg,xp)
- REG ARGPTR arg;
+ register ARGPTR arg;
INT xp;
{
while(arg
- ){REG STRING s=mactrim(arg->argval);
+ ){register STRING s=mactrim(arg->argval);
setname(s, xp);
arg=arg->argnxt;
if (flags&execpr
STRING argi;
INT xp;
{
- REG STRING argscan=argi;
- REG NAMPTR n;
+ register STRING argscan=argi;
+ register NAMPTR n;
if (letter(*argscan)
) { while(alphanum(*argscan) ){argscan++ ;}
}
replace(a, v)
- REG STRING *a;
+ register STRING *a;
STRING v;
{
free(*a); *a=make(v);
STRING *names;
{
FILEBLK fb;
- REG FILE f = &fb;
- REG CHAR c;
- REG INT rc=0;
+ register FILE f = &fb;
+ register CHAR c;
+ register INT rc=0;
NAMPTR n=lookup(*names++); /* done now to avoid storage mess */
STKPTR rel=(STKPTR)relstak();
STRING make(v)
STRING v;
{
- REG STRING p;
+ register STRING p;
if (v
) { movstr(v,p=alloc(length(v)));
NAMPTR lookup(nam)
- REG STRING nam;
+ register STRING nam;
{
- REG NAMPTR nscan=namep;
- REG NAMPTR *prev;
+ register NAMPTR nscan=namep;
+ register NAMPTR *prev;
INT LR;
if (!chkid(nam)
static BOOL chkid(nam)
STRING nam;
{
- REG CHAR * cp=nam;
+ register CHAR * cp=nam;
if (!letter(*cp)
) { return(FALSE);
}
static void namwalk(np)
- REG NAMPTR np;
+ register NAMPTR np;
{
if (np
) { namwalk(np->namlft);
void printnam(n)
NAMPTR n;
{
- REG STRING s;
+ register STRING s;
sigchk();
if (s=n->namval
}
static STRING staknam(n)
- REG NAMPTR n;
+ register NAMPTR n;
{
- REG STRING p;
+ register STRING p;
p=movstr(n->namid,staktop);
p=movstr("=",p);
}
void exname(n)
- REG NAMPTR n;
+ register NAMPTR n;
{
if (n->namflg&N_EXPORT
) { free(n->namenv);
}
void printflg(n)
- REG NAMPTR n;
+ register NAMPTR n;
{
if (n->namflg&N_EXPORT
) { prs(export); blank();
void sh_getenv(void)
{
- REG STRING *e=environ;
+ register STRING *e=environ;
while(*e
){setname(*e++, N_ENVNAM) ;}
STRING *sh_setenv(void)
{
- REG STRING *er;
+ register STRING *er;
namec=0;
namscan(countnam);
void prs(as)
STRING as;
{
- REG STRING s;
+ register STRING s;
if (s=as
) { write(output,s,length(s)-1);
prt(t)
L_INT t;
{
- REG INT hr, min, sec;
+ register INT hr, min, sec;
t += 30; t /= 60;
sec=t%60; t /= 60;
itos(n)
{
- REG char *abuf; REG POS a, i; INT pr, d;
+ register char *abuf; register POS a, i; INT pr, d;
abuf=numbuf; pr=FALSE; a=n;
for (i=10000; i!=1; i/=10
){ if ((pr |= (d=a/i)) ) { *abuf++=d+'0' ;}
stoi(icp)
STRING icp;
{
- REG CHAR *cp = icp;
- REG INT r = 0;
- REG CHAR c;
+ register CHAR *cp = icp;
+ register INT r = 0;
+ register CHAR c;
while((c = *cp, digit(c)) && c && r>=0
){ r = r*10 + c - '0'; cp++ ;}
void initio(iop)
IOPTR iop;
{
- REG STRING ion;
- REG INT iof, fd;
+ register STRING ion;
+ register INT iof, fd;
if(iop
) { iof=iop->iofile;
STRING getpath(s)
STRING s;
{
- REG STRING path;
+ register STRING path;
if(any('/',s)
) { if(flags&rshflg
) { failed(s, restricted);
}
INT pathopen(path, name)
- REG STRING path, name;
+ register STRING path, name;
{
- REG UFD f;
+ register UFD f;
do { path=catpath(path,name);
} while ( (f=open(curstak(),0))<0 && path );
}
STRING catpath(path,name)
- REG STRING path;
+ register STRING path;
STRING name;
{
/* leaves result on top of stack */
- REG STRING scanp = path,
+ register STRING scanp = path,
argp = locstak();
while(*scanp && *scanp!=COLON ){*argp++ = *scanp++ ;}
void execa(at)
STRING at[];
{
- REG STRING path;
- REG STRING *t = at;
+ register STRING path;
+ register STRING *t = at;
if((flags&noexec)==0
) { xecmsg=notfound; path=getpath(*t);
static STRING execs(ap,t)
STRING ap;
- REG STRING t[];
+ register STRING t[];
{
- REG STRING p, prefix;
+ register STRING p, prefix;
prefix=catpath(ap,t[0]);
trim(p=curstak());
postclr()
{
- REG INT *pw = pwlist;
+ register INT *pw = pwlist;
while(pw <= &pwlist[pwc]
){*pw++ = 0 ;}
void post(pcsid)
INT pcsid;
{
- REG INT *pw = pwlist;
+ register INT *pw = pwlist;
if(pcsid
) { while(*pw ){pw++ ;}
post(i);
while(pwc
- ){ REG INT p;
- REG INT sig;
+ ){ register INT p;
+ register INT sig;
INT w_hi;
{
- REG INT *pw=pwlist;
+ register INT *pw=pwlist;
p=wait(&w);
while(pw <= &pwlist[ipwc]
){if(*pw==p
trim(at)
STRING at;
{
- REG STRING p;
- REG CHAR c;
- REG CHAR q=0;
+ register STRING p;
+ register CHAR c;
+ register CHAR q=0;
if(p=at
) { while(c = *p
STRING mactrim(s)
STRING s;
{
- REG STRING t=macro(s);
+ register STRING t=macro(s);
trim(t);
return(t);
}
STRING *scan(argn)
INT argn;
{
- REG ARGPTR argp = (ARGPTR)(Rcheat(gchain)&~ARGMK);
- REG STRING *comargn, *comargm;
+ register ARGPTR argp = (ARGPTR)(Rcheat(gchain)&~ARGMK);
+ register STRING *comargn, *comargm;
comargn=(STRING *)getstak(BYTESPERWORD*argn+BYTESPERWORD); comargm = comargn += argn; *comargn = ENDARGS;
STRING from[], to[];
{
INT k, m, n;
- REG INT i, j;
+ register INT i, j;
if((n=to-from)<=1 ) { return ;}
){ k=n-m;
for (j=0; j<k; j++
){ for (i=j; i>=0; i-=m
- ){ REG STRING *fromi; fromi = &from[i];
+ ){ register STRING *fromi; fromi = &from[i];
if(cf(fromi[m],fromi[0])>0
) { break;
} else { STRING s; s=fromi[m]; fromi[m]=fromi[0]; fromi[0]=s;
INT getarg(ac)
COMPTR ac;
{
- REG ARGPTR argp;
- REG INT count=0;
- REG COMPTR c;
+ register ARGPTR argp;
+ register INT count=0;
+ register COMPTR c;
if(c=ac
) { argp=c->comarg;
}
static INT split(s)
- REG STRING s;
+ register STRING s;
{
- REG STRING argp;
- REG INT c;
+ register STRING argp;
+ register INT c;
INT count=0;
for(;;) {
STKPTR getstak(asize)
INT asize;
{ /* allocate requested stack */
- REG STKPTR oldstak;
- REG INT size;
+ register STKPTR oldstak;
+ register INT size;
size=round(asize,BYTESPERWORD);
oldstak=stakbot;
}
STKPTR endstak(argp)
- REG STRING argp;
+ register STRING argp;
{ /* tidy up after `locstak' */
- REG STKPTR oldstak;
+ register STKPTR oldstak;
*argp++=0;
oldstak=stakbot; stakbot=staktop=(STKPTR)round(argp,BYTESPERWORD);
return(oldstak);
}
void tdystak(x)
- REG STKPTR x;
+ register STKPTR x;
{
/* try to bring stack back to x */
while(ADR(stakbsy)>ADR(x)
STRING movstr(a,b)
- REG STRING a, b;
+ register STRING a, b;
{
while(*b++ = *a++ );
return(--b);
}
INT any(c,s)
- REG CHAR c;
+ register CHAR c;
STRING s;
{
- REG CHAR d;
+ register CHAR d;
while(d = *s++
){if(d==c
}
INT cf(s1, s2)
- REG STRING s1, s2;
+ register STRING s1, s2;
{
while(*s1++ == *s2
){if(*s2++==0
INT length(as)
STRING as;
{
- REG STRING s;
+ register STRING s;
if(s=as ) { while(*s++ ); ;}
return(s-as);
word()
{
- REG CHAR c, d;
- REG CHAR *argp=locstak()+BYTESPERWORD;
+ register CHAR c, d;
+ register CHAR *argp=locstak()+BYTESPERWORD;
INT alpha=1;
wdnum=0; wdset=0;
nextc(quote)
CHAR quote;
{
- REG CHAR c, d;
+ register CHAR c, d;
if((d=readc())==ESCAPE
) { if((c=readc())==NL
) { chkpr(NL); d=nextc(quote);
readc()
{
- REG CHAR c;
- REG INT len;
- REG FILE f;
+ register CHAR c;
+ register INT len;
+ register FILE f;
retry:
if(peekc
static readb()
{
- REG FILE f=standin;
- REG INT len;
+ register FILE f=standin;
+ register INT len;
do { if(trapnote&SIGSET ) { newline(); sigchk() ;}
} while ( (len=read(f->fdes,f->fbuf,f->fsiz))<0 && trapnote );
INT *pf1, *pf2;
{
/* `stakbot' is preserved by this routine */
- REG TREPTR t;
+ register TREPTR t;
STKPTR sav=savstak();
sigchk();
if( (t=argt) && execbrk==0
- ) { REG INT treeflgs;
+ ) { register INT treeflgs;
INT oldexit, type;
- REG STRING *com;
+ register STRING *com;
treeflgs = t->tretyp; type = treeflgs&COMMSK;
oldexit=exitval; exitval=0;
case SYSDOT:
if( a1
- ) { REG INT f;
+ ) { register INT f;
if( (f=pathopen(getpath(a1), a1)) < 0
) { failed(a1,notfound);
case TSW:
{
- REG STRING r = mactrim(((SWPTR)t)->swarg);
+ register STRING r = mactrim(((SWPTR)t)->swarg);
t=(TREPTR)((SWPTR)t)->swlst;
while(t
){ARGPTR rex=((REGPTR)t)->regptr;
while(rex
- ){REG STRING s;
+ ){register STRING s;
if( gmatch(r,s=macro(rex->argval)) || (trim(s), eq(r,s))
) { execute(((REGPTR)t)->regcom,0);
t=0; break;