]> Shamusworld >> Repos - rmac/blobdiff - rmac.c
Fix for bug #173 - expressions that contain "*" are treated as absolute when ORG...
[rmac] / rmac.c
diff --git a/rmac.c b/rmac.c
index f43b83b8e6e2fb1047803e5d79c593aa035e9cd0..ef190ec0fc959434839d45cfb8a7a2c34ab89f46 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -1,7 +1,7 @@
 //
-// RMAC - Reboot's Macro Assembler for all Atari computers
+// RMAC - Renamed Macro Assembler for all Atari computers
 // RMAC.C - Main Application Code
-// Copyright (C) 199x Landon Dyer, 2011-2020 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
 // Source utilised with the kind permission of Landon Dyer
 //
@@ -50,7 +50,8 @@ 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[512] = { 0 };  // Search path for include files
+char searchpatha[512] = { 0 }; // Buffer to hold searchpath when specified
+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 activecpu = CPU_68000;             // Active 68k CPU (68000 by default)
@@ -100,6 +101,17 @@ char * fext(char * name, char * extension, int stripp)
        return name;
 }
 
+static int is_sep(char c)
+{
+    const char *seps = PATH_SEPS;
+
+    for (seps = PATH_SEPS; *seps; seps++) {
+        if (*seps == c)
+            return 1;
+    }
+
+    return 0;
+}
 
 //
 // Return 'item'nth element of semicolon-seperated pathnames specified in the
@@ -119,13 +131,13 @@ int nthpath(char * env_var, int itemno, char * buf)
                return 0;
 
        while (itemno--)
-               while (*s != EOS && *s++ != ';')
+               while (*s != EOS && !is_sep(*s++))
                        ;
 
        if (*s == EOS)
                return 0;
 
-       while (*s != EOS && *s != ';')
+       while (*s != EOS && !is_sep(*s))
                *buf++ = *s++;
 
        *buf++ = EOS;
@@ -206,8 +218,8 @@ void DisplayVersion(void)
                "| '__| '_ ` _ \\ / _` |/ __|\n"
                "| |  | | | | | | (_| | (__ \n"
                "|_|  |_| |_| |_|\\__,_|\\___|\n"
-               "\nReboot's Macro Assembler\n"
-               "Copyright (C) 199x Landon Dyer, 2011-2020 Reboot\n"
+               "\nRenamed Macro Assembler\n"
+               "Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends\n"
                "V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
 }
 
@@ -410,8 +422,9 @@ int Process(int argc, char ** argv)
                        case 'i':                               // Set directory search path
                        case 'I':
                        {
-                               strcat(searchpath, argv[argno] + 2);
-                strcat(searchpath, ";");
+                               strcat(searchpatha, argv[argno] + 2);
+                               strcat(searchpatha, ";");
+                               searchpath = searchpatha;
 
                                // Check to see if include paths actually exist
                                char current_path[256];