This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: [Patch] Fix libstdc++/13582
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Paolo Carlini" <pcarlini at suse dot de>,"libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 9 Jan 2004 15:16:36 -0000
- Subject: RE: [Patch] Fix libstdc++/13582
Paolo Carlini wrote:
> Whee!
! 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. The testcases in the
patch would probably catch this one if they were changed to use char
instead of wchar_t.
! // 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.
This should be easy to check with:
wfilebuf fb;
fb.open(...); // Some file containing the text "12345"
fb.sbumpc(); // should return '1'
fb.pubimbue(...);
fb.pubseekoff(0, ios_base::cur); // should succeed
fb.sbumpc(); // should return '2'
Petur