mainly new comments
authorceriel <none@none>
Fri, 19 Feb 1988 15:54:01 +0000 (15:54 +0000)
committerceriel <none@none>
Fri, 19 Feb 1988 15:54:01 +0000 (15:54 +0000)
61 files changed:
lang/m2/libm2/.distr
lang/m2/libm2/ASCII.def
lang/m2/libm2/Arguments.c
lang/m2/libm2/Arguments.def
lang/m2/libm2/ArraySort.mod
lang/m2/libm2/CSP.def
lang/m2/libm2/CSP.mod
lang/m2/libm2/ChkCards.e
lang/m2/libm2/Conversion.def
lang/m2/libm2/Conversion.mod
lang/m2/libm2/EM.def
lang/m2/libm2/EM.e
lang/m2/libm2/Epilogue.def
lang/m2/libm2/InOut.def
lang/m2/libm2/InOut.mod
lang/m2/libm2/LIST
lang/m2/libm2/LtoUset.e
lang/m2/libm2/Makefile
lang/m2/libm2/MathLib0.def
lang/m2/libm2/MathLib0.mod
lang/m2/libm2/Mathlib.def
lang/m2/libm2/Mathlib.mod
lang/m2/libm2/PascalIO.mod
lang/m2/libm2/Processes.def
lang/m2/libm2/Processes.mod
lang/m2/libm2/RealConver.def
lang/m2/libm2/RealConver.mod
lang/m2/libm2/RealInOut.def
lang/m2/libm2/RealInOut.mod
lang/m2/libm2/Semaphores.def
lang/m2/libm2/Semaphores.mod
lang/m2/libm2/Storage.def
lang/m2/libm2/Storage.mod
lang/m2/libm2/StrAss.c
lang/m2/libm2/Streams.def
lang/m2/libm2/Streams.mod
lang/m2/libm2/Strings.def
lang/m2/libm2/Strings.mod
lang/m2/libm2/Terminal.def
lang/m2/libm2/Terminal.mod
lang/m2/libm2/Traps.def
lang/m2/libm2/Traps.mod
lang/m2/libm2/Unix.def
lang/m2/libm2/absd.c
lang/m2/libm2/absf.e
lang/m2/libm2/absi.c
lang/m2/libm2/absl.c
lang/m2/libm2/catch.c
lang/m2/libm2/confarray.c
lang/m2/libm2/halt.c
lang/m2/libm2/head_m2.e
lang/m2/libm2/load.c
lang/m2/libm2/random.def
lang/m2/libm2/random.mod
lang/m2/libm2/rcki.e
lang/m2/libm2/rckil.e
lang/m2/libm2/rcku.e
lang/m2/libm2/rckul.e
lang/m2/libm2/stackprio.c
lang/m2/libm2/store.c
lang/m2/libm2/transfer.e

index dc9fdf4..d402b31 100644 (file)
@@ -15,7 +15,6 @@ RealConver.def
 Semaphores.def
 Storage.def
 Strings.def
-TTY.def
 Terminal.def
 Unix.def
 head_m2.e
index 54c0cf4..827b4e0 100644 (file)
@@ -1,4 +1,10 @@
+(*$Foreign*)
 DEFINITION MODULE ASCII;
+(*
+  Module:      Mnemonics for ASCII control characters
+  From:                ???
+  Version:     $Header$
+*)
 
 CONST
        nul = 00C;      soh = 01C;      stx = 02C;      etx = 03C;
index cbd2c6c..036dae6 100644 (file)
@@ -1,3 +1,14 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      Access to program arguments and environment
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
+
 extern char **_argv, **_environ;
 extern int _argc;
 unsigned int Arguments_Argc;
index a849504..c4d19a3 100644 (file)
@@ -1,6 +1,8 @@
 DEFINITION MODULE Arguments;
