in a next patch someone could add something like:

xasprinf()
{
        if (asprintf(cmd) <0)
          fatal("%s: Out of memory\n", ProgramName);
        return cmd
}

btw: i noticed
  (void) mktemp(tmpname3);
should that be mkstemp() ?

just my 2 cents

Reviewed-by: <[email protected]>

Am 20.07.2013 04:52, schrieb Alan Coopersmith:
> Restores ability to use m4 (broken in xrdb-1.0.8 by commit 117021570515f)
> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=34546
> 
> Signed-off-by: Alan Coopersmith <[email protected]>
> ---
>  xrdb.c |   25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/xrdb.c b/xrdb.c
> index f13ae5e..58dd049 100644
> --- a/xrdb.c
> +++ b/xrdb.c
> @@ -1250,8 +1250,18 @@ Process(int scrno, Bool doScreen, Bool execute)
>                     template, editFile);
>       }
>      } else {
> +     const char *cpp_addflags = "";
> +
>       if (oper == OPMERGE || oper == OPOVERRIDE)
>           GetEntriesString(&newDB, xdefs);
> +
> +     /* Add -P flag only if using cpp, not another preprocessor */
> +     if (cpp_program) {
> +         const char *cp = strstr(cpp_program, "cpp");
> +
> +         if (cp && ((cp[3] == '\0') || cp[3] == ' '))
> +             cpp_addflags = "-P";
> +     }
>  #ifdef PATHETICCPP
>       if (need_real_defines) {
>  #ifdef WIN32
> @@ -1261,8 +1271,8 @@ Process(int scrno, Bool doScreen, Bool execute)
>           fprintf(input, "\n#include \"%s\"\n", filename);
>           fclose(input);
>           (void) mktemp(tmpname3);
> -         if (asprintf(&cmd, "%s -P%s %s > %s", cpp_program, includes.val,
> -                      tmpname2, tmpname3) == -1)
> +         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 (system(cmd) < 0)
>               fatal("%s: cannot run '%s'\n", ProgramName, cmd);
> @@ -1276,7 +1286,8 @@ Process(int scrno, Bool doScreen, Bool execute)
>           fprintf(stdin, "\n#include \"%s\"\n", filename);
>           fflush(stdin);
>           fseek(stdin, 0, 0);
> -         if (asprintf(&cmd, "%s -P%s", cpp_program, includes.val) == -1)
> +         if (asprintf(&cmd, "%s %s %s", cpp_program, cpp_addflags,
> +                      includes.val) == -1)
>               fatal("%s: Out of memory\n", ProgramName);
>           if (!(input = popen(cmd, "r")))
>               fatal("%s: cannot run '%s'\n", ProgramName, cmd);
> @@ -1291,8 +1302,8 @@ Process(int scrno, Bool doScreen, Bool execute)
>       if (cpp_program) {
>  #ifdef WIN32
>           (void) mktemp(tmpname3);
> -         if (asprintf(&cmd, "%s -P%s %s %s > %s", cpp_program,
> -                      includes.val, defines.val,
> +         if (asprintf(&cmd, "%s %s %s %s %s > %s", cpp_program,
> +                      cpp_addflags, includes.val, defines.val,
>                        filename ? filename : "", tmpname3) == -1)
>               fatal("%s: Out of memory\n", ProgramName);
>           if (system(cmd) < 0)
> @@ -1301,8 +1312,8 @@ Process(int scrno, Bool doScreen, Bool execute)
>           if (!(input = fopen(tmpname3, "r")))
>               fatal("%s: can't open file '%s'\n", ProgramName, tmpname3);
>  #else
> -         if (asprintf(&cmd, "%s -P%s %s %s", cpp_program,
> -                      includes.val, defines.val,
> +         if (asprintf(&cmd, "%s %s %s %s %s", cpp_program,
> +                      cpp_addflags, includes.val, defines.val,
>                        filename ? filename : "") == -1)
>               fatal("%s: Out of memory\n", ProgramName);
>           if (!(input = popen(cmd, "r")))
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to