view growbuf read until() suggestion
Roland Illig
roland.illig at gmx.de
Sat Aug 6 02:03:05 UTC 2005
Pavel Tsekov wrote:
> Of course you might still be right in assuming that fread() may return less
> bytes than requested. I can imagine that it could happen with a fdopen()-ed
> FILE which has a file descriptor in non-blocking mode. This is of coure just
> speculation. Of course, calls to feof() and ferror() could be added to
> detect the situation where the read didn't fail but still returned less
> data.
ISO C99, 7.19.3p3:
[...] characters may be accumulated to or from the host environment as a
block. [...] characters are intended to be transmitted [...] when a
block is filled. [...]
The relevant part is the "may" and "are intended to". These are not
strict requirements, so we cannot rely on it.
My patch has the side effect that mcview reads one byte more than
strictly necessary in some situations. As it already reads data in
blocks of 8k, this should not harm.
Roland
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: view.c.patch
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20050806/04a0e407/attachment.ksh>
More information about the mc-devel
mailing list