) { comdiv=argp[2];
argp[1]=argp[0]; argp++; argc--;
} else { failed(argv[1],badopt);
- FI
+ ;}
OD
argp[1]=argp[0]; argc--;
- FI
+ ;}
/* set up $- */
flagc=flagchar;
WHILE *flagc
DO IF flags&flagval[flagc-flagchar]
) { *flagp++ = *flagc;
- FI
+ ;}
flagc++;
OD
*flagp++=0;
) { FOR argp=(STRING *)argblk->dolarg; Rcheat(*argp)!=ENDARGS; argp++
DO free(*argp) OD
free(argblk);
- FI
- FI
+ ;}
+ ;}
return(argr);
}
dolh->dolnxt=argfor;
return(argfor=dolh);
} else { return(0);
- FI
+ ;}
}
) { blokp = BLK(ADR(p)+rbytes);
IF q > blokp
) { blokp->word = p->word;
- FI
+ ;}
p->word=BLK(Rcheat(blokp)|BUSY);
return(ADR(p+1));
- FI
- FI
+ ;}
+ ;}
q = p; p = BLK(Rcheat(p->word)&~BUSY);
PER p>q || (c++)==0 DONE
addblok(rbytes);
blokstak->word=stakbsy; stakbsy=blokstak;
bloktop->word=BLK(Rcheat(rndstak)|BUSY);
bloktop=BLK(rndstak);
- FI
+ ;}
reqd += brkincr; reqd &= ~(brkincr-1);
blokp=bloktop;
bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd);
IF (p=ap) && p<bloktop
) { Lcheat((--p)->word) &= ~BUSY;
- FI
+ ;}
}
#ifdef DEBUG
for (;;) {
q = Rcheat(p->word)&~BUSY;
- IF p==ptr ) { exf++ FI
- IF q<end || q>bloktop ) { abort(3) FI
- IF p==bloktop ) { break FI
+ IF p==ptr ) { exf++ ;}
+ IF q<end || q>bloktop ) { abort(3) ;}
+ IF p==bloktop ) { break ;}
IF busy(p)
) { us += q-p;
} else { un += q-p;
- FI
- IF p>=q ) { abort(4) FI
+ ;}
+ IF p>=q ) { abort(4) ;}
p=q;
}
- IF exf==0 ) { abort(1) FI
+ IF exf==0 ) { abort(1) ;}
prn(un); prc(SP); prn(us); prc(NL);
}
#endif
} else { t = (LSTPTR)getstak(LSTTYPE);
t->lsttyp = type;
t->lstlef = i; t->lstrit = r;
- FI
+ ;}
return(TREPTR)(t);
}
IF wdval==NL
) { IF flg&NLFLG
) { wdval=';'; chkpr(NL);
- FI
+ ;}
} else if ( i==0 && (flg&MTFLG)==0
) { synbad();
- FI
+ ;}
switch(wdval) {
IF i
) { i = makefork(FINT|FPRS|FAMP, i);
} else { synbad();
- FI
+ ;}
case ';':
IF e=cmd(sym,flg|MTFLG)
) { i=makelist(TLST, i, e);
- FI
+ ;}
break;
case EOFSYM:
IF sym==NL
) { break;
- FI
+ ;}
default:
IF sym
) { chksym(sym);
- FI
+ ;}
}
return(i);
IF flg&NLFLG
) { skipnl();
} else { word();
- FI
+ ;}
IF (t=item(TRUE)) && (wdval=='^' || wdval=='|')
) { return(makelist(TFIL, makefork(FPOU,t), makefork(FPIN|FPCL,term(NLFLG))));
} else { return(t);
- FI
+ ;}
}
static REGPTR syncase(esym)
r->regptr=wdarg;
IF wdval || ( word()!=')' && wdval!='|' )
) { synbad();
- FI
+ ;}
IF wdval=='|'
) { word();
} else { break;
- FI
+ ;}
}
r->regcom=cmd(0,NLFLG|MTFLG);
IF wdval==ECSYM
) { r->regnxt=syncase(esym);
} else { chksym(esym);
r->regnxt=0;
- FI
+ ;}
return(r);
- FI
+ ;}
}
/*
IF flag
) { io=inout((IOPTR)0);
} else { io=0;
- FI
+ ;}
switch(wdval) {
((IFPTR)t)->iftre=cmd(THSYM,NLFLG);
((IFPTR)t)->thtre=cmd(ELSYM|FISYM|EFSYM,NLFLG);
((IFPTR)t)->eltre=((w=wdval)==ELSYM ? cmd(FISYM,NLFLG) : (w==EFSYM ? (wdval=IFSYM, item(0)) : 0));
- IF w==EFSYM ) { return(t) FI
+ IF w==EFSYM ) { return(t) ;}
break;
}
((FORPTR)t)->forlst=(COMPTR)item(0);
IF wdval!=NL && wdval!=';'
) { synbad();
- FI
+ ;}
chkpr(wdval); skipnl();
- FI
+ ;}
chksym(DOSYM|BRSYM);
((FORPTR)t)->fortre=cmd(wdval==DOSYM?ODSYM:KTSYM,NLFLG);
break;
default:
IF io==0
) { return(0);
- FI
+ ;}
case 0:
{
) { argp->argnxt=(ARGPTR)argset;
argset=(ARGPTR *)argp;
} else { *argtail=argp; argtail = &(argp->argnxt); keywd=flags&keyflg;
- FI
+ ;}
word();
IF flag
) { ((COMPTR)t)->comio=inout(((COMPTR)t)->comio);
- FI
+ ;}
OD
((COMPTR)t)->comtyp=TCOM;
reserv++; word();
IF io=inout(io)
) { t=makefork(0,t); t->treio=io;
- FI
+ ;}
return(t);
}
case APPSYM:
case '>':
- IF wdnum==0 ) { iof |= 1 FI
+ IF wdnum==0 ) { iof |= 1 ;}
iof |= IOPUT;
IF wdval==APPSYM
) { iof |= IOAPP; break;
- FI
+ ;}
case '<':
IF (c=nextc(0))=='&'
} else if ( c=='>'
) { iof |= IORDW;
} else { peekc=c|MARK;
- FI
+ ;}
break;
default:
iop->iofile=iof;
IF iof&IODOC
) { iop->iolst=iopend; iopend=iop;
- FI
+ ;}
word(); iop->ionxt=inout(lastio);
return(iop);
}
{
IF word()
) { synbad();
- FI
+ ;}
}
static void chksym(sym)
REG INT x = sym&wdval;
IF ((x&SYMFLG) ? x : sym) != wdval
) { synbad();
- FI
+ ;}
}
static void prsym(sym)
prs(sp->sysnam);
} else if ( sym==EOFSYM
) { prs(endoffile);
- } else { IF sym&SYMREP ) { prc(sym) FI
+ } else { IF sym&SYMREP ) { prc(sym) ;}
IF sym==NL
) { prs("newline");
} else { prc(sym);
- FI
- FI
+ ;}
+ ;}
}
static void synbad()
prp(); prs(synmsg);
IF (flags&ttyflg)==0
) { prs(atline); prn(standin->flin);
- FI
+ ;}
prs(colon);
prc(LQ);
IF wdval
) { prsym(wdval);
} else { prs(wdarg->argval);
- FI
+ ;}
prc(RQ); prs(unexpected);
newline();
exitsh(SYNBAD);
*/
IF trapnote&SIGSET
) { exitsh(SIGFAIL);
- FI
+ ;}
}
failed(s1,s2)
prp(); prs(s1);
IF s2
) { prs(colon); prs(s2);
- FI
+ ;}
newline(); exitsh(ERROR);
}
} else {
clearup();
longjmp(errshell,1);
- FI
+ ;}
}
done()
IF t=trapcom[0]
) { trapcom[0]=0; /*should free but not long */
execexp(t,0);
- FI
+ ;}
rmtemp(0);
exit(exitval);
}
struct dirent entry;
STATBUF statb;
- IF trapnote&SIGSET ) { return(0); FI
+ IF trapnote&SIGSET ) { return(0); ;}
s=cs=as; entry.d_name[DIRSIZ-1]=0; /* to end the string */
REG BOOL slash; slash=0;
WHILE !fngchar(*cs)
DO IF *cs++==0
- ) { IF rflg && slash ) { break; } else { return(0) FI
+ ) { IF rflg && slash ) { break; } else { return(0) ;}
} else if ( *cs=='/'
) { slash++;
- FI
+ ;}
OD
}
break;
} else if ( *--cs == '/'
) { *cs=0;
- IF s==cs ) { s="/" FI
+ IF s==cs ) { s="/" ;}
break;
- FI
+ ;}
}
IF stat(s,&statb)>=0
&& (statb.st_mode&S_IFMT)==S_IFDIR
&& (dirf=open(s,0))>0
) { dir++;
- FI
+ ;}
count=0;
- IF *cs==0 ) { *cs++=0200 FI
+ IF *cs==0 ) { *cs++=0200 ;}
IF dir
) { /* check for rescan */
REG STRING rs; rs=cs;
- REP IF *rs=='/' ) { rescan=rs; *rs=0; gchain=0 FI
+ REP IF *rs=='/' ) { rescan=rs; *rs=0; gchain=0 ;}
PER *rs++ DONE
// FIXME: readdir
DO IF entry.d_ino==0 ||
(*entry.d_name=='.' && *cs!='.')
) { continue;
- FI
+ ;}
IF gmatch(entry.d_name, cs)
) { addg(s,entry.d_name,rescan); count++;
- FI
+ ;}
OD
close(dirf);
DO count += expand(rchain->argval,1);
rchain=rchain->argnxt;
OD
- FI
+ ;}
*rescan='/';
- FI
- FI
+ ;}
+ ;}
{
REG CHAR c;
IF scc = *s++
) { IF (scc &= STRIP)==0
) { scc=0200;
- FI
- FI
+ ;}
+ ;}
switch(c = *p++) {
case '[':
{BOOL ok; INT lc;
DO IF c==']'
) { return(ok?gmatch(s,p):0);
} else if ( c==MINUS
- ) { IF lc<=scc && scc<=(*p++) ) { ok++ FI
- } else { IF scc==(lc=(c&STRIP)) ) { ok++ FI
- FI
+ ) { IF lc<=scc && scc<=(*p++) ) { ok++ ;}
+ } else { IF scc==(lc=(c&STRIP)) ) { ok++ ;}
+ ;}
OD
return(0);
}
default:
- IF (c&STRIP)!=scc ) { return(0) FI
+ IF (c&STRIP)!=scc ) { return(0) ;}
case '?':
return(scc?gmatch(s,p):0);
case '*':
- IF *p==0 ) { return(1) FI
+ IF *p==0 ) { return(1) ;}
--s;
WHILE *s
- DO IF gmatch(s++,p) ) { return(1) FI OD
+ DO IF gmatch(s++,p) ) { return(1) ;} OD
return(0);
case 0:
DO IF (c &= STRIP)==0
) { *s2++='/';
break;
- FI
+ ;}
*s2++=c;
OD
s1=as2;
IF s1=as3
) { *s2++='/';
WHILE *s2++ = *++s1 DONE
- FI
+ ;}
makearg(endstak(s2));
}
IF sig==MEMF
) { IF setbrk(brkincr) == -1
) { error(nospace);
- FI
+ ;}
} else if (sig==ALARM
) { IF flags&waiting
) { done();
- FI
+ ;}
} else { flag = (trapcom[sig] ? TRAPSET : SIGSET);
trapnote |= flag;
trapflg[sig] |= flag;
- FI
+ ;}
}
stdsigs()
// FIXME: need to do proper SIG_IGN checks/handling
IF (s=signal(i=n,1)&01)==0
) { trapflg[i] |= SIGMOD;
- FI
+ ;}
#endif
return(s);
}
IF trapflg[i=n]&SIGMOD || ignsig(i)==0
) { signal(i,fault);
- FI
+ ;}
}
oldsigs()
DO t=trapcom[i];
IF t==0 || *t
) { clrsig(i);
- FI
+ ;}
trapflg[i]=0;
OD
trapnote=0;
IF trapflg[i]&SIGMOD
) { signal(i,fault);
trapflg[i] &= ~SIGMOD;
- FI
+ ;}
}
chktrap()
) { INT savxit=exitval;
execexp(t,0);
exitval=savxit; exitset();
- FI
- FI
+ ;}
+ ;}
OD
}
REG FILE f;
IF (f=standin)->fstak
- ) { IF f->fdes>=0 ) { close(f->fdes) FI
+ ) { IF f->fdes>=0 ) { close(f->fdes) ;}
standin=f->fstak;
return(TRUE);
} else { return(FALSE);
- FI
+ ;}
}
chkpipe(pv)
{
IF pipe(pv)<0 || pv[INPIPE]<0 || pv[OTPIPE]<0
) { error(piperr);
- FI
+ ;}
}
chkopen(idf)
IF (rc=open(idf,0))<0
) { failed(idf,badopen);
} else { return(rc);
- FI
+ ;}
}
sh_rename(f1,f2)
IF f1!=f2
) { dup2(f1, f2);
close(f1);
- IF f2==0 ) { ioset|=1 FI
- FI
+ IF f2==0 ) { ioset|=1 ;}
+ ;}
}
create(s)
IF (rc=creat(s,0666))<0
) { failed(s,badcreate);
} else { return(rc);
- FI
+ ;}
}
tmpfil()
IF iop=ioparg
) { copy(iop->iolst);
- ends=mactrim(iop->ioname); IF nosubst ) { iop->iofile &= ~IODOC FI
+ ends=mactrim(iop->ioname); IF nosubst ) { iop->iofile &= ~IODOC ;}
fd=tmpfil();
iop->ioname=cpystak(tmpout);
iop->iolst=iotemp; iotemp=iop;
clinep=cline; chkpr(NL);
WHILE (c = (nosubst ? readc() : nextc(*ends)), !eolchar(c)) DO *clinep++ = c OD
*clinep=0;
- IF eof || eq(cline,ends) ) { break FI
+ IF eof || eq(cline,ends) ) { break ;}
*clinep++=NL;
write(fd,cline,clinep-cline);
}
close(fd);
- FI
+ ;}
}
#define REG register
#define IF if(
-#define FI ;}
#define FOR for(
#define WHILE while(
WHILE (c=getch(endch))!=endch && c
DO pushstak(c|quote) OD
zerostak();
- IF c!=endch ) { error(badsub) FI
+ IF c!=endch ) { error(badsub) ;}
}
static skipto(endch)
case DOLLAR: IF readc()==BRACE
) { skipto('}');
- FI
+ ;}
}
OD
- IF c!=endch ) { error(badsub) FI
+ IF c!=endch ) { error(badsub) ;}
}
static getch(endch)
d=readc();
IF !subchar(d)
) { return(d);
- FI
+ ;}
IF d==DOLLAR
) { REG INT c;
IF (c=readc(), dolchar(c))
CHAR idb[2];
STRING id=idb;
- IF bra=(c==BRACE) ) { c=readc() FI
+ IF bra=(c==BRACE) ) { c=readc() ;}
IF letter(c)
) { argp=(STRING)relstak();
WHILE alphanum(c) DO pushstak(c); c=readc() OD
) { *id=c; idb[1]=0;
IF astchar(c)
) { dolg=1; c='1';
- FI
+ ;}
c -= '0';
v=((c==0) ? cmdadr : (c<=dolc) ? dolv[c] : (STRING)(dolg=0));
} else if ( c=='$'
) { v=flagadr;
} else if ( bra ) { error(badsub);
} else { goto retry;
- FI
+ ;}
c = readc();
IF !defchar(c) && bra
) { error(badsub);
- FI
+ ;}
argp=0;
IF bra
) { IF c!='}'
IF (v==0)^(setchar(c))
) { copyto('}');
} else { skipto('}');
- FI
+ ;}
argp=absstak(argp);
- FI
+ ;}
} else { peekc = c|MARK; c = 0;
- FI
+ ;}
IF v
) { IF c!='+'
) { for (;;) {
IF dolg==0 || (++dolg>dolc)
) { break;
} else { v=dolv[dolg]; pushstak(SP|(*id=='*' ? quote : 0));
- FI
+ ;}
}
- FI
+ ;}
} else if ( argp
) { IF c=='?'
) { failed(id,*argp?argp:badparam);
) { IF n
) { assign(n,argp);
} else { error(badsub);
- FI
- FI
+ ;}
+ ;}
} else if ( flags&setflg
) { failed(id,badparam);
- FI
+ ;}
goto retry;
} else { peekc=c|MARK;
- FI
+ ;}
} else if ( d==endch
) { return(d);
} else if ( d==SQUOTE
) { comsubst(); goto retry;
} else if ( d==DQUOTE
) { quoted++; quote^=QUOTE; goto retry;
- FI
+ ;}
return(d);
}
quote=0; quoted=0;
copyto(0);
pop();
- IF quoted && (stakbot==staktop) ) { pushstak(QUOTE) FI
+ IF quoted && (stakbot==staktop) ) { pushstak(QUOTE) ;}
quote=savq; quoted=savqu;
return(fixstak());
}
WHILE stakbot!=staktop
DO IF (*--staktop&STRIP)!=NL
) { ++staktop; break;
- FI
+ ;}
OD
pop();
}
DO pushstak(c);
IF --count == 0
) { flush(ot); count=CPYSIZ;
- FI
+ ;}
OD
flush(ot);
pop();
static flush(ot)
{
write(ot,stakbot,staktop-stakbot);
- IF flags&execpr ) { write(output,stakbot,staktop-stakbot) FI
+ IF flags&execpr ) { write(output,stakbot,staktop-stakbot) ;}
staktop=stakbot;
}
sh_getenv();
/* look for restricted */
-/* IF c>0 && any('r', *v) ) { rflag=0 FI */
+/* IF c>0 && any('r', *v) ) { rflag=0 ;} */
/* look for options */
dolc=options(c,v);
- IF dolc<2 ) { flags |= stdflg FI
+ IF dolc<2 ) { flags |= stdflg ;}
IF (flags&stdflg)==0
) { dolc--;
- FI
+ ;}
dolv=v+c-dolc; dolc--;
/* return here for shell file execution */
IF *cmdadr=='-'
&& (input=pathopen(nullstr, profile))>=0
) { exfile(rflag); flags &= ~ttyflg;
- FI
- IF rflag==0 ) { flags |= rshflg FI
+ ;}
+ IF rflag==0 ) { flags |= rshflg ;}
/* open input file if specified */
IF comdiv
) { estabf(comdiv); input = -1;
} else { input=((flags&stdflg) ? 0 : chkopen(cmdadr));
comdiv--;
- FI
+ ;}
// } else { *execargs=(char *)dolv; /* for `ps' cmd */
- FI
+ ;}
exfile(0);
done();
IF input>0
) { Ldup(input,INIO);
input=INIO;
- FI
+ ;}
/* move output to safe place */
IF output==2
) { Ldup(dup(2),OTIO);
output=OTIO;
- FI
+ ;}
userid=getuid();
flags |= ttyflg|prompt; ignsig(KILL);
} else {
flags |= prof; flags &= ~prompt;
- FI
+ ;}
IF setjmp(errshell) && prof
) { close(input); return;
- FI
+ ;}
/* error return here */
loopcnt=breakcnt=peekc=0; iopend=0;
- IF input>=0 ) { initf(input) FI
+ IF input>=0 ) { initf(input) ;}
/* command loop */
for(;;) {
&& (statb.st_mtime != mailtime)
&& mailtime
) { prs(mailmsg)
- FI
+ ;}
mailtime=statb.st_mtime;
prs(ps1nod.namval); alarm(TIMEOUT); flags |= waiting;
- FI
+ ;}
trapnote=0; peekc=readc();
IF eof
) { return;
- FI
+ ;}
alarm(0); flags &= ~waiting;
execute(cmd(NL,MTFLG),0);
eof |= (flags&oneflg);
{
IF (flags&prompt) && standin->fstak==0 && eor==NL
) { prs(ps2nod.namval);
- FI
+ ;}
}
settmp()
DO IF first == *s
&& eq(w,s)
) { return(syscan->sysval);
- FI
+ ;}
syscan++;
OD
return(0);
arg=arg->argnxt;
IF flags&execpr
) { prs(s);
- IF arg ) { blank(); } else { newline(); FI
- FI
+ IF arg ) { blank(); } else { newline(); ;}
+ ;}
OD
}
IF xp&N_ENVNAM
) { n->namenv = n->namval = argscan;
} else { assign(n, argscan);
- FI
+ ;}
return;
- FI
- FI
+ ;}
+ ;}
failed(argi,notid);
}
{
IF n->namval==0
) { assign(n,v)
- FI
+ ;}
}
assign(n,v)
IF n->namflg&N_RDONLY
) { failed(n->namid,wtfailed);
} else { replace(&n->namval,v);
- FI
+ ;}
}
INT readvar(names)
push(f); initf(dup(0));
IF lseek(0,0L,1)==-1
) { f->fsiz=1;
- FI
+ ;}
for(;;) {
c=nextc(0);
IF *names
) { n=lookup(*names++);
} else { n=0;
- FI
+ ;}
IF eolchar(c)
) { break;
- FI
+ ;}
} else { pushstak(c);
- FI
+ ;}
}
WHILE n
DO assign(n, nullstr);
- IF *names ) { n=lookup(*names++); } else { n=0; FI
+ IF *names ) { n=lookup(*names++); } else { n=0; ;}
OD
- IF eof ) { rc=1 FI
+ IF eof ) { rc=1 ;}
lseek(0, (long)(f->fnxt-f->fend), 1);
pop();
return(rc);
) { movstr(v,p=alloc(length(v)));
return(p);
} else { return(0);
- FI
+ ;}
}
IF !chkid(nam)
) { failed(nam,notid);
- FI
+ ;}
WHILE nscan
DO IF (LR=cf(nam,nscan->namid))==0
) { return(nscan);
} else if ( LR<0
) { prev = &(nscan->namlft);
} else { prev = &(nscan->namrgt);
- FI
+ ;}
nscan = *prev;
OD
} else { WHILE *++cp
DO IF !alphanum(*cp)
) { return(FALSE);
- FI
+ ;}
OD
- FI
+ ;}
return(TRUE);
}
) { namwalk(np->namlft);
(*namfn)(np);
namwalk(np->namrgt);
- FI
+ ;}
}
void printnam(n)
) { prs(n->namid);
prc('='); prs(s);
newline();
- FI
+ ;}
}
static STRING staknam(n)
n->namenv = make(n->namval);
} else { free(n->namval);
n->namval = make(n->namenv);
- FI
+ ;}
}
void printflg(n)
{
IF n->namflg&N_EXPORT
) { prs(export); blank();
- FI
+ ;}
IF n->namflg&N_RDONLY
) { prs(readonly); blank();
- FI
+ ;}
IF n->namflg&(N_EXPORT|N_RDONLY)
) { prs(n->namid); newline();
- FI
+ ;}
}
void sh_getenv(void)
{
IF n->namval
) { *argnam++ = staknam(n);
- FI
+ ;}
}
STRING *sh_setenv(void)
{
IF (flags&prompt)==0 && cmdadr
) { prs(cmdadr); prs(colon);
- FI
+ ;}
}
void prs(as)
IF s=as
) { write(output,s,length(s)-1);
- FI
+ ;}
}
void prc(c)
{
IF c
) { write(output,&c,1);
- FI
+ ;}
}
prt(t)
min=t%60;
IF hr=t/60
) { prn(hr); prc('h');
- FI
+ ;}
prn(min); prc('m');
prn(sec); prc('s');
}
REG char *abuf; REG POS a, i; INT pr, d;
abuf=numbuf; pr=FALSE; a=n;
FOR i=10000; i!=1; i/=10
- DO IF (pr |= (d=a/i)) ) { *abuf++=d+'0' FI
+ DO IF (pr |= (d=a/i)) ) { *abuf++=d+'0' ;}
a %= i;
OD
*abuf++=a+'0';
IF r<0 || cp==icp
) { failed(icp,badnum);
} else { return(r);
- FI
+ ;}
}
} else if ( (fd=stoi(ion))>=USERIO
) { failed(ion,badfile);
} else { fd=dup(fd);
- FI
+ ;}
} else if ( (iof&IOPUT)==0
) { fd=chkopen(ion);
} else if ( flags&rshflg
} else if ( iof&IOAPP && (fd=open(ion,1))>=0
) { lseek(fd, 0L, 2);
} else { fd=create(ion);
- FI
+ ;}
IF fd>=0
) { sh_rename(fd,iof&IOUFD);
- FI
- FI
+ ;}
+ ;}
initio(iop->ionxt);
- FI
+ ;}
}
STRING getpath(s)
) { IF flags&rshflg
) { failed(s, restricted);
} else { return(nullstr);
- FI
+ ;}
} else if ( (path = pathnod.namval)==0
) { return(defpath);
} else { return(cpystak(path));
- FI
+ ;}
}
INT pathopen(path, name)
argp = locstak();
WHILE *scanp && *scanp!=COLON DO *argp++ = *scanp++ OD
- IF scanp!=path ) { *argp++='/' FI
- IF *scanp==COLON ) { scanp++ FI
+ IF scanp!=path ) { *argp++='/' ;}
+ IF *scanp==COLON ) { scanp++ ;}
path=(*scanp ? scanp : 0); scanp=name;
WHILE (*argp++ = *scanp++) DONE
return(path);
xecenv=sh_setenv();
WHILE path=execs(path,t) DONE
failed(*t,xecmsg);
- FI
+ ;}
}
static STRING execs(ap,t)
flags=0;
comdiv=0; ioset=0;
clearup(); /* remove open files and for loop junk */
- IF input ) { close(input) FI
+ IF input ) { close(input) ;}
close(output); output=2;
input=chkopen(p);
IF pwc >= MAXP-1
) { pw--;
} else { pwc++;
- FI
+ ;}
*pw = pcsid;
- FI
+ ;}
}
void await(i)
DO IF *pw==p
) { *pw=0; pwc--;
} else { pw++;
- FI
+ ;}
OD
}
- IF p == -1 ) { continue FI
+ IF p == -1 ) { continue ;}
w_hi = (w>>8)&LOBYTE;
) { IF sig == 0177 /* ptrace! return */
) { prs("ptrace: ");
sig = w_hi;
- FI
+ ;}
IF sysmsg[sig]
- ) { IF i!=p || (flags&prompt)==0 ) { prp(); prn(p); blank() FI
+ ) { IF i!=p || (flags&prompt)==0 ) { prp(); prn(p); blank() ;}
prs(sysmsg[sig]);
- IF w&0200 ) { prs(coredump) FI
- FI
+ IF w&0200 ) { prs(coredump) ;}
+ ;}
newline();
- FI
+ ;}
IF rc==0
) { rc = (sig ? sig|SIGFLG : w_hi);
- FI
+ ;}
wx |= w;
OD
IF wx && flags&errflg
) { exitsh(rc);
- FI
+ ;}
exitval=rc; exitset();
}
IF p=at
) { WHILE c = *p
DO *p++=c&STRIP; q |= c OD
- FI
+ ;}
nosubst=q"E;
}
DO *--comargn = argp->argval;
IF argp = argp->argnxt
) { trim(*comargn);
- FI
+ ;}
IF argp==0 || Rcheat(argp)&ARGMK
) { gsort(comargn,comargm);
comargm = comargn;
- FI
+ ;}
/* Lcheat(argp) &= ~ARGMK; */
argp = (ARGPTR)(Rcheat(argp)&~ARGMK);
OD
INT k, m, n;
REG INT i, j;
- IF (n=to-from)<=1 ) { return FI
+ IF (n=to-from)<=1 ) { return ;}
FOR j=1; j<=n; j*=2 DONE
IF cf(fromi[m],fromi[0])>0
) { break;
} else { STRING s; s=fromi[m]; fromi[m]=fromi[0]; fromi[0]=s;
- FI
+ ;}
OD
OD
OD
DO count += split(macro(argp->argval));
argp=argp->argnxt;
OD
- FI
+ ;}
return(count);
}
) { IF c
) { continue;
} else { return(count);
- FI
+ ;}
} else if (c==0
) { s--;
- FI
+ ;}
IF c=expand(((ARGPTR)(argp=endstak(argp)))->argval,0)
) { count += c;
} else { /* assign(&fngnod, argp->argval); */
makearg(argp); count++;
- FI
+ ;}
Lcheat(gchain) |= ARGMK;
}
}
) { setbrk(brkincr);
IF brkincr < BRKMAX
) { brkincr += 256;
- FI
- FI
+ ;}
+ ;}
return(stakbot);
}
{
IF (brkend-stakbas)>BRKINCR+BRKINCR
) { setbrk(-BRKINCR);
- FI
+ ;}
}
STKPTR cpystak(x)
WHILE d = *s++
DO IF d==c
) { return(TRUE);
- FI
+ ;}
OD
return(FALSE);
}
WHILE *s1++ == *s2
DO IF *s2++==0
) { return(0);
- FI
+ ;}
OD
return(*--s1 - *s2);
}
{
REG STRING s;
- IF s=as ) { WHILE *s++ DONE FI
+ IF s=as ) { WHILE *s++ DONE ;}
return(s-as);
}
DO *argp++=(c|QUOTE); chkpr(c) OD
*argp++=(DQUOTE);
} else { *argp++=(c);
- IF c=='=' ) { wdset |= alpha FI
- IF !alphanum(c) ) { alpha=0 FI
+ IF c=='=' ) { wdset |= alpha ;}
+ IF !alphanum(c) ) { alpha=0 ;}
IF qotchar(c)
) { d=c;
WHILE (*argp++=(c=nextc(d))) && c!=d
DO chkpr(c) OD
- FI
- FI
+ ;}
+ ;}
PER (c=nextc(0), !eofmeta(c)) DONE
argp=endstak(argp);
- IF !letter(((ARGPTR)argp)->argval[0]) ) { wdset=0 FI
+ IF !letter(((ARGPTR)argp)->argval[0]) ) { wdset=0 ;}
peekc=c|MARK;
IF ((ARGPTR)argp)->argval[1]==0 && (d=((ARGPTR)argp)->argval[0], digit(d)) && (c=='>' || c=='<')
} else { /*check for reserved words*/
IF reserv==FALSE || (wdval=syslook(((ARGPTR)argp)->argval,reserved))==0
) { wdarg=(ARGPTR)argp; wdval=0;
- FI
- FI
+ ;}
+ ;}
} else if ( dipchar(c)
) { IF (d=nextc(0))==c
) { wdval = c|SYMREP;
} else { peekc = d|MARK; wdval = c;
- FI
+ ;}
} else { IF (wdval=c)==EOF
) { wdval=EOFSYM;
- FI
+ ;}
IF iopend && eolchar(c)
) { copy(iopend); iopend=0;
- FI
- FI
+ ;}
+ ;}
reserv=FALSE;
return(wdval);
}
} else if ( quote && c!=quote && !escchar(c)
) { peekc=c|MARK;
} else { d = c|QUOTE;
- FI
- FI
+ ;}
+ ;}
return(d);
}
) { IF estabf(*f->feval++)
) { c=EOF;
} else { c=SP;
- FI
+ ;}
} else { goto retry; /* = c=readc(); */
- FI
- FI
- IF flags&readpr && standin->fstak==0 ) { prc(c) FI
- IF c==NL ) { f->flin++ FI
+ ;}
+ ;}
+ IF flags&readpr && standin->fstak==0 ) { prc(c) ;}
+ IF c==NL ) { f->flin++ ;}
} else if ( f->feof || f->fdes<0
) { c=EOF; f->feof++;
} else if ( (len=readb())<=0
) { close(f->fdes); f->fdes = -1; c=EOF; f->feof++;
} else { f->fend = (f->fnxt = f->fbuf)+len;
goto retry;
- FI
+ ;}
return(c);
}
REG FILE f=standin;
REG INT len;
- REP IF trapnote&SIGSET ) { newline(); sigchk() FI
+ REP IF trapnote&SIGSET ) { newline(); sigchk() ;}
PER (len=read(f->fdes,f->fbuf,f->fsiz))<0 && trapnote DONE
return(len);
}
IF (internal=syslook(com[0],commands)) || argn==0
) { setlist(((COMPTR)t)->comset, 0);
- FI
+ ;}
IF argn && (flags&noexec)==0
) { /* print command if execpr */
WHILE com[argn]!=ENDARGS
DO prs(com[argn++]); blank() OD
newline();
- FI
+ ;}
switch(internal) {
IF (f=pathopen(getpath(a1), a1)) < 0
) { failed(a1,notfound);
} else { execexp(0,f);
- FI
- FI
+ ;}
+ ;}
break;
case SYSTIMES:
case SYSBREAK:
IF (execbrk=loopcnt) && a1
) { breakcnt=stoi(a1);
- FI
+ ;}
break;
case SYSTRAP:
) { BOOL clear;
IF (clear=digit(*a1))==0
) { ++com;
- FI
+ ;}
WHILE *++com
DO INT i;
IF (i=stoi(*com))>=MAXTRAP || i<MINTRAP
IF *a1
) { getsig(i);
} else { ignsig(i);
- FI
- FI
+ ;}
+ ;}
OD
} else { /* print out current traps */
INT i;
FOR i=0; i<MAXTRAP; i++
DO IF trapcom[i]
) { prn(i); prs(colon); prs(trapcom[i]); newline();
- FI
+ ;}
OD
- FI
+ ;}
break;
case SYSEXEC:
com++;
initio(io); ioset=0; io=0;
- IF a1==0 ) { break FI
+ IF a1==0 ) { break ;}
case SYSLOGIN:
flags |= forked;
) { failed(com[0],restricted);
} else if ( (a1==0 && (a1=homenod.namval)==0) || chdir(a1)<0
) { failed(a1,baddir);
- FI
+ ;}
break;
case SYSSHFT:
IF dolc<1
) { error(badshift);
} else { dolv++; dolc--;
- FI
+ ;}
assnum(&dolladr, dolc);
break;
argc = options(argn,com);
IF argc>1
) { setargs(com+argn-argc);
- FI
+ ;}
} else if ( ((COMPTR)t)->comset==0
) { /*scan name chain and print*/
namscan(printnam);
- FI
+ ;}
break;
case SYSRDONLY:
exitval=N_RDONLY;
case SYSXPORT:
- IF exitval==0 ) { exitval=N_EXPORT; FI
+ IF exitval==0 ) { exitval=N_EXPORT; ;}
IF a1
) { WHILE *++com
DO attrib(lookup(*com), exitval) OD
} else { namscan(printflg);
- FI
+ ;}
exitval=0;
break;
case SYSEVAL:
IF a1
) { execexp(a1,&com[2]);
- FI
+ ;}
break;
case SYSUMASK:
}
IF internal
- ) { IF io ) { error(illegal) FI
+ ) { IF io ) { error(illegal) ;}
chktrap();
break;
- FI
+ ;}
} else if ( t->treio==0
) { break;
- FI
+ ;}
}
case TFORK:
) { parent=0;
} else { WHILE (parent=fork()) == -1
DO sigchk(); alarm(10); pause() OD
- FI
+ ;}
IF parent
) { /* This is the parent branch of fork; */
/* it may or may not wait for the child. */
IF treeflgs&FPRS && flags&ttyflg
) { prn(parent); newline();
- FI
- IF treeflgs&FPCL ) { closepipe(pf1) FI
+ ;}
+ IF treeflgs&FPCL ) { closepipe(pf1) ;}
IF (treeflgs&(FAMP|FPOU))==0
) { await(parent);
} else if ( (treeflgs&FAMP)==0
) { post(parent);
} else { assnum(&pcsadr, parent);
- FI
+ ;}
chktrap();
break;
oldsigs();
IF treeflgs&FINT
) { signal(INTR,1); signal(QUIT,1);
- FI
+ ;}
/* pipe in or out */
IF treeflgs&FPIN
) { sh_rename(pf1[INPIPE],0);
close(pf1[OTPIPE]);
- FI
+ ;}
IF treeflgs&FPOU
) { sh_rename(pf2[OTPIPE],1);
close(pf2[INPIPE]);
- FI
+ ;}
/* default std input for & */
IF treeflgs&FINT && ioset==0
) { sh_rename(chkopen(devnull),0);
- FI
+ ;}
/* io redirection */
initio(t->treio);
} else if ( com[0]!=ENDARGS
) { setlist(((COMPTR)t)->comset,N_EXPORT);
execa(com);
- FI
+ ;}
done();
- FI
+ ;}
case TPAR:
sh_rename(dup(2),output);
IF execute(((LSTPTR)t)->lstlef, 0, pf1, pv)==0
) { execute(((LSTPTR)t)->lstrit, execflg, pv, pf2);
} else { closepipe(pv);
- FI
+ ;}
}
break;
case TAND:
IF execute(((LSTPTR)t)->lstlef,0)==0
) { execute(((LSTPTR)t)->lstrit,execflg);
- FI
+ ;}
break;
case TORF:
IF execute(((LSTPTR)t)->lstlef,0)!=0
) { execute(((LSTPTR)t)->lstrit,execflg);
- FI
+ ;}
break;
case TFOR:
gchain=0;
trim((args=scan(getarg(((FORPTR)t)->forlst)))[0]);
gchain=schain;
- FI
+ ;}
loopcnt++;
WHILE *args!=ENDARGS && execbrk==0
DO assign(n,*args++);
execute(((FORPTR)t)->fortre,0);
- IF execbrk<0 ) { execbrk=0 FI
+ IF execbrk<0 ) { execbrk=0 ;}
OD
- IF breakcnt ) { breakcnt-- FI
+ IF breakcnt ) { breakcnt-- ;}
execbrk=breakcnt; loopcnt--;
argfor=freeargs(argsav);
}
loopcnt++;
WHILE execbrk==0 && (execute(((WHPTR)t)->whtre,0)==0)==(type==TWH)
DO i=execute(((WHPTR)t)->dotre,0);
- IF execbrk<0 ) { execbrk=0 FI
+ IF execbrk<0 ) { execbrk=0 ;}
OD
- IF breakcnt ) { breakcnt-- FI
+ IF breakcnt ) { breakcnt-- ;}
execbrk=breakcnt; loopcnt--; exitval=i;
}
break;
IF execute(((IFPTR)t)->iftre,0)==0
) { execute(((IFPTR)t)->thtre,execflg);
} else { execute(((IFPTR)t)->eltre,execflg);
- FI
+ ;}
break;
case TSW:
) { execute(((REGPTR)t)->regcom,0);
t=0; break;
} else { rex=((ARGPTR)rex)->argnxt;
- FI
+ ;}
OD
- IF t ) { t=(TREPTR)((REGPTR)t)->regnxt FI
+ IF t ) { t=(TREPTR)((REGPTR)t)->regnxt ;}
OD
}
break;
}
exitset();
- FI
+ ;}
sigchk();
tdystak(sav);
) { estabf(s); fb.feval=(STRING *)f;
} else if ( f>=0
) { initf(f);
- FI
+ ;}
execute(cmd(NL, NLFLG|MTFLG),0);
pop();
}