From a6049e7b8266caf164d813e80e686a224ec1f400 Mon Sep 17 00:00:00 2001 From: David Brown Date: Sat, 3 Dec 2016 18:44:22 +0000 Subject: [PATCH] Update bootstrap C sources. --- bootstrap/unix-44/Compiler.c | 2 +- bootstrap/unix-44/Configuration.c | 4 +- bootstrap/unix-44/Configuration.h | 2 +- bootstrap/unix-44/Files.c | 2 +- bootstrap/unix-44/Files.h | 2 +- bootstrap/unix-44/Heap.c | 2 +- bootstrap/unix-44/Heap.h | 2 +- bootstrap/unix-44/Modules.c | 229 +++++++++++++++++++++++---- bootstrap/unix-44/Modules.h | 3 +- bootstrap/unix-44/OPB.c | 2 +- bootstrap/unix-44/OPB.h | 2 +- bootstrap/unix-44/OPC.c | 2 +- bootstrap/unix-44/OPC.h | 2 +- bootstrap/unix-44/OPM.c | 6 +- bootstrap/unix-44/OPM.h | 2 +- bootstrap/unix-44/OPP.c | 2 +- bootstrap/unix-44/OPP.h | 2 +- bootstrap/unix-44/OPS.c | 2 +- bootstrap/unix-44/OPS.h | 2 +- bootstrap/unix-44/OPT.c | 2 +- bootstrap/unix-44/OPT.h | 2 +- bootstrap/unix-44/OPV.c | 2 +- bootstrap/unix-44/OPV.h | 2 +- bootstrap/unix-44/Out.c | 2 +- bootstrap/unix-44/Out.h | 2 +- bootstrap/unix-44/Platform.c | 2 +- bootstrap/unix-44/Platform.h | 2 +- bootstrap/unix-44/Reals.c | 2 +- bootstrap/unix-44/Reals.h | 2 +- bootstrap/unix-44/Strings.c | 2 +- bootstrap/unix-44/Strings.h | 2 +- bootstrap/unix-44/Texts.c | 2 +- bootstrap/unix-44/Texts.h | 2 +- bootstrap/unix-44/VT100.c | 2 +- bootstrap/unix-44/VT100.h | 2 +- bootstrap/unix-44/extTools.c | 6 +- bootstrap/unix-44/extTools.h | 2 +- bootstrap/unix-48/Compiler.c | 2 +- bootstrap/unix-48/Configuration.c | 4 +- bootstrap/unix-48/Configuration.h | 2 +- bootstrap/unix-48/Files.c | 2 +- bootstrap/unix-48/Files.h | 2 +- bootstrap/unix-48/Heap.c | 2 +- bootstrap/unix-48/Heap.h | 2 +- bootstrap/unix-48/Modules.c | 229 +++++++++++++++++++++++---- bootstrap/unix-48/Modules.h | 3 +- bootstrap/unix-48/OPB.c | 2 +- bootstrap/unix-48/OPB.h | 2 +- bootstrap/unix-48/OPC.c | 2 +- bootstrap/unix-48/OPC.h | 2 +- bootstrap/unix-48/OPM.c | 6 +- bootstrap/unix-48/OPM.h | 2 +- bootstrap/unix-48/OPP.c | 2 +- bootstrap/unix-48/OPP.h | 2 +- bootstrap/unix-48/OPS.c | 2 +- bootstrap/unix-48/OPS.h | 2 +- bootstrap/unix-48/OPT.c | 2 +- bootstrap/unix-48/OPT.h | 2 +- bootstrap/unix-48/OPV.c | 2 +- bootstrap/unix-48/OPV.h | 2 +- bootstrap/unix-48/Out.c | 2 +- bootstrap/unix-48/Out.h | 2 +- bootstrap/unix-48/Platform.c | 2 +- bootstrap/unix-48/Platform.h | 2 +- bootstrap/unix-48/Reals.c | 2 +- bootstrap/unix-48/Reals.h | 2 +- bootstrap/unix-48/Strings.c | 2 +- bootstrap/unix-48/Strings.h | 2 +- bootstrap/unix-48/Texts.c | 2 +- bootstrap/unix-48/Texts.h | 2 +- bootstrap/unix-48/VT100.c | 2 +- bootstrap/unix-48/VT100.h | 2 +- bootstrap/unix-48/extTools.c | 6 +- bootstrap/unix-48/extTools.h | 2 +- bootstrap/unix-88/Compiler.c | 2 +- bootstrap/unix-88/Configuration.c | 4 +- bootstrap/unix-88/Configuration.h | 2 +- bootstrap/unix-88/Files.c | 2 +- bootstrap/unix-88/Files.h | 2 +- bootstrap/unix-88/Heap.c | 2 +- bootstrap/unix-88/Heap.h | 2 +- bootstrap/unix-88/Modules.c | 229 +++++++++++++++++++++++---- bootstrap/unix-88/Modules.h | 3 +- bootstrap/unix-88/OPB.c | 2 +- bootstrap/unix-88/OPB.h | 2 +- bootstrap/unix-88/OPC.c | 2 +- bootstrap/unix-88/OPC.h | 2 +- bootstrap/unix-88/OPM.c | 6 +- bootstrap/unix-88/OPM.h | 2 +- bootstrap/unix-88/OPP.c | 2 +- bootstrap/unix-88/OPP.h | 2 +- bootstrap/unix-88/OPS.c | 2 +- bootstrap/unix-88/OPS.h | 2 +- bootstrap/unix-88/OPT.c | 2 +- bootstrap/unix-88/OPT.h | 2 +- bootstrap/unix-88/OPV.c | 2 +- bootstrap/unix-88/OPV.h | 2 +- bootstrap/unix-88/Out.c | 2 +- bootstrap/unix-88/Out.h | 2 +- bootstrap/unix-88/Platform.c | 2 +- bootstrap/unix-88/Platform.h | 2 +- bootstrap/unix-88/Reals.c | 2 +- bootstrap/unix-88/Reals.h | 2 +- bootstrap/unix-88/Strings.c | 2 +- bootstrap/unix-88/Strings.h | 2 +- bootstrap/unix-88/Texts.c | 2 +- bootstrap/unix-88/Texts.h | 2 +- bootstrap/unix-88/VT100.c | 2 +- bootstrap/unix-88/VT100.h | 2 +- bootstrap/unix-88/extTools.c | 6 +- bootstrap/unix-88/extTools.h | 2 +- bootstrap/windows-48/Compiler.c | 2 +- bootstrap/windows-48/Configuration.c | 4 +- bootstrap/windows-48/Configuration.h | 2 +- bootstrap/windows-48/Files.c | 2 +- bootstrap/windows-48/Files.h | 2 +- bootstrap/windows-48/Heap.c | 2 +- bootstrap/windows-48/Heap.h | 2 +- bootstrap/windows-48/Modules.c | 229 +++++++++++++++++++++++---- bootstrap/windows-48/Modules.h | 3 +- bootstrap/windows-48/OPB.c | 2 +- bootstrap/windows-48/OPB.h | 2 +- bootstrap/windows-48/OPC.c | 2 +- bootstrap/windows-48/OPC.h | 2 +- bootstrap/windows-48/OPM.c | 6 +- bootstrap/windows-48/OPM.h | 2 +- bootstrap/windows-48/OPP.c | 2 +- bootstrap/windows-48/OPP.h | 2 +- bootstrap/windows-48/OPS.c | 2 +- bootstrap/windows-48/OPS.h | 2 +- bootstrap/windows-48/OPT.c | 2 +- bootstrap/windows-48/OPT.h | 2 +- bootstrap/windows-48/OPV.c | 2 +- bootstrap/windows-48/OPV.h | 2 +- bootstrap/windows-48/Out.c | 2 +- bootstrap/windows-48/Out.h | 2 +- bootstrap/windows-48/Platform.c | 2 +- bootstrap/windows-48/Platform.h | 2 +- bootstrap/windows-48/Reals.c | 2 +- bootstrap/windows-48/Reals.h | 2 +- bootstrap/windows-48/Strings.c | 2 +- bootstrap/windows-48/Strings.h | 2 +- bootstrap/windows-48/Texts.c | 2 +- bootstrap/windows-48/Texts.h | 2 +- bootstrap/windows-48/VT100.c | 2 +- bootstrap/windows-48/VT100.h | 2 +- bootstrap/windows-48/extTools.c | 6 +- bootstrap/windows-48/extTools.h | 2 +- bootstrap/windows-88/Compiler.c | 2 +- bootstrap/windows-88/Configuration.c | 4 +- bootstrap/windows-88/Configuration.h | 2 +- bootstrap/windows-88/Files.c | 2 +- bootstrap/windows-88/Files.h | 2 +- bootstrap/windows-88/Heap.c | 2 +- bootstrap/windows-88/Heap.h | 2 +- bootstrap/windows-88/Modules.c | 229 +++++++++++++++++++++++---- bootstrap/windows-88/Modules.h | 3 +- bootstrap/windows-88/OPB.c | 2 +- bootstrap/windows-88/OPB.h | 2 +- bootstrap/windows-88/OPC.c | 2 +- bootstrap/windows-88/OPC.h | 2 +- bootstrap/windows-88/OPM.c | 6 +- bootstrap/windows-88/OPM.h | 2 +- bootstrap/windows-88/OPP.c | 2 +- bootstrap/windows-88/OPP.h | 2 +- bootstrap/windows-88/OPS.c | 2 +- bootstrap/windows-88/OPS.h | 2 +- bootstrap/windows-88/OPT.c | 2 +- bootstrap/windows-88/OPT.h | 2 +- bootstrap/windows-88/OPV.c | 2 +- bootstrap/windows-88/OPV.h | 2 +- bootstrap/windows-88/Out.c | 2 +- bootstrap/windows-88/Out.h | 2 +- bootstrap/windows-88/Platform.c | 2 +- bootstrap/windows-88/Platform.h | 2 +- bootstrap/windows-88/Reals.c | 2 +- bootstrap/windows-88/Reals.h | 2 +- bootstrap/windows-88/Strings.c | 2 +- bootstrap/windows-88/Strings.h | 2 +- bootstrap/windows-88/Texts.c | 2 +- bootstrap/windows-88/Texts.h | 2 +- bootstrap/windows-88/VT100.c | 2 +- bootstrap/windows-88/VT100.h | 2 +- bootstrap/windows-88/extTools.c | 6 +- bootstrap/windows-88/extTools.h | 2 +- 185 files changed, 1215 insertions(+), 345 deletions(-) diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index 9322477d..4eac6b2e 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index f30fe61f..c7d8b4a8 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index 39dd27b9..38963a37 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index 96dd911c..30a596c2 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index c97d14a6..aa5fec57 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index 95b746d7..752ece9b 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index 86033649..0126c839 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index 73c918d9..7eb1cd6e 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -46,21 +46,31 @@ export Modules_ModuleName Modules_imported, Modules_importing; export INT32 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT32 Modules_ArgVector; +export CHAR Modules_BinaryDir[1024]; export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len); +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); export void Modules_AssertFail (INT32 code); +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len); static void Modules_DisplayHaltCode (INT32 code); +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len); +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len); export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all); export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); export void Modules_GetIntArg (INT16 n, INT32 *val); export void Modules_Halt (INT32 code); export void Modules_Init (INT32 argc, INT32 argvadr); +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); static void Modules_errstring (CHAR *s, ADDRESS s__len); @@ -72,32 +82,24 @@ extern void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m -typedef - INT32 (*ArgVecPtr__14)[1]; - void Modules_Init (INT32 argc, INT32 argvadr) { - ArgVecPtr__14 av = NIL; Modules_MainStackFrame = argvadr; Modules_ArgCount = __VAL(INT16, argc); - av = (ArgVecPtr__14)(ADDRESS)argvadr; - Modules_ArgVector = (*av)[0]; + __GET(argvadr, Modules_ArgVector, INT32); Modules_InitHeap(); Modules_ModulesInit(); } typedef - CHAR (*ArgPtr__9)[1024]; - -typedef - ArgPtr__9 (*ArgVec__10)[1024]; + CHAR (*argptr__15)[1024]; void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len) { - ArgVec__10 av = NIL; + argptr__15 arg = NIL; if (n < Modules_ArgCount) { - av = (ArgVec__10)(ADDRESS)Modules_ArgVector; - __COPY(*(*av)[__X(n, 1024)], val, val__len); + __GET(Modules_ArgVector + __ASHL(n, 2), arg, argptr__15); + __COPY(*arg, val, val__len); } } @@ -142,22 +144,188 @@ INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len) return i; } -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len) +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len) { - INT16 i, j; - __DUP(b, b__len, CHAR); + INT16 i; + __DUP(s, s__len, CHAR); i = 0; - while (a[__X(i, a__len)] != 0x00) { + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - j = 0; - while (b[__X(j, b__len)] != 0x00) { - a[__X(i, a__len)] = b[__X(j, b__len)]; + __DEL(s); + return i; +} + +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; i += 1; j += 1; } - a[__X(i, a__len)] = 0x00; - __DEL(b); + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + if ((j > 0 && d[__X(j - 1, d__len)] != c)) { + d[__X(j, d__len)] = c; + j += 1; + } + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; + i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len) +{ + INT16 i; + __DUP(s, s__len, CHAR); + if (c == 0x00) { + __DEL(s); + return 0; + } + i = 0; + while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) { + i += 1; + } + __DEL(s); + return s[__X(i, s__len)] == c; +} + +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len) +{ + __DUP(d, d__len, CHAR); + if (d[0] == 0x00) { + __DEL(d); + return 0; + } + if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) { + __DEL(d); + return 1; + } + if (d[__X(1, d__len)] == ':') { + __DEL(d); + return 1; + } + __DEL(d); + return 0; +} + +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + __DUP(s, s__len, CHAR); + if (Modules_IsAbsolute(s, s__len)) { + __COPY(s, d, d__len); + } else { + __COPY(Platform_CWD, d, d__len); + Modules_AppendPart('/', s, s__len, (void*)d, d__len); + } + __DEL(s); +} + +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len) +{ + Platform_FileIdentity identity; + __DUP(s, s__len, CHAR); + __DEL(s); + return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0; +} + +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len) +{ + INT16 j; + __DUP(s, s__len, CHAR); + __DUP(p, p__len, CHAR); + j = 0; + while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) { + d[__X(j, d__len)] = s[__X(*i, s__len)]; + *i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) { + *i += 1; + } + __DEL(s); + __DEL(p); +} + +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + CHAR part[1024]; + __DUP(s, s__len, CHAR); + i = 0; + j = 0; + while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) { + i += 1; + d[__X(j, d__len)] = '/'; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (s[__X(i, s__len)] != 0x00) { + Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024); + if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) { + Modules_AppendPart('/', part, 1024, (void*)d, d__len); + } + } + __DEL(s); +} + +typedef + CHAR pathstring__12[4096]; + +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len) +{ + pathstring__12 executable, dir, testpath, pathlist; + INT16 i, j, k; + BOOLEAN present; + if (Modules_ArgCount < 1) { + d[0] = 0x00; + return; + } + Modules_GetArg(0, (void*)testpath, 4096); + Modules_Trim(testpath, 4096, (void*)executable, 4096); + Modules_Canonify(executable, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + if ((!present && !Modules_IsAbsolute(testpath, 4096))) { + Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096); + i = 0; + while ((!present && pathlist[__X(i, 4096)] != 0x00)) { + Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)dir, 4096); + Modules_Trim(dir, 4096, (void*)testpath, 4096); + Modules_AppendPart('/', executable, 4096, (void*)testpath, 4096); + Modules_Canonify(testpath, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + } + } + if (present) { + k = Modules_CharCount(d, d__len); + while ((k > 0 && !Modules_IsOneOf(d[__X(k - 1, d__len)], (CHAR*)"/\\", 3))) { + k -= 1; + } + if (k == 0) { + d[__X(k, d__len)] = 0x00; + } else { + d[__X(k - 1, d__len)] = 0x00; + } + } else { + d[0] = 0x00; + } } Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) @@ -177,8 +345,8 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) Modules_res = 1; __COPY(name, Modules_importing, 20); __MOVE(" module \"", Modules_resMsg, 10); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); } __DEL(name); return m; @@ -201,10 +369,10 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam Modules_res = 2; __MOVE(" command \"", Modules_resMsg, 11); __COPY(name, Modules_importing, 20); - Modules_Append((void*)Modules_resMsg, 256, mod->name, 20); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)".", 2); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); __DEL(name); return NIL; } @@ -371,5 +539,6 @@ export void *Modules__init(void) __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ + Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; } diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 92ebb074..e114cae2 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h @@ -42,6 +42,7 @@ import Modules_ModuleName Modules_imported, Modules_importing; import INT32 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT32 Modules_ArgVector; +import CHAR Modules_BinaryDir[1024]; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index 57fde3a0..0b1509bc 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index e841f317..d6b81543 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index d3e4eaf5..620dd88e 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 06fa9996..20ac9ae8 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 9aca428d..330d8fde 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -267,6 +267,10 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) BOOLEAN OPM_OpenPar (void) { CHAR s[256]; + Out_String((CHAR*)"Testing. Binary directory is: '", 32); + Out_String(Modules_BinaryDir, 1024); + Out_String((CHAR*)"'.", 3); + Out_Ln(); if (Modules_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index 6ea722dc..ec6947a6 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 24a04912..e6d8b614 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index b6d59055..da746402 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 311cbe15..2c97a4d0 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index 28618fe1..0b780918 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index dcaf0156..c12b6ffd 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index ab443dff..0a26e546 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 5a44f258..950e0e36 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index d26a1b3e..1afcee74 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index 73f0311a..2558adfa 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index a4eb7cb6..62f9d414 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 95c8d97b..2de4df02 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index 1f183fc5..798f6253 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 33c286b7..8668f3be 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 6fc2dd5c..a864fcae 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 42190367..697accbd 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 1806a7cc..30317939 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 489acce0..28b11c5a 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index 00add2ac..a9c20822 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/VT100.c b/bootstrap/unix-44/VT100.c index c6c421f9..ea43623a 100644 --- a/bootstrap/unix-44/VT100.c +++ b/bootstrap/unix-44/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/VT100.h b/bootstrap/unix-44/VT100.h index b1771722..70c0dfa9 100644 --- a/bootstrap/unix-44/VT100.h +++ b/bootstrap/unix-44/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index e89705a7..f08daa40 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -65,7 +65,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len) { - __COPY("x86_64-w64-mingw32-gcc -g", s, s__len); + __COPY("gcc -g", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); @@ -95,7 +95,7 @@ void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN stati Strings_Append((CHAR*)".c ", 4, (void*)cmd, 1023); Strings_Append(additionalopts, additionalopts__len, (void*)cmd, 1023); if (statically) { - Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); + Strings_Append((CHAR*)"-static", 8, (void*)cmd, 1023); } Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index e92a4c5f..e736dc46 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/Compiler.c b/bootstrap/unix-48/Compiler.c index 9322477d..4eac6b2e 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index f30fe61f..c7d8b4a8 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index 39dd27b9..38963a37 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index 96dd911c..30a596c2 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index c97d14a6..aa5fec57 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index 95b746d7..752ece9b 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index 86033649..0126c839 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index 73c918d9..7eb1cd6e 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -46,21 +46,31 @@ export Modules_ModuleName Modules_imported, Modules_importing; export INT32 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT32 Modules_ArgVector; +export CHAR Modules_BinaryDir[1024]; export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len); +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); export void Modules_AssertFail (INT32 code); +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len); static void Modules_DisplayHaltCode (INT32 code); +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len); +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len); export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all); export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); export void Modules_GetIntArg (INT16 n, INT32 *val); export void Modules_Halt (INT32 code); export void Modules_Init (INT32 argc, INT32 argvadr); +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); static void Modules_errstring (CHAR *s, ADDRESS s__len); @@ -72,32 +82,24 @@ extern void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m -typedef - INT32 (*ArgVecPtr__14)[1]; - void Modules_Init (INT32 argc, INT32 argvadr) { - ArgVecPtr__14 av = NIL; Modules_MainStackFrame = argvadr; Modules_ArgCount = __VAL(INT16, argc); - av = (ArgVecPtr__14)(ADDRESS)argvadr; - Modules_ArgVector = (*av)[0]; + __GET(argvadr, Modules_ArgVector, INT32); Modules_InitHeap(); Modules_ModulesInit(); } typedef - CHAR (*ArgPtr__9)[1024]; - -typedef - ArgPtr__9 (*ArgVec__10)[1024]; + CHAR (*argptr__15)[1024]; void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len) { - ArgVec__10 av = NIL; + argptr__15 arg = NIL; if (n < Modules_ArgCount) { - av = (ArgVec__10)(ADDRESS)Modules_ArgVector; - __COPY(*(*av)[__X(n, 1024)], val, val__len); + __GET(Modules_ArgVector + __ASHL(n, 2), arg, argptr__15); + __COPY(*arg, val, val__len); } } @@ -142,22 +144,188 @@ INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len) return i; } -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len) +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len) { - INT16 i, j; - __DUP(b, b__len, CHAR); + INT16 i; + __DUP(s, s__len, CHAR); i = 0; - while (a[__X(i, a__len)] != 0x00) { + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - j = 0; - while (b[__X(j, b__len)] != 0x00) { - a[__X(i, a__len)] = b[__X(j, b__len)]; + __DEL(s); + return i; +} + +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; i += 1; j += 1; } - a[__X(i, a__len)] = 0x00; - __DEL(b); + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + if ((j > 0 && d[__X(j - 1, d__len)] != c)) { + d[__X(j, d__len)] = c; + j += 1; + } + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; + i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len) +{ + INT16 i; + __DUP(s, s__len, CHAR); + if (c == 0x00) { + __DEL(s); + return 0; + } + i = 0; + while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) { + i += 1; + } + __DEL(s); + return s[__X(i, s__len)] == c; +} + +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len) +{ + __DUP(d, d__len, CHAR); + if (d[0] == 0x00) { + __DEL(d); + return 0; + } + if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) { + __DEL(d); + return 1; + } + if (d[__X(1, d__len)] == ':') { + __DEL(d); + return 1; + } + __DEL(d); + return 0; +} + +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + __DUP(s, s__len, CHAR); + if (Modules_IsAbsolute(s, s__len)) { + __COPY(s, d, d__len); + } else { + __COPY(Platform_CWD, d, d__len); + Modules_AppendPart('/', s, s__len, (void*)d, d__len); + } + __DEL(s); +} + +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len) +{ + Platform_FileIdentity identity; + __DUP(s, s__len, CHAR); + __DEL(s); + return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0; +} + +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len) +{ + INT16 j; + __DUP(s, s__len, CHAR); + __DUP(p, p__len, CHAR); + j = 0; + while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) { + d[__X(j, d__len)] = s[__X(*i, s__len)]; + *i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) { + *i += 1; + } + __DEL(s); + __DEL(p); +} + +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + CHAR part[1024]; + __DUP(s, s__len, CHAR); + i = 0; + j = 0; + while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) { + i += 1; + d[__X(j, d__len)] = '/'; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (s[__X(i, s__len)] != 0x00) { + Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024); + if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) { + Modules_AppendPart('/', part, 1024, (void*)d, d__len); + } + } + __DEL(s); +} + +typedef + CHAR pathstring__12[4096]; + +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len) +{ + pathstring__12 executable, dir, testpath, pathlist; + INT16 i, j, k; + BOOLEAN present; + if (Modules_ArgCount < 1) { + d[0] = 0x00; + return; + } + Modules_GetArg(0, (void*)testpath, 4096); + Modules_Trim(testpath, 4096, (void*)executable, 4096); + Modules_Canonify(executable, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + if ((!present && !Modules_IsAbsolute(testpath, 4096))) { + Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096); + i = 0; + while ((!present && pathlist[__X(i, 4096)] != 0x00)) { + Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)dir, 4096); + Modules_Trim(dir, 4096, (void*)testpath, 4096); + Modules_AppendPart('/', executable, 4096, (void*)testpath, 4096); + Modules_Canonify(testpath, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + } + } + if (present) { + k = Modules_CharCount(d, d__len); + while ((k > 0 && !Modules_IsOneOf(d[__X(k - 1, d__len)], (CHAR*)"/\\", 3))) { + k -= 1; + } + if (k == 0) { + d[__X(k, d__len)] = 0x00; + } else { + d[__X(k - 1, d__len)] = 0x00; + } + } else { + d[0] = 0x00; + } } Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) @@ -177,8 +345,8 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) Modules_res = 1; __COPY(name, Modules_importing, 20); __MOVE(" module \"", Modules_resMsg, 10); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); } __DEL(name); return m; @@ -201,10 +369,10 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam Modules_res = 2; __MOVE(" command \"", Modules_resMsg, 11); __COPY(name, Modules_importing, 20); - Modules_Append((void*)Modules_resMsg, 256, mod->name, 20); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)".", 2); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); __DEL(name); return NIL; } @@ -371,5 +539,6 @@ export void *Modules__init(void) __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ + Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; } diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 92ebb074..e114cae2 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h @@ -42,6 +42,7 @@ import Modules_ModuleName Modules_imported, Modules_importing; import INT32 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT32 Modules_ArgVector; +import CHAR Modules_BinaryDir[1024]; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index 57fde3a0..0b1509bc 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index e841f317..d6b81543 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index d3e4eaf5..620dd88e 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 06fa9996..20ac9ae8 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 9aca428d..330d8fde 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -267,6 +267,10 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) BOOLEAN OPM_OpenPar (void) { CHAR s[256]; + Out_String((CHAR*)"Testing. Binary directory is: '", 32); + Out_String(Modules_BinaryDir, 1024); + Out_String((CHAR*)"'.", 3); + Out_Ln(); if (Modules_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index 6ea722dc..ec6947a6 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 24a04912..e6d8b614 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index b6d59055..da746402 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 311cbe15..2c97a4d0 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index 28618fe1..0b780918 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index 7284592a..719dab04 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index ab443dff..0a26e546 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 5a44f258..950e0e36 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index d26a1b3e..1afcee74 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index 73f0311a..2558adfa 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index a4eb7cb6..62f9d414 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 95c8d97b..2de4df02 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index 1f183fc5..798f6253 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 33c286b7..8668f3be 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 6fc2dd5c..a864fcae 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 42190367..697accbd 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 1806a7cc..30317939 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index cc68acd9..0ccbbbd1 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index 9aed03da..ceb5355e 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/VT100.c b/bootstrap/unix-48/VT100.c index c6c421f9..ea43623a 100644 --- a/bootstrap/unix-48/VT100.c +++ b/bootstrap/unix-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/VT100.h b/bootstrap/unix-48/VT100.h index b1771722..70c0dfa9 100644 --- a/bootstrap/unix-48/VT100.h +++ b/bootstrap/unix-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index e89705a7..f08daa40 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -65,7 +65,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len) { - __COPY("x86_64-w64-mingw32-gcc -g", s, s__len); + __COPY("gcc -g", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); @@ -95,7 +95,7 @@ void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN stati Strings_Append((CHAR*)".c ", 4, (void*)cmd, 1023); Strings_Append(additionalopts, additionalopts__len, (void*)cmd, 1023); if (statically) { - Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); + Strings_Append((CHAR*)"-static", 8, (void*)cmd, 1023); } Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index e92a4c5f..e736dc46 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/Compiler.c b/bootstrap/unix-88/Compiler.c index 9322477d..4eac6b2e 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index f30fe61f..c7d8b4a8 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index 39dd27b9..38963a37 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index a2d72b8e..161a30a4 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 4dab2431..52d281d9 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 5f4cd2f3..34ef3786 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index da41e4b8..648265c8 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index fcf1bb3a..01e9bcbd 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -46,21 +46,31 @@ export Modules_ModuleName Modules_imported, Modules_importing; export INT64 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT64 Modules_ArgVector; +export CHAR Modules_BinaryDir[1024]; export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len); +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); export void Modules_AssertFail (INT32 code); +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len); static void Modules_DisplayHaltCode (INT32 code); +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len); +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len); export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all); export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); export void Modules_GetIntArg (INT16 n, INT32 *val); export void Modules_Halt (INT32 code); export void Modules_Init (INT32 argc, INT64 argvadr); +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); static void Modules_errstring (CHAR *s, ADDRESS s__len); @@ -72,32 +82,24 @@ extern void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m -typedef - INT64 (*ArgVecPtr__14)[1]; - void Modules_Init (INT32 argc, INT64 argvadr) { - ArgVecPtr__14 av = NIL; Modules_MainStackFrame = argvadr; Modules_ArgCount = __VAL(INT16, argc); - av = (ArgVecPtr__14)(ADDRESS)argvadr; - Modules_ArgVector = (*av)[0]; + __GET(argvadr, Modules_ArgVector, INT64); Modules_InitHeap(); Modules_ModulesInit(); } typedef - CHAR (*ArgPtr__9)[1024]; - -typedef - ArgPtr__9 (*ArgVec__10)[1024]; + CHAR (*argptr__15)[1024]; void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len) { - ArgVec__10 av = NIL; + argptr__15 arg = NIL; if (n < Modules_ArgCount) { - av = (ArgVec__10)(ADDRESS)Modules_ArgVector; - __COPY(*(*av)[__X(n, 1024)], val, val__len); + __GET(Modules_ArgVector + (INT64)__ASHL(n, 3), arg, argptr__15); + __COPY(*arg, val, val__len); } } @@ -142,22 +144,188 @@ INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len) return i; } -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len) +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len) { - INT16 i, j; - __DUP(b, b__len, CHAR); + INT16 i; + __DUP(s, s__len, CHAR); i = 0; - while (a[__X(i, a__len)] != 0x00) { + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - j = 0; - while (b[__X(j, b__len)] != 0x00) { - a[__X(i, a__len)] = b[__X(j, b__len)]; + __DEL(s); + return i; +} + +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; i += 1; j += 1; } - a[__X(i, a__len)] = 0x00; - __DEL(b); + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + if ((j > 0 && d[__X(j - 1, d__len)] != c)) { + d[__X(j, d__len)] = c; + j += 1; + } + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; + i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len) +{ + INT16 i; + __DUP(s, s__len, CHAR); + if (c == 0x00) { + __DEL(s); + return 0; + } + i = 0; + while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) { + i += 1; + } + __DEL(s); + return s[__X(i, s__len)] == c; +} + +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len) +{ + __DUP(d, d__len, CHAR); + if (d[0] == 0x00) { + __DEL(d); + return 0; + } + if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) { + __DEL(d); + return 1; + } + if (d[__X(1, d__len)] == ':') { + __DEL(d); + return 1; + } + __DEL(d); + return 0; +} + +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + __DUP(s, s__len, CHAR); + if (Modules_IsAbsolute(s, s__len)) { + __COPY(s, d, d__len); + } else { + __COPY(Platform_CWD, d, d__len); + Modules_AppendPart('/', s, s__len, (void*)d, d__len); + } + __DEL(s); +} + +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len) +{ + Platform_FileIdentity identity; + __DUP(s, s__len, CHAR); + __DEL(s); + return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0; +} + +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len) +{ + INT16 j; + __DUP(s, s__len, CHAR); + __DUP(p, p__len, CHAR); + j = 0; + while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) { + d[__X(j, d__len)] = s[__X(*i, s__len)]; + *i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) { + *i += 1; + } + __DEL(s); + __DEL(p); +} + +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + CHAR part[1024]; + __DUP(s, s__len, CHAR); + i = 0; + j = 0; + while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) { + i += 1; + d[__X(j, d__len)] = '/'; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (s[__X(i, s__len)] != 0x00) { + Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024); + if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) { + Modules_AppendPart('/', part, 1024, (void*)d, d__len); + } + } + __DEL(s); +} + +typedef + CHAR pathstring__12[4096]; + +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len) +{ + pathstring__12 executable, dir, testpath, pathlist; + INT16 i, j, k; + BOOLEAN present; + if (Modules_ArgCount < 1) { + d[0] = 0x00; + return; + } + Modules_GetArg(0, (void*)testpath, 4096); + Modules_Trim(testpath, 4096, (void*)executable, 4096); + Modules_Canonify(executable, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + if ((!present && !Modules_IsAbsolute(testpath, 4096))) { + Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096); + i = 0; + while ((!present && pathlist[__X(i, 4096)] != 0x00)) { + Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)dir, 4096); + Modules_Trim(dir, 4096, (void*)testpath, 4096); + Modules_AppendPart('/', executable, 4096, (void*)testpath, 4096); + Modules_Canonify(testpath, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + } + } + if (present) { + k = Modules_CharCount(d, d__len); + while ((k > 0 && !Modules_IsOneOf(d[__X(k - 1, d__len)], (CHAR*)"/\\", 3))) { + k -= 1; + } + if (k == 0) { + d[__X(k, d__len)] = 0x00; + } else { + d[__X(k - 1, d__len)] = 0x00; + } + } else { + d[0] = 0x00; + } } Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) @@ -177,8 +345,8 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) Modules_res = 1; __COPY(name, Modules_importing, 20); __MOVE(" module \"", Modules_resMsg, 10); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); } __DEL(name); return m; @@ -201,10 +369,10 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam Modules_res = 2; __MOVE(" command \"", Modules_resMsg, 11); __COPY(name, Modules_importing, 20); - Modules_Append((void*)Modules_resMsg, 256, mod->name, 20); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)".", 2); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); __DEL(name); return NIL; } @@ -371,5 +539,6 @@ export void *Modules__init(void) __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ + Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; } diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 327f139b..6cad66e4 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h @@ -42,6 +42,7 @@ import Modules_ModuleName Modules_imported, Modules_importing; import INT64 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT64 Modules_ArgVector; +import CHAR Modules_BinaryDir[1024]; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 57fde3a0..0b1509bc 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index e841f317..d6b81543 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index d3e4eaf5..620dd88e 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index 06fa9996..20ac9ae8 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 0533cbfc..39f36504 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -267,6 +267,10 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) BOOLEAN OPM_OpenPar (void) { CHAR s[256]; + Out_String((CHAR*)"Testing. Binary directory is: '", 32); + Out_String(Modules_BinaryDir, 1024); + Out_String((CHAR*)"'.", 3); + Out_Ln(); if (Modules_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 6ea722dc..ec6947a6 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index a7630159..34d1f0e4 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index b6d59055..da746402 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 311cbe15..2c97a4d0 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index 28618fe1..0b780918 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 0dd110b2..63667f88 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index ab443dff..0a26e546 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 6a1d23a7..5520370e 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index d26a1b3e..1afcee74 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index 73f0311a..2558adfa 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index a4eb7cb6..62f9d414 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 11b9bd14..e1be57b0 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index f84abacb..37d890d8 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index 33c286b7..8668f3be 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index 6fc2dd5c..a864fcae 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 42190367..697accbd 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index 1806a7cc..30317939 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 627eb31d..9a2c7cb4 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index ac4a8157..def1eeef 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/VT100.c b/bootstrap/unix-88/VT100.c index c6c421f9..ea43623a 100644 --- a/bootstrap/unix-88/VT100.c +++ b/bootstrap/unix-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/VT100.h b/bootstrap/unix-88/VT100.h index b1771722..70c0dfa9 100644 --- a/bootstrap/unix-88/VT100.h +++ b/bootstrap/unix-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index e89705a7..f08daa40 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -65,7 +65,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len) { - __COPY("x86_64-w64-mingw32-gcc -g", s, s__len); + __COPY("gcc -g", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); @@ -95,7 +95,7 @@ void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN stati Strings_Append((CHAR*)".c ", 4, (void*)cmd, 1023); Strings_Append(additionalopts, additionalopts__len, (void*)cmd, 1023); if (statically) { - Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); + Strings_Append((CHAR*)"-static", 8, (void*)cmd, 1023); } Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index e92a4c5f..e736dc46 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/Compiler.c b/bootstrap/windows-48/Compiler.c index 9322477d..4eac6b2e 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index f30fe61f..c7d8b4a8 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index 39dd27b9..38963a37 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index c0bb12ed..8d916fc1 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index b2973453..dafb5071 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index 95b746d7..752ece9b 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index 86033649..0126c839 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index 85b323b2..e83c0383 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -46,21 +46,31 @@ export Modules_ModuleName Modules_imported, Modules_importing; export INT32 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT32 Modules_ArgVector; +export CHAR Modules_BinaryDir[1024]; export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len); +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); export void Modules_AssertFail (INT32 code); +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len); static void Modules_DisplayHaltCode (INT32 code); +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len); +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len); export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all); export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); export void Modules_GetIntArg (INT16 n, INT32 *val); export void Modules_Halt (INT32 code); export void Modules_Init (INT32 argc, INT32 argvadr); +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); static void Modules_errstring (CHAR *s, ADDRESS s__len); @@ -72,32 +82,24 @@ extern void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m -typedef - INT32 (*ArgVecPtr__14)[1]; - void Modules_Init (INT32 argc, INT32 argvadr) { - ArgVecPtr__14 av = NIL; Modules_MainStackFrame = argvadr; Modules_ArgCount = __VAL(INT16, argc); - av = (ArgVecPtr__14)(ADDRESS)argvadr; - Modules_ArgVector = (*av)[0]; + __GET(argvadr, Modules_ArgVector, INT32); Modules_InitHeap(); Modules_ModulesInit(); } typedef - CHAR (*ArgPtr__9)[1024]; - -typedef - ArgPtr__9 (*ArgVec__10)[1024]; + CHAR (*argptr__15)[1024]; void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len) { - ArgVec__10 av = NIL; + argptr__15 arg = NIL; if (n < Modules_ArgCount) { - av = (ArgVec__10)(ADDRESS)Modules_ArgVector; - __COPY(*(*av)[__X(n, 1024)], val, val__len); + __GET(Modules_ArgVector + __ASHL(n, 2), arg, argptr__15); + __COPY(*arg, val, val__len); } } @@ -142,22 +144,188 @@ INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len) return i; } -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len) +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len) { - INT16 i, j; - __DUP(b, b__len, CHAR); + INT16 i; + __DUP(s, s__len, CHAR); i = 0; - while (a[__X(i, a__len)] != 0x00) { + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - j = 0; - while (b[__X(j, b__len)] != 0x00) { - a[__X(i, a__len)] = b[__X(j, b__len)]; + __DEL(s); + return i; +} + +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; i += 1; j += 1; } - a[__X(i, a__len)] = 0x00; - __DEL(b); + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + if ((j > 0 && d[__X(j - 1, d__len)] != c)) { + d[__X(j, d__len)] = c; + j += 1; + } + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; + i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len) +{ + INT16 i; + __DUP(s, s__len, CHAR); + if (c == 0x00) { + __DEL(s); + return 0; + } + i = 0; + while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) { + i += 1; + } + __DEL(s); + return s[__X(i, s__len)] == c; +} + +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len) +{ + __DUP(d, d__len, CHAR); + if (d[0] == 0x00) { + __DEL(d); + return 0; + } + if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) { + __DEL(d); + return 1; + } + if (d[__X(1, d__len)] == ':') { + __DEL(d); + return 1; + } + __DEL(d); + return 0; +} + +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + __DUP(s, s__len, CHAR); + if (Modules_IsAbsolute(s, s__len)) { + __COPY(s, d, d__len); + } else { + __COPY(Platform_CWD, d, d__len); + Modules_AppendPart('/', s, s__len, (void*)d, d__len); + } + __DEL(s); +} + +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len) +{ + Platform_FileIdentity identity; + __DUP(s, s__len, CHAR); + __DEL(s); + return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0; +} + +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len) +{ + INT16 j; + __DUP(s, s__len, CHAR); + __DUP(p, p__len, CHAR); + j = 0; + while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) { + d[__X(j, d__len)] = s[__X(*i, s__len)]; + *i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) { + *i += 1; + } + __DEL(s); + __DEL(p); +} + +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + CHAR part[1024]; + __DUP(s, s__len, CHAR); + i = 0; + j = 0; + while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) { + i += 1; + d[__X(j, d__len)] = '/'; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (s[__X(i, s__len)] != 0x00) { + Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024); + if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) { + Modules_AppendPart('/', part, 1024, (void*)d, d__len); + } + } + __DEL(s); +} + +typedef + CHAR pathstring__12[4096]; + +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len) +{ + pathstring__12 executable, dir, testpath, pathlist; + INT16 i, j, k; + BOOLEAN present; + if (Modules_ArgCount < 1) { + d[0] = 0x00; + return; + } + Modules_GetArg(0, (void*)testpath, 4096); + Modules_Trim(testpath, 4096, (void*)executable, 4096); + Modules_Canonify(executable, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + if ((!present && !Modules_IsAbsolute(testpath, 4096))) { + Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096); + i = 0; + while ((!present && pathlist[__X(i, 4096)] != 0x00)) { + Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)dir, 4096); + Modules_Trim(dir, 4096, (void*)testpath, 4096); + Modules_AppendPart('/', executable, 4096, (void*)testpath, 4096); + Modules_Canonify(testpath, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + } + } + if (present) { + k = Modules_CharCount(d, d__len); + while ((k > 0 && !Modules_IsOneOf(d[__X(k - 1, d__len)], (CHAR*)"/\\", 3))) { + k -= 1; + } + if (k == 0) { + d[__X(k, d__len)] = 0x00; + } else { + d[__X(k - 1, d__len)] = 0x00; + } + } else { + d[0] = 0x00; + } } Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) @@ -177,8 +345,8 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) Modules_res = 1; __COPY(name, Modules_importing, 20); __MOVE(" module \"", Modules_resMsg, 10); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); } __DEL(name); return m; @@ -201,10 +369,10 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam Modules_res = 2; __MOVE(" command \"", Modules_resMsg, 11); __COPY(name, Modules_importing, 20); - Modules_Append((void*)Modules_resMsg, 256, mod->name, 20); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)".", 2); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); __DEL(name); return NIL; } @@ -371,5 +539,6 @@ export void *Modules__init(void) __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ + Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; } diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 92ebb074..e114cae2 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h @@ -42,6 +42,7 @@ import Modules_ModuleName Modules_imported, Modules_importing; import INT32 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT32 Modules_ArgVector; +import CHAR Modules_BinaryDir[1024]; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index 57fde3a0..0b1509bc 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index e841f317..d6b81543 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index d3e4eaf5..620dd88e 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 06fa9996..20ac9ae8 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 9aca428d..330d8fde 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -267,6 +267,10 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) BOOLEAN OPM_OpenPar (void) { CHAR s[256]; + Out_String((CHAR*)"Testing. Binary directory is: '", 32); + Out_String(Modules_BinaryDir, 1024); + Out_String((CHAR*)"'.", 3); + Out_Ln(); if (Modules_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index 6ea722dc..ec6947a6 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 24a04912..e6d8b614 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index b6d59055..da746402 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 311cbe15..2c97a4d0 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index 28618fe1..0b780918 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index 7284592a..719dab04 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index ab443dff..0a26e546 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 5a44f258..950e0e36 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index d26a1b3e..1afcee74 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index b5ccb18b..d1ff2558 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index a4eb7cb6..62f9d414 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index 20c5ca89..4a1e30b8 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index f53d70ed..a1fad287 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index 33c286b7..8668f3be 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 6fc2dd5c..a864fcae 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 42190367..697accbd 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 1806a7cc..30317939 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index cc68acd9..0ccbbbd1 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index 9aed03da..ceb5355e 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/VT100.c b/bootstrap/windows-48/VT100.c index c6c421f9..ea43623a 100644 --- a/bootstrap/windows-48/VT100.c +++ b/bootstrap/windows-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/VT100.h b/bootstrap/windows-48/VT100.h index b1771722..70c0dfa9 100644 --- a/bootstrap/windows-48/VT100.h +++ b/bootstrap/windows-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index e89705a7..f08daa40 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -65,7 +65,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len) { - __COPY("x86_64-w64-mingw32-gcc -g", s, s__len); + __COPY("gcc -g", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); @@ -95,7 +95,7 @@ void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN stati Strings_Append((CHAR*)".c ", 4, (void*)cmd, 1023); Strings_Append(additionalopts, additionalopts__len, (void*)cmd, 1023); if (statically) { - Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); + Strings_Append((CHAR*)"-static", 8, (void*)cmd, 1023); } Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index e92a4c5f..e736dc46 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/Compiler.c b/bootstrap/windows-88/Compiler.c index 9322477d..4eac6b2e 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index f30fe61f..c7d8b4a8 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index 39dd27b9..38963a37 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index 27810f46..da080e3e 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 8d9e7acc..969643b0 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 5f4cd2f3..34ef3786 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index da41e4b8..648265c8 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index d3b0e7ec..9d8d2534 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -46,21 +46,31 @@ export Modules_ModuleName Modules_imported, Modules_importing; export INT64 Modules_MainStackFrame; export INT16 Modules_ArgCount; export INT64 Modules_ArgVector; +export CHAR Modules_BinaryDir[1024]; export ADDRESS *Modules_ModuleDesc__typ; export ADDRESS *Modules_CmdDesc__typ; -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len); +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); export INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len); export void Modules_AssertFail (INT32 code); +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len); static void Modules_DisplayHaltCode (INT32 code); +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len); +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len); export void Modules_Free (CHAR *name, ADDRESS name__len, BOOLEAN all); export void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len); export void Modules_GetIntArg (INT16 n, INT32 *val); export void Modules_Halt (INT32 code); export void Modules_Init (INT32 argc, INT64 argvadr); +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len); +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len); +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len); export Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS name__len); export Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len); +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len); static void Modules_errch (CHAR c); static void Modules_errint (INT32 l); static void Modules_errstring (CHAR *s, ADDRESS s__len); @@ -72,32 +82,24 @@ extern void *Modules__init(void); #define Modules_modules() (Modules_Module)Heap_modules #define Modules_setmodules(m) Heap_modules = m -typedef - INT64 (*ArgVecPtr__14)[1]; - void Modules_Init (INT32 argc, INT64 argvadr) { - ArgVecPtr__14 av = NIL; Modules_MainStackFrame = argvadr; Modules_ArgCount = __VAL(INT16, argc); - av = (ArgVecPtr__14)(ADDRESS)argvadr; - Modules_ArgVector = (*av)[0]; + __GET(argvadr, Modules_ArgVector, INT64); Modules_InitHeap(); Modules_ModulesInit(); } typedef - CHAR (*ArgPtr__9)[1024]; - -typedef - ArgPtr__9 (*ArgVec__10)[1024]; + CHAR (*argptr__15)[1024]; void Modules_GetArg (INT16 n, CHAR *val, ADDRESS val__len) { - ArgVec__10 av = NIL; + argptr__15 arg = NIL; if (n < Modules_ArgCount) { - av = (ArgVec__10)(ADDRESS)Modules_ArgVector; - __COPY(*(*av)[__X(n, 1024)], val, val__len); + __GET(Modules_ArgVector + (INT64)__ASHL(n, 3), arg, argptr__15); + __COPY(*arg, val, val__len); } } @@ -142,22 +144,188 @@ INT16 Modules_ArgPos (CHAR *s, ADDRESS s__len) return i; } -static void Modules_Append (CHAR *a, ADDRESS a__len, CHAR *b, ADDRESS b__len) +static INT16 Modules_CharCount (CHAR *s, ADDRESS s__len) { - INT16 i, j; - __DUP(b, b__len, CHAR); + INT16 i; + __DUP(s, s__len, CHAR); i = 0; - while (a[__X(i, a__len)] != 0x00) { + while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - j = 0; - while (b[__X(j, b__len)] != 0x00) { - a[__X(i, a__len)] = b[__X(j, b__len)]; + __DEL(s); + return i; +} + +static void Modules_Append (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; i += 1; j += 1; } - a[__X(i, a__len)] = 0x00; - __DEL(b); + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static void Modules_AppendPart (CHAR c, CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + __DUP(s, s__len, CHAR); + i = 0; + j = Modules_CharCount(d, d__len); + if ((j > 0 && d[__X(j - 1, d__len)] != c)) { + d[__X(j, d__len)] = c; + j += 1; + } + while (s[__X(i, s__len)] != 0x00) { + d[__X(j, d__len)] = s[__X(i, s__len)]; + i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + __DEL(s); +} + +static BOOLEAN Modules_IsOneOf (CHAR c, CHAR *s, ADDRESS s__len) +{ + INT16 i; + __DUP(s, s__len, CHAR); + if (c == 0x00) { + __DEL(s); + return 0; + } + i = 0; + while ((s[__X(i, s__len)] != c && s[__X(i, s__len)] != 0x00)) { + i += 1; + } + __DEL(s); + return s[__X(i, s__len)] == c; +} + +static BOOLEAN Modules_IsAbsolute (CHAR *d, ADDRESS d__len) +{ + __DUP(d, d__len, CHAR); + if (d[0] == 0x00) { + __DEL(d); + return 0; + } + if (Modules_IsOneOf(d[0], (CHAR*)"/\\", 3)) { + __DEL(d); + return 1; + } + if (d[__X(1, d__len)] == ':') { + __DEL(d); + return 1; + } + __DEL(d); + return 0; +} + +static void Modules_Canonify (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + __DUP(s, s__len, CHAR); + if (Modules_IsAbsolute(s, s__len)) { + __COPY(s, d, d__len); + } else { + __COPY(Platform_CWD, d, d__len); + Modules_AppendPart('/', s, s__len, (void*)d, d__len); + } + __DEL(s); +} + +static BOOLEAN Modules_IsFilePresent (CHAR *s, ADDRESS s__len) +{ + Platform_FileIdentity identity; + __DUP(s, s__len, CHAR); + __DEL(s); + return Platform_IdentifyByName(s, s__len, &identity, Platform_FileIdentity__typ) == 0; +} + +static void Modules_ExtractPart (CHAR *s, ADDRESS s__len, INT16 *i, CHAR *p, ADDRESS p__len, CHAR *d, ADDRESS d__len) +{ + INT16 j; + __DUP(s, s__len, CHAR); + __DUP(p, p__len, CHAR); + j = 0; + while ((s[__X(*i, s__len)] != 0x00 && !Modules_IsOneOf(s[__X(*i, s__len)], p, p__len))) { + d[__X(j, d__len)] = s[__X(*i, s__len)]; + *i += 1; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (Modules_IsOneOf(s[__X(*i, s__len)], p, p__len)) { + *i += 1; + } + __DEL(s); + __DEL(p); +} + +static void Modules_Trim (CHAR *s, ADDRESS s__len, CHAR *d, ADDRESS d__len) +{ + INT16 i, j; + CHAR part[1024]; + __DUP(s, s__len, CHAR); + i = 0; + j = 0; + while ((i < 2 && Modules_IsOneOf(s[__X(i, s__len)], (CHAR*)"/\\", 3))) { + i += 1; + d[__X(j, d__len)] = '/'; + j += 1; + } + d[__X(j, d__len)] = 0x00; + while (s[__X(i, s__len)] != 0x00) { + Modules_ExtractPart(s, s__len, &i, (CHAR*)"/\\", 3, (void*)part, 1024); + if ((part[0] != 0x00 && __STRCMP(part, ".") != 0)) { + Modules_AppendPart('/', part, 1024, (void*)d, d__len); + } + } + __DEL(s); +} + +typedef + CHAR pathstring__12[4096]; + +static void Modules_FindBinaryDir (CHAR *d, ADDRESS d__len) +{ + pathstring__12 executable, dir, testpath, pathlist; + INT16 i, j, k; + BOOLEAN present; + if (Modules_ArgCount < 1) { + d[0] = 0x00; + return; + } + Modules_GetArg(0, (void*)testpath, 4096); + Modules_Trim(testpath, 4096, (void*)executable, 4096); + Modules_Canonify(executable, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + if ((!present && !Modules_IsAbsolute(testpath, 4096))) { + Platform_GetEnv((CHAR*)"PATH", 5, (void*)pathlist, 4096); + i = 0; + while ((!present && pathlist[__X(i, 4096)] != 0x00)) { + Modules_ExtractPart(pathlist, 4096, &i, (CHAR*)":;", 3, (void*)dir, 4096); + Modules_Trim(dir, 4096, (void*)testpath, 4096); + Modules_AppendPart('/', executable, 4096, (void*)testpath, 4096); + Modules_Canonify(testpath, 4096, (void*)d, d__len); + present = Modules_IsFilePresent(d, d__len); + } + } + if (present) { + k = Modules_CharCount(d, d__len); + while ((k > 0 && !Modules_IsOneOf(d[__X(k - 1, d__len)], (CHAR*)"/\\", 3))) { + k -= 1; + } + if (k == 0) { + d[__X(k, d__len)] = 0x00; + } else { + d[__X(k - 1, d__len)] = 0x00; + } + } else { + d[0] = 0x00; + } } Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) @@ -177,8 +345,8 @@ Modules_Module Modules_ThisMod (CHAR *name, ADDRESS name__len) Modules_res = 1; __COPY(name, Modules_importing, 20); __MOVE(" module \"", Modules_resMsg, 10); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); } __DEL(name); return m; @@ -201,10 +369,10 @@ Modules_Command Modules_ThisCommand (Modules_Module mod, CHAR *name, ADDRESS nam Modules_res = 2; __MOVE(" command \"", Modules_resMsg, 11); __COPY(name, Modules_importing, 20); - Modules_Append((void*)Modules_resMsg, 256, mod->name, 20); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)".", 2); - Modules_Append((void*)Modules_resMsg, 256, name, name__len); - Modules_Append((void*)Modules_resMsg, 256, (CHAR*)"\" not found", 12); + Modules_Append(mod->name, 20, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)".", 2, (void*)Modules_resMsg, 256); + Modules_Append(name, name__len, (void*)Modules_resMsg, 256); + Modules_Append((CHAR*)"\" not found", 12, (void*)Modules_resMsg, 256); __DEL(name); return NIL; } @@ -371,5 +539,6 @@ export void *Modules__init(void) __INITYP(Modules_ModuleDesc, Modules_ModuleDesc, 0); __INITYP(Modules_CmdDesc, Modules_CmdDesc, 0); /* BEGIN */ + Modules_FindBinaryDir((void*)Modules_BinaryDir, 1024); __ENDMOD; } diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 327f139b..6cad66e4 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Modules__h #define Modules__h @@ -42,6 +42,7 @@ import Modules_ModuleName Modules_imported, Modules_importing; import INT64 Modules_MainStackFrame; import INT16 Modules_ArgCount; import INT64 Modules_ArgVector; +import CHAR Modules_BinaryDir[1024]; import ADDRESS *Modules_ModuleDesc__typ; import ADDRESS *Modules_CmdDesc__typ; diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 57fde3a0..0b1509bc 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index e841f317..d6b81543 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index d3e4eaf5..620dd88e 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index 06fa9996..20ac9ae8 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 0533cbfc..39f36504 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -267,6 +267,10 @@ static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) BOOLEAN OPM_OpenPar (void) { CHAR s[256]; + Out_String((CHAR*)"Testing. Binary directory is: '", 32); + Out_String(Modules_BinaryDir, 1024); + Out_String((CHAR*)"'.", 3); + Out_Ln(); if (Modules_ArgCount == 1) { OPM_LogWLn(); OPM_LogWStr((CHAR*)"Oberon-2 compiler v", 20); diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 6ea722dc..ec6947a6 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index a7630159..34d1f0e4 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index b6d59055..da746402 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 311cbe15..2c97a4d0 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index 28618fe1..0b780918 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. tspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 0dd110b2..63667f88 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index ab443dff..0a26e546 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 6a1d23a7..5520370e 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index d26a1b3e..1afcee74 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index b5ccb18b..d1ff2558 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index a4eb7cb6..62f9d414 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index ca463179..be0400e8 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index 03b75dc0..6926740d 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index 33c286b7..8668f3be 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index 6fc2dd5c..a864fcae 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 42190367..697accbd 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index 1806a7cc..30317939 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 627eb31d..9a2c7cb4 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index ac4a8157..def1eeef 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/VT100.c b/bootstrap/windows-88/VT100.c index c6c421f9..ea43623a 100644 --- a/bootstrap/windows-88/VT100.c +++ b/bootstrap/windows-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/VT100.h b/bootstrap/windows-88/VT100.h index b1771722..70c0dfa9 100644 --- a/bootstrap/windows-88/VT100.h +++ b/bootstrap/windows-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index e89705a7..f08daa40 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -65,7 +65,7 @@ static void extTools_execute (CHAR *title, ADDRESS title__len, CHAR *cmd, ADDRES static void extTools_InitialiseCompilerCommand (CHAR *s, ADDRESS s__len) { - __COPY("x86_64-w64-mingw32-gcc -g", s, s__len); + __COPY("gcc -g", s, s__len); Strings_Append((CHAR*)" -I \"", 6, (void*)s, s__len); Strings_Append(OPM_ResourceDir, 1024, (void*)s, s__len); Strings_Append((CHAR*)"/include\" ", 11, (void*)s, s__len); @@ -95,7 +95,7 @@ void extTools_LinkMain (CHAR *moduleName, ADDRESS moduleName__len, BOOLEAN stati Strings_Append((CHAR*)".c ", 4, (void*)cmd, 1023); Strings_Append(additionalopts, additionalopts__len, (void*)cmd, 1023); if (statically) { - Strings_Append((CHAR*)"", 1, (void*)cmd, 1023); + Strings_Append((CHAR*)"-static", 8, (void*)cmd, 1023); } Strings_Append((CHAR*)" -o ", 5, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index e92a4c5f..e736dc46 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.00 [2016/12/02]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ +/* voc 2.00 [2016/12/03]. Bootstrapping compiler for address size 8, alignment 8. xtspaSF */ #ifndef extTools__h #define extTools__h