scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 35257df51f4fed44e2eb1cb815a9f1f45f74bd78
parent 373ea4b9ebd3324e7b8cd683643dc52566b10b97
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  7 May 2015 12:50:06 +0200

Avoid ugly error messages with non printable characters in expect

Diffstat:
cc1/lex.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/cc1/lex.c b/cc1/lex.c @@ -385,14 +385,17 @@ next(void) return yytoken; } -/* TODO: Remove calls to expect without a character */ void expect(uint8_t tok) { - if (yytoken != tok) - softerror("expected '%c' before '%s'", tok, yytext); - else + if (yytoken != tok) { + if (isgraph(tok)) + softerror("expected '%c' before '%s'", tok, yytext); + else + softerror("unexpected '%s'", yytext); + } else { next(); + } } uint8_t