sh: kill off DO
authorAlan Cox <alan@linux.intel.com>
Sun, 10 May 2015 21:25:39 +0000 (22:25 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 10 May 2015 21:25:39 +0000 (22:25 +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 cdb5750..e269b1a 100644 (file)
@@ -41,9 +41,9 @@ INT   options(argc,argv)
        ) {     cp=argp[1];
                flags &= ~(execpr|readpr);
                while(*++cp
-               DO      flagc=flagchar;
+               ){flagc=flagchar;
 
-                       while(*flagc && *flagc != *cp DO flagc++ OD
+                       while(*flagc && *flagc != *cp ){flagc++ OD
                        if (*cp == *flagc
                        ) {     flags |= flagval[flagc-flagchar];
                        } else if (*cp=='c' && argc>2 && comdiv==0
@@ -59,7 +59,7 @@ INT   options(argc,argv)
        flagc=flagchar;
        flagp=flagadr;
        while(*flagc
-       DO if (flags&flagval[flagc-flagchar]
+       ){if (flags&flagval[flagc-flagchar]
           ) { *flagp++ = *flagc;
           ;}
           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 ){argn++ OD
 
        /* free old ones unless on for loop chain */
        freeargs(dolh);
@@ -96,7 +96,7 @@ freeargs(blk)
        ) {     argr = argblk->dolnxt;
                if ((--argblk->doluse)==0
                ) {     for ( argp=(STRING *)argblk->dolarg; Rcheat(*argp)!=ENDARGS; argp++
-                       DO free(*argp) OD
+                       ){free(*argp) OD
                        free(argblk);
                ;}
        ;}
@@ -115,7 +115,7 @@ static STRING *     copyargs(from, n)
        dolv=np;
 
        while(n--
-       DO *np++ = make(*fp++) OD
+       ){*np++ = make(*fp++) OD
        *np++ = ENDARGS;
        return(pp);
 }
index e53667d..aa7a378 100644 (file)
@@ -36,7 +36,7 @@ ADDRESS       alloc(nbytes)
                REG BLKPTR      p = blokp;
                REG BLKPTR      q;
                do {    if(!busy(p)
-                       ) {     while(!busy(q = p->word) DO p->word = q->word OD
+                       ) {     while(!busy(q = p->word) ){p->word = q->word OD
                                if(ADR(q)-ADR(p) >= rbytes
                                ) {     blokp = BLK(ADR(p)+rbytes);
                                        if(q > blokp
index ae942f0..f8d36db 100644 (file)
@@ -125,7 +125,7 @@ static TREPTR       list(flg)
 
        r = term(flg);
        while(r && ((b=(wdval==ANDFSYM)) || wdval==ORFSYM)
-       DO      r = makelist((b ? TAND : TORF), r, term(NLFLG));
+       ){r = makelist((b ? TAND : TORF), r, term(NLFLG));
        OD
        return(r);
 }
@@ -287,7 +287,7 @@ static TREPTR       item(flag)
                   ((COMPTR)t)->comio=io; /*initial io chain*/
                   argtail = &(((COMPTR)t)->comarg);
                   while(wdval==0
-                  DO   argp = wdarg;
+                  ){argp = wdarg;
                        if (wdset && keywd
                        ) {     argp->argnxt=(ARGPTR)argset;
                                argset=(ARGPTR *)argp;
@@ -316,7 +316,7 @@ static TREPTR       item(flag)
 
 static int     skipnl()
 {
-       while((reserv++, word()==NL) DO chkpr(NL) OD
+       while((reserv++, word()==NL) ){chkpr(NL) OD
        return(wdval);
 }
 
@@ -387,7 +387,7 @@ static void prsym(sym)
        ) {     REG SYSPTR      sp=reserved;
                while(sp->sysval
                        && sp->sysval!=sym
-               DO sp++ OD
+               ){sp++ OD
                prs(sp->sysnam);
        } else if ( sym==EOFSYM
        ) {     prs(endoffile);
index b868457..815b17a 100644 (file)
@@ -80,7 +80,7 @@ rmtemp(base)
        IOPTR           base;
 {
        while(iotemp>base
-       DO  unlink(iotemp->ioname);
+       ){ unlink(iotemp->ioname);
            iotemp=iotemp->iolst;
        OD
 }
index c0e7a1e..84b5312 100644 (file)
@@ -49,7 +49,7 @@ INT   expand(as,rflg)
        {
           REG BOOL slash; slash=0;
           while(!fngchar(*cs)
-          DO   if (*cs++==0
+          ){if (*cs++==0
                ) {     if (rflg && slash ) { break; } else { return(0) ;}
                } else if ( *cs=='/'
                ) {     slash++;
@@ -82,7 +82,7 @@ INT   expand(as,rflg)
 
                // FIXME: readdir
                while(read(dirf, (void *)&entry, 32) == 32 && (trapnote&SIGSET) == 0
-               DO      if (entry.d_ino==0 ||
+               ){if (entry.d_ino==0 ||
                            (*entry.d_name=='.' && *cs!='.')
                        ) {     continue;
                        ;}
@@ -98,7 +98,7 @@ INT   expand(as,rflg)
                        if (count
                        ) {     count=0;
                                while(rchain
-                               DO      count += expand(rchain->argval,1);
+                               ){count += expand(rchain->argval,1);
                                        rchain=rchain->argnxt;
                                OD
                        ;}
@@ -110,7 +110,7 @@ INT expand(as,rflg)
           REG CHAR     c;
           s=as;
           while(c = *s
-          DO   *s++=(c&STRIP?c:'/') OD
+          ){*s++=(c&STRIP?c:'/') OD
        }
        return(count);
 }
@@ -131,7 +131,7 @@ gmatch(s, p)
                {BOOL ok; INT lc;
                ok=0; lc=077777;
                while(c = *p++
-               DO      if (c==']'
+               ){if (c==']'
                        ) {     return(ok?gmatch(s,p):0);
                        } else if ( c==MINUS
                        ) {     if (lc<=scc && scc<=(*p++) ) { ok++ ;}
@@ -151,7 +151,7 @@ gmatch(s, p)
                if (*p==0 ) { return(1) ;}
                --s;
                while(*s
-               DO  if (gmatch(s++,p) ) { return(1) ;} OD
+               ){ if (gmatch(s++,p) ) { return(1) ;} OD
                return(0);
 
            case 0:
@@ -169,14 +169,14 @@ static void       addg(as1,as2,as3)
 
        s1=as1;
        while(c = *s1++
-       DO      if ((c &= STRIP)==0
+       ){if ((c &= STRIP)==0
                ) {     *s2++='/';
                        break;
                ;}
                *s2++=c;
        OD
        s1=as2;
-       while(*s2 = *s1++ DO s2++ OD
+       while(*s2 = *s1++ ){s2++ OD
        if (s1=as3
        ) {     *s2++='/';
                while(*s2++ = *++s1 );
index faedb35..73e54e3 100644 (file)
@@ -75,7 +75,7 @@ oldsigs()
 
        i=MAXTRAP;
        while(i--
-       DO  t=trapcom[i];
+       ){ t=trapcom[i];
            if(t==0 || *t
            ) { clrsig(i);
            ;}
@@ -102,7 +102,7 @@ chktrap()
 
        trapnote &= ~TRAPSET;
        while(--i
-       DO if(trapflg[i]&TRAPSET
+       ){if(trapflg[i]&TRAPSET
           ) { trapflg[i] &= ~TRAPSET;
                if(t=trapcom[i]
                ) {     INT     savxit=exitval;
index 1311571..493a353 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)) ){*clinep++ = c OD
                        *clinep=0;
                        if(eof || eq(cline,ends) ) { break ;}
                        *clinep++=NL;
index 121f3b3..0276d04 100644 (file)
@@ -14,7 +14,6 @@
 #define UNION  TYPE union
 #define REG    register
 
-#define DO     ){
 #define OD     ;}
 
 #define TRUE   (-1)
index 0316d65..c708b9f 100644 (file)
@@ -27,7 +27,7 @@ static STRING copyto(endch)
        REG CHAR        c;
 
        while((c=getch(endch))!=endch && c
-       DO pushstak(c|quote) OD
+       ){pushstak(c|quote) OD
        zerostak();
        if(c!=endch ) { error(badsub) ;}
 }
@@ -38,7 +38,7 @@ static skipto(endch)
        /* skip chars up to } */
        REG CHAR        c;
        while((c=readc()) && c!=endch
-       DO      switch(c) {
+       ){      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) ){pushstak(c); c=readc() OD
                                zerostak();
                                n=lookup(absstak(argp)); setstak(argp);
                                v = n->namval; id = n->namid;
@@ -120,7 +120,7 @@ retry:
                        ) {     if(c!='+'
                                ) {     for (;;) {
                                            while(c = *v++
-                                            DO pushstak(c|quote); OD
+                                            ){pushstak(c|quote); OD
                                             if(dolg==0 || (++dolg>dolc)
                                             ) { break;
                                             } else { v=dolv[dolg]; pushstak(SP|(*id=='*' ? quote : 0));
@@ -181,7 +181,7 @@ static comsubst()
 
        usestak();
        while((d=readc())!=SQUOTE && d
-       DO pushstak(d) OD
+       ){pushstak(d) OD
 
        {
           REG STRING   argc;
@@ -201,10 +201,10 @@ static comsubst()
           close(pv[OTPIPE]);
        }
        tdystak(savptr); staktop=movstr(savptr,stakbot);
-       while(d=readc() DO pushstak(d|quote) OD
+       while(d=readc() ){pushstak(d|quote) OD
        await(0);
        while(stakbot!=staktop
-       DO      if((*--staktop&STRIP)!=NL
+       ){      if((*--staktop&STRIP)!=NL
                ) {     ++staktop; break;
                ;}
        OD
@@ -223,7 +223,7 @@ subst(in,ot)
        push(&fb); initf(in);
        /* DQUOTE used to stop it from quoting */
        while(c=(getch(DQUOTE)&STRIP)
-       DO pushstak(c);
+       ){pushstak(c);
           if(--count == 0
           ) {  flush(ot); count=CPYSIZ;
           ;}
index 73c84a0..40f2ad3 100644 (file)
@@ -40,7 +40,7 @@ syslook(w,syswds)
        syscan=syswds; first = *w;
 
        while(s=syscan->sysnam
-       DO  if (first == *s
+       ){ if (first == *s
                && eq(w,s)
            ) { return(syscan->sysval);
            ;}
@@ -54,7 +54,7 @@ setlist(arg,xp)
        INT             xp;
 {
        while(arg
-       DO REG STRING   s=mactrim(arg->argval);
+       ){REG STRING    s=mactrim(arg->argval);
           setname(s, xp);
           arg=arg->argnxt;
           if (flags&execpr
@@ -72,7 +72,7 @@ void  setname(argi, xp)
        REG NAMPTR      n;
 
        if (letter(*argscan)
-       ) {     while(alphanum(*argscan) DO argscan++ OD
+       ) {     while(alphanum(*argscan) ){argscan++ OD
                if (*argscan=='='
                ) {     *argscan = 0;
                        n=lookup(argi);
@@ -145,7 +145,7 @@ INT readvar(names)
                ;}
        }
        while(n
-       DO assign(n, nullstr);
+       ){assign(n, nullstr);
           if (*names ) { n=lookup(*names++); } else { n=0; ;}
        OD
 
@@ -186,7 +186,7 @@ NAMPTR              lookup(nam)
        ) {     failed(nam,notid);
        ;}
        while(nscan
-       DO      if ((LR=cf(nam,nscan->namid))==0
+       ){      if ((LR=cf(nam,nscan->namid))==0
                ) {     return(nscan);
                } else if ( LR<0
                ) {     prev = &(nscan->namlft);
@@ -211,7 +211,7 @@ static BOOL chkid(nam)
        if (!letter(*cp)
        ) {     return(FALSE);
        } else {        while(*++cp
-               DO if (!alphanum(*cp)
+               ){if (!alphanum(*cp)
                   ) {  return(FALSE);
                   ;}
                OD
@@ -291,7 +291,7 @@ void        sh_getenv(void)
        REG STRING      *e=environ;
 
        while(*e
-       DO setname(*e++, N_ENVNAM) OD
+       ){setname(*e++, N_ENVNAM) OD
 }
 
 static INT     namec;
index a602fda..b7e2902 100644 (file)
@@ -75,7 +75,7 @@ itos(n)
        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' ;}
+       ){      if ((pr |= (d=a/i)) ) { *abuf++=d+'0' ;}
                a %= i;
        OD
        *abuf++=a+'0';
@@ -90,7 +90,7 @@ STRING        icp;
        REG CHAR        c;
 
        while((c = *cp, digit(c)) && c && r>=0
-       DO r = r*10 + c - '0'; cp++ OD
+       ){ r = r*10 + c - '0'; cp++ OD
        if (r<0 || cp==icp
        ) {     failed(icp,badnum);
        } else {        return(r);
index 7e91841..b48b35c 100644 (file)
@@ -103,7 +103,7 @@ STRING      catpath(path,name)
        REG STRING      scanp = path,
                        argp = locstak();
 
-       while(*scanp && *scanp!=COLON DO *argp++ = *scanp++ OD
+       while(*scanp && *scanp!=COLON ){*argp++ = *scanp++ OD
        if(scanp!=path ) { *argp++='/' ;}
        if(*scanp==COLON ) { scanp++ ;}
        path=(*scanp ? scanp : 0); scanp=name;
@@ -179,7 +179,7 @@ postclr()
        REG INT         *pw = pwlist;
 
        while(pw <= &pwlist[pwc]
-       DO *pw++ = 0 OD
+       ){*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 ){pw++ OD
                if(pwc >= MAXP-1
                ) {     pw--;
                } else {        pwc++;
@@ -207,7 +207,7 @@ void        await(i)
 
        post(i);
        while(pwc
-       DO      REG INT         p;
+       ){      REG INT         p;
                REG INT         sig;
                INT             w_hi;
 
@@ -215,7 +215,7 @@ void        await(i)
                   REG INT      *pw=pwlist;
                   p=wait(&w);
                   while(pw <= &pwlist[ipwc]
-                  DO if(*pw==p
+                  ){if(*pw==p
                      ) { *pw=0; pwc--;
                      } else { pw++;
                      ;}
@@ -262,7 +262,7 @@ trim(at)
 
        if(p=at
        ) {     while(c = *p
-               DO *p++=c&STRIP; q |= c OD
+               ){*p++=c&STRIP; q |= c OD
        ;}
        nosubst=q&QUOTE;
 }
@@ -284,7 +284,7 @@ STRING      *scan(argn)
        comargn=(STRING *)getstak(BYTESPERWORD*argn+BYTESPERWORD); comargm = comargn += argn; *comargn = ENDARGS;
 
        while(argp
-       DO      *--comargn = argp->argval;
+       ){      *--comargn = argp->argval;
                if(argp = argp->argnxt
                ) { trim(*comargn);
                ;}
@@ -309,10 +309,10 @@ static void       gsort(from,to)
        for (j=1; j<=n; j*=2 );
 
        for (m=2*j-1; m/=2;
-       DO  k=n-m;
+       ){ k=n-m;
            for (j=0; j<k; j++
-           DO  for (i=j; i>=0; i-=m
-               DO  REG STRING *fromi; fromi = &from[i];
+           ){  for (i=j; i>=0; i-=m
+               ){ REG STRING *fromi; fromi = &from[i];
                    if(cf(fromi[m],fromi[0])>0
                    ) { break;
                    } else { STRING s; s=fromi[m]; fromi[m]=fromi[0]; fromi[0]=s;
@@ -334,7 +334,7 @@ INT getarg(ac)
        if(c=ac
        ) {     argp=c->comarg;
                while(argp
-               DO      count += split(macro(argp->argval));
+               ){      count += split(macro(argp->argval));
                        argp=argp->argnxt;
                OD
        ;}
@@ -351,7 +351,7 @@ static INT  split(s)
        for(;;) {
                sigchk(); argp=locstak()+BYTESPERWORD;
                while((c = *s++, !any(c,ifsnod.namval) && c)
-               DO *argp++ = c OD
+               ){*argp++ = c OD
                if(argp==staktop+BYTESPERWORD
                ) {     if(c
                        ) {     continue;
index 2ca5cbf..c21a458 100644 (file)
@@ -63,7 +63,7 @@ void  tdystak(x)
 {
        /* try to bring stack back to x */
        while(ADR(stakbsy)>ADR(x)
-       DO free(stakbsy);
+       ){free(stakbsy);
           stakbsy = stakbsy->word;
        OD
        staktop=stakbot=max(ADR(x),ADR(stakbas));
index 4bb0b66..ff01268 100644 (file)
@@ -29,7 +29,7 @@ INT   any(c,s)
        REG CHAR d;
 
        while(d = *s++
-       DO      if(d==c
+       ){if(d==c
                ) {     return(TRUE);
                ;}
        OD
@@ -40,7 +40,7 @@ INT   cf(s1, s2)
        REG STRING s1, s2;
 {
        while(*s1++ == *s2
-       DO      if(*s2++==0
+       ){if(*s2++==0
                ) {     return(0);
                ;}
        OD
index 3fa8c92..7fa5af0 100644 (file)
@@ -32,7 +32,7 @@ word()
        ) {     do {    if(c==LITERAL
                        ) {     *argp++=(DQUOTE);
                                while((c=readc()) && c!=LITERAL
-                               DO *argp++=(c|QUOTE); chkpr(c) OD
+                               ){*argp++=(c|QUOTE); chkpr(c) OD
                                *argp++=(DQUOTE);
                        } else {        *argp++=(c);
                                if(c=='=' ) { wdset |= alpha ;}
@@ -40,7 +40,7 @@ word()
                                if(qotchar(c)
                                ) {     d=c;
                                        while((*argp++=(c=nextc(d))) && c!=d
-                                       DO chkpr(c) OD
+                                       ){chkpr(c) OD
                                ;}
                        ;}
                } while ( (c=nextc(0), !eofmeta(c)) );
index e33ee56..6bb9698 100644 (file)
@@ -62,7 +62,7 @@ execute(argt, execflg, pf1, pf2)
                                if( flags&execpr
                                ) {     argn=0; prs(execpmsg);
                                        while(com[argn]!=ENDARGS
-                                       DO prs(com[argn++]); blank() OD
+                                       ){prs(com[argn++]); blank() OD
                                        newline();
                                ;}
 
@@ -109,7 +109,7 @@ execute(argt, execflg, pf1, pf2)
                                                ) {     ++com;
                                                ;}
                                                while(*++com
-                                               DO INT  i;
+                                               ){INT   i;
                                                   if( (i=stoi(*com))>=MAXTRAP || i<MINTRAP
                                                   ) {  failed(*com,badtrap);
                                                   } else if ( clear
@@ -125,7 +125,7 @@ execute(argt, execflg, pf1, pf2)
                                                INT             i;
        
                                                for (i=0; i<MAXTRAP; i++
-                                               DO if( trapcom[i]
+                                               ){if( trapcom[i]
                                                   ) {  prn(i); prs(colon); prs(trapcom[i]); newline();
                                                   ;}
                                                OD
@@ -191,7 +191,7 @@ execute(argt, execflg, pf1, pf2)
        
                                        if( a1
                                        ) {     while(*++com
-                                               DO attrib(lookup(*com), exitval) OD
+                                               ){attrib(lookup(*com), exitval) OD
                                        } else {        namscan(printflg);
                                        ;}
                                        exitval=0;
@@ -240,7 +240,7 @@ execute(argt, execflg, pf1, pf2)
                        if( execflg && (treeflgs&(FAMP|FPOU))==0
                        ) {     parent=0;
                        } else {        while((parent=fork()) == -1
-                               DO sigchk(); alarm(10); pause() OD
+                               ){sigchk(); alarm(10); pause() OD
                        ;}
 
                        if( parent
@@ -348,7 +348,7 @@ execute(argt, execflg, pf1, pf2)
                           ;}
                           loopcnt++;
                           while(*args!=ENDARGS && execbrk==0
-                          DO   assign(n,*args++);
+                          ){assign(n,*args++);
                                execute(((FORPTR)t)->fortre,0);
                                if( execbrk<0 ) { execbrk=0 ;}
                           OD
@@ -365,7 +365,7 @@ execute(argt, execflg, pf1, pf2)
 
                           loopcnt++;
                           while(execbrk==0 && (execute(((WHPTR)t)->whtre,0)==0)==(type==TWH)
-                          DO i=execute(((WHPTR)t)->dotre,0);
+                          ){i=execute(((WHPTR)t)->dotre,0);
                              if( execbrk<0 ) { execbrk=0 ;}
                           OD
                           if( breakcnt ) { breakcnt-- ;}
@@ -385,9 +385,9 @@ execute(argt, execflg, pf1, pf2)
                           REG STRING   r = mactrim(((SWPTR)t)->swarg);
                           t=(TREPTR)((SWPTR)t)->swlst;
                           while(t
-                          DO   ARGPTR          rex=((REGPTR)t)->regptr;
+                          ){ARGPTR             rex=((REGPTR)t)->regptr;
                                while(rex
-                               DO      REG STRING      s;
+                               ){REG STRING    s;
                                        if( gmatch(r,s=macro(rex->argval)) || (trim(s), eq(r,s))
                                        ) {     execute(((REGPTR)t)->regcom,0);
                                                t=0; break;