conversion routinew now initialize whole array, Epilogue module changed slightly

This commit is contained in:
ceriel 1988-01-28 16:37:55 +00:00
parent 355fa2c764
commit 99611d287b
5 changed files with 15 additions and 7 deletions

View 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);

View 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.

View 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;

View 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}
};

View 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()