shithub: scc

Download patch

ref: e0da4313a7c97d3afdb7830e2827e6c106de28b6
parent: eedc3e57df3796c14bda0abad2da4aaff1e17e7e
author: Quentin Rameau <quinq@fifth.space>
date: Thu Jun 16 12:18:57 EDT 2016

[cc1] use dynamic storage for U flags

--- a/cc1/main.c
+++ b/cc1/main.c
@@ -16,6 +16,7 @@
 jmp_buf recover;
 
 static char *base, *output;
+static struct items uflags;
 int onlycpp;
 
 extern int failure;
@@ -41,7 +42,7 @@
 main(int argc, char *argv[])
 {
 	char *base;
-	static char *uvec[NR_USWITCHES], **umacro = uvec;
+	int i;
 
 	atexit(clean);
 	icpp();
@@ -63,9 +64,7 @@
 		incdir(EARGF(usage()));
 		break;
 	case 'U':
-		if (umacro == &uvec[NR_USWITCHES])
-			die("too many -U switches");
-		*umacro++ = EARGF(usage());
+		uflags.s = newitem(uflags.s, uflags.n++, EARGF(usage()));
 		break;
 	case 'd':
 		DBGON();
@@ -89,8 +88,8 @@
 	if (!strcmp(base, "cpp"))
 		onlycpp = 1;
 
-	for (umacro = uvec; *umacro; umacro++)
-		undefmacro(*umacro);
+	for (i = 0; i < uflags.n; ++i)
+		undefmacro(uflags.s[i]);
 
 	ilex(*argv);
 	if (onlycpp) {