diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-03-24 23:24:46 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-03-24 23:24:46 -0700 |
commit | 4c01ea85005fbc3506e32b88e1db3186538f8b9a (patch) | |
tree | 0a55f29da8366a741b056621c2c30938b0d6d92f | |
parent | 74e8f61bd2f6857b8f242ffd34b3fe0ba1a04aa9 (diff) |
Add -E flag to show cpp command line & processed input file
https://bugs.freedesktop.org/show_bug.cgi?id=98300
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | man/xrdb.man | 6 | ||||
-rw-r--r-- | xrdb.c | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/man/xrdb.man b/man/xrdb.man index 211c0a2..7ed14fc 100644 --- a/man/xrdb.man +++ b/man/xrdb.man @@ -231,6 +231,12 @@ into properties. This option is passed to the C preprocessor if used. It prevents it from predefining any system specific macros. .TP 8 +.B \-E +This option indicates that any cpp command run and the output from it should +be shown on standard output. If \fB\-nocpp\fP was also specified, the input +file will be shown as read. The specified changes will also be performed +unless the \fB\-n\fP option is also specified. +.TP 8 .B \-symbols This option indicates that the symbols that are defined for the preprocessor should be printed onto the standard output. @@ -127,6 +127,7 @@ static const char *cpp_program = NULL; static const char * const cpp_locations[] = { CPP }; static const char *backup_suffix = BACKUP_SUFFIX; static Bool dont_execute = False; +static Bool show_cpp = False; static String defines; static size_t defines_base; #define MAX_CMD_DEFINES 512 @@ -428,6 +429,8 @@ ReadFile(Buffer *b, FILE *input) } #endif AppendToBuffer(b, buf, bytes); + if (show_cpp) + fwrite(buf, 1, bytes, stdout); } AppendToBuffer(b, "", 1); } @@ -779,6 +782,7 @@ Syntax(const char *errmsg) " -n show but don't do changes\n" " -cpp filename preprocessor to use [%s]\n" " -nocpp do not use a preprocessor\n" + " -E show preprocessor command & processed input file\n" " -query query resources\n" " -load load resources from file [default]\n" " -override add in resources from file\n" @@ -962,6 +966,10 @@ main(int argc, char *argv[]) cpp_program = argv[i]; continue; } + else if (!strcmp("-E", arg)) { + show_cpp = True; + continue; + } else if (!strcmp("-n", arg)) { dont_execute = True; continue; @@ -1349,6 +1357,8 @@ Process(int scrno, Bool doScreen, Bool execute) if (asprintf(&cmd, "%s %s %s %s > %s", cpp_program, cpp_addflags, includes.val, tmpname2, tmpname3) == -1) fatal("%s: Out of memory\n", ProgramName); + if (show_cpp) + puts(cmd); if (system(cmd) < 0) fatal("%s: cannot run '%s'\n", ProgramName, cmd); free(cmd); @@ -1364,6 +1374,8 @@ Process(int scrno, Bool doScreen, Bool execute) if (asprintf(&cmd, "%s %s %s", cpp_program, cpp_addflags, includes.val) == -1) fatal("%s: Out of memory\n", ProgramName); + if (show_cpp) + puts(cmd); if (!(input = popen(cmd, "r"))) fatal("%s: cannot run '%s'\n", ProgramName, cmd); free(cmd); @@ -1382,6 +1394,8 @@ Process(int scrno, Bool doScreen, Bool execute) cpp_addflags, includes.val, defines.val, filename ? filename : "", tmpname3) == -1) fatal("%s: Out of memory\n", ProgramName); + if (show_cpp) + puts(cmd); if (system(cmd) < 0) fatal("%s: cannot run '%s'\n", ProgramName, cmd); free(cmd); @@ -1392,6 +1406,8 @@ Process(int scrno, Bool doScreen, Bool execute) cpp_addflags, includes.val, defines.val, filename ? filename : "") == -1) fatal("%s: Out of memory\n", ProgramName); + if (show_cpp) + puts(cmd); if (!(input = popen(cmd, "r"))) fatal("%s: cannot run '%s'\n", ProgramName, cmd); free(cmd); |