From 53de40b72170aa96797592623883628784ab9bed Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 10 May 2015 21:47:16 +0100 Subject: [PATCH] sh: kill off BEGIN and END --- Applications/V7/cmd/sh/blok.c | 4 ++-- Applications/V7/cmd/sh/cmd.c | 24 ++++++++++++------------ Applications/V7/cmd/sh/expand.c | 8 ++++---- Applications/V7/cmd/sh/mac.h | 2 -- Applications/V7/cmd/sh/macro.c | 8 ++++---- Applications/V7/cmd/sh/service.c | 4 ++-- Applications/V7/cmd/sh/xec.c | 20 ++++++++++---------- 7 files changed, 34 insertions(+), 36 deletions(-) diff --git a/Applications/V7/cmd/sh/blok.c b/Applications/V7/cmd/sh/blok.c index fd2fbed7..cb6b6338 100644 --- a/Applications/V7/cmd/sh/blok.c +++ b/Applications/V7/cmd/sh/blok.c @@ -70,11 +70,11 @@ void addblok(reqd) blokp=bloktop; bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd); bloktop->word=BLK(ADR(end)+1); - BEGIN + { REG STKPTR stakadr=STK(bloktop+2); staktop=movstr(stakbot,stakadr); stakbas=stakbot=stakadr; - END + } } void free(void *ap) diff --git a/Applications/V7/cmd/sh/cmd.c b/Applications/V7/cmd/sh/cmd.c index 3f575d16..0789d2c9 100644 --- a/Applications/V7/cmd/sh/cmd.c +++ b/Applications/V7/cmd/sh/cmd.c @@ -206,7 +206,7 @@ static TREPTR item(flag) SWITCH wdval IN case CASYM: - BEGIN + { t=(TREPTR)getstak(SWTYPE); chkword(); ((SWPTR)t)->swarg=wdarg->argval; @@ -214,10 +214,10 @@ static TREPTR item(flag) ((SWPTR)t)->swlst=syncase(wdval==INSYM?ESSYM:KTSYM); ((SWPTR)t)->swtyp=TSW; break; - END + } case IFSYM: - BEGIN + { REG INT w; t=(TREPTR)getstak(IFTYPE); ((IFPTR)t)->iftyp=TIF; @@ -226,10 +226,10 @@ static TREPTR item(flag) ((IFPTR)t)->eltre=((w=wdval)==ELSYM ? cmd(FISYM,NLFLG) : (w==EFSYM ? (wdval=IFSYM, item(0)) : 0)); IF w==EFSYM THEN return(t) FI break; - END + } case FORSYM: - BEGIN + { t=(TREPTR)getstak(FORTYPE); ((FORPTR)t)->fortyp=TFOR; ((FORPTR)t)->forlst=0; @@ -246,31 +246,31 @@ static TREPTR item(flag) chksym(DOSYM|BRSYM); ((FORPTR)t)->fortre=cmd(wdval==DOSYM?ODSYM:KTSYM,NLFLG); break; - END + } case WHSYM: case UNSYM: - BEGIN + { t=(TREPTR)getstak(WHTYPE); ((WHPTR)t)->whtyp=(wdval==WHSYM ? TWH : TUN); ((WHPTR)t)->whtre = cmd(DOSYM,NLFLG); ((WHPTR)t)->dotre = cmd(ODSYM,NLFLG); break; - END + } case BRSYM: t=cmd(KTSYM,NLFLG); break; case '(': - BEGIN + { REG PARPTR p; p=(PARPTR)getstak(PARTYPE); p->partre=cmd(')',NLFLG); p->partyp=TPAR; t=makefork(0,p); break; - END + } default: IF io==0 @@ -278,7 +278,7 @@ static TREPTR item(flag) FI case 0: - BEGIN + { REG ARGPTR argp; REG ARGPTR *argtail; REG ARGPTR *argset=0; @@ -303,7 +303,7 @@ static TREPTR item(flag) ((COMPTR)t)->comset=(ARGPTR)argset; *argtail=0; return(t); - END + } ENDSW reserv++; word(); diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index 528dd128..9aac0c09 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -46,7 +46,7 @@ INT expand(as,rflg) s=cs=as; entry.d_name[DIRSIZ-1]=0; /* to end the string */ /* check for meta chars */ - BEGIN + { REG BOOL slash; slash=0; WHILE !fngchar(*cs) DO IF *cs++==0 @@ -55,7 +55,7 @@ INT expand(as,rflg) THEN slash++; FI OD - END + } for(;;) { IF cs==s THEN s=nullstr; @@ -106,12 +106,12 @@ INT expand(as,rflg) FI FI - BEGIN + { REG CHAR c; s=as; WHILE c = *s DO *s++=(c&STRIP?c:'/') OD - END + } return(count); } diff --git a/Applications/V7/cmd/sh/mac.h b/Applications/V7/cmd/sh/mac.h index cb50b7cf..e60f8ac5 100644 --- a/Applications/V7/cmd/sh/mac.h +++ b/Applications/V7/cmd/sh/mac.h @@ -20,8 +20,6 @@ #define ELIF } else if ( #define FI ;} -#define BEGIN { -#define END } #define SWITCH switch( #define IN ){ #define ENDSW } diff --git a/Applications/V7/cmd/sh/macro.c b/Applications/V7/cmd/sh/macro.c index d831bf1b..71a31488 100644 --- a/Applications/V7/cmd/sh/macro.c +++ b/Applications/V7/cmd/sh/macro.c @@ -183,12 +183,12 @@ static comsubst() WHILE (d=readc())!=SQUOTE && d DO pushstak(d) OD - BEGIN + { REG STRING argc; trim(argc=fixstak()); push(&cb); estabf(argc); - END - BEGIN + } + { REG TREPTR t = makefork(FPOU,cmd(EOFSYM,MTFLG|NLFLG)); INT pv[2]; @@ -199,7 +199,7 @@ static comsubst() initf(pv[INPIPE]); execute(t, 0, 0, pv); close(pv[OTPIPE]); - END + } tdystak(savptr); staktop=movstr(savptr,stakbot); WHILE d=readc() DO pushstak(d|quote) OD await(0); diff --git a/Applications/V7/cmd/sh/service.c b/Applications/V7/cmd/sh/service.c index 9d815d4b..8e9df6f8 100644 --- a/Applications/V7/cmd/sh/service.c +++ b/Applications/V7/cmd/sh/service.c @@ -212,7 +212,7 @@ void await(i) REG INT sig; INT w_hi; - BEGIN + { REG INT *pw=pwlist; p=wait(&w); WHILE pw <= &pwlist[ipwc] @@ -221,7 +221,7 @@ void await(i) ELSE pw++; FI OD - END + } IF p == -1 THEN continue FI diff --git a/Applications/V7/cmd/sh/xec.c b/Applications/V7/cmd/sh/xec.c index 0e2e6b12..deab3a4f 100644 --- a/Applications/V7/cmd/sh/xec.c +++ b/Applications/V7/cmd/sh/xec.c @@ -43,7 +43,7 @@ execute(argt, execflg, pf1, pf2) SWITCH type IN case TCOM: - BEGIN + { STRING a1; INT argn, internal; ARGPTR schain=gchain; @@ -234,7 +234,7 @@ execute(argt, execflg, pf1, pf2) ELIF t->treio==0 THEN break; FI - END + } case TFORK: IF execflg && (treeflgs&(FAMP|FPOU))==0 @@ -306,13 +306,13 @@ execute(argt, execflg, pf1, pf2) done(); case TFIL: - BEGIN + { INT pv[2]; chkpipe(pv); IF execute(((LSTPTR)t)->lstlef, 0, pf1, pv)==0 THEN execute(((LSTPTR)t)->lstrit, execflg, pv, pf2); ELSE closepipe(pv); FI - END + } break; case TLST: @@ -333,7 +333,7 @@ execute(argt, execflg, pf1, pf2) break; case TFOR: - BEGIN + { NAMPTR n = lookup(((FORPTR)t)->fornam); STRING *args; DOLPTR argsav=0; @@ -355,12 +355,12 @@ execute(argt, execflg, pf1, pf2) IF breakcnt THEN breakcnt-- FI execbrk=breakcnt; loopcnt--; argfor=freeargs(argsav); - END + } break; case TWH: case TUN: - BEGIN + { INT i=0; loopcnt++; @@ -370,7 +370,7 @@ execute(argt, execflg, pf1, pf2) OD IF breakcnt THEN breakcnt-- FI execbrk=breakcnt; loopcnt--; exitval=i; - END + } break; case TIF: @@ -381,7 +381,7 @@ execute(argt, execflg, pf1, pf2) break; case TSW: - BEGIN + { REG STRING r = mactrim(((SWPTR)t)->swarg); t=(TREPTR)((SWPTR)t)->swlst; WHILE t @@ -396,7 +396,7 @@ execute(argt, execflg, pf1, pf2) OD IF t THEN t=(TREPTR)((REGPTR)t)->regnxt FI OD - END + } break; ENDSW exitset(); -- 2.34.1