http://llvm.org/bugs/show_bug.cgi?id=13602

             Bug #: 13602
           Summary: basic_filebuf's internal buffer is shrinking when
                    using with some codecvt.
           Product: libc++
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


When I replace the codecvt in fstream with my custom codecvt which is
converting char to char32_t, internal representation buffer size keep
shrinking. 

In fstream header file, underflow() call fread with egptr()-eback() as buffer
size and call codecvt->in() with egptr() as buffer end. Because internal
representation can be fewer characters than external representation, so
calculating read size by egptr() result in buffer shrinking. It should be
replace by __ibs_ and eback()+__ibs_ respectively.

line 594
size_t __nmemb = _VSTD::min(static_cast<size_t>(this->egptr() - this->eback() -
__unget_sz), static_cast<size_t>(__extbufend_ - __extbufnext_));

this->egptr() - this->back() should be replaced by __ibs_

line 603
 __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
                                       this->eback() + __unget_sz,
                                       this->egptr(), __inext);

this->egptr() need to be replaced by this->eback() + __ibs_

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to