summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2010-12-03 15:52:04 -0500
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-07-19 18:54:55 -0700
commit11e7f4610cd6468aeea115081dd72ddd7eba0f3f (patch)
treede05d2363cba1a9c8c88564f6e0f30efab8b378d
parentd23e17e09c45e214737ddf8f653dc31cdcf3a0d2 (diff)
predefined cpp macros can produce unexpected results (bug 3413)
GNU cpp is predefining a number of symbols, depending on the host and target architecture. This can produce some unexpected results: for example, the expansion of CLIENTHOST if the host name is i386.my.domain. The attached patch creates a new -undef option to xrdb that is passed to cpp. Acked-by: Gaetan Nadon <memsize@videotron.ca> Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--man/xrdb.man4
-rw-r--r--xrdb.c12
2 files changed, 15 insertions, 1 deletions
diff --git a/man/xrdb.man b/man/xrdb.man
index bdef86f..7f0ccf1 100644
--- a/man/xrdb.man
+++ b/man/xrdb.man
@@ -223,6 +223,10 @@ This option indicates that
should not run the input file through a preprocessor before loading it
into properties.
.TP 8
+.B -undef
+This option is passed to the C preprocessor if used. It prevents it from
+predefining any system specific macros.
+.TP 8
.B \-symbols
This option indicates that the symbols that are defined for the preprocessor
should be printed onto the standard output.
diff --git a/xrdb.c b/xrdb.c
index 63b9539..f13ae5e 100644
--- a/xrdb.c
+++ b/xrdb.c
@@ -531,8 +531,11 @@ DoCmdDefines(String *buff)
*val = '=';
} else
AddSimpleDef(buff, arg + 2);
- } else
+ } else if (arg[1] == 'U') {
AddUndef(buff, arg + 2);
+ } else if (!strcmp(arg, "-undef") && oper != OPSYMBOLS) {
+ addstring(buff, " -undef");
+ }
}
}
@@ -969,6 +972,13 @@ main(int argc, char *argv[])
fatal("%s: Too many -U/-D arguments\n", ProgramName);
}
continue;
+ } else if (!strcmp ("-undef", arg)) {
+ if (num_cmd_defines < MAX_CMD_DEFINES) {
+ cmd_defines[num_cmd_defines++] = "-undef";
+ } else {
+ fatal("%s: Too many cpp arguments\n", ProgramName);
+ }
+ continue;
}
Syntax ();
} else if (arg[0] == '=')