Re: issue-#63 fixes in StdStamps
Posted: Thu Nov 05, 2015 1:10 pm
OK. Anything else?
- Josef
- Josef
There is always something else ...Josef Templ wrote:OK. Anything else?
If fact I did it a few times accidently before I realised what was happening!Josef Templ wrote:This makes it unlikely ...
Code: Select all
PROCEDURE (v: StdView) Internalize (VAR rd: Stores.Reader);
VAR version: INTEGER; format: BYTE; k, purge, i, len,: INTEGER;
d: Dates.Date; t: Dates.Time;
f: Fmtrs.Fmtr;
BEGIN
v.Internalize^(rd);
IF ~rd.cancelled THEN
rd.ReadVersion(minVersion, maxVersion, version);
IF ~rd.cancelled THEN
IF version = origStampVersion THEN (* deal with old StdStamp format *)
(* would like to calculate fingerprint, but hosting model not available at this time *)
NEW(v.history, maxHistoryEntries);
v.history[0].fprint := 0;
v.history[0].snr := 1; v.nentries := 1;
rd.ReadXInt(d.year); rd.ReadXInt(d.month); rd.ReadXInt(d.day);
rd.ReadXInt(t.hour); rd.ReadXInt(t.minute); rd.ReadXInt(t.second);
rd.ReadByte(format); (* format not used anymore *)
v.history[0].date := Dates.Day(d);
v.history[0].time := t.minute + t.hour*64;
ELSE
f := Fmtrs.Log({});
IF version = noSnrVersion THEN NEW(v.history, maxHistoryEntries); rd.ReadInt(v.history[0].snr) END;
rd.ReadXInt(v.nentries);
f.IntLn(v.nentries, 4);
IF version > noSnrVersion THEN NEW(v.history, MAX(v.nentries, maxHistoryEntries)) END;
purge := 0;
FOR k := 0 TO v.nentries-1 DO
i := k - purge;
rd.ReadInt(v.history[i].fprint);
IF version > noSnrVersion THEN rd.ReadInt(v.history[i].snr)
ELSIF (* (version = noSnrVersion) & *) i > 0 THEN v.history[i].snr := v.history[i-1].snr - 1;
END;
rd.ReadInt(v.history[i].date);
rd.ReadXInt(v.history[i].time);
rd.ReadXInt(len);
IF len > 0 THEN
NEW(v.history[i].comment, len + 1);
IF version >= wideCommentVersion THEN
rd.ReadString(v.history[i].comment)
ELSE
rd.ReadXString(v.history[i].comment)
END
ELSE v.history[i].comment := NIL
END;
f.Int(i, 4);
f.Int(v.history[i].date,8);
f.IntStr(v.history[i].snr,8, ' ');
f.SetAsHex(BITS(v.history[i].fprint));
IF v.history[i].comment # NIL THEN f.Str(' ' + v.history[i].comment) END;
IF (i > 0) & (v.history[i].date = v.history[i-1].date) THEN
IF v.history[i-1].comment = NIL THEN
f.Str (' Previous comment empty');
v.history[i-1].comment := v.history[i].comment; INC(purge)
ELSIF v.history[i].comment = NIL THEN
f.Str (' This comment empty');
INC(purge)
END
END;
f.Ln
END;
DEC(v.nentries, purge);
IF version < wideCommentVersion THEN (* cleanup *)
i := v.nentries - 1;
WHILE (i > 0) & (v.history[i].date = 0) DO DEC(i); DEC(v.nentries) END
END
END
END
END
END Internalize;