shithub: scc

Download patch

ref: e441794261a07daf191f12cee98e71423029ef50
parent: 47846316bb2f9c8dfdde56b31021f2e9cf12bcbb
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Jan 16 11:30:33 EST 2017

[cc1] Fix EOF in cpp mode

Lexer was returning EOF in expressions evaluated in CPPMODE
after expanding some macro. It was happening because and
end of line in CPPMODE was always considered EOF, but
since last changes we can have inputs pushed up from
other inputs in CPPMODE.

TODO: Change the input mechanism :(

--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -642,12 +642,18 @@
 repeat:
 	while (isspace(*input->p))
 		++input->p;
-	if (*input->p == '\0' && lexmode != CPPMODE) {
-		if (!moreinput())
+	input->begin = input->p;
+
+	if (*input->p != '\0')
+		return;
+
+	if (lexmode == CPPMODE) {
+		if (!input || !input->next || !input->next->fp)
 			return;
-		goto repeat;
 	}
-	input->begin = input->p;
+	if (!moreinput())
+		return;
+	goto repeat;
 }
 
 unsigned