Browse Source

Merge branch 'winfix'

Arthur Yefimov 2 năm trước cách đây
mục cha
commit
9d0a2d7a59
7 tập tin đã thay đổi với 94 bổ sung32 xóa
  1. 11 4
      src/Builder.Mod
  2. 16 2
      src/Config.Mod
  3. 31 0
      src/Debug.Mod
  4. 13 4
      src/Editor.Mod
  5. 2 13
      src/EditorText.Mod
  6. 10 2
      src/Files.Mod
  7. 11 7
      src/FreeOberon.Mod

+ 11 - 4
src/Builder.Mod

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 You should have received a copy of the GNU General Public License
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 *)
 *)
-IMPORT Term, FoStrings, Files, Utf8, Config, Strings, Int, Out,
+IMPORT Term, FoStrings, Files, Utf8, Config, Strings, Int, Out, Debug,
   Env, Dir, Kernel;
   Env, Dir, Kernel;
 
 
 TYPE
 TYPE
@@ -38,7 +38,7 @@ VAR
   target: ARRAY 64 OF CHAR; (* 'LINUX' or 'WIN32' *)
   target: ARRAY 64 OF CHAR; (* 'LINUX' or 'WIN32' *)
   wrongLinkTarget: BOOLEAN; (* TRUE if target was given and does not match *)
   wrongLinkTarget: BOOLEAN; (* TRUE if target was given and does not match *)
   findLinkInfo: Module; (* If not NIL, "%LINK" comments will be saved here *)
   findLinkInfo: Module; (* If not NIL, "%LINK" comments will be saved here *)
-  workDir: ARRAY 256 OF CHAR; (* Directory of main file of compiled program *)
+  workDir*: ARRAY 1024 OF CHAR; (* Directory of main file of compiled program *)
 
 
 PROCEDURE IsSysModule(IN name: ARRAY OF CHAR): BOOLEAN;
 PROCEDURE IsSysModule(IN name: ARRAY OF CHAR): BOOLEAN;
 VAR p: Module;
 VAR p: Module;
@@ -234,8 +234,7 @@ BEGIN ok := TRUE;
   END;
   END;
 
 
   IF ok THEN
   IF ok THEN
