shithub: scc

Download patch

ref: e3f1b3b7d51adc6b945a6d4db57efb15408cdf62
parent: d77f75260eb21812ac007ba6f867326ed8050133
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Jan 18 07:24:10 EST 2017

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

--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -72,7 +72,7 @@
 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 @@
 		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 @@
 	ip->fp = fp;
 	ip->hide = hide;
 	ip->nline = nline;
-	ip->flags = type;
+	ip->flags = flags;
 	input = ip;
 
 	return 1;
--- a/cc1/main.c
+++ b/cc1/main.c
@@ -109,10 +109,8 @@
 	if (onlycpp) {
 		outcpp();
 	} else {
-		next();
-
-		while (yytoken != EOFTOK)
-			decl();
+		for (next(); yytoken != EOFTOK; decl())
+			/* nothing */;
 	}
 
 	return failure;