Index: src/src/binutils/resrc.c =================================================================== --- src.orig/src/binutils/resrc.c +++ src/src/binutils/resrc.c @@ -351,6 +351,29 @@ open_input_stream (char *cmd) return cpp_pipe; } +/* Check if filename needs quotes. */ +static int +filename_need_quotes (const char *filename) +{ + if (! filename || (filename[0] == '-' && filename[1] == 0)) + return 0; + while (*filename != 0) + { + switch (filename[0]) + { + case '&': + case ' ': + case '<': + case '>': + case '|': + case '%': + return 1; + } + ++filename; + } + return 0; +} + /* look for the preprocessor program */ static FILE * @@ -360,6 +383,7 @@ look_for_default (char *cmd, const char char *space; int found; struct stat s; + const char *fnquotes = (filename_need_quotes (filename) ? "\"" : ""); strcpy (cmd, prefix); @@ -390,8 +414,8 @@ look_for_default (char *cmd, const char strcpy (cmd, prefix); - sprintf (cmd + end_prefix, "%s %s %s", - DEFAULT_PREPROCESSOR, preprocargs, filename); + sprintf (cmd + end_prefix, "%s %s %s%s%s", + DEFAULT_PREPROCESSOR, preprocargs, fnquotes, filename, fnquotes); if (verbose) fprintf (stderr, _("Using `%s'\n"), cmd); @@ -407,6 +431,7 @@ read_rc_file (const char *filename, cons const char *preprocargs, int language, int use_temp_file) { char *cmd; + const char *fnquotes = (filename_need_quotes (filename) ? "\"" : ""); istream_type = (use_temp_file) ? ISTREAM_FILE : ISTREAM_PIPE; @@ -420,8 +445,9 @@ read_rc_file (const char *filename, cons cmd = xmalloc (strlen (preprocessor) + strlen (preprocargs) + strlen (filename) + + strlen (fnquotes) * 2 + 10); - sprintf (cmd, "%s %s %s", preprocessor, preprocargs, filename); + sprintf (cmd, "%s %s %s%s%s", preprocessor, preprocargs, fnquotes, filename, fnquotes); cpp_pipe = open_input_stream (cmd); } @@ -435,6 +461,7 @@ read_rc_file (const char *filename, cons + strlen (preprocessor) + strlen (preprocargs) + strlen (filename) + + strlen (fnquotes) * 2 #ifdef HAVE_EXECUTABLE_SUFFIX + strlen (EXECUTABLE_SUFFIX) #endif =