From 99611d287b146ff1d46d7b60e15d08a7e608d8a2 Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 28 Jan 1988 16:37:55 +0000 Subject: [PATCH] conversion routinew now initialize whole array, Epilogue module changed slightly --- lang/m2/libm2/Conversion.mod | 5 ++++- lang/m2/libm2/Epilogue.def | 4 +++- lang/m2/libm2/RealConver.mod | 6 +++++- lang/m2/libm2/catch.c | 1 - lang/m2/libm2/halt.c | 6 +++--- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lang/m2/libm2/Conversion.mod b/lang/m2/libm2/Conversion.mod index 1bf1f43ca..cdb90c0d7 100644 --- a/lang/m2/libm2/Conversion.mod +++ b/lang/m2/libm2/Conversion.mod @@ -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); diff --git a/lang/m2/libm2/Epilogue.def b/lang/m2/libm2/Epilogue.def index d6ba14f37..ea6d6e9d9 100644 --- a/lang/m2/libm2/Epilogue.def +++ b/lang/m2/libm2/Epilogue.def @@ -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. diff --git a/lang/m2/libm2/RealConver.mod b/lang/m2/libm2/RealConver.mod index b2fd1c0d7..bcd21094d 100644 --- a/lang/m2/libm2/RealConver.mod +++ b/lang/m2/libm2/RealConver.mod @@ -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; diff --git a/lang/m2/libm2/catch.c b/lang/m2/libm2/catch.c index 5014a2fd3..2e6a4ae6d 100644 --- a/lang/m2/libm2/catch.c +++ b/lang/m2/libm2/catch.c @@ -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} }; diff --git a/lang/m2/libm2/halt.c b/lang/m2/libm2/halt.c index 3c8497957..d9571a191 100644 --- a/lang/m2/libm2/halt.c +++ b/lang/m2/libm2/halt.c @@ -1,5 +1,4 @@ -#define MAXPROCS 20 -#include +#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() -- 2.34.1