From ec423cb8d497b5894bb9da7529556b62e1f683b4 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 24 Aug 2012 20:37:00 +0000 Subject: [PATCH] Fix basic_filebuf's internal buffer is shrinking when using with some codecvt. http://llvm.org/bugs/show_bug.cgi?id=13602 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162585 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/fstream | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fstream b/include/fstream index 83731a1a1..aa78d85f3 100644 --- a/include/fstream +++ b/include/fstream @@ -596,7 +596,7 @@ basic_filebuf<_CharT, _Traits>::underflow() memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); - size_t __nmemb = _VSTD::min(static_cast(this->egptr() - this->eback() - __unget_sz), + size_t __nmemb = _VSTD::min(static_cast(__ibs_ - __unget_sz), static_cast(__extbufend_ - __extbufnext_)); codecvt_base::result __r; state_type __svs = __st_; @@ -611,7 +611,7 @@ basic_filebuf<_CharT, _Traits>::underflow() char_type* __inext; __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_, this->eback() + __unget_sz, - this->egptr(), __inext); + this->eback() + __ibs_, __inext); if (__r == codecvt_base::noconv) { this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_); @@ -816,6 +816,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) return pos_type(off_type(-1)); if (fseeko(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); + __st_ = __sp.state; return __sp; }