stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Everton Araujo" <everton.ba...@gmail.com>
Subject STDCXX-522 - v2
Date Fri, 17 Aug 2007 02:34:08 GMT
Hi,

Sorry, I was wrong about the fix of issue STDCXX-522 because it worked for
issue test code, but I've forgot to run test 27 and we I ran that ...
oooops! 75% assertations :-(
I went get more coffee and restart debugging, and with the following changes
in fstream, test on both codes (issue and 27) was successfully.

Following is the overflow code changed (diffs are bold):

template<class _CharT, class _Traits>
_TYPENAME basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
overflow (int_type __c /* = eof () */)
{
    _RWSTD_ASSERT (this->_C_is_valid ());

    if (!this->_C_is_out () || !is_open ())
        return traits_type::eof ();

    this->setg (0, 0, 0);            // invalidate the get area

    const bool __unbuf = this->_C_is_unbuffered ();

    const char_type __c_to_char = traits_type::to_char_type (__c);

    if (this->pptr () == 0 && !__unbuf) {
        // put area not valid yet - just need to initialize it
        this->setp (this->_C_buffer, this->_C_buf_end ());
    }
    else if (   this->pptr () == this->epptr ()
             || this->_C_is_eof (__c)
             || __unbuf) {

        const char_type*  __buf;
        _RWSTD_STREAMSIZE __nchars;

        if (__unbuf) {
          if(this->_C_is_eof(__c)){
            _C_cur_pos.state (0);
            __buf   = 0;
            __nchars = 0;
          }
          else{
            __buf    = &__c_to_char;
            __nchars = 1;
          }
        }
        else {
            // call xsputn() with a special value to have it flush
            // the controlled sequence to the file
            __buf    = _RWSTD_REINTERPRET_CAST (char_type*, this);
            __nchars = this->pptr () - this->pbase ();
        }

        // typedef helps HP aCC 3.27
        typedef basic_filebuf _FileBuf;

        if (__nchars && __nchars != _FileBuf::xsputn (__buf, __nchars))
            return traits_type::eof ();  // error while writing
    }

    // now that there's room in the buffer, call sputc() recursively
    // to actually place the character in the buffer (unless we're
    // in unbuffered mode because we just wrote it out)
    if (!this->_C_is_eof (__c) && !__unbuf)
        this->sputc (__c_to_char);

    this->_C_out_last (true);   // needed by close ()

    return traits_type::not_eof (__c);
}

Hope it helps.

Everton.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message