conversion routinew now initialize whole array, Epilogue module changed slightly
authorceriel <none@none>
Thu, 28 Jan 1988 16:37:55 +0000 (16:37 +0000)
committerceriel <none@none>
Thu, 28 Jan 1988 16:37:55 +0000 (16:37 +0000)
lang/m2/libm2/Conversion.mod
lang/m2/libm2/Epilogue.def
lang/m2/libm2/RealConver.mod
lang/m2/libm2/catch.c
lang/m2/libm2/halt.c

index 1bf1f43..cdb90c0 100644 (file)
@@ -28,7 +28,10 @@ IMPLEMENTATION MODULE Conversions;
        r := 0;
        WHILE len > i DO str[r] := ' '; INC(r); DEC(len); END;
        WHILE i > 0 DO str[r] := tmp[i-1]; DEC(i); INC(r); END;
-       IF r <= HIGH(str) THEN str[r] := 0C; END;
+       WHILE r <= HIGH(str) DO
+               str[r] := 0C;
+               INC(r);
+       END;
     END ConvertNum;
 
   PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
index d6ba14f..ea6d6e9 100644 (file)
@@ -4,10 +4,12 @@ DEFINITION MODULE Epilogue;
    is no mechanism to have some code executed when the program finishes.
    This module is a feeble attempt at solving this problem.
 *)
-  PROCEDURE CallAtEnd(p: PROC);
+  PROCEDURE CallAtEnd(p: PROC): BOOLEAN;
   (* Add procedure "p" to the list of procedures that must be executed when
      the program finishes.
      When the program finishes, these procedures are executed in the order in
      which they were added to the list.
+     This procedure returns FALSE when there are too many procedures to be 
+     called (the list has a fixed size).
   *)
 END Epilogue.
index b2fd1c0..bcd2109 100644 (file)
@@ -202,7 +202,11 @@ IMPLEMENTATION MODULE RealConversions;
                        str[i] := ' ';
                END;
                ind1 := CARDINAL(width);
-               IF (ind1+1) <= HIGH(str) THEN str[ind1+1] := 0C; END;
+               IF (ind1+1) <= HIGH(str) THEN
+                       FOR ind1 := ind1+1 TO HIGH(str) DO
+                               str[ind1] := 0C;
+                       END;
+               END;
        END;
 
   END LongRealToString;
index 5014a2f..2e6a4ae 100644 (file)
@@ -35,7 +35,6 @@ static struct errm {
        { M2_NORESULT,  "no RETURN from procedure function"},
        { M2_UOVFL,     "cardinal overflow"},
        { M2_FORCH,     "Warning: FOR-loop control variable was changed in the body"},
-       { M2_ENDPROCS,  "too many procedures to be called on program termination"},
        { -1,           0}
 };
 
index 3c84979..d9571a1 100644 (file)
@@ -1,5 +1,4 @@
-#define MAXPROCS 20
-#include <m2_traps.h>
+#define MAXPROCS 16
 
 static int callindex;
 static int (*proclist[MAXPROCS])();
@@ -17,11 +16,12 @@ CallAtEnd(p)
        int (*p)();
 {
        if (callindex >= MAXPROCS) {
-               TRP(M2_ENDPROCS);
+               return 0;
        }
        else {
                proclist[callindex++] = p;
        }
+       return 1;
 }
 
 _halt()