From 734d0a834c535851a5d455c453702d8939c2f67d Mon Sep 17 00:00:00 2001 From: Thomas Wolff Date: Mon, 10 May 2021 11:28:15 +0100 Subject: [PATCH] Restore old behaviour of windres so that options containing spaces are not enclosed in double quotes. PR 4356 PR 26865 PR 27594 * windres.c (quot): Revert previous delta. Do not use double quotes when spaces are detected in options. * doc/binutils.texi (windres): Remove suggestion that the --preprocessor option can take arguments. Source (replayed to apply patch -R aftereffects): https://github.com/msys2/MINGW-packages/commit/04805c092970de7f4b41b5aef6eece2723a56052 --- binutils/doc/binutils.texi | 7 ++++--- binutils/windres.c | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index e0028ee0..b506a020 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -4450,7 +4450,8 @@ format, which is the first one listed by the @option{--help} option. @item --preprocessor @var{program} When @command{windres} reads an @code{rc} file, it runs it through the C preprocessor first. This option may be used to specify the preprocessor -to use. The default preprocessor is @code{gcc}. +to use, including any leading arguments. The default preprocessor +argument is @code{gcc}. @item --preprocessor-arg @var{option} When @command{windres} reads an @code{rc} file, it runs it through @@ -4461,8 +4462,8 @@ preprocessor command line. If the @option{--preprocessor} option has not been specified then a default set of preprocessor arguments will be used, with any @option{--preprocessor-arg} options being placed after them on the -command line. These default arguments are @code{-E}, -@code{-xc-header} and @code{-DRC_INVOKED}. +command line. These default arguments are @code{-E -xc-header +-DRC_INVOKED}. @item -I @var{directory} @itemx --include-dir @var{directory} diff --git a/binutils/windres.c b/binutils/windres.c index 3f691d3e..1e65e341 100644 --- a/binutils/windres.c +++ b/binutils/windres.c @@ -710,13 +710,37 @@ quot (const char *string) buf = (char *) xmalloc (buflen); } +#if defined (_WIN32) && !defined (__CYGWIN__) + /* For Windows shells, quote "like this". */ + { + bool quoted = false; + + dest = buf; + if (strchr (string, ' ')) + { + quoted = true; + *dest++ = '"'; + } + + for (src = string; *src; src++, dest++) + { + /* Escape-protect embedded double quotes. */ + if (quoted && *src == '"') + *dest++ = '\\'; + *dest = *src; + } + + if (quoted) + *dest++ = '"'; + } +#else for (src = string, dest = buf; *src; src++, dest++) { if (*src == '(' || *src == ')' || *src == ' ') *dest++ = '\\'; *dest = *src; } - +#endif *dest = 0; return buf; } -- 2.44.0.windows.1