From acc4028ecd99d2af4bff8e492a8187f8659e509a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 15 Oct 2002 22:46:25 +0000 Subject: [PATCH] fix binary incompatiblities in wxHtmlHelpController's cached data bytestream git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/html/helpdata.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index 4dcef850cf..02181732a7 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -307,22 +307,34 @@ inline static wxInt32 CacheReadInt32(wxInputStream *f) } inline static void CacheWriteString(wxOutputStream *f, const wxChar *str) -{ - size_t len = wxStrlen(str)+1; +{ +#if wxUSE_UNICODE + wxWX2MBbuf mbstr(wxConvUTF8.cWX2MB(str)); +#else + const wxChar *mbstr = str; +#endif + size_t len = strlen(mbstr)+1; CacheWriteInt32(f, len); - f->Write(str, len * sizeof(wxChar)); + f->Write(mbstr, len); } -inline static wxChar *CacheReadString(wxInputStream *f) +inline static wxChar* CacheReadString(wxInputStream *f) { - wxChar *str; + char *str; size_t len = (size_t)CacheReadInt32(f); - str = new wxChar[len]; - f->Read(str, len * sizeof(wxChar)); + str = new char[len]; + f->Read(str, len); +#if !wxUSE_UNICODE return str; +#else + wxMB2WXbuf wxstr(wxConvUTF8.cMB2WX(str)); + wxChar *outstr = new wxChar[wxStrlen(wxstr)+1]; + wxStrcpy(outstr, wxstr); + return outstr; +#endif } -#define CURRENT_CACHED_BOOK_VERSION 2 +#define CURRENT_CACHED_BOOK_VERSION 3 bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f) { @@ -331,7 +343,7 @@ bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f) /* load header - version info : */ version = CacheReadInt32(f); - + if (version != CURRENT_CACHED_BOOK_VERSION) { // NB: We can just silently return FALSE here and don't worry about