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: RE: [v3] fix libstdc++/9827



----- Original Message -----
From: Pétur Runólfsson <peturr02 at ru dot 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<<()




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