ref: f5ecaab1bde3f51e6ccce10416530d5b29b4e84b
parent: 7237e9631e196ccca0f772dca2d301d443a019b3
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Mar 8 12:50:30 EST 2014
Simplify declarator()
--- a/decl.c
+++ b/decl.c
@@ -273,32 +273,30 @@
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;
}