===================================================================
@@ -120,10 +120,15 @@
K : Natural := Natural (P - S);
begin
- -- Now Buf (K + 2) should be 0, or otherwise Buf (K) is the 0
- -- put in by fgets, so compensate.
+ -- If K + 2 is greater than N, then Buf (K + 1) cannot be a LM
+ -- character from the source file, as the call to fgets copied at
+ -- most N - 1 characters. Otherwise, either LM is a character from
+ -- the source file and then Buf (K + 2) should be 0, or LM is a
+ -- character put in Buf by memset and then Buf (K) is the 0 put in
+ -- by fgets. In both cases where LM does not come from the source
+ -- file, compensate.
- if K + 2 > Buf'Last or else Buf (K + 2) /= ASCII.NUL then
+ if K + 2 > N or else Buf (K + 2) /= ASCII.NUL then
-- Incomplete last line, so remove the extra 0