[v3] fix libstdc++/9827
jlquinn@optonline.net
jlquinn@optonline.net
Tue Feb 25 19:54:00 GMT 2003
----- Original Message -----
From: Pétur Runólfsson <peturr02@ru.is>
Date: Tuesday, February 25, 2003 12:27 pm
Subject: RE: [v3] fix libstdc++/9827
> > ostreambuf_iterator&
> > _M_put(const _CharT* __ws, streamsize __len)
> > {
> > - this->_M_sbuf->sputn(__ws, __len);
> > + if (this->_M_sbuf->sputn(__ws, __len) != __len)
> > + _M_failed = true;
> > return *this;
> > }
>
> I believe there is still a problem here: You
should only call sputn
> if failed() returns false.
No, failed() is used to test if the sputn succeeded
or not.
The original working code within num_put::put
(called by ostream::operator<<(int)) looked like:
*__s = c; ++__s
with __s being the ostream_iterator. The code
iterated over the string to be output. In this
case, it made N calls to operator=. Operator= tries
to write the char to the streambuf and sets
_M_failed if it can't. This is analogous, except it
writes a full string at once, and again, sets
_M_failed if it isn't able to write the string.
The test of failed() happens in ostream::operator<<()
More information about the Libstdc++
mailing list