shithub: scc

Download patch

ref: 35257df51f4fed44e2eb1cb815a9f1f45f74bd78
parent: 373ea4b9ebd3324e7b8cd683643dc52566b10b97
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu May 7 08:50:06 EDT 2015

Avoid ugly error messages with non printable characters in expect

--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -385,14 +385,17 @@
 	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