This is the mail archive of the
mailing list for the libstdc++ project.
Re: Doubts about in_avail vs showmanyc
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 4 Mar 2003 14:26:00 -0800
- Subject: Re: Doubts about in_avail vs showmanyc
- References: <3E650DC8.firstname.lastname@example.org>
On Tue, Mar 04, 2003 at 09:34:16PM +0100, Paolo Carlini wrote:
> Hi Nathan, hi everyone
> on second tought I have some doubts about your observations
> that showmanyc should return the _sum_ of of whatever is
> already in the buffer and what you get using recv/fstat.
I'm sorry to have made another mistake: ::fstat() tells the full
file size, so you would have to subtract the current position
from that, and ignore the count of characters still in the buffer
(unless it is more). But that's not your point...
> Let us consider again the current in_avail and showmanyc:
> Two observations: first, in_avail calls showmanyc() only when it's
> sure that there are _no_ chars in the buffer; second, showmanyc()
> does almost nothing currently, since it's called exactly
> when it can only return zero (or -1).
> Therefore, it seems that, in case there are actually chars in the
> buffer, it's in_avail which notice it _not_ showmanyc.
The descriptions of in_avail and showmanyc are different. The
former is supposed to tell you (quickly!) about what's buffered,
if any, where the latter is allowed to do more work and tell
whatever it can learn. It's protected, so it may be called by
derived classes and exposed to users. It is defined in terms of
what behavior can be expected from underflow, which is likewise
(only) protected and might be called with a non-empty buffer.
underflow() must return characters already buffered before it
starts returning newly-read characters or EOF. So, the smallest
value showmanyc should return is egptr()-gptr(), but it might
Users can call in_avail() in a loop, and it might be more efficient
if they can read chunks bigger than BUFSIZ.
ncm-nospam at cantrip dot org