sh:kill off WHILE
authorAlan Cox <alan@linux.intel.com>
Sun, 10 May 2015 21:15:22 +0000 (22:15 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 10 May 2015 21:15:22 +0000 (22:15 +0100)
16 files changed:
Applications/V7/cmd/sh/args.c
Applications/V7/cmd/sh/blok.c
Applications/V7/cmd/sh/cmd.c
Applications/V7/cmd/sh/error.c
Applications/V7/cmd/sh/expand.c
Applications/V7/cmd/sh/fault.c
Applications/V7/cmd/sh/io.c
Applications/V7/cmd/sh/mac.h
Applications/V7/cmd/sh/macro.c
Applications/V7/cmd/sh/name.c
Applications/V7/cmd/sh/print.c
Applications/V7/cmd/sh/service.c
Applications/V7/cmd/sh/stak.c
Applications/V7/cmd/sh/string.c
Applications/V7/cmd/sh/word.c
Applications/V7/cmd/sh/xec.c

index 84314b9..ed1663f 100644 (file)
@@ -40,10 +40,10 @@ INT options(argc,argv)
        if (argc>1 && *argp[1]=='-'
        ) {     cp=argp[1];
                flags &= ~(execpr|readpr);
-               WHILE *++cp
+               while(*++cp
                DO      flagc=flagchar;
 
-                       WHILE *flagc && *flagc != *cp DO flagc++ OD
+                       while(*flagc && *flagc != *cp DO flagc++ OD
                        if (*cp == *flagc
                        ) {     flags |= flagval[flagc-flagchar];
                        } else if (*cp=='c' && argc>2 && comdiv==0
@@ -58,7 +58,7 @@ INT   options(argc,argv)
        /* set up $- */
        flagc=flagchar;
        flagp=flagadr;
-       WHILE *flagc
+       while(*flagc
        DO if (flags&flagval[flagc-flagchar]
           ) { *flagp++ = *flagc;
           ;}
@@ -76,7 +76,7 @@ void  setargs(argi)
        REG STRING      *argp=argi;
        REG INT         argn=0;
 
-       WHILE Rcheat(*argp++)!=ENDARGS DO argn++ OD
+       while(Rcheat(*argp++)!=ENDARGS DO argn++ OD
 
        /* free old ones unless on for loop chain */
        freeargs(dolh);
@@ -114,7 +114,7 @@ static STRING *     copyargs(from, n)
        np=(STRING *)((DOLPTR)np)->dolarg;
        dolv=np;
 
-       WHILE n--
+       while(n--
        DO *np++ = make(*fp++) OD
        *np++ = ENDARGS;
        return(pp);
@@ -123,10 +123,10 @@ static STRING *   copyargs(from, n)
 clearup()
 {
        /* force `for' $* lists to go away */
-       WHILE argfor=freeargs(argfor) DONE
+       while(argfor=freeargs(argfor) DONE
 
        /* clean up io files */
-       WHILE pop() DONE
+       while(pop() DONE
 }
 
 DOLPTR useargs()
index 4ab76ac..99a5dd6 100644 (file)
@@ -36,7 +36,7 @@ ADDRESS       alloc(nbytes)
                REG BLKPTR      p = blokp;
                REG BLKPTR      q;
                REP     if(!busy(p)
-                       ) {     WHILE !busy(q = p->word) DO p->word = q->word OD
+                       ) {     while(!busy(q = p->word) DO p->word = q->word OD
                                if(ADR(q)-ADR(p) >= rbytes
                                ) {     blokp = BLK(ADR(p)+rbytes);
                                        if(q > blokp
index 83278e2..ae942f0 100644 (file)
@@ -124,7 +124,7 @@ static TREPTR       list(flg)
        REG INT         b;
 
        r = term(flg);
-       WHILE r && ((b=(wdval==ANDFSYM)) || wdval==ORFSYM)
+       while(r && ((b=(wdval==ANDFSYM)) || wdval==ORFSYM)
        DO      r = makelist((b ? TAND : TORF), r, term(NLFLG));
        OD
        return(r);
@@ -286,7 +286,7 @@ static TREPTR       item(flag)
                   t=(TREPTR)getstak(COMTYPE);
                   ((COMPTR)t)->comio=io; /*initial io chain*/
                   argtail = &(((COMPTR)t)->comarg);
-                  WHILE wdval==0
+                  while(wdval==0
                   DO   argp = wdarg;
                        if (wdset && keywd
                        ) {     argp->argnxt=(ARGPTR)argset;
@@ -316,7 +316,7 @@ static TREPTR       item(flag)
 
 static int     skipnl()
 {
-       WHILE (reserv++, word()==NL) DO chkpr(NL) OD
+       while((reserv++, word()==NL) DO chkpr(NL) OD
        return(wdval);
 }
 
@@ -385,7 +385,7 @@ static void prsym(sym)
 {
        if (sym&SYMFLG
        ) {     REG SYSPTR      sp=reserved;
-               WHILE sp->sysval
+               while(sp->sysval
                        && sp->sysval!=sym
                DO sp++ OD
                prs(sp->sysnam);
index cfa424a..b868457 100644 (file)
@@ -79,7 +79,7 @@ done()
 rmtemp(base)
        IOPTR           base;
 {
-       WHILE iotemp>base
+       while(iotemp>base
        DO  unlink(iotemp->ioname);
            iotemp=iotemp->iolst;
        OD
index 4bda8be..af9dfea 100644 (file)
@@ -48,7 +48,7 @@ INT   expand(as,rflg)
        /* check for meta chars */
        {
           REG BOOL slash; slash=0;
-          WHILE !fngchar(*cs)
+          while(!fngchar(*cs)
           DO   if (*cs++==0
                ) {     if (rflg && slash ) { break; } else { return(0) ;}
                } else if ( *cs=='/'
@@ -81,7 +81,7 @@ INT   expand(as,rflg)
                PER     *rs++ DONE
 
                // FIXME: readdir
-               WHILE read(dirf, (void *)&entry, 32) == 32 && (trapnote&SIGSET) == 0
+               while(read(dirf, (void *)&entry, 32) == 32 && (trapnote&SIGSET) == 0
                DO      if (entry.d_ino==0 ||
                            (*entry.d_name=='.' && *cs!='.')
                        ) {     continue;
@@ -97,7 +97,7 @@ INT   expand(as,rflg)
                        rchain=gchain; gchain=schain;
                        if (count
                        ) {     count=0;
-                               WHILE rchain
+                               while(rchain
                                DO      count += expand(rchain->argval,1);
                                        rchain=rchain->argnxt;
                                OD
@@ -109,7 +109,7 @@ INT expand(as,rflg)
        {
           REG CHAR     c;
           s=as;
-          WHILE c = *s
+          while(c = *s
           DO   *s++=(c&STRIP?c:'/') OD
        }
        return(count);
@@ -130,7 +130,7 @@ gmatch(s, p)
            case '[':
                {BOOL ok; INT lc;
                ok=0; lc=077777;
-               WHILE c = *p++
+               while(c = *p++
                DO      if (c==']'
                        ) {     return(ok?gmatch(s,p):0);
                        } else if ( c==MINUS
@@ -150,7 +150,7 @@ gmatch(s, p)
            case '*':
                if (*p==0 ) { return(1) ;}
                --s;
-               WHILE *s
+               while(*s
                DO  if (gmatch(s++,p) ) { return(1) ;} OD
                return(0);
 
@@ -168,7 +168,7 @@ static void addg(as1,as2,as3)
        s2 = locstak()+BYTESPERWORD;
 
        s1=as1;
-       WHILE c = *s1++
+       while(c = *s1++
        DO      if ((c &= STRIP)==0
                ) {     *s2++='/';
                        break;
@@ -176,10 +176,10 @@ static void       addg(as1,as2,as3)
                *s2++=c;
        OD
        s1=as2;
-       WHILE *s2 = *s1++ DO s2++ OD
+       while(*s2 = *s1++ DO s2++ OD
        if (s1=as3
        ) {     *s2++='/';
-               WHILE *s2++ = *++s1 DONE
+               while(*s2++ = *++s1 DONE
        ;}
        makearg(endstak(s2));
 }
index adfb804..faedb35 100644 (file)
@@ -74,7 +74,7 @@ oldsigs()
        REG STRING      t;
 
        i=MAXTRAP;
-       WHILE i--
+       while(i--
        DO  t=trapcom[i];
            if(t==0 || *t
            ) { clrsig(i);
@@ -101,7 +101,7 @@ chktrap()
        REG STRING      t;
 
        trapnote &= ~TRAPSET;
-       WHILE --i
+       while(--i
        DO if(trapflg[i]&TRAPSET
           ) { trapflg[i] &= ~TRAPSET;
                if(t=trapcom[i]
index 51373f8..1311571 100644 (file)
@@ -125,7 +125,7 @@ copy(ioparg)
 
                for (;;) {
                        clinep=cline; chkpr(NL);
-                       WHILE (c = (nosubst ? readc() :  nextc(*ends)),  !eolchar(c)) DO *clinep++ = c OD
+                       while((c = (nosubst ? readc() :  nextc(*ends)),  !eolchar(c)) DO *clinep++ = c OD
                        *clinep=0;
                        if(eof || eq(cline,ends) ) { break ;}
                        *clinep++=NL;
index cffde0b..0b2ea33 100644 (file)
@@ -14,7 +14,6 @@
 #define UNION  TYPE union
 #define REG    register
 
-#define WHILE  while(
 #define DO     ){
 #define OD     ;}
 #define REP    do{
index 278e89d..0316d65 100644 (file)
@@ -26,7 +26,7 @@ static STRING copyto(endch)
 {
        REG CHAR        c;
 
-       WHILE (c=getch(endch))!=endch && c
+       while((c=getch(endch))!=endch && c
        DO pushstak(c|quote) OD
        zerostak();
        if(c!=endch ) { error(badsub) ;}
@@ -37,7 +37,7 @@ static skipto(endch)
 {
        /* skip chars up to } */
        REG CHAR        c;
-       WHILE (c=readc()) && c!=endch
+       while((c=readc()) && c!=endch
        DO      switch(c) {
 
                case SQUOTE:    skipto(SQUOTE); break;
@@ -75,7 +75,7 @@ retry:
                        if(bra=(c==BRACE) ) { c=readc() ;}
                        if(letter(c)
                        ) {     argp=(STRING)relstak();
-                               WHILE alphanum(c) DO pushstak(c); c=readc() OD
+                               while(alphanum(c) DO pushstak(c); c=readc() OD
                                zerostak();
                                n=lookup(absstak(argp)); setstak(argp);
                                v = n->namval; id = n->namid;
@@ -119,7 +119,7 @@ retry:
                        if(v
                        ) {     if(c!='+'
                                ) {     for (;;) {
-                                           WHILE c = *v++
+                                           while(c = *v++
                                             DO pushstak(c|quote); OD
                                             if(dolg==0 || (++dolg>dolc)
                                             ) { break;
@@ -180,7 +180,7 @@ static comsubst()
        REG STKPTR      savptr = fixstak();
 
        usestak();
-       WHILE (d=readc())!=SQUOTE && d
+       while((d=readc())!=SQUOTE && d
        DO pushstak(d) OD
 
        {
@@ -201,9 +201,9 @@ static comsubst()
           close(pv[OTPIPE]);
        }
        tdystak(savptr); staktop=movstr(savptr,stakbot);
-       WHILE d=readc() DO pushstak(d|quote) OD
+       while(d=readc() DO pushstak(d|quote) OD
        await(0);
-       WHILE stakbot!=staktop
+       while(stakbot!=staktop
        DO      if((*--staktop&STRIP)!=NL
                ) {     ++staktop; break;
                ;}
@@ -222,7 +222,7 @@ subst(in,ot)
 
        push(&fb); initf(in);
        /* DQUOTE used to stop it from quoting */
-       WHILE c=(getch(DQUOTE)&STRIP)
+       while(c=(getch(DQUOTE)&STRIP)
        DO pushstak(c);
           if(--count == 0
           ) {  flush(ot); count=CPYSIZ;
index 37a5f85..73c84a0 100644 (file)
@@ -39,7 +39,7 @@ syslook(w,syswds)
 
        syscan=syswds; first = *w;
 
-       WHILE s=syscan->sysnam
+       while(s=syscan->sysnam
        DO  if (first == *s
                && eq(w,s)
            ) { return(syscan->sysval);
@@ -53,7 +53,7 @@ setlist(arg,xp)
        REG ARGPTR      arg;
        INT             xp;
 {
-       WHILE arg
+       while(arg
        DO REG STRING   s=mactrim(arg->argval);
           setname(s, xp);
           arg=arg->argnxt;
@@ -72,7 +72,7 @@ void  setname(argi, xp)
        REG NAMPTR      n;
 
        if (letter(*argscan)
-       ) {     WHILE alphanum(*argscan) DO argscan++ OD
+       ) {     while(alphanum(*argscan) DO argscan++ OD
                if (*argscan=='='
                ) {     *argscan = 0;
                        n=lookup(argi);
@@ -144,7 +144,7 @@ INT readvar(names)
                } else {        pushstak(c);
                ;}
        }
-       WHILE n
+       while(n
        DO assign(n, nullstr);
           if (*names ) { n=lookup(*names++); } else { n=0; ;}
        OD
@@ -185,7 +185,7 @@ NAMPTR              lookup(nam)
        if (!chkid(nam)
        ) {     failed(nam,notid);
        ;}
-       WHILE nscan
+       while(nscan
        DO      if ((LR=cf(nam,nscan->namid))==0
                ) {     return(nscan);
                } else if ( LR<0
@@ -210,7 +210,7 @@ static BOOL chkid(nam)
 
        if (!letter(*cp)
        ) {     return(FALSE);
-       } else {        WHILE *++cp
+       } else {        while(*++cp
                DO if (!alphanum(*cp)
                   ) {  return(FALSE);
                   ;}
@@ -290,7 +290,7 @@ void        sh_getenv(void)
 {
        REG STRING      *e=environ;
 
-       WHILE *e
+       while(*e
        DO setname(*e++, N_ENVNAM) OD
 }
 
index cb8795d..a602fda 100644 (file)
@@ -89,7 +89,7 @@ STRING        icp;
        REG INT         r = 0;
        REG CHAR        c;
 
-       WHILE (c = *cp, digit(c)) && c && r>=0
+       while((c = *cp, digit(c)) && c && r>=0
        DO r = r*10 + c - '0'; cp++ OD
        if (r<0 || cp==icp
        ) {     failed(icp,badnum);
index af6bd6e..0c9439c 100644 (file)
@@ -103,11 +103,11 @@ STRING    catpath(path,name)
        REG STRING      scanp = path,
                        argp = locstak();
 
-       WHILE *scanp && *scanp!=COLON DO *argp++ = *scanp++ OD
+       while(*scanp && *scanp!=COLON DO *argp++ = *scanp++ OD
        if(scanp!=path ) { *argp++='/' ;}
        if(*scanp==COLON ) { scanp++ ;}
        path=(*scanp ? scanp : 0); scanp=name;
-       WHILE (*argp++ = *scanp++) DONE
+       while((*argp++ = *scanp++) DONE
        return(path);
 }
 
@@ -124,7 +124,7 @@ void        execa(at)
        ) {     xecmsg=notfound; path=getpath(*t);
                namscan(exname);
                xecenv=sh_setenv();
-               WHILE path=execs(path,t) DONE
+               while(path=execs(path,t) DONE
                failed(*t,xecmsg);
        ;}
 }
@@ -178,7 +178,7 @@ postclr()
 {
        REG INT         *pw = pwlist;
 
-       WHILE pw <= &pwlist[pwc]
+       while(pw <= &pwlist[pwc]
        DO *pw++ = 0 OD
        pwc=0;
 }
@@ -189,7 +189,7 @@ void        post(pcsid)
        REG INT         *pw = pwlist;
 
        if(pcsid
-       ) {     WHILE *pw DO pw++ OD
+       ) {     while(*pw DO pw++ OD
                if(pwc >= MAXP-1
                ) {     pw--;
                } else {        pwc++;
@@ -206,7 +206,7 @@ void        await(i)
        INT             ipwc = pwc;
 
        post(i);
-       WHILE pwc
+       while(pwc
        DO      REG INT         p;
                REG INT         sig;
                INT             w_hi;
@@ -214,7 +214,7 @@ void        await(i)
                {
                   REG INT      *pw=pwlist;
                   p=wait(&w);
-                  WHILE pw <= &pwlist[ipwc]
+                  while(pw <= &pwlist[ipwc]
                   DO if(*pw==p
                      ) { *pw=0; pwc--;
                      } else { pw++;
@@ -261,7 +261,7 @@ trim(at)
        REG CHAR        q=0;
 
        if(p=at
-       ) {     WHILE c = *p
+       ) {     while(c = *p
                DO *p++=c&STRIP; q |= c OD
        ;}
        nosubst=q&QUOTE;
@@ -283,7 +283,7 @@ STRING      *scan(argn)
 
        comargn=(STRING *)getstak(BYTESPERWORD*argn+BYTESPERWORD); comargm = comargn += argn; *comargn = ENDARGS;
 
-       WHILE argp
+       while(argp
        DO      *--comargn = argp->argval;
                if(argp = argp->argnxt
                ) { trim(*comargn);
@@ -333,7 +333,7 @@ INT getarg(ac)
 
        if(c=ac
        ) {     argp=c->comarg;
-               WHILE argp
+               while(argp
                DO      count += split(macro(argp->argval));
                        argp=argp->argnxt;
                OD
@@ -350,7 +350,7 @@ static INT  split(s)
 
        for(;;) {
                sigchk(); argp=locstak()+BYTESPERWORD;
-               WHILE (c = *s++, !any(c,ifsnod.namval) && c)
+               while((c = *s++, !any(c,ifsnod.namval) && c)
                DO *argp++ = c OD
                if(argp==staktop+BYTESPERWORD
                ) {     if(c
index ca47a58..2ca5cbf 100644 (file)
@@ -62,7 +62,7 @@ void  tdystak(x)
        REG STKPTR      x;
 {
        /* try to bring stack back to x */
-       WHILE ADR(stakbsy)>ADR(x)
+       while(ADR(stakbsy)>ADR(x)
        DO free(stakbsy);
           stakbsy = stakbsy->word;
        OD
index b7f6a2f..eb4c560 100644 (file)
@@ -18,7 +18,7 @@
 STRING movstr(a,b)
        REG STRING      a, b;
 {
-       WHILE *b++ = *a++ DONE
+       while(*b++ = *a++ DONE
        return(--b);
 }
 
@@ -28,7 +28,7 @@ INT   any(c,s)
 {
        REG CHAR d;
 
-       WHILE d = *s++
+       while(d = *s++
        DO      if(d==c
                ) {     return(TRUE);
                ;}
@@ -39,7 +39,7 @@ INT   any(c,s)
 INT    cf(s1, s2)
        REG STRING s1, s2;
 {
-       WHILE *s1++ == *s2
+       while(*s1++ == *s2
        DO      if(*s2++==0
                ) {     return(0);
                ;}
@@ -52,6 +52,6 @@ INT   length(as)
 {
        REG STRING s;
 
-       if(s=as ) { WHILE *s++ DONE ;}
+       if(s=as ) { while(*s++ DONE ;}
        return(s-as);
 }
index 665e4d1..384bc6a 100644 (file)
@@ -27,11 +27,11 @@ word()
 
        wdnum=0; wdset=0;
 
-       WHILE (c=nextc(0), space(c)) DONE
+       while((c=nextc(0), space(c)) DONE
        if(!eofmeta(c)
        ) {     REP     if(c==LITERAL
                        ) {     *argp++=(DQUOTE);
-                               WHILE (c=readc()) && c!=LITERAL
+                               while((c=readc()) && c!=LITERAL
                                DO *argp++=(c|QUOTE); chkpr(c) OD
                                *argp++=(DQUOTE);
                        } else {        *argp++=(c);
@@ -39,7 +39,7 @@ word()
                                if(!alphanum(c) ) { alpha=0 ;}
                                if(qotchar(c)
                                ) {     d=c;
-                                       WHILE (*argp++=(c=nextc(d))) && c!=d
+                                       while((*argp++=(c=nextc(d))) && c!=d
                                        DO chkpr(c) OD
                                ;}
                        ;}
index 298b9b1..e33ee56 100644 (file)
@@ -61,7 +61,7 @@ execute(argt, execflg, pf1, pf2)
                        ) {     /* print command if execpr */
                                if( flags&execpr
                                ) {     argn=0; prs(execpmsg);
-                                       WHILE com[argn]!=ENDARGS
+                                       while(com[argn]!=ENDARGS
                                        DO prs(com[argn++]); blank() OD
                                        newline();
                                ;}
@@ -108,7 +108,7 @@ execute(argt, execflg, pf1, pf2)
                                                if( (clear=digit(*a1))==0
                                                ) {     ++com;
                                                ;}
-                                               WHILE *++com
+                                               while(*++com
                                                DO INT  i;
                                                   if( (i=stoi(*com))>=MAXTRAP || i<MINTRAP
                                                   ) {  failed(*com,badtrap);
@@ -190,7 +190,7 @@ execute(argt, execflg, pf1, pf2)
                                        if( exitval==0 ) { exitval=N_EXPORT; ;}
        
                                        if( a1
-                                       ) {     WHILE *++com
+                                       ) {     while(*++com
                                                DO attrib(lookup(*com), exitval) OD
                                        } else {        namscan(printflg);
                                        ;}
@@ -239,7 +239,7 @@ execute(argt, execflg, pf1, pf2)
                case TFORK:
                        if( execflg && (treeflgs&(FAMP|FPOU))==0
                        ) {     parent=0;
-                       } else {        WHILE (parent=fork()) == -1
+                       } else {        while((parent=fork()) == -1
                                DO sigchk(); alarm(10); pause() OD
                        ;}
 
@@ -347,7 +347,7 @@ execute(argt, execflg, pf1, pf2)
                                   gchain=schain;
                           ;}
                           loopcnt++;
-                          WHILE *args!=ENDARGS && execbrk==0
+                          while(*args!=ENDARGS && execbrk==0
                           DO   assign(n,*args++);
                                execute(((FORPTR)t)->fortre,0);
                                if( execbrk<0 ) { execbrk=0 ;}
@@ -364,7 +364,7 @@ execute(argt, execflg, pf1, pf2)
                           INT          i=0;
 
                           loopcnt++;
-                          WHILE execbrk==0 && (execute(((WHPTR)t)->whtre,0)==0)==(type==TWH)
+                          while(execbrk==0 && (execute(((WHPTR)t)->whtre,0)==0)==(type==TWH)
                           DO i=execute(((WHPTR)t)->dotre,0);
                              if( execbrk<0 ) { execbrk=0 ;}
                           OD
@@ -384,9 +384,9 @@ execute(argt, execflg, pf1, pf2)
                        {
                           REG STRING   r = mactrim(((SWPTR)t)->swarg);
                           t=(TREPTR)((SWPTR)t)->swlst;
-                          WHILE t
+                          while(t
                           DO   ARGPTR          rex=((REGPTR)t)->regptr;
-                               WHILE rex
+                               while(rex
                                DO      REG STRING      s;
                                        if( gmatch(r,s=macro(rex->argval)) || (trim(s), eq(r,s))
                                        ) {     execute(((REGPTR)t)->regcom,0);