sh: remove LOOP/POOL and fix some bugs introduced earlier
authorAlan Cox <alan@linux.intel.com>
Sun, 10 May 2015 20:44:56 +0000 (21:44 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 10 May 2015 20:44:56 +0000 (21:44 +0100)
Applications/V7/cmd/sh/blok.c
Applications/V7/cmd/sh/cmd.c
Applications/V7/cmd/sh/expand.c
Applications/V7/cmd/sh/io.c
Applications/V7/cmd/sh/mac.h
Applications/V7/cmd/sh/macro.c
Applications/V7/cmd/sh/main.c
Applications/V7/cmd/sh/name.c
Applications/V7/cmd/sh/service.c
Applications/V7/cmd/sh/xec.c

index d76fefe..fd2fbed 100644 (file)
@@ -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 q<end || q>bloktop 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);
 }
index e5ec07b..3f575d1 100644 (file)
@@ -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);
index f86fe50..528dd12 100644 (file)
@@ -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
index 09bc6ed..ca5a9af 100644 (file)
@@ -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
 }
index 54e11f7..cb50b7c 100644 (file)
@@ -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
index 92ef199..d831bf1 100644 (file)
@@ -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=='?'
index be31cc2..58aae6f 100644 (file)
@@ -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)
index a0045b4..a22cb2d 100644 (file)
@@ -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
index 9c96927..9d815d4 100644 (file)
@@ -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
+       }
 }
index 7311954..0e2e6b1 100644 (file)
@@ -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