[hackers] [scc] [cc1] Add support for -U in cc1 || Roberto E. Vargas Caballero
commit 23e5d28bcfafb191be14957906a01453dd911353
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jun 14 12:31:06 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jun 14 12:31:06 2016 +0200
[cc1] Add support for -U in cc1
POSIX indicates that -U remove any definition of a macro,
and it means that we have to parse -U options after having
initialized the preprocessor and having parsed -D options.
diff --git a/cc1/cc1.h b/cc1/cc1.h
index 0dda636..bdf1f6d 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -4,6 +4,8 @@
#define GLOBALCTX 0
+#define NR_USWITCHES 20
+
/*
* Definition of enumerations
*/
_AT_@ -417,6 +419,7 @@ extern int expand(char *begin, Symbol *sym);
extern void incdir(char *dir);
extern void outcpp(void);
extern Symbol *defmacro(char *s);
+extern void undefmacro(char *s);
/*
* Definition of global variables
diff --git a/cc1/cpp.c b/cc1/cpp.c
index f06fe95..81caa5a 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -39,6 +39,12 @@ defmacro(char *s)
}
void
+undefmacro(char *s)
+{
+ killsym(lookup(NS_CPP, s));
+}
+
+void
icpp(void)
{
static char sdate[17], stime[14];
diff --git a/cc1/main.c b/cc1/main.c
index 9e542c7..19bcb39 100644
--- a/cc1/main.c
+++ b/cc1/main.c
_AT_@ -38,8 +38,10 @@ int
main(int argc, char *argv[])
{
char *base;
+ static char *uvec[NR_USWITCHES], **umacro = uvec;
atexit(clean);
+ icpp();
ARGBEGIN {
case 'w':
_AT_@ -51,6 +53,11 @@ main(int argc, char *argv[])
case 'D':
defmacro(EARGF(usage()));
break;
+ case 'U':
+ if (umacro == &uvec[NR_USWITCHES])
+ die("too many -U switches");
+ *umacro++ = EARGF(usage());
+ break;
case 'd':
DBGON();
break;
_AT_@ -64,6 +71,9 @@ main(int argc, char *argv[])
usage();
} ARGEND
+ for (umacro = uvec; *umacro; umacro++)
+ undefmacro(*umacro);
+
if (argc > 1)
usage();
_AT_@ -78,9 +88,7 @@ main(int argc, char *argv[])
if (output && !freopen(output, "w", stdout))
die("error opening output: %s", strerror(errno));
- icpp();
ilex(*argv);
-
if (onlycpp) {
outcpp();
} else {
Received on Tue Jun 14 2016 - 13:03:06 CEST
This archive was generated by hypermail 2.3.0
: Tue Jun 14 2016 - 13:12:15 CEST