scc

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

commit d65e66829ce3e79ffb92fd58675f5e655561a37a
parent 12e0b049f96901be321d7797730555f81af2eee8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 11 Mar 2014 16:27:00 +0100

Optimize ctype function

Unify all the error calls.

Diffstat:
Mtypes.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/types.c b/types.c @@ -107,6 +107,7 @@ struct ctype * ctype(struct ctype *tp, unsigned char tok) { register unsigned char type; + static char *err; if (!tp->defined) { tp->type = 0; @@ -200,13 +201,17 @@ check_sign: switch (type) { return tp; both_sign: - error("both 'signed' and 'unsigned' in declaration specifiers"); + err = "both 'signed' and 'unsigned' in declaration specifiers"; + goto error; duplicated: - error("duplicated '%s'", yytext); + err = "duplicated '%s'"; + goto error; invalid_sign: - error("invalid sign modifier"); + err = "invalid sign modifier"; + goto error; two_or_more: - error("two or more basic types"); + err = "two or more basic types"; +error: error(err, yytext); } struct qualifier *