summaryrefslogtreecommitdiff
path: root/binutils/resrc.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-07-05 09:51:30 +0000
committerNick Clifton <nickc@redhat.com>2007-07-05 09:51:30 +0000
commit948418aae54882521254aeeded7150524fd3f777 (patch)
tree172461fa9be23afcedd5eaec0b6c80c3d8da0d53 /binutils/resrc.c
parent819a89bc3f828a3c4bd3b949cef8acebf8e816af (diff)
downloadbinutils-redhat-948418aae54882521254aeeded7150524fd3f777.tar.gz
* resrc.c: (read_rc_file): Add include path of user passed rc input file.
* windres.c: (windres_add_include_dir): New. (main): Use of windres_add_include_dir. * windres.h: (windres_add_include_dir): Add prototype.
Diffstat (limited to 'binutils/resrc.c')
-rw-r--r--binutils/resrc.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/binutils/resrc.c b/binutils/resrc.c
index ebed255157..2b148efc8c 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -436,6 +436,35 @@ read_rc_file (const char *filename, const char *preprocessor,
char *cmd;
const char *fnquotes = (filename_need_quotes (filename) ? "\"" : "");
+ /* Setup the default resource import path taken from input file. */
+ if (strchr (filename, '/') != NULL || strchr (filename, '\\') != NULL)
+ {
+ char *e, *c;
+
+ if (filename[0] == '/'
+ || filename[0] == '\\'
+ || filename[1] == ':')
+ e = c = xstrdup (filename);
+ else
+ {
+ e = c = xmalloc (strlen (filename) + 3);
+ sprintf (c, "./%s", filename);
+ }
+ e += strlen (c);
+ while (e > c && (e[-1] != '\\' && e[-1] != '/'))
+ {
+ --e;
+ e[0] = 0;
+ }
+ /* Cut off trailing slash. */
+ --e;
+ e[0] = 0;
+ while ((e = strchr (c, '\\')) != NULL)
+ *e = '/';
+
+ windres_add_include_dir (e);
+ }
+
istream_type = (use_temp_file) ? ISTREAM_FILE : ISTREAM_PIPE;
if (preprocargs == NULL)