conversion routinew now initialize whole array, Epilogue module changed slightly
This commit is contained in:
parent
355fa2c764
commit
99611d287b
5 changed files with 15 additions and 7 deletions
|
@ -28,7 +28,10 @@ IMPLEMENTATION MODULE Conversions;
|
||||||
r := 0;
|
r := 0;
|
||||||
WHILE len > i DO str[r] := ' '; INC(r); DEC(len); END;
|
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;
|
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;
|
END ConvertNum;
|
||||||
|
|
||||||
PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
|
PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
|
||||||
|
|
|
@ -4,10 +4,12 @@ DEFINITION MODULE Epilogue;
|
||||||
is no mechanism to have some code executed when the program finishes.
|
is no mechanism to have some code executed when the program finishes.
|
||||||
This module is a feeble attempt at solving this problem.
|
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
|
(* Add procedure "p" to the list of procedures that must be executed when
|
||||||
the program finishes.
|
the program finishes.
|
||||||
When the program finishes, these procedures are executed in the order in
|
When the program finishes, these procedures are executed in the order in
|
||||||
which they were added to the list.
|
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.
|
END Epilogue.
|
||||||
|
|
|
@ -202,7 +202,11 @@ IMPLEMENTATION MODULE RealConversions;
|
||||||
str[i] := ' ';
|
str[i] := ' ';
|
||||||
END;
|
END;
|
||||||
ind1 := CARDINAL(width);
|
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;
|
||||||
|
|
||||||
END LongRealToString;
|
END LongRealToString;
|
||||||
|
|
|
@ -35,7 +35,6 @@ static struct errm {
|
||||||
{ M2_NORESULT, "no RETURN from procedure function"},
|
{ M2_NORESULT, "no RETURN from procedure function"},
|
||||||
{ M2_UOVFL, "cardinal overflow"},
|
{ M2_UOVFL, "cardinal overflow"},
|
||||||
{ M2_FORCH, "Warning: FOR-loop control variable was changed in the body"},
|
{ 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}
|
{ -1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#define MAXPROCS 20
|
#define MAXPROCS 16
|
||||||
#include <m2_traps.h>
|
|
||||||
|
|
||||||
static int callindex;
|
static int callindex;
|
||||||
static int (*proclist[MAXPROCS])();
|
static int (*proclist[MAXPROCS])();
|
||||||
|
@ -17,11 +16,12 @@ CallAtEnd(p)
|
||||||
int (*p)();
|
int (*p)();
|
||||||
{
|
{
|
||||||
if (callindex >= MAXPROCS) {
|
if (callindex >= MAXPROCS) {
|
||||||
TRP(M2_ENDPROCS);
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
proclist[callindex++] = p;
|
proclist[callindex++] = p;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_halt()
|
_halt()
|
||||||
|
|
Loading…
Add table
Reference in a new issue