scc

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

commit f5ecaab1bde3f51e6ccce10416530d5b29b4e84b
parent 7237e9631e196ccca0f772dca2d301d443a019b3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  8 Mar 2014 17:50:30 +0100

Simplify declarator()

Diffstat:
Mdecl.c | 26++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/decl.c b/decl.c @@ -273,32 +273,30 @@ static struct symbol * declarator(struct ctype *tp, unsigned char ns) { unsigned char qlf[NR_DECLARATORS]; - register unsigned char *bp, *lim; + register unsigned char *bp; + register unsigned char n = 0; struct symbol *sym; - lim = &qlf[NR_DECLARATORS]; - for (bp = qlf; yytoken == '*' && bp != lim; ) { - next(); - *bp++ = PTR; - while (bp != lim) { + if (yytoken == '*') { + for (bp = qlf; n < NR_DECLARATORS ; ++n) { switch (yytoken) { + case '*': + yytoken = PTR; case CONST: case VOLATILE: case RESTRICT: *bp++ = yytoken; next(); - break; + continue; default: - goto continue_outer; + goto direct; } } - continue_outer: ; - } - if (bp == lim) error("Too much type declarators"); + } - sym = directdcl(tp, ns); +direct: sym = directdcl(tp, ns); - for (lim = bp, bp = qlf; bp < lim; ++bp) - pushtype(*bp); + for (bp = qlf; n--; pushtype(*bp++)) + /* nothing */; return sym; }