shithub: scc

Download patch

ref: 5d75fa9ad62267658ce6ee314cd185fb02510960
parent: b776ea1b18419b7be3b62e207259f1b4115a5c17
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat May 23 06:10:09 EDT 2015

Fix end of file case

--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -117,7 +117,7 @@
 	FILE *fp;
 
 repeat:
-	while (feof(input->fp) && !eof)
+	while (!input->fp || (feof(input->fp) && !eof))
 		delinput();
 	if (eof) {
 		if (incomment)
@@ -192,12 +192,20 @@
 	char *p;
 
 repeat:
+	if (eof)
+		return 0;
+	while (*input->begin == '\0' && !input->fp) {
+		delinput();
+		if (*input->begin)
+			return 1;
+	}
+
 	*(p = input->line) = '\0';
 	readline();
-	if ((p = preprocessor(p)) == '\0')
+	if (*(p = preprocessor(p)) == '\0')
 		goto repeat;
 	input->p = input->begin = p;
-	return *p != '\0';
+	return 1;
 }
 
 static void