scc

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

commit 6aec731e498f8c7994c24f88b036fa942f05d796
parent 7525bdb75be193b54dce97849fe81e5df378584e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 18 Jan 2017 12:24:10 +0100

[cc1] use for instead of while in main()

Diffstat:
Mcc1/lex.c | 10+++++-----
Mcc1/main.c | 6++----
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/cc1/lex.c b/cc1/lex.c @@ -72,7 +72,7 @@ int addinput(char *fname, Symbol *hide, char *buffer) { FILE *fp; - unsigned type, nline = 0; + unsigned flags, nline = 0; Input *ip; if (hide) { @@ -83,17 +83,17 @@ addinput(char *fname, Symbol *hide, char *buffer) if (hide->hide == UCHAR_MAX) die("Too many macro expansions"); ++hide->hide; - type = IMACRO; + flags = IMACRO|IEOF; } else if (fname) { /* a new file */ if ((fp = fopen(fname, "r")) == NULL) return 0; - type = IFILE; + flags = IFILE; } else { /* reading from stdin */ fp = stdin; fname = "<stdin>"; - type = ISTDIN; + flags = ISTDIN; } ip = xmalloc(sizeof(*ip)); @@ -109,7 +109,7 @@ addinput(char *fname, Symbol *hide, char *buffer) ip->fp = fp; ip->hide = hide; ip->nline = nline; - ip->flags = type; + ip->flags = flags; input = ip; return 1; diff --git a/cc1/main.c b/cc1/main.c @@ -109,10 +109,8 @@ main(int argc, char *argv[]) if (onlycpp) { outcpp(); } else { - next(); - - while (yytoken != EOFTOK) - decl(); + for (next(); yytoken != EOFTOK; decl()) + /* nothing */; } return failure;