ref: 9cd10aa29ae615f703ec0c91275cd9c413e38c01
parent: 8f9b01e50962ab00b65267732fac13960e312cc1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed May 27 11:20:29 EDT 2015
Fix expansion of macros When a macro is expanded it is possible (and common) to have more available characters in the current line, so we cannot be sure that after a delinput() we have to read a line from the current line, because it is possible to return from a macro expansion. This change needs also to discard the content of the line after processing a preprocessor directive.
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -236,13 +236,18 @@
repeat:
if (!input->fp)
delinput();
+ if (*input->begin)
+ return 1;
if (!readline())
return 0;
p = input->line;
while (isspace(*p))
++p;
- if (*p == '\0' || cpp(p) || cppoff)
+ if (*p == '\0' || cpp(p) || cppoff) {
+ *input->begin = '\0';
goto repeat;
+ }
+
input->p = input->begin = p;
return 1;
}