aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-06-06 08:02:47 +0000
committerNick Clifton <nickc@redhat.com>2007-06-06 08:02:47 +0000
commit4b2c5b4af619c40b106d43222fbedf380fc16cb7 (patch)
treecb11a093ef9963535df80f41109920e4e5a01169
parent3cc783058e285c681bab23d6c6237e7d65d76923 (diff)
downloadgdb-4b2c5b4af619c40b106d43222fbedf380fc16cb7.zip
gdb-4b2c5b4af619c40b106d43222fbedf380fc16cb7.tar.gz
gdb-4b2c5b4af619c40b106d43222fbedf380fc16cb7.tar.bz2
PR binutils/4356 binutils/591
* resrc.c (filename_need_quotes): New function. (look_for_default): If filename_need_quotes is true then quote the filename in the command line being created. (read_rc_file): Likewise.
-rw-r--r--binutils/ChangeLog12
-rw-r--r--binutils/resrc.c39
2 files changed, 45 insertions, 6 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 17d94ca..5ea8e3f 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,8 +1,16 @@
+2007-06-06 Kai Tietz <Kai.Tietz@onevision.com>
+
+ PR binutils/4356 binutils/591
+ * resrc.c (filename_need_quotes): New function.
+ (look_for_default): If filename_need_quotes is true then quote the
+ filename in the command line being created.
+ (read_rc_file): Likewise.
+
2007-06-06 Ben Elliston <bje@au.ibm.com>
* doc/binutils.texi (objdump): Fix capitalisation of "PowerPC".
-007-06-05 Kai Tietz <Kai.Tietz@onevision.com>
+2007-06-05 Kai Tietz <Kai.Tietz@onevision.com>
* Makefile.am: Add LIBICONV to windres.
* acinclude.m4: Added missing "lib-*.m4" and "lt*.m4" files.
@@ -10,7 +18,7 @@
* config.in: Add ICONV defines.
* aclocal: Regenerate.
* confugure: Regenerate.
- * winduni.c: (local_iconv_map codepages, wind_language_t
+ * winduni.c: (local_iconv_map codepages, wind_language_t,
languages, unicode_is_valid_codepage, wind_find_language_by_id,
wind_find_language_by_codepage, wind_find_codepage_info,
unicode_from_codepage, codepage_from_unicode, iconv_onechar,
diff --git a/binutils/resrc.c b/binutils/resrc.c
index 24b423d..ebed255 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -351,7 +351,33 @@ open_input_stream (char *cmd)
return cpp_pipe;
}
-/* look for the preprocessor program */
+/* Determine if FILENAME contains special characters that
+ can cause problems unless the entire filename is quoted. */
+
+static int
+filename_need_quotes (const char *filename)
+{
+ if (filename == NULL || (filename[0] == '-' && filename[1] == 0))
+ return 0;
+
+ while (*filename != 0)
+ {
+ switch (*filename)
+ {
+ case '&':
+ case ' ':
+ case '<':
+ case '>':
+ case '|':
+ case '%':
+ return 1;
+ }
+ ++filename;
+ }
+ return 0;
+}
+
+/* Look for the preprocessor program. */
static FILE *
look_for_default (char *cmd, const char *prefix, int end_prefix,
@@ -360,6 +386,7 @@ look_for_default (char *cmd, const char *prefix, int end_prefix,
char *space;
int found;
struct stat s;
+ const char *fnquotes = (filename_need_quotes (filename) ? "\"" : "");
strcpy (cmd, prefix);
@@ -390,8 +417,8 @@ look_for_default (char *cmd, const char *prefix, int end_prefix,
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 +434,7 @@ read_rc_file (const char *filename, const char *preprocessor,
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 +448,10 @@ read_rc_file (const char *filename, const char *preprocessor,
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 +465,7 @@ read_rc_file (const char *filename, const char *preprocessor,
+ strlen (preprocessor)
+ strlen (preprocargs)
+ strlen (filename)
+ + strlen (fnquotes) * 2
#ifdef HAVE_EXECUTABLE_SUFFIX
+ strlen (EXECUTABLE_SUFFIX)
#endif