]> git.sur5r.net Git - cc65/commitdiff
.incbin did not honor the include search path
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 26 Feb 2003 23:17:42 +0000 (23:17 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 26 Feb 2003 23:17:42 +0000 (23:17 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1996 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/pseudo.c

index d2c380a38cecca0ebc506864d512c19250e681f3..4621bdb25a699bc58a9fd3b862b62d1cffe31b8b 100644 (file)
@@ -7,9 +7,9 @@
 /*                                                                           */
 /*                                                                           */
 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -45,6 +45,7 @@
 #include "coll.h"
 #include "symdefs.h"
 #include "tgttrans.h"
+#include "xmalloc.h"
 
 /* ca65 */
 #include "condasm.h"
@@ -53,6 +54,7 @@
 #include "expr.h"
 #include "feature.h"
 #include "global.h"
+#include "incpath.h"
 #include "instr.h"
 #include "listing.h"
 #include "macpack.h"
@@ -880,8 +882,21 @@ static void DoIncBin (void)
     /* Try to open the file */
     F = fopen (Name, "rb");
     if (F == 0) {
-               ErrorSkip (ERR_CANNOT_OPEN_INCLUDE, Name, strerror (errno));
-       return;
+
+               /* Search for the file in the include directories. */
+       char* PathName = FindInclude (Name);
+               if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
+           /* Not found or cannot open, print an error and bail out */
+                   ErrorSkip (ERR_CANNOT_OPEN_INCLUDE, Name, strerror (errno));
+       }
+
+       /* Free the allocated memory */
+       xfree (PathName);
+
+        /* If we had an error before, bail out now */
+        if (F == 0) {
+            return;
+        }
     }
 
     /* Get the size of the file */