public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] windres: add quotes around preprocessor cmd if needed
@ 2022-06-28 14:54 =?unknown-8bit?q?Cl=E9ment_Chigot_=3Chelflym=40sourceware=2Eorg=3E?=
0 siblings, 0 replies; only message in thread
From: =?unknown-8bit?q?Cl=E9ment_Chigot_=3Chelflym=40sourceware=2Eorg=3E?= @ 2022-06-28 14:54 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fadaf8f7f99f8fe81aa8403c5d90c95cae5bd2ec
commit fadaf8f7f99f8fe81aa8403c5d90c95cae5bd2ec
Author: Clément Chigot <chigot@adacore.com>
Date: Thu Jun 16 13:43:26 2022 +0200
windres: add quotes around preprocessor cmd if needed
This patch ensures that the gcc binary called by windres is quoted if
needed. Otherwise, errors can occur if the gcc is under a folder having
a name containing a space (eg "Program Files").
binutils/
* resrc.c (DEFAULT_PREPROCESSOR): Split into...
(DEFAULT_PREPROCESSOR_CMD): that...
(DEFAULT_PREPROCESSOR_ARGS): and that.
(look_for_default): Add quotes around the command if needed.
(read_rc_file): Adapt to new defines.
Diff:
---
binutils/resrc.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/binutils/resrc.c b/binutils/resrc.c
index 42afdc1d954..fff77f4f28a 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -75,7 +75,8 @@
/* The default preprocessor. */
-#define DEFAULT_PREPROCESSOR "gcc -E -xc -DRC_INVOKED"
+#define DEFAULT_PREPROCESSOR_CMD "gcc"
+#define DEFAULT_PREPROCESSOR_ARGS "-E -xc -DRC_INVOKED"
/* We read the directory entries in a cursor or icon file into
instances of this structure. */
@@ -378,17 +379,13 @@ static FILE *
look_for_default (char *cmd, const char *prefix, int end_prefix,
const char *preprocargs, const char *filename)
{
- char *space;
int found;
struct stat s;
const char *fnquotes = (filename_need_quotes (filename) ? "\"" : "");
strcpy (cmd, prefix);
- sprintf (cmd + end_prefix, "%s", DEFAULT_PREPROCESSOR);
- space = strchr (cmd + end_prefix, ' ');
- if (space)
- *space = 0;
+ sprintf (cmd + end_prefix, "%s", DEFAULT_PREPROCESSOR_CMD);
if (
#if defined (__DJGPP__) || defined (__CYGWIN__) || defined (_WIN32)
@@ -410,10 +407,16 @@ look_for_default (char *cmd, const char *prefix, int end_prefix,
}
}
- strcpy (cmd, prefix);
+ if (filename_need_quotes (cmd))
+ {
+ char *cmd_copy = xmalloc (strlen (cmd));
+ strcpy (cmd_copy, cmd);
+ sprintf (cmd, "\"%s\"", cmd_copy);
+ free (cmd_copy);
+ }
- sprintf (cmd + end_prefix, "%s %s %s%s%s",
- DEFAULT_PREPROCESSOR, preprocargs, fnquotes, filename, fnquotes);
+ sprintf (cmd + strlen (cmd), " %s %s %s%s%s",
+ DEFAULT_PREPROCESSOR_ARGS, preprocargs, fnquotes, filename, fnquotes);
if (verbose)
fprintf (stderr, _("Using `%s'\n"), cmd);
@@ -490,10 +493,9 @@ read_rc_file (const char *filename, const char *preprocessor,
{
char *dash, *slash, *cp;
- preprocessor = DEFAULT_PREPROCESSOR;
-
cmd = xmalloc (strlen (program_name)
- + strlen (preprocessor)
+ + strlen (DEFAULT_PREPROCESSOR_CMD)
+ + strlen (DEFAULT_PREPROCESSOR_ARGS)
+ strlen (preprocargs)
+ strlen (filename)
+ strlen (fnquotes) * 2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-28 14:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 14:54 [binutils-gdb] windres: add quotes around preprocessor cmd if needed =?unknown-8bit?q?Cl=E9ment_Chigot_=3Chelflym=40sourceware=2Eorg=3E?=
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).