[PATCH xrdb] Allow the CPP macro to contain preprocessors with command line options (v2)

Egbert Eich eich at freedesktop.org
Thu Jan 3 12:45:25 PST 2013


The preprocessor used for xrdb may require a command line option to
produce the desired output. For the GNU cpp this could be
'traditional-cpp' which may not be valid for other preprocessors.
Therefore support the specification of preprocessors along with
required command line arguments when using the '--with-cpp' configure
option.
Example:
   ./configure --with-cpp="/usr/bin/cpp --traditional-cpp, /usr/lib/cpp".

v2: Followed a suggestion by Julien Cristau <jcristau at debian.org>
    to allocate memory for the dup string dynamically instead of
    using a static buffer.

Signed-off-by: Egbert Eich <eich at freedesktop.org>
---
 xrdb.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/xrdb.c b/xrdb.c
index 74ac03b..b7c9fa3 100644
--- a/xrdb.c
+++ b/xrdb.c
@@ -855,11 +855,19 @@ main(int argc, char *argv[])
 	int j;
 
 	for (j = 0; j < number_of_elements; j++) {
-	    if (access(cpp_locations[j], X_OK) == 0) {
+	    char *end, *dup;
+	    /* cut off arguments */
+	    dup = strdup(cpp_locations[j]);
+	    end = strchr(dup,' ');
+	    if (end)
+		*end = '\0';
+	    if (access(dup, X_OK) == 0) {
 		cpp_program = cpp_locations[j];
+		free(dup);
 		break;
 	    }
-	} 
+	    free(dup);
+	}
     }
 
     /* needs to be replaced with XrmParseCommand */
-- 
1.7.7



More information about the xorg-devel mailing list