- size_t bufsize = m_o_streambuf->GetBufferEnd() - m_o_streambuf->GetBufferStart();
- size_t oldpos = m_o_streambuf->GetIntPosition();
- m_o_streambuf->Write(buffer, nbytes);
- size_t newpos = m_o_streambuf->GetIntPosition();
- if (newpos == 0) return bufsize - oldpos;
- else return newpos - oldpos;
+ size_t oldpos = m_o_streambuf->GetIntPosition();
+ m_o_streambuf->Write(buffer, nbytes);
+ size_t newpos = m_o_streambuf->GetIntPosition();
+
+ // FIXME can someone please explain what this does? (VZ)
+ if ( !newpos )
+ newpos = m_o_streambuf->GetBufferSize();
+
+ return newpos - oldpos;