From: nealcrook Date: Tue, 22 Nov 2016 08:39:07 +0000 (+0000) Subject: Using assignments as truth values seems to have been a favoured X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2b1b8f49c252be2d7da5d0266bc657fedef1ba6a;p=FUZIX.git Using assignments as truth values seems to have been a favoured programming style of Mr Bourne. gcc moans about it though: "suggest parentheses around assignment used as truth value" so in the interests of fewer compile warnings I have complied with the suggestion. --- diff --git a/Applications/V7/cmd/sh/args.c b/Applications/V7/cmd/sh/args.c index f0f6c6de..bc677d7c 100644 --- a/Applications/V7/cmd/sh/args.c +++ b/Applications/V7/cmd/sh/args.c @@ -94,7 +94,7 @@ DOLPTR freeargs(DOLPTR blk) register DOLPTR argr = 0; register DOLPTR argblk; - if (argblk = blk) { + if ( (argblk = blk) ) { argr = argblk->dolnxt; if ((--argblk->doluse) == 0) { for (argp = (char **) argblk->dolarg; @@ -128,7 +128,7 @@ static const char **copyargs(const char *from[], int n) void clearup(void) { /* force `for' $* lists to go away */ - while (argfor = freeargs(argfor)); + while ( (argfor = freeargs(argfor)) ); /* clean up io files */ while (pop()); diff --git a/Applications/V7/cmd/sh/cmd.c b/Applications/V7/cmd/sh/cmd.c index 4e018281..6abc7fc0 100644 --- a/Applications/V7/cmd/sh/cmd.c +++ b/Applications/V7/cmd/sh/cmd.c @@ -89,7 +89,7 @@ TREPTR cmd(register int sym, int flg) synbad(); case ';': - if (e = cmd(sym, flg | MTFLG)) + if ( (e = cmd(sym, flg | MTFLG)) ) i = makelist(TLST, i, e); break; @@ -307,7 +307,7 @@ static TREPTR item(BOOL flag) } reserv++; word(); - if (io = inout(io)) { + if ( (io = inout(io)) ) { t = makefork(0, t); t->treio = io; } diff --git a/Applications/V7/cmd/sh/error.c b/Applications/V7/cmd/sh/error.c index 8e8cd79c..d59e6228 100644 --- a/Applications/V7/cmd/sh/error.c +++ b/Applications/V7/cmd/sh/error.c @@ -69,8 +69,7 @@ void exitsh(int xno) void done(void) { register STRING t; - if (t = trapcom[0] - ) { + if ( (t = trapcom[0]) ) { trapcom[0] = 0; /*should free but not long */ execexp(t, 0); ; diff --git a/Applications/V7/cmd/sh/expand.c b/Applications/V7/cmd/sh/expand.c index c2128ca5..acbb09d1 100644 --- a/Applications/V7/cmd/sh/expand.c +++ b/Applications/V7/cmd/sh/expand.c @@ -164,7 +164,7 @@ int expand(char *as, int rflg) { register char c; s = as; - while (c = *s) + while ( (c = *s) ) *s++ = (c & STRIP ? c : '/'); } return count; @@ -175,7 +175,7 @@ int gmatch(register char *s, register char *p) register int scc; char c; - if (scc = *s++) { + if ( (scc = *s++) ) { if ((scc &= STRIP) == 0) { scc = 0200; } @@ -187,7 +187,7 @@ int gmatch(register char *s, register char *p) int lc; ok = 0; lc = 077777; - while (c = *p++) { + while ( (c = *p++) ) { if (c == ']') { return (ok ? gmatch(s, p) : 0); } else if (c == MINUS) { @@ -234,7 +234,7 @@ static void addg(const char *as1, char *as2, const char *as3) s2 = locstak() + BYTESPERWORD; s1 = as1; - while (c = *s1++) { + while ( (c = *s1++) ) { if ((c &= STRIP) == 0) { *s2++ = '/'; break; @@ -243,12 +243,12 @@ static void addg(const char *as1, char *as2, const char *as3) *s2++ = c; } s1 = as2; - while (*s2 = *s1++) { + while ( (*s2 = *s1++) ) { s2++; } - if (s1 = as3) { + if ( (s1 = as3) ) { *s2++ = '/'; - while (*s2++ = *++s1); + while ( (*s2++ = *++s1) ); } makearg(endstak(s2)); } diff --git a/Applications/V7/cmd/sh/fault.c b/Applications/V7/cmd/sh/fault.c index d3f43868..dd5c452b 100644 --- a/Applications/V7/cmd/sh/fault.c +++ b/Applications/V7/cmd/sh/fault.c @@ -98,7 +98,7 @@ void chktrap(void) while (--i) { if (trapflg[i] & TRAPSET) { trapflg[i] &= ~TRAPSET; - if (t = trapcom[i]) { + if ( (t = trapcom[i]) ) { int savxit = exitval; execexp(t, 0); exitval = savxit; diff --git a/Applications/V7/cmd/sh/io.c b/Applications/V7/cmd/sh/io.c index 7276cfe4..f407cf1b 100644 --- a/Applications/V7/cmd/sh/io.c +++ b/Applications/V7/cmd/sh/io.c @@ -115,7 +115,7 @@ void copy(IOPTR ioparg) int fd; register IOPTR iop; - if (iop = ioparg) { + if ( (iop = ioparg) ) { copy(iop->iolst); ends = mactrim(iop->ioname); diff --git a/Applications/V7/cmd/sh/macro.c b/Applications/V7/cmd/sh/macro.c index 26199409..534a87a4 100644 --- a/Applications/V7/cmd/sh/macro.c +++ b/Applications/V7/cmd/sh/macro.c @@ -77,7 +77,7 @@ retry: CHAR idb[2]; char *id = idb; - if (bra = (c == BRACE)) + if ( (bra = (c == BRACE)) ) c = readc(); if (letter(c)) { @@ -141,7 +141,7 @@ retry: if (v) { if (c != '+') { for (;;) { - while (c = *v++) + while ( (c = *v++) ) pushstak(c | quote); if (dolg == 0 || (++dolg > dolc)) @@ -239,7 +239,7 @@ static void comsubst(void) tdystak(savptr); staktop = movstr(savptr, stakbot); - while (d = readc()) + while ( (d = readc()) ) pushstak(d | quote); await(0); @@ -264,7 +264,7 @@ void subst(int in, int ot) push(&fb); initf(in); /* DQUOTE used to stop it from quoting */ - while (c = (getch(DQUOTE) & STRIP)) { + while ( (c = (getch(DQUOTE) & STRIP)) ) { pushstak(c); if (--count == 0) { flush(ot); diff --git a/Applications/V7/cmd/sh/name.c b/Applications/V7/cmd/sh/name.c index dff927ab..7bd9a9f6 100644 --- a/Applications/V7/cmd/sh/name.c +++ b/Applications/V7/cmd/sh/name.c @@ -38,7 +38,7 @@ int syslook(char *w, SYSTAB syswds) syscan = syswds; first = *w; - while (s = syscan->sysnam) { + while ( (s = syscan->sysnam) ) { if (first == *s && eq(w, s)) return (syscan->sysval); syscan++; @@ -236,7 +236,7 @@ void printnam(NAMPTR n) register const char *s; sigchk(); - if (s = n->namval) { + if ( (s = n->namval) ) { prs(n->namid); prc('='); prs(s); diff --git a/Applications/V7/cmd/sh/print.c b/Applications/V7/cmd/sh/print.c index a51f98a3..1ee9ae4e 100644 --- a/Applications/V7/cmd/sh/print.c +++ b/Applications/V7/cmd/sh/print.c @@ -38,7 +38,7 @@ void prs(const char *as) { register const char *s; - if (s = as) + if ( (s = as) ) write(output, s, length(s) - 1); } @@ -57,7 +57,7 @@ void prt(clock_t t) sec = t % 60; t /= 60; min = t % 60; - if (hr = t / 60) { + if ( (hr = t / 60) ) { prn(hr); prc('h'); } diff --git a/Applications/V7/cmd/sh/service.c b/Applications/V7/cmd/sh/service.c index fc51695c..01ae0b92 100644 --- a/Applications/V7/cmd/sh/service.c +++ b/Applications/V7/cmd/sh/service.c @@ -133,7 +133,7 @@ void execa(const char **at) path = getpath(*t); namscan(exname); xecenv = sh_setenv(); - while (path = execs(path, t)); + while ( (path = execs(path, t)) ); failed(*t, xecmsg); } } @@ -149,7 +149,7 @@ static const char *execs(const char *ap, const char *t[]) sigchk(); execve(p, (char**) &t[0], (char **)xecenv); switch (errno) { - case ENOEXEC: + case ENOEXEC: /* could be a shell script */ flags = 0; comdiv = 0; ioset = 0; @@ -240,7 +240,7 @@ void await(int i) w_hi = (w >> 8) & LOBYTE; - if (sig = w & 0177) { + if ( (sig = w & 0177) ) { if (sig == 0177) { /* ptrace! return */ prs("ptrace: "); sig = w_hi; @@ -277,8 +277,8 @@ void trim(char *at) register char c; register char q = 0; - if (p = at) { - while (c = *p) { + if ( (p = at) ) { + while ( (c = *p) ) { *p++ = c & STRIP; q |= c; } @@ -304,7 +304,7 @@ char **scan(int argn) while (argp) { *--comargn = argp->argval; - if (argp = argp->argnxt) + if ( (argp = argp->argnxt) ) trim(*comargn); if (argp == 0 || ((intptr_t)(argp)) & ARGMK) { gsort(comargn, comargm); @@ -352,7 +352,7 @@ int getarg(COMPTR ac) register int count = 0; register COMPTR c; - if (c = ac) { + if ( (c = ac) ) { argp = c->comarg; while (argp) { count += split(macro(argp->argval)); @@ -386,7 +386,7 @@ static int split(register const char *s) } else if (c == 0) { s--; } - if (c = expand(((ARGPTR) (argp = endstak(argp)))->argval, 0)) { + if ( (c = expand(((ARGPTR) (argp = endstak(argp)))->argval, 0)) ) { count += c; } else { /* assign(&fngnod, argp->argval); */ makearg(argp); diff --git a/Applications/V7/cmd/sh/string.c b/Applications/V7/cmd/sh/string.c index 0d893ffb..8e21d151 100644 --- a/Applications/V7/cmd/sh/string.c +++ b/Applications/V7/cmd/sh/string.c @@ -17,7 +17,7 @@ char *movstr(register const char *a, register char *b) { - while (*b++ = *a++); + while ( (*b++ = *a++) ); return (--b); } @@ -25,7 +25,7 @@ int any(char c, const char *s) { register char d; - while (d = *s++) { + while ( (d = *s++) ) { if (d == c) { return (TRUE); ; @@ -49,7 +49,7 @@ int length(const char *as) { register const char *s; - if (s = as) { + if ( (s = as) ) { while (*s++);; } return (s - as);