scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 8022f78f34e2b0532f880d2d64d363bb1e20531d
parent e6183c2b047fec411a87bcb04ccc3833ec846b20
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 18 Jul 2015 10:31:19 +0200

Rewrite clever expressions in cpp.c

These expressions were too much clever and obscure. Using
an intermediate variable helps to understand them.

Diffstat:
Mcc1/cpp.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -447,9 +447,11 @@ ifclause(int isdef) { Symbol *sym; unsigned n; + int status; if (cppctx == NR_COND-1) error("too much nesting levels of conditional inclusion"); + n = cppctx++; if (yytoken != IDEN) { error("no macro name given in #%s directive", @@ -458,7 +460,10 @@ ifclause(int isdef) sym = lookup(NS_CPP); next(); - if (!(ifstatus[n] = (sym->flags & ISDEFINED) != 0 == isdef)) + + status = (sym->flags & ISDEFINED) != 0 == isdef; + + if (!(ifstatus[n] = status)) ++cppoff; } @@ -486,10 +491,13 @@ endif(void) static void elseclause(void) { + int status; + if (cppctx == 0) error("#else without #ifdef/ifndef"); - cppoff += (ifstatus[cppctx-1] ^= 1) ? -1 : 1; + status = (ifstatus[cppctx-1] ^= 1); + cppoff += (status) ? -1 : 1; } static void