Re: KI_FILE count precondition
"Bernd Schoeller" <[email protected]>
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Organization | ETH Zurich |
| Message-ID | <[email protected]> |
On Thu, 18 Jan 2007 18:45:59 +0100, Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]> wrote: > If this code is in Gobo then it needs to be fixed. Indeed there > is no guarantee that `read_string' will read `filesize' characters. > It could well be implemented to read only one character even if > the file is much bigger. So we need a loop until the end of file > is reached. Therefore the value of `filesize' that you provide is > arbitrary. Even more under Windows with the %R%N end-of-line. I understand and will fix the location ASAP, definitely before the release. The original code was not written by me, but obviously I didn't see the problem. Perhaps the documentation string of 'read_string' could be updated to say clearly that read_string might read less than specified. Obviously, I has to read at least one character. >> It would be best if there was a 'read_string(-1)' that would just read >> in >> everything available. > > This -1 is very ugly. This might be common practice in > other languages, but in Eiffel I would prefer to have a new > feature `read_all' or `read_to_end' or something like that. > Then I wonder whether this routine should write to `last_string' > or to a string given as argument (like `read_to_string'). True, I think such a functionality would be very helpful, as many people have probably the same problem and a common solution with a reasonable buffer size would prevent common mistakes. Bernd