X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/319106d6e2c158d1ff322ee14a4b5c8e7154900c..76b0f8384ed211c5f6b48597a62da743b604e666:/src/html/htmlpars.cpp?ds=inline diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 0b43365821..0e38da7bc4 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -2,7 +2,6 @@ // Name: src/html/htmlpars.cpp // Purpose: wxHtmlParser class (generic parser) // Author: Vaclav Slavik -// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -227,7 +226,7 @@ void wxHtmlParser::CreateDOMSubTree(wxHtmlTag *cur, else { while (i < end_pos && *i != wxT('>')) ++i; - textBeginning = i+1; + textBeginning = i < end_pos ? i+1 : i; } } else ++i; @@ -250,8 +249,7 @@ void wxHtmlParser::DestroyDOMTree() } m_Tags = m_CurTag = NULL; - delete m_TextPieces; - m_TextPieces = NULL; + wxDELETE(m_TextPieces); } void wxHtmlParser::DoParsing() @@ -433,7 +431,7 @@ void wxHtmlTagHandler::ParseInnerSource(const wxString& source) IMPLEMENT_DYNAMIC_CLASS(wxHtmlEntitiesParser,wxObject) wxHtmlEntitiesParser::wxHtmlEntitiesParser() -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE : m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM) #endif { @@ -441,14 +439,14 @@ wxHtmlEntitiesParser::wxHtmlEntitiesParser() wxHtmlEntitiesParser::~wxHtmlEntitiesParser() { -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE delete m_conv; #endif } +#if !wxUSE_UNICODE void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) { -#if wxUSE_WCHAR_T && !wxUSE_UNICODE if (encoding == m_encoding) return; @@ -459,10 +457,8 @@ void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) m_conv = NULL; else m_conv = new wxCSConv(wxFontMapper::GetEncodingName(m_encoding)); -#else - (void) encoding; -#endif } +#endif // !wxUSE_UNICODE wxString wxHtmlEntitiesParser::Parse(const wxString& input) const { @@ -523,7 +519,6 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input) const #if !wxUSE_UNICODE wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const { -#if wxUSE_WCHAR_T char buf[2]; wchar_t wbuf[2]; wbuf[0] = (wchar_t)code; @@ -532,9 +527,6 @@ wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) return '?'; return buf[0]; -#else - return (code < 256) ? (wxChar)code : '?'; -#endif } #endif @@ -876,10 +868,14 @@ wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity) const return GetCharForCode(code); } -wxFSFile *wxHtmlParser::OpenURL(wxHtmlURLType WXUNUSED(type), +wxFSFile *wxHtmlParser::OpenURL(wxHtmlURLType type, const wxString& url) const { - return m_FS ? m_FS->OpenFile(url) : NULL; + int flags = wxFS_READ; + if (type == wxHTML_URL_IMAGE) + flags |= wxFS_SEEKABLE; + + return m_FS ? m_FS->OpenFile(url, flags) : NULL; } @@ -960,12 +956,14 @@ wxHtmlParser::SkipCommentTag(wxString::const_iterator& start, wxString::const_iterator p = start; - // comments begin with "