From 21c0a5b2d38031b6907b6b7f5392140cff41fc32 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 10 May 2015 22:15:22 +0100 Subject: [PATCH] sh:kill off WHILE --- Applications/V7/cmd/sh/args.c | 14 +++++++------- Applications/V7/cmd/sh/blok.c | 2 +- Applications/V7/cmd/sh/cmd.c | 8 ++++---- Applications/V7/cmd/sh/error.c | 2 +- Applications/V7/cmd/sh/expand.c | 18 +++++++++--------- Applications/V7/cmd/sh/fault.c | 4 ++-- Applications/V7/cmd/sh/io.c | 2 +- Applications/V7/cmd/sh/mac.h | 1 - Applications/V7/cmd/sh/macro.c | 16 ++++++++-------- Applications/V7/cmd/sh/name.c | 14 +++++++------- Applications/V7/cmd/sh/print.c | 2 +- Applications/V7/cmd/sh/service.c | 22 +++++++++++----------- Applications/V7/cmd/sh/stak.c | 2 +- Applications/V7/cmd/sh/string.c | 8 ++++---- Applications/V7/cmd/sh/word.c | 6 +++--- Applications/V7/cmd/sh/xec.c | 16 ++++++++-------- 16 files changed, 68 insertions(+), 69 deletions(-) diff --git a/Applications/V7/cmd/sh/args.c b/Applications/V7/cmd/sh/args.c index 84314b95..ed1663f3 100644 --- a/Applications/V7/cmd/sh/args.c +++ b/Applications/V7/cmd/sh/args.c @@ -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() diff --git a/Applications/V7/cmd/sh/blok.c b/Applications/V7/cmd/sh/blok.c index 4ab76acf..99a5dd6d 100644 --- a/Applications/V7/cmd/sh/blok.c +++ b/Applications/V7/cmd/sh/blok.c @@ -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 diff --git a/Applications/V7/cmd/sh/cmd.c b/Applications/V7/cmd/sh/cmd.c index 83278e26..ae942f02 100644 --- a/Applications/V7/cmd/sh/cmd.c +++ b/Applications/V7/cmd/sh/cmd.c @@ -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); diff --git a/Applications/V7/cmd/sh/error.c b/Applications/V7/cmd/sh/error.c index cfa424af..b8684578 100644 --- a/Applications/V7/cmd/sh/error.c +++ b/Applications/V7/cmd/sh/error.c @@ -79,7 +79,7 @@ done() rmtemp(base) IOPTR base; { - WHILE iotemp>base + while(iotemp>base DO unlink(iotemp->ioname); iotemp=iotemp->iolst; OD diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index 4bda8be2..af9dfea8 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -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)); } diff --git a/Applications/V7/cmd/sh/fault.c b/Applications/V7/cmd/sh/fault.c index adfb8044..faedb35a 100644 --- a/Applications/V7/cmd/sh/fault.c +++ b/Applications/V7/cmd/sh/fault.c @@ -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] diff --git a/Applications/V7/cmd/sh/io.c b/Applications/V7/cmd/sh/io.c index 51373f88..13115713 100644 --- a/Applications/V7/cmd/sh/io.c +++ b/Applications/V7/cmd/sh/io.c @@ -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; diff --git a/Applications/V7/cmd/sh/mac.h b/Applications/V7/cmd/sh/mac.h index cffde0b7..0b2ea33f 100644 --- a/Applications/V7/cmd/sh/mac.h +++ b/Applications/V7/cmd/sh/mac.h @@ -14,7 +14,6 @@ #define UNION TYPE union #define REG register -#define WHILE while( #define DO ){ #define OD ;} #define REP do{ diff --git a/Applications/V7/cmd/sh/macro.c b/Applications/V7/cmd/sh/macro.c index 278e89d5..0316d659 100644 --- a/Applications/V7/cmd/sh/macro.c +++ b/Applications/V7/cmd/sh/macro.c @@ -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; diff --git a/Applications/V7/cmd/sh/name.c b/Applications/V7/cmd/sh/name.c index 37a5f85c..73c84a0d 100644 --- a/Applications/V7/cmd/sh/name.c +++ b/Applications/V7/cmd/sh/name.c @@ -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 } diff --git a/Applications/V7/cmd/sh/print.c b/Applications/V7/cmd/sh/print.c index cb8795d3..a602fda1 100644 --- a/Applications/V7/cmd/sh/print.c +++ b/Applications/V7/cmd/sh/print.c @@ -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); diff --git a/Applications/V7/cmd/sh/service.c b/Applications/V7/cmd/sh/service.c index af6bd6e4..0c9439cd 100644 --- a/Applications/V7/cmd/sh/service.c +++ b/Applications/V7/cmd/sh/service.c @@ -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"E; @@ -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 diff --git a/Applications/V7/cmd/sh/stak.c b/Applications/V7/cmd/sh/stak.c index ca47a58d..2ca5cbf5 100644 --- a/Applications/V7/cmd/sh/stak.c +++ b/Applications/V7/cmd/sh/stak.c @@ -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 diff --git a/Applications/V7/cmd/sh/string.c b/Applications/V7/cmd/sh/string.c index b7f6a2fc..eb4c5600 100644 --- a/Applications/V7/cmd/sh/string.c +++ b/Applications/V7/cmd/sh/string.c @@ -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); } diff --git a/Applications/V7/cmd/sh/word.c b/Applications/V7/cmd/sh/word.c index 665e4d1c..384bc6a3 100644 --- a/Applications/V7/cmd/sh/word.c +++ b/Applications/V7/cmd/sh/word.c @@ -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 ;} ;} diff --git a/Applications/V7/cmd/sh/xec.c b/Applications/V7/cmd/sh/xec.c index 298b9b1f..e33ee56b 100644 --- a/Applications/V7/cmd/sh/xec.c +++ b/Applications/V7/cmd/sh/xec.c @@ -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 || ifortre,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); -- 2.34.1