public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Add default include path to support rc resource file imports.
@ 2007-07-02 12:00 Kai Tietz
  2007-07-05  9:54 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Kai Tietz @ 2007-07-02 12:00 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

Hello,

this patch adds for the rc import files the path of the rc-input path (if 
not the current working directory) to the include_dir list. This allows, 
that resources placed within the input file folder are found by default. 
This behaviour is equivalent to the MS resource compiler.

ChangeLog for binutils/:

2007-07-01  Kai Tietz  <kai.tietz@onevision.com>

        * 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.


Cheers,
 i.A. Kai Tietz


|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

------------------------------------------------------------------------------------------
  OneVision Software Entwicklungs GmbH & Co. KG
  Dr.-Leo-Ritter-Straße 9 - 93049 Regensburg
  Tel: +49.(0)941.78004.0 - Fax: +49.(0)941.78004.489 - www.OneVision.com
  Commerzbank Regensburg - BLZ 750 400 62 - Konto 6011050
  Handelsregister: HRA 6744, Amtsgericht Regensburg
  Komplementärin: OneVision Software Entwicklungs Verwaltungs GmbH
  Dr.-Leo-Ritter-Straße 9 – 93049 Regensburg
  Handelsregister: HRB 8932, Amtsgericht Regensburg - Geschäftsführer: 
Ulrike Döhler, Manuela Kluger

[-- Attachment #2: windres_fileres.txt --]
[-- Type: text/plain, Size: 2652 bytes --]

Index: src/binutils/resrc.c
===================================================================
--- src.orig/binutils/resrc.c
+++ src/binutils/resrc.c
@@ -436,6 +436,34 @@ read_rc_file (const char *filename, cons
   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)
Index: src/binutils/windres.c
===================================================================
--- src.orig/binutils/windres.c
+++ src/binutils/windres.c
@@ -925,19 +925,7 @@ main (int argc, char **argv)
 	      free (preprocargs);
 	      preprocargs = n;
 	    }
-
-	  {
-	    struct include_dir *n, **pp;
-
-	    n = (struct include_dir *) xmalloc (sizeof *n);
-	    n->next = NULL;
-	    n->dir = optarg;
-
-	    for (pp = &include_dirs; *pp != NULL; pp = &(*pp)->next)
-	      ;
-	    *pp = n;
-	  }
-
+	  windres_add_include_dir (optarg);
 	  break;
 
 	case 'l':
@@ -1387,3 +1375,17 @@ int wr_print (FILE *e, const char *fmt, 
   va_end (arg);
   return r;    
 }
+
+void
+windres_add_include_dir (const char *p)
+{
+  struct include_dir *n, **pp;
+
+  n = (struct include_dir *) xmalloc (sizeof *n);
+  n->next = NULL;
+  n->dir = p;
+
+  for (pp = &include_dirs; *pp != NULL; pp = &(*pp)->next)
+    ;
+  *pp = n;
+}
Index: src/binutils/windres.h
===================================================================
--- src.orig/binutils/windres.h
+++ src/binutils/windres.h
@@ -115,6 +115,7 @@ extern rc_ver_stringinfo *append_verval 
 extern rc_ver_varinfo *append_vertrans (rc_ver_varinfo *, rc_uint_type, rc_uint_type);
 
 extern bfd *windres_open_as_binary (const char *, int);
+extern void windres_add_include_dir (const char *);
 
 extern int wr_printcomment (FILE *, const char *, ...);
 extern int wr_print (FILE *, const char *, ...);
=

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: Add default include path to support rc resource file imports.
  2007-07-02 12:00 PATCH: Add default include path to support rc resource file imports Kai Tietz
@ 2007-07-05  9:54 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2007-07-05  9:54 UTC (permalink / raw)
  To: Kai Tietz; +Cc: binutils

Hi Kai,

> ChangeLog for binutils/:
> 2007-07-01  Kai Tietz  <kai.tietz@onevision.com>
> 
>         * 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.

I have applied this patch.

There were two minor problems:

   +  if(strchr (filename; '/')!=NULL || strchr (filename, '\\') != NULL)

That should be a comma between filename and '/'.


   +  n->dir = p;

p is a "const char *" but n->dir is a "char *".  I added a cast to 
remove the const qualifier and so stop a compiler warning.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-05  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-02 12:00 PATCH: Add default include path to support rc resource file imports Kai Tietz
2007-07-05  9:54 ` Nick Clifton

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).