From 0f4badb13e3321f11c042e7b71eb1993d6482466 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 10 May 2015 22:25:39 +0100 Subject: [PATCH] sh: kill off DO --- Applications/V7/cmd/sh/args.c | 12 ++++++------ 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 | 16 ++++++++-------- 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 | 4 ++-- Applications/V7/cmd/sh/service.c | 24 ++++++++++++------------ Applications/V7/cmd/sh/stak.c | 2 +- Applications/V7/cmd/sh/string.c | 4 ++-- Applications/V7/cmd/sh/word.c | 4 ++-- Applications/V7/cmd/sh/xec.c | 18 +++++++++--------- 16 files changed, 66 insertions(+), 67 deletions(-) diff --git a/Applications/V7/cmd/sh/args.c b/Applications/V7/cmd/sh/args.c index cdb57501..e269b1aa 100644 --- a/Applications/V7/cmd/sh/args.c +++ b/Applications/V7/cmd/sh/args.c @@ -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); } diff --git a/Applications/V7/cmd/sh/blok.c b/Applications/V7/cmd/sh/blok.c index e53667df..aa7a3784 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; 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 diff --git a/Applications/V7/cmd/sh/cmd.c b/Applications/V7/cmd/sh/cmd.c index ae942f02..f8d36dbb 100644 --- a/Applications/V7/cmd/sh/cmd.c +++ b/Applications/V7/cmd/sh/cmd.c @@ -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); diff --git a/Applications/V7/cmd/sh/error.c b/Applications/V7/cmd/sh/error.c index b8684578..815b17a7 100644 --- a/Applications/V7/cmd/sh/error.c +++ b/Applications/V7/cmd/sh/error.c @@ -80,7 +80,7 @@ rmtemp(base) IOPTR base; { while(iotemp>base - DO unlink(iotemp->ioname); + ){ unlink(iotemp->ioname); iotemp=iotemp->iolst; OD } diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index c0e7a1e6..84b53122 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -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 ); diff --git a/Applications/V7/cmd/sh/fault.c b/Applications/V7/cmd/sh/fault.c index faedb35a..73e54e3a 100644 --- a/Applications/V7/cmd/sh/fault.c +++ b/Applications/V7/cmd/sh/fault.c @@ -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; diff --git a/Applications/V7/cmd/sh/io.c b/Applications/V7/cmd/sh/io.c index 13115713..493a3534 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)) ){*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 121f3b31..0276d047 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 DO ){ #define OD ;} #define TRUE (-1) diff --git a/Applications/V7/cmd/sh/macro.c b/Applications/V7/cmd/sh/macro.c index 0316d659..c708b9f4 100644 --- a/Applications/V7/cmd/sh/macro.c +++ b/Applications/V7/cmd/sh/macro.c @@ -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; ;} diff --git a/Applications/V7/cmd/sh/name.c b/Applications/V7/cmd/sh/name.c index 73c84a0d..40f2ad30 100644 --- a/Applications/V7/cmd/sh/name.c +++ b/Applications/V7/cmd/sh/name.c @@ -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; diff --git a/Applications/V7/cmd/sh/print.c b/Applications/V7/cmd/sh/print.c index a602fda1..b7e2902a 100644 --- a/Applications/V7/cmd/sh/print.c +++ b/Applications/V7/cmd/sh/print.c @@ -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); diff --git a/Applications/V7/cmd/sh/service.c b/Applications/V7/cmd/sh/service.c index 7e918410..b48b35ce 100644 --- a/Applications/V7/cmd/sh/service.c +++ b/Applications/V7/cmd/sh/service.c @@ -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"E; } @@ -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=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; diff --git a/Applications/V7/cmd/sh/stak.c b/Applications/V7/cmd/sh/stak.c index 2ca5cbf5..c21a4584 100644 --- a/Applications/V7/cmd/sh/stak.c +++ b/Applications/V7/cmd/sh/stak.c @@ -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)); diff --git a/Applications/V7/cmd/sh/string.c b/Applications/V7/cmd/sh/string.c index 4bb0b661..ff012684 100644 --- a/Applications/V7/cmd/sh/string.c +++ b/Applications/V7/cmd/sh/string.c @@ -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 diff --git a/Applications/V7/cmd/sh/word.c b/Applications/V7/cmd/sh/word.c index 3fa8c927..7fa5af05 100644 --- a/Applications/V7/cmd/sh/word.c +++ b/Applications/V7/cmd/sh/word.c @@ -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)) ); diff --git a/Applications/V7/cmd/sh/xec.c b/Applications/V7/cmd/sh/xec.c index e33ee56b..6bb96983 100644 --- a/Applications/V7/cmd/sh/xec.c +++ b/Applications/V7/cmd/sh/xec.c @@ -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 || ifortre,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; -- 2.34.1