Added check to see that include paths actually exist.
authorShamus Hammons <jlhamm@acm.org>
Fri, 28 Feb 2020 23:24:59 +0000 (17:24 -0600)
committerShamus Hammons <jlhamm@acm.org>
Fri, 28 Feb 2020 23:24:59 +0000 (17:24 -0600)
RMAC will now yell at you if you give it a bogus include path.  Thanks
to ggn for the idea!  Now at v2.0.11.

rmac.c
rmac.h
version.h

diff --git a/rmac.c b/rmac.c
index bcb587a8925e64d79a6699966da33328617b5bdd..9f52e0b49f94856e1434c7d1006ab90ede01b7df 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -50,7 +50,7 @@ int endian;                                           // Host processor endianess (0 = LE, 1 = BE)
 char * objfname;                               // Object filename pointer
 char * firstfname;                             // First source filename
 char * cmdlnexec;                              // Executable name, pointer to ARGV[0]
-char * searchpath;                             // Search path for include files
+char * searchpath = NULL;              // Search path for include files
 char defname[] = "noname.o";   // Default output filename
 int optim_flags[OPT_COUNT];            // Specific optimisations on/off matrix
 int optim_pc = 0;                              // Enforce PC relative
@@ -154,7 +154,7 @@ void DisplayHelp(void)
                "                    p: P56 (use this for DSP56001 only)\n"
                "                    l: LOD (use this for DSP56001 only)\n"
                "                    x: com/exe/xex (Atari 800)\n"
-               "                    r: absolute address"
+               "                    r: absolute address\n"
                "  -i[path]          Directory to search for include files\n"
                "  -l[filename]      Create an output listing file\n"
                "  -l*[filename]     Create an output listing file without pagination\n"
@@ -393,8 +393,26 @@ int Process(int argc, char ** argv)
                                break;
                        case 'i':                               // Set directory search path
                        case 'I':
+                       {
                                searchpath = argv[argno] + 2;
+
+                               // Check to see if include paths actually exist
+                               if (strlen(searchpath) > 0)
+                               {
+                                       DIR * test = opendir(searchpath);
+
+                                       if (test == NULL)
+                                       {
+                                               printf("Invalid include path: %s\n", searchpath);
+                                               errcnt++;
+                                               return errcnt;
+                                       }
+
+                                       closedir(test);
+                               }
+
                                break;
+                       }
                        case 'l':                               // Produce listing file
                        case 'L':
                                if (*(argv[argno] + 2) == '*')
diff --git a/rmac.h b/rmac.h
index 1c6fcf15c71249d6c562b0a6bbd649f4d8eca8b8..3d23ed55573b8c73554f5aeb0bc78f656a500f51 100644 (file)
--- a/rmac.h
+++ b/rmac.h
 // Non-target specific stuff
 //
 #include <inttypes.h>
+#include <dirent.h>
 #include "symbol.h"
 
 #define BYTE         uint8_t
index 7d8787f7f64c7f314bd0627dfc58981c3ddead22..1346d164ba25eedc47aa7288cb3c1a6c25ed794d 100644 (file)
--- a/version.h
+++ b/version.h
@@ -15,7 +15,7 @@
 
 #define MAJOR   2              // Major version number
 #define MINOR   0              // Minor version number
-#define PATCH   10             // Patch release number
+#define PATCH   11             // Patch release number
 
 #endif // __VERSION_H__