view growbuf read until() suggestion
Pavel Tsekov
ptsekov at gmx.net
Fri Aug 5 21:29:06 UTC 2005
Hello,
> --- Ursprüngliche Nachricht ---
> Von: Roland Illig
> An: MC dev
> Betreff: Re: view_growbuf_read_until() suggestion
> Datum: Fri, 05 Aug 2005 18:53:42 +0200
>
> Pavel Tsekov wrote:
> > I forgot to attach the patch in the original message.
> >
> > On Fri, 5 Aug 2005, Pavel Tsekov wrote:
> >
> >
> >>Hello Roland,
> >>
> >>There is a small "bug" in the new viewer code. When the viewer is used
> in
> >>growing buffer mode it incorrectly displays in the status bar ">= size"
> >>even if the data source was exhausted and despite the fact the the
> >>size of the whole buffer is known. Please, take a look at the attached
> >>patch for a idea how to fix it. Of course you could find a better way to
> >>solve this since you know the code better.
>
> I confirm that the "bug" does not look nice. But your code has a little
> problem. It _might_ report a too small file size.
>
> > nread = fread (p, 1, bytesfree, view->ds_stdio_pipe);
> > - if (nread == 0) {
> > + if (nread > 0)
> > + view->growbuf_lastindex += nread;
> > + if (nread < bytesfree) {
>
> Nothing in the C standard prevents fread from always returning only one
> element instead of ''bytesfree''. It's just a "quality of
> implementation" that most system's fread(3) function calls read(2)
> repeatedly until either EOF is reached or the necessary number of bytes
> is read.
[...]
RETURN VALUES
The functions fread() and fwrite() advance the file position indicator
for the stream by the number of bytes read or written. They return the
number of objects read or written. If an error occurs, or the end-of-
file is reached, the return value is a short object count (or zero).
[...]
[...]
Note that popen() output streams are fully buffered by default.
[...]
--
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++
More information about the mc-devel
mailing list