shithub: scc

Download patch

ref: beac8a2f180a7bb9941b20f39339d12d2b5582c9
parent: ec024fa76037859d683d2befaee81b93e586fea1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 12 04:02:49 EDT 2015

Allow empty preprocessor directives

C standard allows it, I don't knwo why.

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -273,9 +273,12 @@
 		return p;
 	for (++p; isspace(*p); ++p)
 		/* nothing */;
+	if (*p == '\0')
+		return NULL;
 	for (q = p; isalpha(*q); ++q)
 		/* nothing */;
-	n = q - p;
+	if ((n = q - p) == 0)
+		goto incorrect;
 	while (isspace(*q))
 		++q;
 	for (bp = cmds; bp->name; ++bp) {
@@ -288,5 +291,6 @@
 			error("trailing characters after preprocessor directive");
 		return NULL;
 	}
+incorrect:
 	error("incorrect preprocessor directive");
 }