This is the mail archive of the libstdc++@gcc.gnu.org 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]
Other format: [Raw text]

Re: [Patch] Fix libstdc++/9533


On Tue, Mar 04, 2003 at 02:52:05PM +0100, Paolo Carlini wrote:
> Nathan Myers wrote:
> 
> >No.  If there is a codecvt<> involved (is there? I didn't look, 
> >I thought that was a filebuf<> thing) then showmanyc() should divide 
> >the number of bytes by the maximum character size, 
> >std::codecvt<>::max_length().  Remember it's returning an estimate,
> >a lower bound, and shouldn't be doing too much work.
> >
> That's the key point, thanks!
> Just a lower bound, so max_length() suffices and we are done once and 
> for all even for
> encodings -1 (not yet implemented) and 0 (partially so).

One more thing: for a stateful encoding, the most you can return 
is 0 unless you have converted characters already in the buffer.  
The pending sequence might be just shift and unshift prefixes with 
no actual character.  (The return value is the sum of whatever is 
already in the buffer and what you get using recv/fstat.  You only
return -1 if the buffer is empty *and* you're sure there's nothing
else to come.)

BTW, if filebuf is doing unnecessary work in open(), or in its 
constructor, that's to fix too.

Nathan Myers
ncm-nospame at cantrip dot org


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