commit bde0ef892aeb95d7aaa95ffb11b0bd82b2a31d9c Author: Roberto E. Vargas Caballero <k...@shike2.com> AuthorDate: Thu Jan 12 08:51:17 2017 +0100 Commit: Roberto E. Vargas Caballero <k...@shike2.com> CommitDate: Thu Jan 12 08:51:17 2017 +0100
[cc1] Fix readline() After the modification of macro expansions to use push up buffers readline was broken, because after expanding a macro we have to return always from readline, otherwise we can remove some newline from the input. This new version also makes better use of 'goto' than the previous version. diff --git a/cc1/lex.c b/cc1/lex.c index d861be6..d7e8aa3 100644 --- a/cc1/lex.c +++ b/cc1/lex.c @@ -202,27 +202,21 @@ readline(void) char *bp, *lim; char c, peekc = 0; -repeat_from_file: - *input->line = '\0'; - input->p = input->line; - -repeat_from_expand: - input->begin = input->p; - - if (*input->begin) - return 1; +repeat: if (eof) return 0; - if (!input->fp) { delinput(); - goto repeat_from_expand; + return 1; } if (feof(input->fp)) { delinput(); - goto repeat_from_file; + goto repeat; } + + *input->line = '\0'; + input->begin = input->p = input->line; lim = &input->line[INPUTSIZ-1]; for (bp = input->line; bp < lim; *bp++ = c) { c = (peekc) ? peekc : readchar();