This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: filebuf.in_avail


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

From: Dietmar Kuehl <dietmar_kuehl@yahoo.com>
Sent: 08 June 2000 03:28
> Hi,
> 
> --- brent verner <brent@rcfile.org> wrote:
> > my reading of this is that in_avail() should return -1 when EOF
> > ... 
> 
> Correct.
> 
> > I can't see where it _could_ return 0;
> 
> It will often return '0': The intentation of 'in_avail()' is to
> determine how many characters can be read without running the risk
> of blocking. Once a file is exhausted and the position sits at the
> [current] end of the file, 'in_avail()' will return '0' but not
> EOF! The file, even a non-special file might grow. Thus, if a user
> read right to the end but not beyond, EOF is not reached and
> 'in_avail()' returns '0'. Actually, 'in_avail()' might even return
> '0' in the middle of a file, namely when hitting the boundary of a
> buffer: It is QoI issue whether 'showmanyc()' tries to be clever
> and determine a better approximation than what is known to the
> stream buffer any.  
> 
> It is important to note that there is a difference between EOF and
> sitting at the end of a file: After EOF is reached, no character
> will be available from the stream. If a stream sits currently at
> the end of the file, there may be characters available in the
> future.  

OK, so if I open a file that happens to be empty (maybe it was
created by the open), but don't read from it, am I at EOF, or just
sitting at the end of the file? I think "just sitting at the end of
the file", and thus in_avail() should return 0. If I attempt to read
from it, then I hit EOF, and in_avail() should return -1.

Anthony

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.1 for non-commercial use <http://www.pgp.com>
Comment: PGP Key at: http://i3.yimg.com/3/c7e5ee24/g/68fc2307.asc

iQA/AwUBOT9ZwZvw+P4cG5rVEQKI1gCeJ+1saGkuKGkMVEBu8RUHOM358mcAn0rr
xKO3l2Ov6ZlBIfPdUi4j5OM5
=lA1w
-----END PGP SIGNATURE-----



__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]