scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 04b94d81004857b6f21a15622001bb8c8996d9c5
parent 41b20e066ab2f220c3a6b5107a546d17fbcc891f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 16 Jan 2017 16:30:33 +0100

[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 :(

Diffstat:
Mcc1/lex.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/cc1/lex.c b/cc1/lex.c @@ -642,12 +642,18 @@ skipspaces(void) 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