-(*     Routines and variables to access the programs arguments and
-       environment
+(*
+  Module:      Access to program arguments and environment
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
 *)
 
 VAR    Argc: CARDINAL; (* Number of program arguments, including the program
index 8ad9c3e..f481628 100644 (file)
@@ -1,3 +1,8 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE ArraySort;
 (* 
@@ -21,6 +26,7 @@ IMPLEMENTATION MODULE ArraySort;
   END Sort;
 
   PROCEDURE qsort(a1, a2: ADDRESS; size: CARDINAL);
+  (* Implemented with quick-sort, with some extra's *)
     VAR        left, right, lefteq, righteq: ADDRESS;
        cmp: CompareResult;
        mainloop: BOOLEAN;
index 4d0d319..5fb7deb 100644 (file)
@@ -1,8 +1,10 @@
 DEFINITION MODULE CSP;
-(* From 
-       "A Modula-2 Implementation of CSP",
-       M. Collado, R. Morales, J.J. Moreno,
-       SIGPlan Notices, Volume 22, Number 6, June 1987.
+(*
+  Module:      Communicating Sequential Processes
+  From:                "A Modula-2 Implementation of CSP",
+               M. Collado, R. Morales, J.J. Moreno,
+               SIGPlan Notices, Volume 22, Number 6, June 1987.
+  Version:     $Header$
 
    See this article for an explanation of the use of this module.
 *)
index a9c6292..74fdd98 100644 (file)
@@ -1,9 +1,12 @@
 (*$R-*)
 IMPLEMENTATION MODULE CSP;
-(* From 
-       "A Modula-2 Implementation of CSP",
-       M. Collado, R. Morales, J.J. Moreno,
-       SIGPlan Notices, Volume 22, Number 6, June 1987.
+(*
+  Module:      Communicating Sequential Processes
+  From:                "A Modula-2 Implementation of CSP",
+               M. Collado, R. Morales, J.J. Moreno,
+               SIGPlan Notices, Volume 22, Number 6, June 1987.
+               Some modifications by Ceriel J.H. Jacobs
+  Version:     $Header$
 
    See this article for an explanation of the use of this module.
 *)
index b6d7a05..0369818 100644 (file)
@@ -1,4 +1,13 @@
 #include <m2_traps.h>
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      CARDINAL operations with overflow checking
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
 
  mes 2,EM_WSIZE,EM_PSIZE
 
index bfaa7e4..f732fa2 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Conversions;
+(*
+  Module:      Numeric-to-string conversions
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
   (* Convert number "num" to right-justified octal representation of
index cdb90c0..b64ebc4 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Conversions;
+(*
+  Module:      numeric-to-string conversions
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   PROCEDURE ConvertNum(num, len, base: CARDINAL;
                       neg: BOOLEAN;
index 755d6b4..82b53de 100644 (file)
@@ -1,6 +1,10 @@
 (*$Foreign *)
 DEFINITION MODULE EM;
-(* An interface to EM instructions and data *)
+(*
+  Module:      Interface to some EM instructions and data
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
        FROM SYSTEM IMPORT ADDRESS;
 
@@ -20,8 +24,15 @@ DEFINITION MODULE EM;
        (* Generate EM trap number "trapno" *)
 
        PROCEDURE SIG(t: TrapHandler): TrapHandler;
+       (* install traphandler t; return previous handler *)
 
        PROCEDURE FILN(): ADDRESS;
+       (* return current program file-name. This only works if file-name
+          and line-number generation is not disabled during compilation
+       *)
 
        PROCEDURE LINO(): INTEGER;
+       (* return current program line-number. This only works if file-name
+          and line-number generation is not disabled during compilation
+       *)
 END EM.
index 174c82f..f5f1b36 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      Interface to some EM instructions and data
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
  mes 2,EM_WSIZE,EM_PSIZE
 
 #define ARG1    0
index ea6d6e9..ee87c46 100644 (file)
@@ -1,6 +1,12 @@
 (*$Foreign*)
 DEFINITION MODULE Epilogue;
-(* MODULA-2 offers a facility for the initialization of modules, but there
+(*
+  Module:      install module termination procedures to be called at
+               program termination
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+
+   MODULA-2 offers a facility for the initialization of modules, but there
    is no mechanism to have some code executed when the program finishes.
    This module is a feeble attempt at solving this problem.
 *)
index 1179298..d8c142c 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE InOut;
+(*
+  Module:      Wirth's Input/Output module
+  From:                "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:     $Header$
+*)
 
        CONST   EOL = 12C;
 
@@ -23,11 +28,13 @@ DEFINITION MODULE InOut;
        *)
 
        PROCEDURE OpenInputFile(filename: ARRAY OF CHAR);
-       (* Like OpenInput, but filename given as parameter
+       (* Like OpenInput, but filename given as parameter.
+          This procedure is not in Wirth's InOut.
        *)
 
        PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR);
-       (* Like OpenOutput, but filename given as parameter
+       (* Like OpenOutput, but filename given as parameter.
+          This procedure is not in Wirth's InOut.
        *)
 
        PROCEDURE CloseInput;
index ab7eebf..2fd0771 100644 (file)
@@ -1,10 +1,19 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE InOut ;
+(*
+  Module:      Wirth's Input/Output module
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   IMPORT Streams;
   IMPORT Conversions;
   IMPORT Traps;
-  FROM TTY IMPORT isatty;
 
   CONST        TAB = 11C;
 
@@ -123,7 +132,7 @@ IMPLEMENTATION MODULE InOut ;
        j : CARDINAL;
   BEGIN
        Done := TRUE;
-       IF isatty(0) THEN
+       IF isatty(Streams.InputStream) THEN
                XWriteString(prompt);
        END;
        XReadString(buf);
index 3c5b0b2..91e78c4 100644 (file)
@@ -5,8 +5,6 @@ RealInOut.mod
 InOut.mod
 Streams.mod
 Terminal.mod
-TTY.mod
-ASCII.mod
 MathLib0.mod
 Mathlib.mod
 Processes.mod
index 5957472..2be4da7 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      Compute non-constant set displays
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
  mes 2,EM_WSIZE,EM_PSIZE
 
  ; _LtoUset is called for set displays containing { expr1 .. expr2 }.
index b945a18..313d130 100644 (file)
@@ -4,7 +4,7 @@ DEFDIR = $(HOME)/lib/m2
 SOURCES =      ASCII.def EM.def MathLib0.def Processes.def \
                RealInOut.def Storage.def Arguments.def Conversion.def \
                random.def Semaphores.def Unix.def RealConver.def \
-               Strings.def InOut.def Terminal.def TTY.def \
+               Strings.def InOut.def Terminal.def \
                Mathlib.def PascalIO.def Traps.def CSP.def \
                Epilogue.def Streams.def ArraySort.def
 
index 985a6da..196c66e 100644 (file)
@@ -1,5 +1,9 @@
 DEFINITION MODULE MathLib0;
 (*
+  Module:      Some mathematical functions
+  From:                "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:     $Header$
+
        Exists for compatibility.
        A more elaborate math lib can be found in Mathlib.def
 *)
index 9834ac0..a27d29f 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE MathLib0;
+(*
+  Module:      Some mathematical functions
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   IMPORT Mathlib;
 
index 979d1b6..d860673 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Mathlib;
+(*
+  Module:      Mathematical functions
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   (* Some mathematical constants: *)
 
index 79858a3..7b84f89 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Mathlib;
+(*
+  Module:      Mathematical functions
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   FROM EM IMPORT FIF, FEF;
   FROM Traps IMPORT Message;
index ecfdd7e..352a77d 100644 (file)
@@ -1,3 +1,8 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE PascalIO;
 (*
index 8437deb..0bbac30 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Processes;
+(*
+  Module:      Processes
+  From:                "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:     $Header$
+*)
 
        TYPE SIGNAL;
 
index 2bc5d66..18b28a6 100644 (file)
@@ -1,8 +1,9 @@
 (*$R-*)
 IMPLEMENTATION MODULE Processes [1];
-(* This implementation module comes from
-       "Programming in Modula-2", by Niklaus Wirth,
-       3rd edition, Springer-Verlag, New York, 1985
+(*
+  Module:       Processes
+  From:         "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:      $Header$
 *)
 
   FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER;
index 6808564..e970836 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE RealConversions;
+(*
+  Module:      string-to-real and real-to-string conversions
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
   (* Convert string "str" to a real number "r" according to the syntax:
index bcd2109..eac853e 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE RealConversions;
+(*
+  Module:       string-to-real and real-to-string conversions
+  Author:       Ceriel J.H. Jacobs
+  Version:      $Header$
+*)
 
   FROM EM IMPORT FIF;
 
index c7eb7eb..6a13a48 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE RealInOut;
+(*
+  Module:      InOut for REAL numbers
+  From:                "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:     $Header$
+*)
 
   VAR Done: BOOLEAN;
 
index 64a97d2..3421801 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE RealInOut;
+(*
+  Module:       InOut for REAL numbers
+  Author:      Ceriel J.H. Jacobs
+  Version:      $Header$
+*)
 
   IMPORT InOut;
   IMPORT RealConversions;
index 9883fb9..53a674e 100644 (file)
@@ -1,4 +1,12 @@
 DEFINITION MODULE Semaphores;
+(*
+  Module:      Processes with semaphores
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+
+  On systems using quasi-concurrency, the only opportunities for process-
+  switches are calls to Down and Up.
+*)
 
   TYPE Sema;
 
@@ -12,12 +20,10 @@ DEFINITION MODULE Semaphores;
   (* If the value of "s" is > 0, then just decrement "s".
      Else, suspend the current process until the semaphore becomes
      positive again.
-     May result in a process switch.
   *)
 
   PROCEDURE Up(VAR s: Sema);
   (* Increment the semaphore "s".
-     This call may result in a process switch
   *)
 
   PROCEDURE StartProcess(P: PROC; n: CARDINAL);
index 96fc248..7767225 100644 (file)
@@ -1,5 +1,17 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Semaphores [1];
+(*
+  Module:       Processes with semaphores
+  Author:       Ceriel J.H. Jacobs
+  Version:      $Header$
+
+  Quasi-concurrency implementation
+*)
 
   FROM SYSTEM IMPORT ADDRESS, NEWPROCESS, TRANSFER;
   FROM Storage IMPORT ALLOCATE;
index fda4c9c..234562b 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Storage;
+(*
+  Module:      Dynamic storage allocation
+  From:                "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:     $Header$
+*)
 
        FROM SYSTEM IMPORT ADDRESS;
 
index e3e30fa..19a7d3b 100644 (file)
@@ -1,5 +1,16 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Storage;
+(*
+  Module:      Dynamic Storage Allocation
+  Author:      Ceriel J.H. Jacobs
+               Adapted from a version in C by Hans Tebra
+  Version:     $Header$
+*)
 (* This storage manager maintains an array of lists of objects with the
    same size. Commonly used sizes have their own bucket. The larger ones
    are put in a single list.
index 371042d..92f1001 100644 (file)
@@ -1,3 +1,14 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      assign string to character array, with possible 0-byte
+               extension
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 _StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
        register char *dstaddr, *srcaddr;
 {
@@ -6,8 +17,7 @@ _StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
                srcsiz--;
                dstsiz--;
        }
-       while (dstsiz > 0) {
-               *dstaddr++ = 0;
-               dstsiz--;
+       if (dstsiz > 0) {
+               *dstaddr = 0;
        }
 }
index 4bdc851..e613367 100644 (file)
@@ -1,5 +1,9 @@
 DEFINITION MODULE Streams;
 (*
+  Module:      Stream Input/Output
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+
  * This module provides sequential IO through streams.
  * A stream is either a text stream or a binary stream, and is either in
  * reading, writing or appending mode.
@@ -134,10 +138,16 @@ DEFINITION MODULE Streams;
                        position: LONGINT;
                        VAR result: StreamResult);
   (* sets the actual read/write position to "position".
-     "result" is set to illegaloperation if "stream" is not a stream or
-     the stream was opened for appending and the position is in front of
-     the current position, or it failed for some other
-     reason (f.i. when the stream is connected to a terminal).
+     "result" is set to nostream if "stream" is not a stream.
+     It is set to illegaloperation if the stream was opened for appending and
+     the position is in front of the current position, or it failed for some
+     other reason (f.i. when the stream is connected to a terminal).
+  *)
+
+  PROCEDURE isatty(stream: Stream; VAR result: StreamResult): BOOLEAN;
+  (* return TRUE if the stream is connected to a terminal.
+     "result" is set to nostream if "stream" is not a stream, and
+     set to illegaloperation if the operation failed for some other reason.
   *)
 
 END Streams.
index 23f472e..dd4f918 100644 (file)
@@ -1,8 +1,21 @@
+#
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Streams;
+(*
+  Module:       Stream Input/Output
+  Author:       Ceriel J.H. Jacobs
+  Version:      $Header$
+
+  Implementation for Unix
+*)
 
   FROM SYSTEM IMPORT BYTE, ADR;
-  IMPORT Unix, TTY, Storage, Epilogue;
+  IMPORT Unix, Storage, Epilogue;
 
   CONST BUFSIZ = 1024; (* tunable *)
   TYPE IOB = RECORD
@@ -332,7 +345,7 @@ IMPLEMENTATION MODULE Streams;
   BEGIN
        currpos := 0D;
        IF (s = NIL) OR (s^.kind = none) THEN
-               result := illegaloperation;
+               result := nostream;
                RETURN;
        END;
        IF (s^.mode # reading) THEN
@@ -360,6 +373,24 @@ IMPLEMENTATION MODULE Streams;
        result := succeeded;
   END SetPosition;
 
+  PROCEDURE isatty(stream: Stream): BOOLEAN;
+    VAR buf: ARRAY[1..100] OF CHAR;
+  BEGIN
+       IF (stream = NIL) OR (s^.kind = none) THEN
+               result := nostream;
+               RETURN FALSE;
+       END;
+#ifdef __USG
+       RETURN ioctl(stream^.fildes, INTEGER(ORD('T') * 256 + 1), ADR(buf)) >= 0;
+#else
+#ifdef __BSD4_2
+       RETURN ioctl(stream^.fildes, INTEGER(ORD('t') * 256 + 8 + 6*65536 + 40000000H), ADR(buf)) >= 0;
+#else
+       RETURN ioctl(stream^.fildes, INTEGER(ORD('t') * 256 + 8), ADR(buf)) >= 0;
+#endif
+#endif
+  END isatty;
+
 BEGIN
        InputStream := ADR(ibuf);
        OutputStream := ADR(obuf);
@@ -383,7 +414,7 @@ BEGIN
                maxcnt := 0;
                cnt := 0;
                bufferedcnt := BUFSIZ;
-               IF TTY.isatty(1) THEN
+               IF isatty(OutputStream) THEN
                        buffering := linebuffered;
                ELSE
                        buffering := blockbuffered;
@@ -398,7 +429,7 @@ BEGIN
                maxcnt := 0;
                cnt := 0;
                bufferedcnt := BUFSIZ;
-               IF TTY.isatty(2) THEN
+               IF isatty(ErrorStream) THEN
                        buffering := linebuffered;
                ELSE
                        buffering := blockbuffered;
index a5ce67e..d2f22d5 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Strings;
+(*
+  Module:      String manipulations
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 (* Note: truncation of strings may occur if the user does not provide
    large enough variables to contain the result of the operation.
 *)
index 9d12261..20e6ccc 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Strings;
+(*
+  Module:       String manipulations
+  Author:       Ceriel J.H. Jacobs
+  Version:      $Header$
+*)
 
 PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
 (* Assign string source to dest
index 1a5a71a..7ea3e63 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Terminal;
+(*
+  Module:      Input/Output to/from terminals
+  From:                "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+  Version:     $Header$
+*)
 
        PROCEDURE Read(VAR ch : CHAR);
        (* Read a character from the terminal and leave it in ch
index 2c905a2..0ac6c61 100644 (file)
@@ -1,7 +1,17 @@
 #
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Terminal;
-(* This implementation is Unix-dependant
+(*
+  Module:       Input/Output to/from terminals
+  Author:      Ceriel J.H. Jacobs
+  Version:      $Header$
+
+  Implementation for Unix.
 *)
   IMPORT Unix;
   FROM SYSTEM IMPORT ADR;
index 46d34aa..fc6d174 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE Traps;
+(*
+  Module:      Facility for handling traps
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
   IMPORT EM;
 
index 2e8f9ff..e8874b7 100644 (file)
@@ -1,5 +1,16 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE Traps;
+(*
+  Module:       Facility for handling traps
+  Author:       Ceriel J.H. Jacobs
+  Version:      $Header$
+*)
+
   IMPORT EM;
   IMPORT Unix;
   FROM SYSTEM IMPORT ADDRESS, ADR;
index afa2123..57e238e 100644 (file)
@@ -1,6 +1,10 @@
 (*$Foreign language module *)
 DEFINITION MODULE Unix;
-(*     An interface to some Unix system-calls *)
+(*
+  Module:      interface to some Unix systemcalls
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
   FROM SYSTEM IMPORT WORD, ADDRESS;
 
 (* Type needed for Signal *)
index f0d5c53..51ce0b5 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      double abs function
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 #ifndef NOFLOAT
 double
 _absd(i)
index f52bcbe..ff9f4d9 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      REAL abs function
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
  mes 2,EM_WSIZE,EM_PSIZE
  exp $_absf
  pro $_absf,0
index 16c8838..4381792 100644 (file)
@@ -1,3 +1,14 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      integer abs function
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
+
 _absi(i)
 {
        return i >= 0 ? i : -i;
index 20feb98..ae8aa4c 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      longint abs function
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 long
 _absl(i)
        long i;
index 2e6a4ae..ca6402c 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      default modula-2 trap handler
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 #include <em_abs.h>
 #include <m2_traps.h>
 
index 2e89d8d..204ae69 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      runtime support for conformant arrays
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 #include <m2_traps.h>
 
 struct descr {
index d9571a1..f070350 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      program termination routines
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 #define MAXPROCS 16
 
 static int callindex;
index b990ddf..c9bfc2a 100644 (file)
@@ -1,22 +1,13 @@
 #
-/*
- * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
- *
- *          This product is part of the Amsterdam Compiler Kit.
- *
- * Permission to use, sell, duplicate or disclose this software must be
- * obtained in writing. Requests for such permissions may be sent to
- *
- *      Dr. Andrew S. Tanenbaum
- *      Wiskundig Seminarium
- *      Vrije Universiteit
- *      Postbox 7161
- *      1007 MC Amsterdam
- *      The Netherlands
- *
- */
-
-/* Author: C.J.H. Jacobs */
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      Modula-2 runtime startoff
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
 
  mes 2,EM_WSIZE,EM_PSIZE
 
index f88e9a6..893b33c 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      get value on stack, byte by byte
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 _load(siz, addr, p)
        register char *addr;
        register int siz;
index 44d31f7..d79e0d3 100644 (file)
@@ -1,4 +1,9 @@
 DEFINITION MODULE random;
+(*
+  Module:      random numbers
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*)
 
 PROCEDURE Random(): CARDINAL;
 (* Return a random CARDINAL
@@ -9,4 +14,9 @@ PROCEDURE Uniform (lwb, upb: CARDINAL): CARDINAL;
    "lwb" must be smaller than "upb", or "lwb" is returned.
 *)
 
+PROCEDURE StartSeed(seed: CARDINAL);
+(* Initialize the generator. You don't have to call this procedure, unless
+   you don't want the system to pick a starting value for itself.
+*)
+
 END random.
index ca6fb34..ef983c8 100644 (file)
@@ -1,5 +1,15 @@
+(*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
 (*$R-*)
 IMPLEMENTATION MODULE random;
+(*
+  Module:       random numbers
+  Author:       Ceriel J.H. Jacobs
+  Version:      $Header$
+*)
 
 FROM Unix IMPORT getpid, time;
 TYPE index = [0..54];
@@ -21,12 +31,17 @@ BEGIN
        RETURN lwb + (Random() MOD (upb - lwb + 1));
 END Uniform;
 
+PROCEDURE StartSeed(seed: CARDINAL);
 BEGIN
-       X[0] := time(NIL);
-       X[0] := CARDINAL(getpid()) * X[0];
+       X[0] := seed;
        FOR k := 1 TO 54 DO
                X[k] := X[k-1] * 1297;
        END;
        k := 54;
        j := 30;
+END StartSeed;
+
+BEGIN
+       X0 := time(NIL);
+       StartSeed(CARDINAL(getpid()) * X[0]);
 END random.
index 57d2b7e..72df511 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      range checks for INTEGER
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
 #include <em_abs.h>
 
  mes 2,EM_WSIZE,EM_PSIZE
index 5b373a7..88f461c 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      range checks for LONGINTS
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
 #include <em_abs.h>
 
  mes 2,EM_WSIZE,EM_PSIZE
index ffb1c8c..687ea51 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      range checks for CARDINAL
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
 #include <em_abs.h>
 
  mes 2,EM_WSIZE,EM_PSIZE
index 6bac67c..62fb78d 100644 (file)
@@ -1,4 +1,13 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      Range checks for LONGCARD
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
 #include <em_abs.h>
 
  mes 2,EM_WSIZE,EM_PSIZE
index a1fcd7c..c7b1953 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      Dummy priority routines
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 _stackprio(n)
 {
 }
index 6a72878..b306e87 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+  See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+  Module:      store values from stack, byte by byte
+  Author:      Ceriel J.H. Jacobs
+  Version:     $Header$
+*/
 _store(siz, addr, p)
        register char *addr;
        register int siz;
index 8d18160..65d693f 100644 (file)
@@ -1,4 +1,16 @@
 #
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module:      implementation of coroutines
+; Author:      Ceriel J.H. Jacobs
+; Version:     $Header$
+;
+; This version works for EM implementations that have a contiguous downwards
+; growing stack, on which data below the stack-pointer is not destroyed.
+;
 #include <em_mes.h>
 #include <m2_traps.h>