From 9bf114981936461766bd03035895403332c4e078 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 10 May 2015 21:53:23 +0100 Subject: [PATCH] sh: kill off ELIF --- Applications/V7/cmd/sh/args.c | 2 +- Applications/V7/cmd/sh/cmd.c | 6 +++--- Applications/V7/cmd/sh/expand.c | 6 +++--- Applications/V7/cmd/sh/fault.c | 2 +- Applications/V7/cmd/sh/mac.h | 1 - Applications/V7/cmd/sh/macro.c | 28 ++++++++++++++-------------- Applications/V7/cmd/sh/name.c | 2 +- Applications/V7/cmd/sh/service.c | 14 +++++++------- Applications/V7/cmd/sh/word.c | 10 +++++----- Applications/V7/cmd/sh/xec.c | 14 +++++++------- 10 files changed, 42 insertions(+), 43 deletions(-) diff --git a/Applications/V7/cmd/sh/args.c b/Applications/V7/cmd/sh/args.c index 2f2d1db6..b6de50da 100644 --- a/Applications/V7/cmd/sh/args.c +++ b/Applications/V7/cmd/sh/args.c @@ -46,7 +46,7 @@ INT options(argc,argv) WHILE *flagc && *flagc != *cp DO flagc++ OD IF *cp == *flagc THEN flags |= flagval[flagc-flagchar]; - ELIF *cp=='c' && argc>2 && comdiv==0 + } else if (*cp=='c' && argc>2 && comdiv==0 THEN comdiv=argp[2]; argp[1]=argp[0]; argp++; argc--; ELSE failed(argv[1],badopt); diff --git a/Applications/V7/cmd/sh/cmd.c b/Applications/V7/cmd/sh/cmd.c index 8083e518..3390c90b 100644 --- a/Applications/V7/cmd/sh/cmd.c +++ b/Applications/V7/cmd/sh/cmd.c @@ -79,7 +79,7 @@ TREPTR cmd(sym,flg) THEN IF flg&NLFLG THEN wdval=';'; chkpr(NL); FI - ELIF i==0 && (flg&MTFLG)==0 + } else if ( i==0 && (flg&MTFLG)==0 THEN synbad(); FI @@ -345,7 +345,7 @@ static IOPTR inout(lastio) case '<': IF (c=nextc(0))=='&' THEN iof |= IOMOV; - ELIF c=='>' + } else if ( c=='>' THEN iof |= IORDW; ELSE peekc=c|MARK; FI @@ -389,7 +389,7 @@ static void prsym(sym) && sp->sysval!=sym DO sp++ OD prs(sp->sysnam); - ELIF sym==EOFSYM + } else if ( sym==EOFSYM THEN prs(endoffile); ELSE IF sym&SYMREP THEN prc(sym) FI IF sym==NL diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index 4e7b67ef..0536f3a8 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -51,7 +51,7 @@ INT expand(as,rflg) WHILE !fngchar(*cs) DO IF *cs++==0 THEN IF rflg && slash THEN break; ELSE return(0) FI - ELIF *cs=='/' + } else if ( *cs=='/' THEN slash++; FI OD @@ -60,7 +60,7 @@ INT expand(as,rflg) for(;;) { IF cs==s THEN s=nullstr; break; - ELIF *--cs == '/' + } else if ( *--cs == '/' THEN *cs=0; IF s==cs THEN s="/" FI break; @@ -133,7 +133,7 @@ gmatch(s, p) WHILE c = *p++ DO IF c==']' THEN return(ok?gmatch(s,p):0); - ELIF c==MINUS + } else if ( c==MINUS THEN IF lc<=scc && scc<=(*p++) THEN ok++ FI ELSE IF scc==(lc=(c&STRIP)) THEN ok++ FI FI diff --git a/Applications/V7/cmd/sh/fault.c b/Applications/V7/cmd/sh/fault.c index 1defdb1f..fe5a2f3c 100644 --- a/Applications/V7/cmd/sh/fault.c +++ b/Applications/V7/cmd/sh/fault.c @@ -29,7 +29,7 @@ void fault(sig) THEN IF setbrk(brkincr) == -1 THEN error(nospace); FI - ELIF sig==ALARM + } else if (sig==ALARM THEN IF flags&waiting THEN done(); FI diff --git a/Applications/V7/cmd/sh/mac.h b/Applications/V7/cmd/sh/mac.h index bb7525c7..f302ab09 100644 --- a/Applications/V7/cmd/sh/mac.h +++ b/Applications/V7/cmd/sh/mac.h @@ -17,7 +17,6 @@ #define IF if( #define THEN ){ #define ELSE } else { -#define ELIF } else if ( #define FI ;} #define FOR for( diff --git a/Applications/V7/cmd/sh/macro.c b/Applications/V7/cmd/sh/macro.c index 2d6a9988..6e4ee3fd 100644 --- a/Applications/V7/cmd/sh/macro.c +++ b/Applications/V7/cmd/sh/macro.c @@ -1,5 +1,5 @@ /* UNIX V7 source code: see /COPYRIGHT or www.tuhs.org for details. */ -/* Changes: Copyright (c) 1999 Robert Nordier. All rights reserved. */ +/* Changes: Copyright (c) 1999 Robert Nordier. All rights reserved. */ # /* @@ -80,24 +80,24 @@ retry: n=lookup(absstak(argp)); setstak(argp); v = n->namval; id = n->namid; peekc = c|MARK;; - ELIF digchar(c) + } else if ( digchar(c) THEN *id=c; idb[1]=0; IF astchar(c) THEN dolg=1; c='1'; FI c -= '0'; v=((c==0) ? cmdadr : (c<=dolc) ? dolv[c] : (STRING)(dolg=0)); - ELIF c=='$' + } else if ( c=='$' THEN v=pidadr; - ELIF c=='!' + } else if ( c=='!' THEN v=pcsadr; - ELIF c=='#' + } else if ( c=='#' THEN v=dolladr; - ELIF c=='?' + } else if ( c=='?' THEN v=exitadr; - ELIF c=='-' + } else if ( c=='-' THEN v=flagadr; - ELIF bra THEN error(badsub); + } else if ( bra THEN error(badsub); ELSE goto retry; FI c = readc(); @@ -127,26 +127,26 @@ retry: FI } FI - ELIF argp + } else if ( argp THEN IF c=='?' THEN failed(id,*argp?argp:badparam); - ELIF c=='=' + } else if ( c=='=' THEN IF n THEN assign(n,argp); ELSE error(badsub); FI FI - ELIF flags&setflg + } else if ( flags&setflg THEN failed(id,badparam); FI goto retry; ELSE peekc=c|MARK; FI - ELIF d==endch + } else if ( d==endch THEN return(d); - ELIF d==SQUOTE + } else if ( d==SQUOTE THEN comsubst(); goto retry; - ELIF d==DQUOTE + } else if ( d==DQUOTE THEN quoted++; quote^=QUOTE; goto retry; FI return(d); diff --git a/Applications/V7/cmd/sh/name.c b/Applications/V7/cmd/sh/name.c index a22cb2d3..59a07df5 100644 --- a/Applications/V7/cmd/sh/name.c +++ b/Applications/V7/cmd/sh/name.c @@ -188,7 +188,7 @@ NAMPTR lookup(nam) WHILE nscan DO IF (LR=cf(nam,nscan->namid))==0 THEN return(nscan); - ELIF LR<0 + } else if ( LR<0 THEN prev = &(nscan->namlft); ELSE prev = &(nscan->namrgt); FI diff --git a/Applications/V7/cmd/sh/service.c b/Applications/V7/cmd/sh/service.c index 6427ad1f..f4e17c6f 100644 --- a/Applications/V7/cmd/sh/service.c +++ b/Applications/V7/cmd/sh/service.c @@ -46,19 +46,19 @@ void initio(iop) THEN IF iof&IODOC THEN subst(chkopen(ion),(fd=tmpfil())); close(fd); fd=chkopen(tmpout); unlink(tmpout); - ELIF iof&IOMOV + } else if ( iof&IOMOV THEN IF eq(minus,ion) THEN fd = -1; close(iof&IOUFD); - ELIF (fd=stoi(ion))>=USERIO + } else if ( (fd=stoi(ion))>=USERIO THEN failed(ion,badfile); ELSE fd=dup(fd); FI - ELIF (iof&IOPUT)==0 + } else if ( (iof&IOPUT)==0 THEN fd=chkopen(ion); - ELIF flags&rshflg + } else if ( flags&rshflg THEN failed(ion,restricted); - ELIF iof&IOAPP && (fd=open(ion,1))>=0 + } else if ( iof&IOAPP && (fd=open(ion,1))>=0 THEN lseek(fd, 0L, 2); ELSE fd=create(ion); FI @@ -79,7 +79,7 @@ STRING getpath(s) THEN failed(s, restricted); ELSE return(nullstr); FI - ELIF (path = pathnod.namval)==0 + } else if ( (path = pathnod.namval)==0 THEN return(defpath); ELSE return(cpystak(path)); FI @@ -357,7 +357,7 @@ static INT split(s) THEN continue; ELSE return(count); FI - ELIF c==0 + } else if (c==0 THEN s--; FI IF c=expand(((ARGPTR)(argp=endstak(argp)))->argval,0) diff --git a/Applications/V7/cmd/sh/word.c b/Applications/V7/cmd/sh/word.c index 50494bf7..fa6dd4e3 100644 --- a/Applications/V7/cmd/sh/word.c +++ b/Applications/V7/cmd/sh/word.c @@ -56,7 +56,7 @@ word() FI FI - ELIF dipchar(c) + } else if ( dipchar(c) THEN IF (d=nextc(0))==c THEN wdval = c|SYMREP; ELSE peekc = d|MARK; wdval = c; @@ -79,7 +79,7 @@ nextc(quote) IF (d=readc())==ESCAPE THEN IF (c=readc())==NL THEN chkpr(NL); d=nextc(quote); - ELIF quote && c!=quote && !escchar(c) + } else if ( quote && c!=quote && !escchar(c) THEN peekc=c|MARK; ELSE d = c|QUOTE; FI @@ -96,7 +96,7 @@ readc() retry: IF peekc THEN c=peekc; peekc=0; - ELIF (f=standin, f->fnxt!=f->fend) + } else if ( (f=standin, f->fnxt!=f->fend) THEN IF (c = *f->fnxt++)==0 THEN IF f->feval THEN IF estabf(*f->feval++) @@ -108,9 +108,9 @@ retry: FI IF flags&readpr && standin->fstak==0 THEN prc(c) FI IF c==NL THEN f->flin++ FI - ELIF f->feof || f->fdes<0 + } else if ( f->feof || f->fdes<0 THEN c=EOF; f->feof++; - ELIF (len=readb())<=0 + } else if ( (len=readb())<=0 THEN close(f->fdes); f->fdes = -1; c=EOF; f->feof++; ELSE f->fend = (f->fnxt = f->fbuf)+len; goto retry; diff --git a/Applications/V7/cmd/sh/xec.c b/Applications/V7/cmd/sh/xec.c index f1cf13f2..a1cbef8b 100644 --- a/Applications/V7/cmd/sh/xec.c +++ b/Applications/V7/cmd/sh/xec.c @@ -112,7 +112,7 @@ execute(argt, execflg, pf1, pf2) DO INT i; IF (i=stoi(*com))>=MAXTRAP || i1 THEN setargs(com+argn-argc); FI - ELIF ((COMPTR)t)->comset==0 + } else if ( ((COMPTR)t)->comset==0 THEN /*scan name chain and print*/ namscan(printnam); FI @@ -231,7 +231,7 @@ execute(argt, execflg, pf1, pf2) chktrap(); break; FI - ELIF t->treio==0 + } else if ( t->treio==0 THEN break; FI } @@ -252,7 +252,7 @@ execute(argt, execflg, pf1, pf2) IF treeflgs&FPCL THEN closepipe(pf1) FI IF (treeflgs&(FAMP|FPOU))==0 THEN await(parent); - ELIF (treeflgs&FAMP)==0 + } else if ( (treeflgs&FAMP)==0 THEN post(parent); ELSE assnum(&pcsadr, parent); FI @@ -293,7 +293,7 @@ execute(argt, execflg, pf1, pf2) initio(t->treio); IF type!=TCOM THEN execute(((FORKPTR)t)->forktre,1); - ELIF com[0]!=ENDARGS + } else if ( com[0]!=ENDARGS THEN setlist(((COMPTR)t)->comset,N_EXPORT); execa(com); FI @@ -416,7 +416,7 @@ execexp(s,f) push(&fb); IF s THEN estabf(s); fb.feval=(STRING *)f; - ELIF f>=0 + } else if ( f>=0 THEN initf(f); FI execute(cmd(NL, NLFLG|MTFLG),0); -- 2.34.1