gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] POSIX spec expert needed


From: Andrew Suffield
Subject: Re: [Gnu-arch-users] POSIX spec expert needed
Date: Tue, 31 Aug 2004 00:33:15 +0100
User-agent: Mutt/1.5.6+20040818i

On Mon, Aug 30, 2004 at 05:27:34PM -0500, Matthew Dempsky wrote:
> >> Also, that after:
> >> 
> >>           amt = vu_read_retry (errn, file_fd, buf, sizeof (buf));
> >> 
> >> when buf is defined to 'char buf[1025]' that we will be missing the
> >> last (possibly newline) byte of the file?
> >
> > No, see above. These operations aren't atomic; there might be more
> > data. Just keep reading until you run out of file - treat the seek as
> > an optimisation hint, rather than a part of the algorithm.
> 
> Again, see above -- no external operations.

You really can't assume that. Any twit with an editor can break this;
extend the file at the wrong moment and you'll miss the tagline
completely.

> And how do you figure vu_read_retry could keep reading until it hits
> the end of the file if it's only called once and the buffer is fixed
> at 1025 bytes?

Call it differently. I'd do it with a pair of alternating buffers.

-- 
  .''`.  ** Debian GNU/Linux ** | Andrew Suffield
 : :' :  http://www.debian.org/ |
 `. `'                          |
   `-             -><-          |

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]