X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/259d1674f293dcb7bbc0fa1c38392d899ce71bc0..6627a4b0497f89221ea9f7848990f8830cf81b7e:/src/html/htmlhelp_io.cpp diff --git a/src/html/htmlhelp_io.cpp b/src/html/htmlhelp_io.cpp index 001f085a39..fa9a4c39fc 100644 --- a/src/html/htmlhelp_io.cpp +++ b/src/html/htmlhelp_io.cpp @@ -6,6 +6,11 @@ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// +#error This file should not be compiled! Update your build system! \ +(configure users, rerun configure to get a new Makefile) \ +Instead of htmlhelp[_io], use helpdata, helpfrm and helpctrl. This \ +file is only left to point out the problem and will be removed r.s.n. + //#ifdef __GNUG__ //#pragma implementation "htmlhelp.h" @@ -78,9 +83,9 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag) m_Items = (HtmlContentsItem*) realloc(m_Items, (m_ItemsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem)); m_Items[m_ItemsCnt].m_Level = m_Level; m_Items[m_ItemsCnt].m_ID = m_ID; - m_Items[m_ItemsCnt].m_Page = (char*) malloc(m_Page.Length() + 1); + m_Items[m_ItemsCnt].m_Page = new char[m_Page.Length() + 1]; strcpy(m_Items[m_ItemsCnt].m_Page, m_Page.c_str()); - m_Items[m_ItemsCnt].m_Name = (char*) malloc(m_Name.Length() + 1); + m_Items[m_ItemsCnt].m_Name = new char [m_Name.Length() + 1]; strcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str()); m_Items[m_ItemsCnt].m_Book = m_Book; m_ItemsCnt++; @@ -127,30 +132,32 @@ void wxHtmlHelpController::LoadMSProject(HtmlBookRecord *book, wxFileSystem& fsy HP_TagHandler *handler = new HP_TagHandler(book); parser.AddTagHandler(handler); - f = fsys.OpenFile(contentsfile); + // Don't panic if no index or contensfile is supplied. + // (without contents is a bit useless, but leaving out the index is sometimes handy) + f = ( contentsfile.IsEmpty() ? NULL : fsys.OpenFile(contentsfile) ); if (f) { sz = f -> GetStream() -> GetSize(); - buf = (char*) malloc(sz+1); + buf = new char[sz+1]; buf[sz] = 0; f -> GetStream() -> Read(buf, sz); delete f; handler -> ReadIn(m_Contents, m_ContentsCnt); parser.Parse(buf); handler -> WriteOut(m_Contents, m_ContentsCnt); - free(buf); + delete[] buf; } - f = fsys.OpenFile(indexfile); + f = ( indexfile.IsEmpty() ? NULL : fsys.OpenFile(indexfile) ); if (f) { sz = f -> GetStream() -> GetSize(); - buf = (char*) malloc(sz+1); + buf = new char[sz+1]; buf[sz] = 0; f -> GetStream() -> Read(buf, sz); delete f; handler -> ReadIn(m_Index, m_IndexCnt); parser.Parse(buf); handler -> WriteOut(m_Index, m_IndexCnt); - free(buf); + delete[] buf; } if (show_wait_msg) delete busyinfo; } @@ -177,10 +184,10 @@ void wxHtmlHelpController::LoadCachedBook(HtmlBookRecord *book, wxInputStream *f f -> Read(&x, sizeof(x)); m_Contents[i].m_ID = x; f -> Read(&x, sizeof(x)); - m_Contents[i].m_Name = (char*) malloc(x); + m_Contents[i].m_Name = new char[x]; f -> Read(m_Contents[i].m_Name, x); f -> Read(&x, sizeof(x)); - m_Contents[i].m_Page = (char*) malloc(x); + m_Contents[i].m_Page = new char[x]; f -> Read(m_Contents[i].m_Page, x); m_Contents[i].m_Book = book; } @@ -193,10 +200,10 @@ void wxHtmlHelpController::LoadCachedBook(HtmlBookRecord *book, wxInputStream *f m_Index = (HtmlContentsItem*) realloc(m_Index, (m_IndexCnt / HTML_REALLOC_STEP + 1) * HTML_REALLOC_STEP * sizeof(HtmlContentsItem)); for (i = st; i < m_IndexCnt; i++) { f -> Read(&x, sizeof(x)); - m_Index[i].m_Name = (char*) malloc(x); + m_Index[i].m_Name = new char[x]; f -> Read(m_Index[i].m_Name, x); f -> Read(&x, sizeof(x)); - m_Index[i].m_Page = (char*) malloc(x); + m_Index[i].m_Page = new char[x]; f -> Read(m_Index[i].m_Page, x); m_Index[i].m_Book = book; } @@ -247,4 +254,4 @@ void wxHtmlHelpController::SaveCachedBook(HtmlBookRecord *book, wxOutputStream * } } -#endif \ No newline at end of file +#endif