commit 5d75fa9ad62267658ce6ee314cd185fb02510960 parent b776ea1b18419b7be3b62e207259f1b4115a5c17 Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Sat, 23 May 2015 10:10:09 +0200 Fix end of file case Diffstat:
M | cc1/lex.c | | | 14 | +++++++++++--- |
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/cc1/lex.c b/cc1/lex.c @@ -117,7 +117,7 @@ readchar(void) FILE *fp; repeat: - while (feof(input->fp) && !eof) + while (!input->fp || (feof(input->fp) && !eof)) delinput(); if (eof) { if (incomment) @@ -192,12 +192,20 @@ moreinput(void) 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