From 3a7060b7241bdac65ecb70a0dfdb2eed5e57d153 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 10 May 2015 21:44:56 +0100 Subject: [PATCH] sh: remove LOOP/POOL and fix some bugs introduced earlier --- Applications/V7/cmd/sh/blok.c | 8 ++++---- Applications/V7/cmd/sh/cmd.c | 9 +++++---- Applications/V7/cmd/sh/expand.c | 4 ++-- Applications/V7/cmd/sh/io.c | 5 +++-- Applications/V7/cmd/sh/mac.h | 3 --- Applications/V7/cmd/sh/macro.c | 5 +++-- Applications/V7/cmd/sh/main.c | 5 +++-- Applications/V7/cmd/sh/name.c | 5 +++-- Applications/V7/cmd/sh/service.c | 5 +++-- Applications/V7/cmd/sh/xec.c | 2 +- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Applications/V7/cmd/sh/blok.c b/Applications/V7/cmd/sh/blok.c index d76fefe3..fd2fbed7 100644 --- a/Applications/V7/cmd/sh/blok.c +++ b/Applications/V7/cmd/sh/blok.c @@ -32,7 +32,7 @@ ADDRESS alloc(nbytes) { REG POS rbytes = round(nbytes+BYTESPERWORD,BYTESPERWORD); - LOOP INT c=0; + for (;;) { INT c=0; REG BLKPTR p = blokp; REG BLKPTR q; REP IF !busy(p) @@ -49,7 +49,7 @@ ADDRESS alloc(nbytes) q = p; p = BLK(Rcheat(p->word)&~BUSY); PER p>q || (c++)==0 DONE addblok(rbytes); - POOL + } } void addblok(reqd) @@ -95,7 +95,7 @@ chkbptr(ptr) REG BLKPTR q; INT us=0, un=0; - LOOP + for (;;) { q = Rcheat(p->word)&~BUSY; IF p==ptr THEN exf++ FI IF qbloktop THEN abort(3) FI @@ -106,7 +106,7 @@ chkbptr(ptr) FI IF p>=q THEN abort(4) FI p=q; - POOL + } IF exf==0 THEN abort(1) FI prn(un); prc(SP); prn(us); prc(NL); } diff --git a/Applications/V7/cmd/sh/cmd.c b/Applications/V7/cmd/sh/cmd.c index e5ec07bf..3f575d16 100644 --- a/Applications/V7/cmd/sh/cmd.c +++ b/Applications/V7/cmd/sh/cmd.c @@ -124,8 +124,8 @@ static TREPTR list(flg) REG INT b; r = term(flg); - WHILE r && ((b=(wdval==ANDFSYM)) || wdval==||SYM) - DO r = makelist((b ? TAND : T||), r, term(NLFLG)); + WHILE r && ((b=(wdval==ANDFSYM)) || wdval==ORFSYM) + DO r = makelist((b ? TAND : TORF), r, term(NLFLG)); OD return(r); } @@ -160,7 +160,8 @@ static REGPTR syncase(esym) THEN return(0); ELSE REG REGPTR r=(REGPTR)getstak(REGTYPE); r->regptr=0; - LOOP wdarg->argnxt=r->regptr; + for(;;) { + wdarg->argnxt=r->regptr; r->regptr=wdarg; IF wdval || ( word()!=')' && wdval!='|' ) THEN synbad(); @@ -169,7 +170,7 @@ static REGPTR syncase(esym) THEN word(); ELSE break; FI - POOL + } r->regcom=cmd(0,NLFLG|MTFLG); IF wdval==ECSYM THEN r->regnxt=syncase(esym); diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index f86fe500..528dd128 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -57,7 +57,7 @@ INT expand(as,rflg) OD END - LOOP IF cs==s + for(;;) { IF cs==s THEN s=nullstr; break; ELIF *--cs == '/' @@ -65,7 +65,7 @@ INT expand(as,rflg) IF s==cs THEN s="/" FI break; FI - POOL + } IF stat(s,&statb)>=0 && (statb.st_mode&S_IFMT)==S_IFDIR && (dirf=open(s,0))>0 diff --git a/Applications/V7/cmd/sh/io.c b/Applications/V7/cmd/sh/io.c index 09bc6edf..ca5a9af0 100644 --- a/Applications/V7/cmd/sh/io.c +++ b/Applications/V7/cmd/sh/io.c @@ -123,13 +123,14 @@ copy(ioparg) iop->iolst=iotemp; iotemp=iop; cline=locstak(); - LOOP clinep=cline; chkpr(NL); + for (;;) { + clinep=cline; chkpr(NL); WHILE (c = (nosubst ? readc() : nextc(*ends)), !eolchar(c)) DO *clinep++ = c OD *clinep=0; IF eof || eq(cline,ends) THEN break FI *clinep++=NL; write(fd,cline,clinep-cline); - POOL + } close(fd); FI } diff --git a/Applications/V7/cmd/sh/mac.h b/Applications/V7/cmd/sh/mac.h index 54e11f7c..cb50b7cf 100644 --- a/Applications/V7/cmd/sh/mac.h +++ b/Applications/V7/cmd/sh/mac.h @@ -9,7 +9,6 @@ * */ -#define PROC extern #define TYPE typedef #define STRUCT TYPE struct #define UNION TYPE union @@ -33,8 +32,6 @@ #define REP do{ #define PER }while( #define DONE ); -#define LOOP for(;;){ -#define POOL } #define TRUE (-1) #define FALSE 0 diff --git a/Applications/V7/cmd/sh/macro.c b/Applications/V7/cmd/sh/macro.c index 92ef199d..d831bf1b 100644 --- a/Applications/V7/cmd/sh/macro.c +++ b/Applications/V7/cmd/sh/macro.c @@ -118,13 +118,14 @@ retry: FI IF v THEN IF c!='+' - THEN LOOP WHILE c = *v++ + THEN for (;;) { + WHILE c = *v++ DO pushstak(c|quote); OD IF dolg==0 || (++dolg>dolc) THEN break; ELSE v=dolv[dolg]; pushstak(SP|(*id=='*' ? quote : 0)); FI - POOL + } FI ELIF argp THEN IF c=='?' diff --git a/Applications/V7/cmd/sh/main.c b/Applications/V7/cmd/sh/main.c index be31cc2c..58aae6fa 100644 --- a/Applications/V7/cmd/sh/main.c +++ b/Applications/V7/cmd/sh/main.c @@ -131,7 +131,8 @@ BOOL prof; IF input>=0 THEN initf(input) FI /* command loop */ - LOOP tdystak(0); + for(;;) { + tdystak(0); stakchk(); /* may reduce sbrk */ exitset(); IF (flags&prompt) && standin->fstak==0 && !eof @@ -152,7 +153,7 @@ BOOL prof; alarm(0); flags &= ~waiting; execute(cmd(NL,MTFLG),0); eof |= (flags&oneflg); - POOL + } } chkpr(eor) diff --git a/Applications/V7/cmd/sh/name.c b/Applications/V7/cmd/sh/name.c index a0045b48..a22cb2d3 100644 --- a/Applications/V7/cmd/sh/name.c +++ b/Applications/V7/cmd/sh/name.c @@ -129,7 +129,8 @@ INT readvar(names) THEN f->fsiz=1; FI - LOOP c=nextc(0); + for(;;) { + c=nextc(0); IF (*names && any(c, ifsnod.namval)) || eolchar(c) THEN zerostak(); assign(n,absstak(rel)); setstak(rel); @@ -142,7 +143,7 @@ INT readvar(names) FI ELSE pushstak(c); FI - POOL + } WHILE n DO assign(n, nullstr); IF *names THEN n=lookup(*names++); ELSE n=0; FI diff --git a/Applications/V7/cmd/sh/service.c b/Applications/V7/cmd/sh/service.c index 9c969270..9d815d4b 100644 --- a/Applications/V7/cmd/sh/service.c +++ b/Applications/V7/cmd/sh/service.c @@ -349,7 +349,8 @@ static INT split(s) REG INT c; INT count=0; - LOOP sigchk(); argp=locstak()+BYTESPERWORD; + for(;;) { + sigchk(); argp=locstak()+BYTESPERWORD; WHILE (c = *s++, !any(c,ifsnod.namval) && c) DO *argp++ = c OD IF argp==staktop+BYTESPERWORD @@ -366,5 +367,5 @@ static INT split(s) makearg(argp); count++; FI Lcheat(gchain) |= ARGMK; - POOL + } } diff --git a/Applications/V7/cmd/sh/xec.c b/Applications/V7/cmd/sh/xec.c index 73119541..0e2e6b12 100644 --- a/Applications/V7/cmd/sh/xec.c +++ b/Applications/V7/cmd/sh/xec.c @@ -326,7 +326,7 @@ execute(argt, execflg, pf1, pf2) FI break; - case T||: + case TORF: IF execute(((LSTPTR)t)->lstlef,0)!=0 THEN execute(((LSTPTR)t)->lstrit,execflg); FI -- 2.34.1