From: DeaDDooMER Date: Tue, 4 Aug 2020 20:43:23 +0000 (+0300) Subject: cpmake: fix open source out of any subsystem X-Git-Url: https://deadsoftware.ru/gitweb?p=cpc.git;a=commitdiff_plain;h=HEAD cpmake: fix open source out of any subsystem --- diff --git a/src/generic/Dsw/Mod/MakeMain.cp b/src/generic/Dsw/Mod/MakeMain.cp index 25c80b5..ad0ead7 100644 --- a/src/generic/Dsw/Mod/MakeMain.cp +++ b/src/generic/Dsw/Mod/MakeMain.cp @@ -432,33 +432,37 @@ MODULE DswMakeMain; Kernel.FastCollect END CheckModule; - PROCEDURE MakePath (IN dir, name: Files.Name; IN type: Files.Type; OUT path: Files.Name); + PROCEDURE GetModText (IN base, sub, name: Files.Name; OUT path: Files.Name; OUT text: DswDocuments.Model); + VAR res: INTEGER; loc: Files.Locator; BEGIN ASSERT(name # "", 21); - IF dir = "" THEN path := modDir + "/" + name - ELSE path := dir + "/" + modDir + "/" + name + IF sub = "" THEN + loc := Files.dir.This(base); + IF base = "" THEN path := name + ELSE path := base + "/" + name + END + ELSE + loc := Files.dir.This(base).This(sub).This(modDir); + IF base = "" THEN path := sub + "/" + modDir + "/" + name + ELSE path := base + "/" + sub + "/" + modDir + "/" + name + END END; - Kernel.MakeFileName(path, type) - END MakePath; + DswDocuments.Open(loc, name, text, res) + END GetModText; - PROCEDURE Open (loc: Files.Locator; IN sub, name: Files.Name; OUT path: Files.Name; OUT text: DswDocuments.Model); - VAR res: INTEGER; + PROCEDURE Open (IN base, sub, name: Files.Name; OUT path: Files.Name; OUT text: DswDocuments.Model); + VAR cp, odc: Files.Name; BEGIN - ASSERT(loc # NIL, 20); - ASSERT(name # "", 21); - (* !!! use Kernel.MakeFileName instead ".ext" concat !!! *) - MakePath(sub, name, "cp", path); - DswDocuments.Open(loc, name + ".cp", text, res); + ASSERT(name # "", 20); + Files.dir.GetFileName(name, "cp", cp); (* !!! *) + GetModText(base, sub, cp, path, text); IF text = NIL THEN - MakePath(sub, name, "odc", path); - DswDocuments.Open(loc, name + ".odc", text, res); + Files.dir.GetFileName(name, "odc", odc); (* !!! *) + GetModText(base, sub, odc, path, text); IF (text = NIL) & (sub = "") THEN - MakePath(sysDir, name, "cp", path); - loc := Files.dir.This(sysDir).This(modDir); - DswDocuments.Open(loc, name + ".cp", text, res); + GetModText(base, sysDir, cp, path, text); IF text = NIL THEN - MakePath(sysDir, name, "odc", path); - DswDocuments.Open(loc, name + ".odc", text, res); + GetModText(base, sysDir, odc, path, text); IF text = NIL THEN path := "" END @@ -469,17 +473,18 @@ MODULE DswMakeMain; PROCEDURE GetSource (IN modName: ARRAY OF CHAR; list: DevCPM.Directory; OUT path: Files.Name; OUT s: String); VAR - sub, name: Files.Name; loc: Files.Locator; base: DevCPM.Directory; - text: DswDocuments.Model; r: DswDocuments.Reader; i, res: INTEGER; + sub, name: Files.Name; + base: DevCPM.Directory; + text: DswDocuments.Model; + r: DswDocuments.Reader; + i, res: INTEGER; BEGIN s := NIL; path := ""; base := list; Kernel.SplitName(modName, sub, name); - loc := Files.dir.This(sub).This(modDir); - Open(loc, sub, name, path, text); + Open("", sub, name, path, text); WHILE (text = NIL) & (base # NIL) DO ASSERT(base.legacy, 100); - loc := Files.dir.This(base.path).This(sub).This(modDir); - Open(loc, sub, name, path, text); + Open(base.path, sub, name, path, text); base := base.next END; IF text # NIL THEN @@ -542,7 +547,7 @@ MODULE DswMakeMain; CheckModule(m, src, ok); IF ~ok THEN INC(err) END ELSE - Error("unable to open module ^1", m.name$, "", 0) + Error("unable to open module ^0", m.name$, "", 0) END; INC(i) END;