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


on Wed, Jun 07, 2000 at 02:04:20PM +0100, Anthony Williams typed aloud:
| -----BEGIN PGP SIGNED MESSAGE-----
| Hash: SHA1
| 
| For an empty file, filebuf.in_avail() returns -1, which is checked
| for in the test suite.
| 
| However, I wonder whether this is in fact compliant. Surely it makes
| no sense to be able to retrieve -1 characters without error? Isn't
| zero a far more sensible value?
| It certainly wouldn't be in violation of the standard for an
| implementation to return zero, so this ought to be permitted in the
| testsuite.

27.5.2.2.3
streamsize in_avail();

Returns: If a read position is available, returns egptr() - gptr(). 
Otherwise returns showmanyc() (27.5.2.4.3).

...

27.5.2.4.3
streamsize showmanyc();

Returns: an estimate of the number of characters available in the
sequence, or -1. If it returns a positive value, then successive
calls to underflow() will not return traits::eof() until at least
that number of characters have been supplied. If showmanyc() returns
-1, then calls to underflow() or uflow() will fail.

underflow() returns traits::eof() to indicate failure.


my reading of this is that in_avail() should return -1 when EOF ...
I can't see where it _could_ return 0;

(first time reading the _real_ standard, so I could be _all_ wrong ;)

  Brent

-- 
Damon Brent Verner
Cracker JackŪ Certified Professional
brent@rcfile.org, brent@linux1.org

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