scc

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

commit eb199b65415473bee2a424731e35e8a1cba05b6d
parent 6b8a852b671c3a2a5eb677d36c898ef92ca4373b
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; }