shithub: scc

Download patch

ref: 6650268eca2441b777636a3aad411b2d70e23281
parent: 5510ac1ca190a4bacb6330ca37a7ab5f0b347225
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Aug 21 09:04:15 EDT 2015

Basic support for -E flag

This flag makes compilation stop after preprocessor. This version
is only a draft of how it must work.

--- a/cc1/main.c
+++ b/cc1/main.c
@@ -13,6 +13,7 @@
 jmp_buf recover;
 
 static char *output;
+static int onlycpp;
 
 static void
 clean(void)
@@ -46,6 +47,9 @@
 			case 'w':
 				warnings = 1;
 				break;
+			case 'E':
+				onlycpp = 1;
+				break;
 			case 'o':
 				if (!*++argv || argv[0][0] == '-')
 					usage();
@@ -67,8 +71,13 @@
 	ikeywords();
 	ilex(*argv);
 
-	for (next(); yytoken != EOFTOK; decl())
-		/* nothing */;
+	if (onlycpp) {
+		for (next(); yytoken != EOFTOK; next())
+			printf("%s ", yytext);
+	} else {
+		for (next(); yytoken != EOFTOK; decl())
+			/* nothing */;
+	}
 
 	return 0;
 }