chk(inputtext, reading);
WITH inputtext^ DO
IF eof THEN
- (* ??? trap here ??? *)
+ Traps.Message("unexpected EOF");
+ HALT;
END;
IF cnt > maxcnt THEN
dummy := FillBuf(inputtext);
ch: CHAR;
ok: BOOLEAN;
index: INTEGER;
+
+ PROCEDURE inch(): CHAR;
+ BEGIN
+ buf[index] := ch;
+ INC(index);
+ Get(inputtext);
+ RETURN NextCHAR(inputtext);
+ END inch;
+
BEGIN
index := 0;
WHILE NextCHAR(inputtext) IN spaces DO
END;
ch := NextCHAR(inputtext);
IF (ch ='+') OR (ch = '-') THEN
- buf[index] := ch;
- INC(index);
- Get(inputtext);
- ch := NextCHAR(inputtext);
+ ch := inch();
END;
IF (ch >= '0') AND (ch <= '9') THEN
WHILE (ch >= '0') AND (ch <= '9') DO
- buf[index] := ch;
- INC(index);
- Get(inputtext);
- ch := NextCHAR(inputtext);
+ ch := inch();
END;
IF (ch = '.') THEN
+ ch := inch();
IF (ch >= '0') AND (ch <= '9') THEN
WHILE (ch >= '0') AND (ch <= '9') DO
- buf[index] := ch;
- INC(index);
- Get(inputtext);
- ch := NextCHAR(inputtext);
+ ch := inch();
END;
ELSE
ok := FALSE;
END;
END;
IF ok AND (ch = 'E') THEN
- Get(inputtext);
- ch := NextCHAR(inputtext);
+ ch := inch();
IF (ch ='+') OR (ch = '-') THEN
- buf[index] := ch;
- INC(index);
- Get(inputtext);
- ch := NextCHAR(inputtext);
+ ch := inch();
END;
IF (ch >= '0') AND (ch <= '9') THEN
WHILE (ch >= '0') AND (ch <= '9') DO
- buf[index] := ch;
- INC(index);
- Get(inputtext);
- ch := NextCHAR(inputtext);
+ ch := inch();
END;
ELSE
ok := FALSE;
width := SIZE(buf);
END;
IF nfrac > 0 THEN
- RealConversions.RealToString(real, nfrac, width, buf, ok);
+ RealConversions.RealToString(real, width, nfrac, buf, ok);
ELSE
IF width < 9 THEN width := 9; END;
IF real < 0.0 THEN
ELSE
digits := 6 - INTEGER(width);
END;
- RealConversions.RealToString(real, digits, width, buf, ok);
+ RealConversions.RealToString(real, width, digits, buf, ok);
END;
WriteSTRING(outputtext, buf, 0);
END WriteREAL;
BEGIN
r := arg;
- DEC(width);
IF digits < 0 THEN
ecvtflag := TRUE;
ndigits := -digits;
ecvtflag := FALSE;
ndigits := digits;
END;
- IF HIGH(str) < ndigits + 3 THEN str[0] := 0C; ok := FALSE; RETURN END;
+ IF (HIGH(str) < ndigits + 3) THEN
+ str[0] := 0C; ok := FALSE; RETURN
+ END;
pointpos := 0;
sign := r < 0.0D;
IF sign THEN r := -r END;
END;
END;
END;
- str[ind1] := 0C;
IF ecvtflag THEN
FOR i := ind1 TO 2 BY -1 DO
str[i] := str[i-1];
INC(ind1);
END;
END;
- IF ind1 > CARDINAL(width) THEN
+ IF (ind1+1) <= HIGH(str) THEN str[ind1+1] := 0C; END;
+ IF ind1 >= CARDINAL(width) THEN
ok := FALSE;
RETURN;
END;
- IF ind1 < CARDINAL(width) THEN
+ IF width > 0 THEN
+ DEC(width);
+ END;
+ IF (width > 0) AND (ind1 < CARDINAL(width)) THEN
FOR i := ind1 TO 0 BY -1 DO
str[i + CARDINAL(width) - ind1] := str[i];
END;
str[i] := ' ';
END;
ind1 := CARDINAL(width);
+ IF (ind1+1) <= HIGH(str) THEN str[ind1+1] := 0C; END;
END;
- IF (ind1+1) <= HIGH(str) THEN str[ind1+1] := 0C; END;
END LongRealToString;