[PATCH xrdb] Call C preprocessor with -P option (changed behaviour in GCC 4.5)

Ulrich Mueller ulm at gentoo.org
Tue Jan 4 03:01:40 PST 2011


> Alternatively, -P could be added when constructing the final command
> line. That would avoid both above-mentioned issues. New patch is
> included below.

Looks like the patch got lost, at least I don't see it in the list
archives. So here it is again:


http://bugs.freedesktop.org/show_bug.cgi?id=32701
http://bugs.gentoo.org/show_bug.cgi?id=347758

Signed-off-by: Ulrich Mueller <ulm at gentoo.org>
---
 xrdb.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xrdb.c b/xrdb.c
index 21005c0..75dfde7 100644
--- a/xrdb.c
+++ b/xrdb.c
@@ -1163,11 +1163,11 @@ Process(int scrno, Bool doScreen, Bool execute)
 	    fclose(input);
 	    (void) mktemp(tmpname3);
 	    if((cmd = (char *)
-		malloc(strlen(cpp_program) + strlen(includes.val) +
+		malloc(strlen(cpp_program) + 3 + strlen(includes.val) +
 		       1 + strlen(tmpname2) + 3 + strlen(tmpname3) + 1)) ==
 	       NULL)
 		fatal("%s: Out of memory\n", ProgramName);
-	    sprintf(cmd, "%s%s %s > %s", cpp_program, includes.val,
+	    sprintf(cmd, "%s -P%s %s > %s", cpp_program, includes.val,
 		    tmpname2, tmpname3);
 	    if (system(cmd) < 0)
 		fatal("%s: cannot run '%s'\n", ProgramName, cmd);
@@ -1182,10 +1182,10 @@ Process(int scrno, Bool doScreen, Bool execute)
 	    fflush(stdin);
 	    fseek(stdin, 0, 0);
 	    if((cmd = (char *)
-		malloc(strlen(cpp_program) + strlen(includes.val) + 1)) ==
+		malloc(strlen(cpp_program) + 3 + strlen(includes.val) + 1)) ==
 	       NULL)
 		fatal("%s: Out of memory\n", ProgramName);
-	    sprintf(cmd, "%s%s", cpp_program, includes.val);
+	    sprintf(cmd, "%s -P%s", cpp_program, includes.val);
 	    if (!(input = popen(cmd, "r")))
 		fatal("%s: cannot run '%s'\n", ProgramName, cmd);
 	    free(cmd);
@@ -1200,13 +1200,13 @@ Process(int scrno, Bool doScreen, Bool execute)
 #ifdef WIN32
 	    (void) mktemp(tmpname3);
 	    if((cmd = (char *)
-		malloc(strlen(cpp_program) + strlen(includes.val) +
+		malloc(strlen(cpp_program) + 3 + strlen(includes.val) +
 		       1 + strlen(defines.val) + 1 +
 		       strlen(filename ? filename : "") + 3 +
 		       strlen(tmpname3) + 1)) ==
 	       NULL)
 		fatal("%s: Out of memory\n", ProgramName);
-	    sprintf(cmd, "%s%s %s %s > %s", cpp_program,
+	    sprintf(cmd, "%s -P%s %s %s > %s", cpp_program,
 		    includes.val, defines.val,
 		    filename ? filename : "", tmpname3);
 	    if (system(cmd) < 0)
@@ -1216,12 +1216,12 @@ Process(int scrno, Bool doScreen, Bool execute)
 		fatal("%s: can't open file '%s'\n", ProgramName, tmpname3);
 #else
 	    if((cmd = (char *)
-		malloc(strlen(cpp_program) + strlen(includes.val) + 1 +
+		malloc(strlen(cpp_program) + 3 + strlen(includes.val) + 1 +
 		       strlen(defines.val) + 1 +
 		       strlen(filename ? filename : "") + 1)) ==
 	       NULL)
 		fatal("%s: Out of memory\n", ProgramName);
-	    sprintf(cmd, "%s%s %s %s", cpp_program,
+	    sprintf(cmd, "%s -P%s %s %s", cpp_program,
 		    includes.val, defines.val,
 		    filename ? filename : "");
 	    if (!(input = popen(cmd, "r")))
-- 
1.7.3.4


More information about the xorg-devel mailing list