else
{
while (i < end_pos && *i != wxT('>')) ++i;
- textBeginning = i+1;
+ textBeginning = i < end_pos ? i+1 : i;
}
}
else ++i;
}
m_Tags = m_CurTag = NULL;
- delete m_TextPieces;
- m_TextPieces = NULL;
+ wxDELETE(m_TextPieces);
}
void wxHtmlParser::DoParsing()
IMPLEMENT_DYNAMIC_CLASS(wxHtmlEntitiesParser,wxObject)
wxHtmlEntitiesParser::wxHtmlEntitiesParser()
-#if wxUSE_WCHAR_T && !wxUSE_UNICODE
+#if !wxUSE_UNICODE
: m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM)
#endif
{
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;
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
{
#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;
if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1)
return '?';
return buf[0];
-#else
- return (code < 256) ? (wxChar)code : '?';
-#endif
}
#endif
ENTITY("amp", 38),
ENTITY("and", 8743),
ENTITY("ang", 8736),
+ ENTITY("apos", 39),
ENTITY("aring", 229),
ENTITY("asymp", 8776),
ENTITY("atilde", 227),
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;
}
wxString::const_iterator p = start;
- // comments begin with "<!--" in HTML 4.0
- if ( p > end - 3 || *++p != '!' || *++p != '-' || *++p != '-' )
- {
- // not a comment at all
- return false;
- }
+ // Comments begin with "<!--" in HTML 4.0; anything shorter or not containing
+ // these characters is not a comment and we're not going to skip it.
+ if ( ++p == end || *p != '!' )
+ return false;
+ if ( ++p == end || *p != '-' )
+ return false;
+ if ( ++p == end || *p != '-' )
+ return false;
// skip the start of the comment tag in any case, if we don't find the
// closing tag we should ignore broken markup