incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r640831 - /stdcxx/trunk/include/sstream.cc
Date Wed, 26 Mar 2008 16:00:19 GMT
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
>> Sent: Tuesday, March 25, 2008 5:11 PM
>> To: dev@stdcxx.apache.org
>> Subject: Re: svn commit: r640831 - /stdcxx/trunk/include/sstream.cc
>>
>> Any idea what caused it? I've gone through the recent history 
>> of the function and this looks like the likely change might 
>> be this one:
>>
>>    http://svn.apache.org/viewvc?view=rev&revision=442675
>>
>> but the test wasn't failing. Maybe because the test doesn't 
>> cause the buffer to reallocate?
> 
>   I think the bug introduced in
> http://svn.apache.org/viewvc?view=rev&revision=380995

Okay, thanks for the detective work! Looking at the test,
it does appear to exercise very long sequences (just like
in Mark's test case) so I should probably try to figure
why it didn't reveal such a blatant bug.

Martin

> since the overflow() and xsputn() started calling the str() for
> reallocate the buffer.
> 
> rev 442675:
> ---------------
> +    if (this->_C_is_out ()) {
> +        this->setp (this->_C_buffer, this->_C_buffer +
> this->_C_bufsize);
> +
> +        if (__s != __buf || this->_C_state & (ios_base::app |
> ios_base::ate))
> +            this->pbump (__slen);   // seek to end
>      }
> ---------------
> 
>  After that change setp() resets pptr to pbase, then pbump() seeks pptr
> to end always,
> when str() is called from xsputn() or overflow() (the str() is called to
> reallocate buffer,
> so __s != __buf). The original position of pptr is lost.
> 
> rev 442675:
> ---------------
>      if (this->_C_is_out ()) {
>          this->setp (this->_C_buffer, this->_C_buffer +
> this->_C_bufsize);
>  
> -        if (__s != __buf || this->_C_state & (ios_base::app |
> ios_base::ate))
> -            this->pbump (__slen);   // seek to end
> +        if (   __s != __buf && this->_C_state & ios_base::in
> +            || this->_C_state & (ios_base::app | ios_base::ate)) {
> +            // in input or append/ate modes seek to end
> +            // (see also lwg issue 562 for clarification)
> +            this->pbump (__slen);
> +        }
>      }
>  ---------------
> 
>   After that change setp() resets the pptr to pbase, then if _C_state &
> ios_base::in != 0
> then pbump() seeks pptr to end. In both cases the original position of
> pptr is lost.
> 
>   In STDCXX-515 the stringstream is used (_C_state & ios_base::in != 0)
> and subsequent
> output to stream is appended to end of the buffer despite of that pptr
> is not points to end
> due to seek(-1), ios_base::cur).
> 
>   In STDCXX-795 the ostringstream is used (_C_state & ios_base::in == 0)
> and subsequent
> output to stream is inserted from the begin of the buffer.
> 
> Farid.


Mime
View raw message