From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1499) id 2AFD43858410; Tue, 24 Jan 2023 22:42:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AFD43858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674600124; bh=gPH3Jmln+Iarpn2ET3PGPRX0wqjvSVC4F0l+gDUygjo=; h=From:To:Subject:Date:From; b=dxRIJWsyOJ4gB8Wl88CAPwYJM6PAayDP3tUYYDSnRkDGnUmAH/LCgi7Of6ojeawGa Wq3xeqIzZkGAFkUgyOLX6204LqCrcpRCc+pt4i5E8JItfdL3ciNleF7PyBXmQQc0WU epzXB9YkHZCYRTf9Iz3vmdGn/jaL9+k29fqKhAPk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Gaius Mulley To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5336] Introduce new module to create search paths of dynamic strings. X-Act-Checkin: gcc X-Git-Author: Gaius Mulley X-Git-Refname: refs/heads/master X-Git-Oldrev: 327d45c57ebd2655a7599df0f01b8b5e2f82eda7 X-Git-Newrev: f235d695729cc745cf15a00fb8b2cfaded80fd1e Message-Id: <20230124224204.2AFD43858410@sourceware.org> Date: Tue, 24 Jan 2023 22:42:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f235d695729cc745cf15a00fb8b2cfaded80fd1e commit r13-5336-gf235d695729cc745cf15a00fb8b2cfaded80fd1e Author: Gaius Mulley Date: Tue Jan 24 22:41:45 2023 +0000 Introduce new module to create search paths of dynamic strings. Introduce a simple DynamicStringPath module to allow the front end to create and modify a search path from dynamic strings. gcc/m2/ChangeLog: * Make-lang.in (GM2-COMP-BOOT-DEFS): Add DynamicStringPath.def. (GM2-COMP-BOOT-MODS): Add DynamicStringPath.mod. (GM2-COMP-DEFS): Add DynamicStringPath.def. (GM2-COMP-MODS): Add DynamicStringPath.mod. ($(objdir)/m2/gm2-libs-min/SYSTEM.def): Split path into multiple -I components. ($(objdir)/m2/gm2-libs/SYSTEM.def): Ditto. ($(objdir)/m2/gm2-libs-coroutines/SYSTEM.def): Ditto. * gm2-compiler/M2Options.mod: Import DynamicStringPath. (SetSearchPath): Reimplement using DynamicStringPath procedures. * gm2-compiler/M2Search.def (InitSearchPath): Remove. (PrependSearchPath): Remove. * gm2-compiler/M2Search.mod (SFIO): Remove import. (DynamicStringPath): Add import. (Directory): Remove. (UserPath): Remove. (InitialPath): Remove. (InitSearchPath): Remove. (PrependSearchPath): Remove. (FindSourceFile): Re-implement. (FindSourceDefFile): Re-implement. (FindSourceModFile): Re-implement. * gm2-gcc/init.cc (_M2_DynamicStringPath_init): New prototype. (init_FrontEndInit): Call _M2_DynamicStringPath_init. * tools-src/makeSystem: Allow multiple -I paths. * gm2-compiler/DynamicStringPath.def: New file. * gm2-compiler/DynamicStringPath.mod: New file. * gm2-gcc/m2options.h (M2Options_SetMakeIncludePath): Add prototype. Co-Authored by: Iain Sandoe libgm2/ChangeLog: * libm2cor/Makefile.am (SYSTEM.def): Split path into multiple -I components. * libm2cor/Makefile.in: Rebuild. * libm2min/Makefile.am (SYSTEM.def): Split path into multiple -I components. * libm2min/Makefile.in: Rebuild. * libm2iso/Makefile.am (SYSTEM.def): Split path into multiple -I components. * libm2iso/Makefile.in: Rebuild. Co-Authored by: Iain Sandoe Signed-off-by: Gaius Mulley Diff: --- gcc/m2/Make-lang.in | 10 +- gcc/m2/gm2-compiler/DynamicStringPath.def | 113 +++++++++++++ gcc/m2/gm2-compiler/DynamicStringPath.mod | 265 ++++++++++++++++++++++++++++++ gcc/m2/gm2-compiler/M2Options.mod | 12 +- gcc/m2/gm2-compiler/M2Search.def | 25 --- gcc/m2/gm2-compiler/M2Search.mod | 131 +++------------ gcc/m2/gm2-gcc/init.cc | 2 + gcc/m2/gm2-gcc/m2options.h | 1 - gcc/m2/tools-src/makeSystem | 17 +- libgm2/libm2cor/Makefile.am | 2 +- libgm2/libm2cor/Makefile.in | 2 +- libgm2/libm2iso/Makefile.am | 2 +- libgm2/libm2iso/Makefile.in | 2 +- libgm2/libm2min/Makefile.am | 2 +- libgm2/libm2min/Makefile.in | 2 +- 15 files changed, 435 insertions(+), 153 deletions(-) diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index 00cca7de617..0d3ff237385 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -690,6 +690,7 @@ GM2-COMP-BOOT-DEFS = \ M2DebugStack.def \ M2Defaults.def \ M2DriverOptions.def \ + DynamicStringPath.def \ M2Emit.def \ M2Error.def \ M2EvalSym.def \ @@ -761,6 +762,7 @@ GM2-COMP-BOOT-MODS = \ M2DebugStack.mod \ M2Defaults.mod \ M2DriverOptions.mod \ + DynamicStringPath.mod \ M2Emit.mod \ M2Error.mod \ M2FileName.mod \ @@ -965,6 +967,7 @@ GM2-COMP-DEFS = \ M2DebugStack.def \ M2Defaults.def \ M2DriverOptions.def \ + DynamicStringPath.def \ M2Emit.def \ M2Error.def \ M2FileName.def \ @@ -1032,6 +1035,7 @@ GM2-COMP-MODS = \ M2DebugStack.mod \ M2Defaults.mod \ M2DriverOptions.mod \ + DynamicStringPath.mod \ M2Emit.mod \ M2Error.mod \ M2FileName.mod \ @@ -1522,7 +1526,7 @@ $(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP) $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \ $(srcdir)/m2/gm2-libs-min/SYSTEM.def \ $(srcdir)/m2/gm2-libs-min/SYSTEM.mod \ - -I$(srcdir)/m2/gm2-libs-min:$(srcdir)/m2/gm2-libs \ + -I$(srcdir)/m2/gm2-libs-min -I$(srcdir)/m2/gm2-libs \ "$(GM2_FOR_TARGET)" $@ $(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP) @@ -1540,7 +1544,7 @@ $(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP) $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fiso \ $(srcdir)/m2/gm2-libs-iso/SYSTEM.def \ $(srcdir)/m2/gm2-libs-iso/SYSTEM.mod \ - -I$(srcdir)/m2/gm2-libs-iso:$(srcdir)/m2/gm2-libs \ + -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs \ "$(GM2_FOR_TARGET)" $@ $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP) @@ -1548,7 +1552,7 @@ $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP) $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \ $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.def \ $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.mod \ - -I$(srcdir)/m2/gm2-libs-coroutines:$(srcdir)/m2/gm2-libs-iso:$(srcdir)/m2/gm2-libs \ + -I$(srcdir)/m2/gm2-libs-coroutines -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs \ "$(GM2_FOR_TARGET)" $@ build-compiler: $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \ diff --git a/gcc/m2/gm2-compiler/DynamicStringPath.def b/gcc/m2/gm2-compiler/DynamicStringPath.def new file mode 100644 index 00000000000..e9fdff7ee14 --- /dev/null +++ b/gcc/m2/gm2-compiler/DynamicStringPath.def @@ -0,0 +1,113 @@ +(* DynamicStringPath.def implements a path for DynamicStrings. + +Copyright (C) 2001-2023 Free Software Foundation, Inc. +Contributed by Gaius Mulley . + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. *) + +DEFINITION MODULE DynamicStringPath ; (*!m2iso+gm2*) + +FROM DynamicStrings IMPORT String ; + +TYPE + PathList ; + + +(* + GetUserPath - returns the current UserPath. +*) + +PROCEDURE GetUserPath () : PathList ; + + +(* + GetSystemPath - returns the current SystemPath. +*) + +PROCEDURE GetSystemPath () : PathList ; + + +(* + SetUserPath - assigns UserPath to pl. +*) + +PROCEDURE SetUserPath (pl: PathList) ; + + +(* + SetSystemPath - assigns SystemPath to pl. +*) + +PROCEDURE SetSystemPath (pl: PathList) ; + + +(* + InitPathList - creates a new empty path list. +*) + +PROCEDURE InitPathList (str: String) : PathList ; + + +(* + KillPathList - places list pl onto the freelist. + Postcondition: pl will be NIL. +*) + +PROCEDURE KillPathList (VAR pl: PathList) ; + + +(* + Cons - appends str to the end of a path list. + If pl is NIL a new list is created and returned + containing str. +*) + +PROCEDURE Cons (pl: PathList; str: String) : PathList ; + + +(* + ConsList - concatenates path list left and right together. + It always returns NIL which should be assigned + to the callers right parameter after ConsList + has been completed signifying that right should + no longer be accessed. +*) + +PROCEDURE ConsList (left, right: PathList) : PathList ; + + +(* + Stash - returns pl before setting pl to NIL. +*) + +PROCEDURE Stash (VAR pl: PathList) : PathList ; + + +(* + FindFileName - returns NIL if a file cannot be found otherwise + it returns the path including the filename. +*) + +PROCEDURE FindFileName (filename: String; pl: PathList) : String ; + + +END DynamicStringPath. diff --git a/gcc/m2/gm2-compiler/DynamicStringPath.mod b/gcc/m2/gm2-compiler/DynamicStringPath.mod new file mode 100644 index 00000000000..601456e0787 --- /dev/null +++ b/gcc/m2/gm2-compiler/DynamicStringPath.mod @@ -0,0 +1,265 @@ +(* DynamicStringPath.def implements a path for DynamicStrings. + +Copyright (C) 2001-2023 Free Software Foundation, Inc. +Contributed by Gaius Mulley . + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. *) + +IMPLEMENTATION MODULE DynamicStringPath ; (*!m2iso+gm2*) + +FROM Storage IMPORT ALLOCATE, DEALLOCATE ; +FROM DynamicStrings IMPORT InitString, ConCat, ConCatChar, char, Dup, + KillString, Length ; +FROM SFIO IMPORT Exists ; +FROM FIO IMPORT StdErr ; +FROM M2Printf IMPORT fprintf0, fprintf1 ; + +CONST + Directory = '/' ; + Debugging = FALSE ; + +TYPE + PathList = POINTER TO RECORD + tail, + next : PathList ; + entry: String ; + END ; + + +VAR + FreeList, + DefaultUserPath, + DefaultSystemPath: PathList ; + + +(* + GetUserPath - returns the current UserPath. +*) + +PROCEDURE GetUserPath () : PathList ; +BEGIN + RETURN DefaultUserPath +END GetUserPath ; + + +(* + GetSystemPath - returns the current SystemPath. +*) + +PROCEDURE GetSystemPath () : PathList ; +BEGIN + RETURN DefaultSystemPath +END GetSystemPath ; + + +(* + SetUserPath - assigns UserPath to pl. +*) + +PROCEDURE SetUserPath (pl: PathList) ; +BEGIN + DefaultUserPath := pl ; + DumpPath ('DefaultUserPath', DefaultUserPath) +END SetUserPath ; + + +(* + SetSystemPath - assigns SystemPath to pl. +*) + +PROCEDURE SetSystemPath (pl: PathList) ; +BEGIN + DefaultSystemPath := pl ; + DumpPath ('DefaultSystemPath', DefaultSystemPath) +END SetSystemPath ; + + +(* + KillPathList - places list pl onto the freelist. + Postcondition: pl will be NIL. +*) + +PROCEDURE KillPathList (VAR pl: PathList) ; +BEGIN + IF pl # NIL + THEN + pl^.tail^.next := FreeList ; + FreeList := pl ; + pl := NIL + END +END KillPathList ; + + +(* + InitPathList - creates a new empty path list. + It takes a copy of the string. +*) + +PROCEDURE InitPathList (str: String) : PathList ; +VAR + pl: PathList ; +BEGIN + NEW (pl) ; + WITH pl^ DO + tail := pl ; + next := NIL ; + entry := Dup (str) + END ; + RETURN pl +END InitPathList ; + + +(* + Cons - appends str to the end of a path list. + If pl is NIL a new list is created and returned + containing str. +*) + +PROCEDURE Cons (pl: PathList; str: String) : PathList ; +BEGIN + IF pl = NIL + THEN + pl := InitPathList (str) + ELSE + pl := ConsList (pl, InitPathList (str)) + END ; + RETURN pl +END Cons ; + + +(* + ConsList - concatenates path list left and right together. + It always returns NIL which should be assigned + to the callers right parameter after ConsList + has been completed signifying that right should + no longer be accessed. +*) + +PROCEDURE ConsList (left, right: PathList) : PathList ; +BEGIN + IF right # NIL + THEN + left^.tail^.next := right ; + left^.tail := right^.tail + END ; + RETURN left +END ConsList ; + + +(* + Stash - returns pl before setting pl to NIL. +*) + +PROCEDURE Stash (VAR pl: PathList) : PathList ; +VAR + old: PathList ; +BEGIN + old := pl ; + pl := NIL ; + RETURN old +END Stash ; + + +(* + AddDir - if str is not empty and does not end with / then add + a directory. + Postcondition: str is returned (with a '/' at the end) + or is empty. +*) + +PROCEDURE AddDir (str: String) : String ; +BEGIN + IF Length (str) > 0 + THEN + IF char (str, -1) # Directory + THEN + str := ConCatChar (str, Directory) + END + END ; + RETURN str +END AddDir ; + + +(* + FindFileName - returns NIL if a file cannot be found otherwise + it returns the path including the filename. +*) + +PROCEDURE FindFileName (filename: String; pl: PathList) : String ; +VAR + s: String ; +BEGIN + WHILE pl # NIL DO + s := ConCat (AddDir (Dup (pl^.entry)), Dup (filename)) ; + IF Debugging + THEN + fprintf1 (StdErr, "testing for %s: ", s) + END ; + IF Exists (s) + THEN + IF Debugging + THEN + fprintf0 (StdErr, "yes\n") + END ; + RETURN s + END ; + IF Debugging + THEN + fprintf0 (StdErr, "no\n") + END ; + s := KillString (s) ; + pl := pl^.next + END ; + IF Debugging + THEN + fprintf1 (StdErr, "FindFileName did not find: %s in path\n", filename) + END ; + RETURN NIL +END FindFileName ; + + +(* + DumpPath - debugging dump of the pathlist. +*) + +PROCEDURE DumpPath (name: ARRAY OF CHAR; pl: PathList) ; +BEGIN + IF Debugging + THEN + fprintf0 (StdErr, name) ; + fprintf0 (StdErr, ":") ; + WHILE pl # NIL DO + fprintf0 (StdErr, " {") ; + fprintf1 (StdErr, "%s", pl^.entry) ; + fprintf0 (StdErr, "}") ; + pl := pl^.next + END ; + fprintf0 (StdErr, "\n") + END +END DumpPath ; + + +BEGIN + DefaultSystemPath := NIL ; + DefaultUserPath := NIL ; + FreeList := NIL +END DynamicStringPath. diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod index f046e294a1a..14e978a46ba 100644 --- a/gcc/m2/gm2-compiler/M2Options.mod +++ b/gcc/m2/gm2-compiler/M2Options.mod @@ -24,8 +24,10 @@ IMPLEMENTATION MODULE M2Options ; IMPORT CmdArgs ; FROM SArgs IMPORT GetArg, Narg ; -FROM M2Search IMPORT PrependSearchPath, SetDefExtension, SetModExtension ; -FROM M2Printf IMPORT printf0, printf1 ; +FROM M2Search IMPORT SetDefExtension, SetModExtension ; +FROM DynamicStringPath IMPORT Cons, GetUserPath, SetUserPath, Cons ; +FROM M2Printf IMPORT printf0, printf1, fprintf1 ; +FROM FIO IMPORT StdErr ; FROM libc IMPORT exit ; FROM Debug IMPORT Halt ; FROM m2linemap IMPORT location_t ; @@ -789,10 +791,10 @@ BEGIN s := InitStringCharStar(arg) ; IF Debugging THEN - printf1("setting search path to: %s\n", s) + fprintf1 (StdErr, "M2Search.SetSearchPath setting search path to: %s\n", s) END ; - PrependSearchPath(s) ; - s := KillString(s) + SetUserPath (Cons (GetUserPath (), s)) ; + s := KillString (s) END SetSearchPath ; diff --git a/gcc/m2/gm2-compiler/M2Search.def b/gcc/m2/gm2-compiler/M2Search.def index 9bed7eb4746..3d172378cf5 100644 --- a/gcc/m2/gm2-compiler/M2Search.def +++ b/gcc/m2/gm2-compiler/M2Search.def @@ -31,31 +31,6 @@ DEFINITION MODULE M2Search ; *) FROM DynamicStrings IMPORT String ; -EXPORT QUALIFIED InitSearchPath, PrependSearchPath, FindSourceFile, - FindSourceDefFile, FindSourceModFile, - SetDefExtension, SetModExtension ; - - -(* - InitSearchPath - assigns the search path to Path. - The string Path may take the form: - - Path ::= IndividualPath { ":" IndividualPath } - IndividualPath ::= "." | DirectoryPath - DirectoryPath ::= [ "/" ] Name { "/" Name } - Name ::= Letter { (Letter | Number) } - Letter ::= A..Z | a..z - Number ::= 0..9 -*) - -PROCEDURE InitSearchPath (Path: String) ; - - -(* - PrependSearchPath - prepends a new path to the initial search path. -*) - -PROCEDURE PrependSearchPath (path: String) ; (* diff --git a/gcc/m2/gm2-compiler/M2Search.mod b/gcc/m2/gm2-compiler/M2Search.mod index e2dd82d3627..cc61ebfb353 100644 --- a/gcc/m2/gm2-compiler/M2Search.mod +++ b/gcc/m2/gm2-compiler/M2Search.mod @@ -22,9 +22,9 @@ along with GNU Modula-2; see the file COPYING3. If not see IMPLEMENTATION MODULE M2Search ; -FROM SFIO IMPORT Exists ; FROM M2FileName IMPORT CalculateFileName ; FROM Assertion IMPORT Assert ; +FROM DynamicStringPath IMPORT GetUserPath, GetSystemPath, FindFileName ; FROM DynamicStrings IMPORT InitString, InitStringChar, KillString, ConCat, ConCatChar, Index, Slice, @@ -35,13 +35,10 @@ FROM DynamicStrings IMPORT InitString, InitStringChar, CONST - Directory = '/' ; GarbageDebugging = FALSE ; VAR - Def, Mod, - UserPath, - InitialPath: String ; + Def, Mod: String ; (* Internal garbage collection debugging routines. *) @@ -109,24 +106,6 @@ END DSdbExit ; *) -(* - PrependSearchPath - prepends a new path to the initial search path. -*) - -PROCEDURE PrependSearchPath (path: String) ; -BEGIN - DSdbEnter ; - IF EqualArray(UserPath, '') - THEN - UserPath := KillString(UserPath) ; - UserPath := Dup(path) - ELSE - UserPath := ConCat(ConCatChar(UserPath, ':'), path) - END ; - DSdbExit (UserPath) -END PrependSearchPath ; - - (* FindSourceFile - attempts to locate the source file FileName. If a file is found then TRUE is returned otherwise @@ -143,55 +122,13 @@ END PrependSearchPath ; PROCEDURE FindSourceFile (FileName: String; VAR FullPath: String) : BOOLEAN ; -VAR - CompleteSearchPath: String ; - start, end : INTEGER ; - newpath : String ; BEGIN - IF EqualArray(UserPath, '') + FullPath := FindFileName (FileName, GetUserPath ()) ; + IF FullPath = NIL THEN - IF EqualArray(InitialPath, '') - THEN - CompleteSearchPath := InitString('.') - ELSE - CompleteSearchPath := Dup(InitialPath) - END - ELSE - CompleteSearchPath := ConCat(ConCatChar(Dup(UserPath), ':'), InitialPath) + FullPath := FindFileName (FileName, GetSystemPath ()) END ; - start := 0 ; - end := Index(CompleteSearchPath, ':', CARDINAL(start)) ; - REPEAT - IF end=-1 - THEN - end := 0 - END ; - newpath := Slice(CompleteSearchPath, start, end) ; - IF EqualArray(newpath, '.') - THEN - newpath := KillString(newpath) ; - newpath := Dup(FileName) - ELSE - newpath := ConCat(ConCatChar(newpath, Directory), FileName) - END ; - IF Exists(newpath) - THEN - FullPath := newpath ; - CompleteSearchPath := KillString(CompleteSearchPath) ; - RETURN( TRUE ) - END ; - newpath := KillString(newpath) ; - IF end#0 - THEN - start := end+1 ; - end := Index(CompleteSearchPath, ':', CARDINAL(start)) - END - UNTIL end=0 ; - - FullPath := NIL ; - newpath := KillString(newpath) ; - CompleteSearchPath := KillString(CompleteSearchPath) ; - RETURN( FALSE ) + RETURN FullPath # NIL END FindSourceFile ; @@ -206,18 +143,18 @@ PROCEDURE FindSourceDefFile (Stem: String; VAR FullPath: String) : BOOLEAN ; VAR f: String ; BEGIN - IF Def#NIL + IF Def # NIL THEN - f := CalculateFileName(Stem, Def) ; - IF FindSourceFile(f, FullPath) + f := CalculateFileName (Stem, Def) ; + IF FindSourceFile (f, FullPath) THEN - RETURN( TRUE ) + RETURN TRUE END ; - f := KillString(f) + f := KillString (f) END ; - (* and try the GNU Modula-2 default extension *) - f := CalculateFileName(Stem, Mark(InitString('def'))) ; - RETURN( FindSourceFile(f, FullPath) ) + (* Try the GNU Modula-2 default extension. *) + f := CalculateFileName (Stem, Mark(InitString ('def'))) ; + RETURN FindSourceFile (f, FullPath) END FindSourceDefFile ; @@ -234,16 +171,16 @@ VAR BEGIN IF Mod#NIL THEN - f := CalculateFileName(Stem, Mod) ; - IF FindSourceFile(f, FullPath) + f := CalculateFileName (Stem, Mod) ; + IF FindSourceFile (f, FullPath) THEN - RETURN( TRUE ) + RETURN TRUE END ; - f := KillString(f) + f := KillString (f) END ; - (* and try the GNU Modula-2 default extension *) - f := CalculateFileName(Stem, Mark(InitString('mod'))) ; - RETURN( FindSourceFile(f, FullPath) ) + (* Try the GNU Modula-2 default extension. *) + f := CalculateFileName (Stem, Mark(InitString ('mod'))) ; + RETURN FindSourceFile (f, FullPath) END FindSourceModFile ; @@ -274,35 +211,11 @@ END SetModExtension ; (* - InitSearchPath - assigns the search path to Path. - The string Path may take the form: - - Path ::= IndividualPath { ":" IndividualPath } - IndividualPath ::= "." | DirectoryPath - DirectoryPath ::= [ "/" ] Name { "/" Name } - Name ::= Letter { (Letter | Number) } - Letter ::= A..Z | a..z - Number ::= 0..9 -*) - -PROCEDURE InitSearchPath (Path: String) ; -BEGIN - IF InitialPath#NIL - THEN - InitialPath := KillString(InitialPath) - END ; - InitialPath := Path -END InitSearchPath ; - - -(* - Init - initializes the search path. + Init - initializes the def and mod default string names to NIL. *) PROCEDURE Init ; BEGIN - UserPath := InitString('') ; - InitialPath := InitStringChar('.') ; Def := NIL ; Mod := NIL END Init ; diff --git a/gcc/m2/gm2-gcc/init.cc b/gcc/m2/gm2-gcc/init.cc index 42d81517515..a9dfcc70069 100644 --- a/gcc/m2/gm2-gcc/init.cc +++ b/gcc/m2/gm2-gcc/init.cc @@ -55,6 +55,7 @@ EXTERN void _M2_CmdArgs_init (int argc, char *argv[], char *envp[]); EXTERN void _M2_M2Preprocess_init (int argc, char *argv[], char *envp[]); EXTERN void _M2_M2Error_init (int argc, char *argv[], char *envp[]); EXTERN void _M2_M2Search_init (int argc, char *argv[], char *envp[]); +EXTERN void _M2_DynamicStringPath_init (int argc, char *argv[], char *envp[]); EXTERN void _M2_Indexing_init (int argc, char *argv[], char *envp[]); EXTERN void _M2_NameKey_init (int argc, char *argv[], char *envp[]); EXTERN void _M2_NumberIO_init (int argc, char *argv[], char *envp[]); @@ -141,6 +142,7 @@ init_FrontEndInit (void) _M2_StrLib_init (0, NULL, NULL); _M2_dtoa_init (0, NULL, NULL); _M2_ldtoa_init (0, NULL, NULL); + _M2_DynamicStringPath_init (0, NULL, NULL); _M2_M2Search_init (0, NULL, NULL); _M2_M2Options_init (0, NULL, NULL); } diff --git a/gcc/m2/gm2-gcc/m2options.h b/gcc/m2/gm2-gcc/m2options.h index 80c7968b558..9cccb370a1a 100644 --- a/gcc/m2/gm2-gcc/m2options.h +++ b/gcc/m2/gm2-gcc/m2options.h @@ -38,7 +38,6 @@ along with GNU Modula-2; see the file COPYING3. If not see #include "input.h" -EXTERN void M2Options_SetMakeIncludePath (const char *arg); EXTERN void M2Options_SetSearchPath (const char *arg); EXTERN void M2Options_setdefextension (const char *arg); EXTERN void M2Options_setmodextension (const char *arg); diff --git a/gcc/m2/tools-src/makeSystem b/gcc/m2/tools-src/makeSystem index 49b58a2923e..b1156b559b0 100644 --- a/gcc/m2/tools-src/makeSystem +++ b/gcc/m2/tools-src/makeSystem @@ -23,7 +23,7 @@ Usage () { - echo "Usage: makesystem dialectflag SYSTEM.def SYSTEM.mod librarypath compiler" + echo "Usage: makesystem dialectflag SYSTEM.def SYSTEM.mod { librarypath } compiler" } if [ $# -lt 6 ] ; then @@ -34,9 +34,18 @@ fi DIALECT=$1 SYSTEMDEF=$2 SYSTEMMOD=$3 -LIBRARY=$4 -COMPILER=$5 -OUTPUTFILE=$6 +shift 3 +LIBRARY="" +while [ $# -gt 2 ] ; do + if [ "$LIBRARY" = "" ] ; then + LIBRARY=$1 + else + LIBRARY="${LIBRARY} $1" + fi + shift +done +COMPILER=$1 +OUTPUTFILE=$2 if [ "$COMPILER" = "" ] ; then echo "parameter 5 of makeSystem is incorrect, GM2_FOR_TARGET was unset" diff --git a/libgm2/libm2cor/Makefile.am b/libgm2/libm2cor/Makefile.am index 2cc30847849..e7c72732ade 100644 --- a/libgm2/libm2cor/Makefile.am +++ b/libgm2/libm2cor/Makefile.am @@ -129,7 +129,7 @@ SYSTEM.def: Makefile bash $(GM2_SRC)/tools-src/makeSystem -fpim \ $(GM2_SRC)/gm2-libs-coroutines/SYSTEM.def \ $(GM2_SRC)/gm2-libs-coroutines/SYSTEM.mod \ - -I$(GM2_SRC)/gm2-libs-coroutines:$(GM2_SRC)/gm2-libs:$(GM2_SRC)/gm2-libs-iso \ + -I$(GM2_SRC)/gm2-libs-coroutines -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso \ "$(GM2_FOR_TARGET)" $@ .mod.lo: diff --git a/libgm2/libm2cor/Makefile.in b/libgm2/libm2cor/Makefile.in index 8806d7bccf6..677aebf0a60 100644 --- a/libgm2/libm2cor/Makefile.in +++ b/libgm2/libm2cor/Makefile.in @@ -795,7 +795,7 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES @BUILD_CORLIB_TRUE@ bash $(GM2_SRC)/tools-src/makeSystem -fpim \ @BUILD_CORLIB_TRUE@ $(GM2_SRC)/gm2-libs-coroutines/SYSTEM.def \ @BUILD_CORLIB_TRUE@ $(GM2_SRC)/gm2-libs-coroutines/SYSTEM.mod \ -@BUILD_CORLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-coroutines:$(GM2_SRC)/gm2-libs:$(GM2_SRC)/gm2-libs-iso \ +@BUILD_CORLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-coroutines -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso \ @BUILD_CORLIB_TRUE@ "$(GM2_FOR_TARGET)" $@ @BUILD_CORLIB_TRUE@.mod.lo: diff --git a/libgm2/libm2iso/Makefile.am b/libgm2/libm2iso/Makefile.am index a28cd5ac8aa..af3728bd1e1 100644 --- a/libgm2/libm2iso/Makefile.am +++ b/libgm2/libm2iso/Makefile.am @@ -204,7 +204,7 @@ SYSTEM.def: Makefile bash $(GM2_SRC)/tools-src/makeSystem -fiso \ $(GM2_SRC)/gm2-libs-iso/SYSTEM.def \ $(GM2_SRC)/gm2-libs-iso/SYSTEM.mod \ - -I$(GM2_SRC)/gm2-libs-iso:$(GM2_SRC)/gm2-libs \ + -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs \ "$(GM2_FOR_TARGET)" $@ ## add these to the .mod.o rule when optimization is fixed $(CFLAGS_FOR_TARGET) $(LIBCFLAGS) diff --git a/libgm2/libm2iso/Makefile.in b/libgm2/libm2iso/Makefile.in index 0ca852a6124..b327cbcfab5 100644 --- a/libgm2/libm2iso/Makefile.in +++ b/libgm2/libm2iso/Makefile.in @@ -905,7 +905,7 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES @BUILD_ISOLIB_TRUE@ bash $(GM2_SRC)/tools-src/makeSystem -fiso \ @BUILD_ISOLIB_TRUE@ $(GM2_SRC)/gm2-libs-iso/SYSTEM.def \ @BUILD_ISOLIB_TRUE@ $(GM2_SRC)/gm2-libs-iso/SYSTEM.mod \ -@BUILD_ISOLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-iso:$(GM2_SRC)/gm2-libs \ +@BUILD_ISOLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs \ @BUILD_ISOLIB_TRUE@ "$(GM2_FOR_TARGET)" $@ @BUILD_ISOLIB_TRUE@.mod.lo: diff --git a/libgm2/libm2min/Makefile.am b/libgm2/libm2min/Makefile.am index bbbf3d4f943..f63f2436747 100644 --- a/libgm2/libm2min/Makefile.am +++ b/libgm2/libm2min/Makefile.am @@ -128,7 +128,7 @@ SYSTEM.def: Makefile bash $(GM2_SRC)/tools-src/makeSystem -fpim \ $(GM2_SRC)/gm2-libs-min/SYSTEM.def \ $(GM2_SRC)/gm2-libs-min/SYSTEM.mod \ - -I$(GM2_SRC)/gm2-libs-min:$(GM2_SRC)/gm2-libs \ + -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs \ "$(GM2_FOR_TARGET) -fno-exceptions" $@ install-data-local: force diff --git a/libgm2/libm2min/Makefile.in b/libgm2/libm2min/Makefile.in index ad818bc01d5..7e4496c9ff1 100644 --- a/libgm2/libm2min/Makefile.in +++ b/libgm2/libm2min/Makefile.in @@ -754,7 +754,7 @@ SYSTEM.def: Makefile bash $(GM2_SRC)/tools-src/makeSystem -fpim \ $(GM2_SRC)/gm2-libs-min/SYSTEM.def \ $(GM2_SRC)/gm2-libs-min/SYSTEM.mod \ - -I$(GM2_SRC)/gm2-libs-min:$(GM2_SRC)/gm2-libs \ + -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs \ "$(GM2_FOR_TARGET) -fno-exceptions" $@ install-data-local: force