ref: 0aee0027b0ae4f745250ca8ca90e7d5c6017151d
parent: f82124efc20c2976037f821cfa502b03f11bd2a6
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Apr 4 10:26:09 EDT 2022
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.
--- a/src/cmd/cc/cc1/lex.c
+++ b/src/cmd/cc/cc1/lex.c
@@ -204,6 +204,7 @@
if (feof(input->fp)) {
input->flags |= IEOF;
+ *input->p = '\0';
return 0;
}
@@ -284,7 +285,11 @@
delinput();
goto repeat;
}
- if (!readline() || cpp()) {
+ if (!readline()) {
+ *input->p = '\0';
+ goto repeat;
+ }
+ if (cpp()) {
*input->p = '\0';
goto repeat;
}