-    s := fname$;
-    Strings.Append(s, cmd);
+    s := fname$; Config.FixFname(s); Strings.Append(s, cmd);
 
 
     IF main THEN Strings.Append(' -m', cmd)
     IF main THEN Strings.Append(' -m', cmd)
     ELSIF link & (list # NIL) THEN
     ELSIF link & (list # NIL) THEN
@@ -261,6 +260,10 @@ BEGIN ok := TRUE;
     END;
     END;
     Utf8.Encode(cmd, q);
     Utf8.Encode(cmd, q);
 
 
+    IF Config.debug THEN
+      Out.String('Term.RunProcess "'); Out.String(cmd); Out.Char('"'); Out.Ln
+    END;
+
     success := (Term.RunProcess(q, buf, bufLen, len, err) # 0) & (err = 0);
     success := (Term.RunProcess(q, buf, bufLen, len, err) # 0) & (err = 0);
     IF ~success & (onError # NIL) THEN
     IF ~success & (onError # NIL) THEN
       z := ''; line := 0; col := 0;
       z := ''; line := 0; col := 0;
@@ -553,6 +556,7 @@ BEGIN mod.foreign := FALSE; res := 401; NEW(top); top.next := NIL; p := top;
         END;
         END;
         findLinkInfo := NIL
         findLinkInfo := NIL
       END
       END
+    ELSE Debug.StrVal('GetImportedModules: First symbol is: ', s)
     END
     END
   END ;
   END ;
 RETURN top.next END GetModuleInfo;
 RETURN top.next END GetModuleInfo;
@@ -606,6 +610,9 @@ BEGIN L := NIL; res := 0(*OK*); foreign := FALSE;
     END
     END
   END;
   END;
   IF res = 0 THEN AddUniqueToList(mod, L); foreign := mod.foreign END ;
   IF res = 0 THEN AddUniqueToList(mod, L); foreign := mod.foreign END ;
+  Debug.String('UsedModuleList modname="'); Debug.String(modname);
+  Debug.String('", fname="'); Debug.String(fname);
+  Debug.String('", res = '); Debug.Int(res); Debug.Ln ;
 RETURN L END UsedModuleList;
 RETURN L END UsedModuleList;
 
 
 BEGIN
 BEGIN

+ 16 - 2
src/Config.Mod

@@ -2,10 +2,12 @@ MODULE Config;
 IMPORT Platform;
 IMPORT Platform;
 CONST
 CONST
   isWindows* = Platform.Windows;
   isWindows* = Platform.Windows;
+  pathDelimiter* = Platform.PathDelimiter;
   stdPath* = 'Programs/';
   stdPath* = 'Programs/';
+  startInFullscreen* = FALSE; (** Should Free Oberon start in full screen *)
 
 
-  version* = '1.1.0-alpha.6';
-  year* = 2022;
+  version* = '1.1.0-alpha.7';
+  year* = 2023;
 
 
 VAR
 VAR
   debug*: BOOLEAN;
   debug*: BOOLEAN;
@@ -14,6 +16,18 @@ PROCEDURE SetDebug*(deb: BOOLEAN);
 BEGIN debug := deb
 BEGIN debug := deb
 END SetDebug;
 END SetDebug;
 
 
+(** Replace all / with \ if on Windows *)
+PROCEDURE FixFname*(VAR s: ARRAY OF CHAR);
+VAR i: INTEGER;
+BEGIN
+  IF pathDelimiter = '\' THEN i := 0;
+    WHILE (i # LEN(s)) & (s[i] # 0X) DO
+      IF s[i] = '/' THEN s[i] := '\' END;
+      INC(i)
+    END
+  END
+END FixFname;
+
 BEGIN
 BEGIN
   debug := FALSE
   debug := FALSE
 END Config.
 END Config.

+ 31 - 0
src/Debug.Mod

@@ -0,0 +1,31 @@
+MODULE Debug;
+IMPORT Out, Config;
+
+PROCEDURE String*(s: ARRAY OF CHAR);
+BEGIN
+  IF Config.debug THEN Out.String(s) END
+END String;
+
+PROCEDURE Int*(n: INTEGER);
+BEGIN
+  IF Config.debug THEN Out.Int(n, 0) END
+END Int;
+
+PROCEDURE Ln*;
+BEGIN
+  IF Config.debug THEN Out.Ln END
+END Ln;
+
+PROCEDURE StrVal*(label, val: ARRAY OF CHAR);
+BEGIN
+  IF Config.debug THEN
+    Out.String(label); Out.Char('"'); Out.String(val); Out.Char('"'); Out.Ln
+  END
+END StrVal;
+
+PROCEDURE IntVal*(label: ARRAY OF CHAR; val: INTEGER);
+BEGIN
+  IF Config.debug THEN Out.String(label); Out.Int(val, 0); Out.Ln END
+END IntVal;
+
+END Debug.

+ 13 - 4
src/Editor.Mod

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 You should have received a copy of the GNU General Public License
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 *)
 *)
-IMPORT OV, T := TermBox, Text := EditorText, Config,
+IMPORT OV, T := TermBox, Text := EditorText, Config, Debug,
   Int, Strings, FoStrings, StrList, Dir, Out;
   Int, Strings, FoStrings, StrList, Dir, Out;
 CONST
 CONST
   dotChar = 0B7X; (* To higlight spaces *)
   dotChar = 0B7X; (* To higlight spaces *)
@@ -159,16 +159,22 @@ PROCEDURE FileDialogOkClick*(c: OV.Control);
 VAR w: FileDialog;
 VAR w: FileDialog;
   s, full: ARRAY 256 OF CHAR;
   s, full: ARRAY 256 OF CHAR;
   i, L: INTEGER;
   i, L: INTEGER;
-BEGIN w := c.parent(FileDialog); s := w.edtFilename.caption$;
+  ok: BOOLEAN;
+BEGIN ok := FALSE; w := c.parent(FileDialog); s := w.edtFilename.caption$;
   (* Replace all \ with / and set L to length of s *)
   (* Replace all \ with / and set L to length of s *)
   L := 0; WHILE s[L] # 0X DO IF s[L] = '\' THEN s[L] := '/' END; INC(L) END;
   L := 0; WHILE s[L] # 0X DO IF s[L] = '\' THEN s[L] := '/' END; INC(L) END;
+  Debug.StrVal('FileDialogOkClick s = ', s);
   IF L = 0 THEN
   IF L = 0 THEN
     IF w.colFiles.onChange # NIL THEN w.colFiles.onChange(w.colFiles) END
     IF w.colFiles.onChange # NIL THEN w.colFiles.onChange(w.colFiles) END
   ELSE
   ELSE
     IF (s[L - 1] = '/') OR (s[0] = '/') THEN
     IF (s[L - 1] = '/') OR (s[0] = '/') THEN
       IF s[L - 1] # '/' THEN s[L] := '/'; INC(L); s[L] := 0X END;
       IF s[L - 1] # '/' THEN s[L] := '/'; INC(L); s[L] := 0X END;
       FileDialogApplyDir(w, s); FileDialogUpdateFileList(w)
       FileDialogApplyDir(w, s); FileDialogUpdateFileList(w)
+    ELSIF (('A' <= s[0]) & (s[0] <= 'Z') OR ('a' <= s[0]) & (s[0] <= 'z')) &
+    	  (s[1] = ':') & (s[2] = '/')
+    THEN full := s$; ok := TRUE
     ELSE full := w.path$;
     ELSE full := w.path$;
+      Debug.StrVal('FileDialogOkClick full = ', full);
       WHILE (s[0] = '.') & (s[1] = '.') & (s[2] = '/') &
       WHILE (s[0] = '.') & (s[1] = '.') & (s[2] = '/') &
             ~((full[1] = ':') & (full[2] = '/') & (full[3] = 0X))
             ~((full[1] = ':') & (full[2] = '/') & (full[3] = 0X))
       DO Strings.Delete(s, 0, 3); i := Strings.Length(full) - 2;
       DO Strings.Delete(s, 0, 3); i := Strings.Length(full) - 2;
@@ -181,10 +187,13 @@ BEGIN w := c.parent(FileDialog); s := w.edtFilename.caption$;
           Strings.Delete(full, 0, Strings.Length(w.home));
           Strings.Delete(full, 0, Strings.Length(w.home));
           Strings.Insert(Config.stdPath, 0, full)
           Strings.Insert(Config.stdPath, 0, full)
         END;
         END;
-        OV.CloseCurWindow(c);
-        IF w.onFileOk # NIL THEN w.onFileOk(c, full) END
+	ok := TRUE
       END
       END
     END
     END
+  END;
+  IF ok THEN
+    OV.CloseCurWindow(c);
+    IF w.onFileOk # NIL THEN w.onFileOk(c, full) END
   END
   END
 END FileDialogOkClick;
 END FileDialogOkClick;
 
 

+ 2 - 13
src/EditorText.Mod

@@ -372,23 +372,12 @@ BEGIN
   Files.WriteChar(r, 0AX)
   Files.WriteChar(r, 0AX)
 END WriteLn;
 END WriteLn;
 
 
-PROCEDURE FixFname(VAR fname: ARRAY OF CHAR);
-VAR i: INTEGER;
-BEGIN
-  IF Config.isWindows THEN i := 0;
-    WHILE fname[i] # 0X DO
-      IF fname[i] = '/' THEN fname[i] := '\' END;
-      INC(i)
-    END
-  END
-END FixFname;
-
 PROCEDURE (t: Text) SaveToFile*(fname: ARRAY OF CHAR): BOOLEAN, NEW;
 PROCEDURE (t: Text) SaveToFile*(fname: ARRAY OF CHAR): BOOLEAN, NEW;
 VAR f: Files.File; r: Files.Rider;
 VAR f: Files.File; r: Files.Rider;
   success: BOOLEAN;
   success: BOOLEAN;
   L: Line;
   L: Line;
 BEGIN success := FALSE;
 BEGIN success := FALSE;
-  FixFname(fname);
+  Config.FixFname(fname);
   f := Files.New(fname);
   f := Files.New(fname);
   IF f # NIL THEN (*!FIXME error checking is wrong *)
   IF f # NIL THEN (*!FIXME error checking is wrong *)
     Files.Set(r, f, 0);
     Files.Set(r, f, 0);
@@ -428,7 +417,7 @@ VAR f: Files.File; r: Files.Rider;
   lf, crlf: INTEGER; (* Count of CR and CRLF line endings *)
   lf, crlf: INTEGER; (* Count of CR and CRLF line endings *)
 BEGIN success := FALSE; lf := 0; crlf := 0;
 BEGIN success := FALSE; lf := 0; crlf := 0;
   IF fname[0] # 0X THEN
   IF fname[0] # 0X THEN
-    FixFname(fname);
+    Config.FixFname(fname);
     f := Files.Old(fname);
     f := Files.Old(fname);
     IF f # NIL THEN
     IF f # NIL THEN
       Files.Set(r, f, 0);
       Files.Set(r, f, 0);

+ 10 - 2
src/Files.Mod

@@ -310,10 +310,10 @@ BEGIN f := files;
   RETURN NIL
   RETURN NIL
 END CacheEntry;
 END CacheEntry;
 
 
-PROCEDURE Old*(IN name: ARRAY OF CHAR): File;
+PROCEDURE Old*(name: ARRAY OF CHAR): File;
 VAR f: File;
 VAR f: File;
   fd: Platform.FileHandle;
   fd: Platform.FileHandle;
-  pos: INTEGER;
+  i, pos: INTEGER;
   done: BOOLEAN;
   done: BOOLEAN;
   dir, path: ARRAY 256 OF CHAR;
   dir, path: ARRAY 256 OF CHAR;
   error: Platform.ErrorCode;
   error: Platform.ErrorCode;
@@ -322,6 +322,14 @@ VAR f: File;
   n: INT64;
   n: INT64;
 BEGIN
 BEGIN
   IF name # '' THEN
   IF name # '' THEN
+    (* Replace all / with \ if required *)
+    IF Platform.PathDelimiter = '\' THEN i := 0;
+      WHILE (i # LEN(name)) & (name[i] # 0X) DO
+        IF name[i] = '/' THEN name[i] := '\' END;
+        INC(i)
+      END
+    END;
+
     IF HasDir(name) THEN dir := ''; path := name$
     IF HasDir(name) THEN dir := ''; path := name$
     ELSE pos := 0; ScanPath(pos, dir);
     ELSE pos := 0; ScanPath(pos, dir);
       MakeFileName(dir, name, path); ScanPath(pos, dir)
       MakeFileName(dir, name, path); ScanPath(pos, dir)

+ 11 - 7
src/FreeOberon.Mod

@@ -16,7 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 You should have received a copy of the GNU General Public License
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 *)
 *)
-IMPORT T := TermBox, Files, Args, Utf8, Builder, Env,
+IMPORT T := TermBox, Files, Args, Utf8, Builder, Env, Debug,
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
        OV, Editor, Term, FoStrings, Config, Strings, Int, Out, Kernel;
 CONST
 CONST
   (* Direction of Selection *)
   (* Direction of Selection *)
@@ -412,6 +412,7 @@ END OpenFileOkClick;
 PROCEDURE DoSaveFile(c: OV.Control; fname: ARRAY OF CHAR);
 PROCEDURE DoSaveFile(c: OV.Control; fname: ARRAY OF CHAR);
 VAR w: OV.Window; e: Editor.Editor;
 VAR w: OV.Window; e: Editor.Editor;
 BEGIN
 BEGIN
+  Debug.StrVal('DoSaveFile fname = ', fname);
   IF fname[0] # 0X THEN w := c.app.windows;
   IF fname[0] # 0X THEN w := c.app.windows;
     IF (w # NIL) & (w IS Editor.Editor) THEN e := w(Editor.Editor);
     IF (w # NIL) & (w IS Editor.Editor) THEN e := w(Editor.Editor);
       IF e.text.SaveToFile(fname) THEN
       IF e.text.SaveToFile(fname) THEN
@@ -517,11 +518,15 @@ BEGIN w := c.app.windows;
     IF Editor.TextChanged(w(Editor.Editor)) THEN FileSave(c) END;
     IF Editor.TextChanged(w(Editor.Editor)) THEN FileSave(c) END;
     IF w(Editor.Editor).fname[0] # 0X THEN
     IF w(Editor.Editor).fname[0] # 0X THEN
       mainFname := w(Editor.Editor).fname$;
       mainFname := w(Editor.Editor).fname$;
+      Debug.StrVal('File name of main module: ', mainFname);
       Builder.SetWorkDir(mainFname);
       Builder.SetWorkDir(mainFname);
+      Debug.StrVal('Work directory: ', Builder.workDir);
       Builder.GetModuleName(mainFname, modname);
       Builder.GetModuleName(mainFname, modname);
+      Debug.StrVal('Module name: ', modname);
       modules := Builder.UsedModuleList(modname, mainFname,
       modules := Builder.UsedModuleList(modname, mainFname,
         errFname, errLine, errCol, foreign, res);
         errFname, errLine, errCol, foreign, res);
       IF foreign THEN res := 402 END;
       IF foreign THEN res := 402 END;
+      Debug.IntVal('Result of UserModuleList: ', res);
       IF res = 0 THEN
       IF res = 0 THEN
         IF Builder.CompileAll(modules, exename, FALSE, BuildErrorCallback)
         IF Builder.CompileAll(modules, exename, FALSE, BuildErrorCallback)
         THEN RunProgram(exename)
         THEN RunProgram(exename)
@@ -530,7 +535,7 @@ BEGIN w := c.app.windows;
         FocusOrOpenFile(errFname);
         FocusOrOpenFile(errFname);
         e := app.windows(Editor.Editor);
         e := app.windows(Editor.Editor);
         e.text.MoveToLineCol(errLine, errCol, e.h - 2);
         e.text.MoveToLineCol(errLine, errCol, e.h - 2);
-        FoStrings.MakeErrorStr(res(*!FIXME should be just 401?*), s);
+        FoStrings.MakeErrorStr(res, s);
         ShowError(s)
         ShowError(s)
       END
       END
     END
     END
@@ -922,16 +927,15 @@ PROCEDURE ParseArgs(VAR fs, sw: BOOLEAN; VAR w, h: INTEGER;
     VAR lang: ARRAY OF CHAR; VAR fnames: Fnames);
     VAR lang: ARRAY OF CHAR; VAR fnames: Fnames);
 VAR i, nofnames: INTEGER;
 VAR i, nofnames: INTEGER;
   s: ARRAY 2048 OF CHAR;
   s: ARRAY 2048 OF CHAR;
-BEGIN fs := TRUE; sw := FALSE; i := 1; nofnames := 0; w := defW; h := defH;
-  lang := '';
+BEGIN fs := Config.startInFullscreen; sw := FALSE; i := 1;
+  nofnames := 0; w := defW; h := defH; lang := '';
   WHILE i <= Args.Count DO Args.Get(i, s);
   WHILE i <= Args.Count DO Args.Get(i, s);
     IF s = '--window' THEN fs := FALSE
     IF s = '--window' THEN fs := FALSE
+    ELSIF s = '--fullscreen' THEN fs := TRUE
     ELSIF s = '--software' THEN sw := TRUE
     ELSIF s = '--software' THEN sw := TRUE
     ELSIF s = '--debug' THEN Config.SetDebug(TRUE)
     ELSIF s = '--debug' THEN Config.SetDebug(TRUE)
     ELSIF s = '--size' THEN
     ELSIF s = '--size' THEN
-      IF i # Args.Count THEN
-        INC(i); Args.Get(i, s); ParseSize(s, w, h)
-      END
+      IF i # Args.Count THEN INC(i); Args.Get(i, s); ParseSize(s, w, h) END
     ELSIF s = '--lang' THEN
     ELSIF s = '--lang' THEN
       IF i # Args.Count THEN
       IF i # Args.Count THEN
         INC(i); Args.Get(i, lang);
         INC(i); Args.Get(i, lang);