[Patch] Fix libstdc++/13582

Paolo Carlini pcarlini@unitus.it
Fri Jan 9 15:47:00 GMT 2004


Pétur Runólfsson wrote:

>! 	      if (__check_facet(_M_codecvt).always_noconv())
>! 		__testvalid = this->seekoff(0, ios_base::cur, this->_M_mode)
>! 		              != pos_type(off_type(-1));
>
>When always_noconv() returns true for both the old and new locale, it
>should be sufficient to do absolutely nothing.
>
Yes, I noticed that this was the case but considered this case not so 
important.
Agreed, anyway, let's do the right thing here too!

>! 		  // External position corresponding to gptr().		  
>! 		  _M_ext_next = _M_ext_buf
>! 		    + _M_codecvt->length(_M_state_last, _M_ext_buf, _M_ext_next,
>! 					 this->gptr() - this->eback());
>! 		  _M_reading = false;
>! 		  _M_set_buffer(-1);
>
>I suspect that this is wrong if overflow() or seekoff(..., ios::cur)
>are called after the call to imbue. Since the file pointer isn't
>backed up, _M_reading should be left as true so overflow() won't get
>confused.
>
>seekoff() will back up the file pointer if needed, but only if
>_M_reading is true. It also requires _M_ext_buf to match eback() and
>_M_ext_next to match egptr(). After the call to _M_set_buffer, egptr()
>will equal eback(), so _M_ext_next should also equal _M_ext_buf.
>
I see, ok.

Will do those changes, complete the testcases and repost...

Thanks!
Paolo.



More information about the Libstdc++ mailing list