scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 0aee0027b0ae4f745250ca8ca90e7d5c6017151d
parent f82124efc20c2976037f821cfa502b03f11bd2a6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  4 Apr 2022 14:26:09 +0200

cc1: Improve readline() readbility

Having readline() and cpp() in the same if was a bit confusing
because it seemed like there was some relation between them, but
they are totally independent. In the same way, at EOF there was
an implicit condition of having an empty string pointed by p
but it was really obsucre how it was happening.

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

diff --git a/src/cmd/cc/cc1/lex.c b/src/cmd/cc/cc1/lex.c @@ -204,6 +204,7 @@ readline(void) if (feof(input->fp)) { input->flags |= IEOF; + *input->p = '\0'; return 0; } @@ -284,7 +285,11 @@ repeat: delinput(); goto repeat; } - if (!readline() || cpp()) { + if (!readline()) { + *input->p = '\0'; + goto repeat; + } + if (cpp()) { *input->p = '\0'; goto repeat; }