fixed wxDataInputStream::ReadString for empty strings

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2000-03-04 20:37:16 +00:00
parent 11eaa98105
commit 39a16cb41d

View File

@ -90,19 +90,23 @@ wxString wxDataInputStream::ReadString()
len = Read32(); len = Read32();
if (len > 0)
{
#if wxUSE_UNICODE #if wxUSE_UNICODE
char *tmp = new char[len + 1]; char *tmp = new char[len + 1];
m_input->Read(tmp, len); m_input->Read(tmp, len);
tmp[len] = 0; tmp[len] = 0;
wxString s(tmp); wxString s(tmp);
delete[] tmp; delete[] tmp;
#else #else
wxString s; wxString s;
m_input->Read(s.GetWriteBuf(len), len); m_input->Read(s.GetWriteBuf(len), len);
s.UngetWriteBuf(); s.UngetWriteBuf();
#endif #endif
return s;
return s; }
else
return wxEmptyString;
} }
wxDataInputStream& wxDataInputStream::operator>>(wxString& s) wxDataInputStream& wxDataInputStream::operator>>(wxString& s)
@ -203,8 +207,9 @@ void wxDataOutputStream::Write8(wxUint8 i)
void wxDataOutputStream::WriteString(const wxString& string) void wxDataOutputStream::WriteString(const wxString& string)
{ {
const wxWX2MBbuf buf = string.mb_str(); const wxWX2MBbuf buf = string.mb_str();
Write32(string.Length()); Write32(string.Len());
m_output->Write(buf, string.Len()); if (string.Len() > 0)
m_output->Write(buf, string.Len());
} }
// Must be at global scope for VC++ 5 // Must be at global scope for VC++ 5