scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 9cd10aa29ae615f703ec0c91275cd9c413e38c01
parent 8f9b01e50962ab00b65267732fac13960e312cc1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 27 May 2015 15:20:29 +0200

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.

Diffstat:
cc1/lex.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cc1/lex.c b/cc1/lex.c @@ -236,13 +236,18 @@ moreinput(void) 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; }