[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ooc-980713 & oo2c-1.3.8
Ian Rae <ianrae@istar.ca> wrote:
> 1.3.8 works fine for all 3 eol types.
>
> one small gripe:
> ReadLine returns readAfterEnd on the last line of a text
> file if no eol exists for that line. Since there is generally
> no guarantee of eol on the last line, especially for user-
> created files (it just depends whether you hit enter or not
> after typing the last line), this behaviour is a bit odd.
> Certainly gets() in C has more forgiving logic: "read until
> eol or eof".
The behavior of ReadLine that you describe matches the spec:
Method: `(R: Reader)' ReadLine `(VAR S: ARRAY OF CHAR)'
Reads a sequence of characters into S until an end-of-line
character is encountered, or the array S is full. The end-of-line
character is discarded and S is always terminated with `0X'.
If the end of the channel is reached before encountering an
end-of-line character, a `readAfterEnd' error occurs.
If S is not large enough to hold the entire input, a
`valueOutOfRange' error occurs.
(1) Upon encountering an error, the value of S is undefined.
*Please note:* If the channel is already positioned at an
end-of-line character, this method returns an empty string.
However,
> This isn't a huge issue. I can live with it since the implementation
> still returns the last line, but perhaps this issue should be put
> on a wish list and if lots of people raise it, then fix it in a later
> release.
(1) says that there is no valid way to read the last line if it is not
terminated by an EOL (even though, in the current implementation, S does
contain the value of the last line). IMO, the spec should be changed to
Method: `(R: Reader)' ReadLine `(VAR S: ARRAY OF CHAR)'
Reads a sequence of characters into S; reading continues until an
end-of-line character is encountered, the array S is full, or R reaches
the end of the channel. The end-of-line character is discarded and S
is always terminated with `0X'.
If R is already positioned at an end-of-line character,
S returns as an empty string.
If S is not large enough to hold the entire input, a
`valueOutOfRange' error occurs; S returns with the sequence of
characters that have been read so far (terminated by `0X').
If R has already reached the end of the channel (i.e., there are no
more characters left to read), a `readAfterEnd' error occurs and S
returns as an empty string.
Eric