X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/daa616fca06ce77df132d31eda6d1f829b449aad..0f2ecc913ba8f6998a3c77001e20210aca0b9d0a:/src/html/htmlpars.cpp diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index dc572b0a89..612f74bbfe 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -22,7 +22,8 @@ #endif #ifndef WXPRECOMP -#include "wx/wx.h" + #include "wx/log.h" + #include "wx/intl.h" #endif #include "wx/tokenzr.h" @@ -40,8 +41,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject) -wxHtmlParser::wxHtmlParser() - : wxObject(), m_Cache(NULL), m_HandlersHash(wxKEY_STRING), +wxHtmlParser::wxHtmlParser() + : wxObject(), m_Cache(NULL), m_HandlersHash(wxKEY_STRING), m_FS(NULL), m_HandlersStack(NULL) { m_entitiesParser = new wxHtmlEntitiesParser; @@ -97,22 +98,22 @@ void wxHtmlParser::DoParsing(int begin_pos, int end_pos) templen = 0; i = begin_pos; - while (i < end_pos) + while (i < end_pos) { c = m_Source[(unsigned int) i]; // continue building word: - if (c != '<') + if (c != '<') { temp[templen++] = c; i++; } - else if (c == '<') + else if (c == '<') { - wxHtmlTag tag(m_Source, i, end_pos, m_Cache); + wxHtmlTag tag(m_Source, i, end_pos, m_Cache, m_entitiesParser); - if (templen) + if (templen) { temp[templen] = 0; AddText(temp); @@ -124,7 +125,7 @@ void wxHtmlParser::DoParsing(int begin_pos, int end_pos) } } - if (templen) + if (templen) { // last word of block :-( temp[templen] = 0; AddText(temp); @@ -140,7 +141,7 @@ void wxHtmlParser::AddTag(const wxHtmlTag& tag) h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName()); if (h) inner = h->HandleTag(tag); - if (!inner) + if (!inner) { if (tag.HasEnding()) DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); @@ -166,7 +167,7 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags) wxStringTokenizer tokenizer(tags, ", "); wxString key; - if (m_HandlersStack == NULL) + if (m_HandlersStack == NULL) { m_HandlersStack = new wxList; m_HandlersStack->DeleteContents(TRUE); @@ -174,7 +175,7 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags) m_HandlersStack->Insert(new wxHashTable(m_HandlersHash)); - while (tokenizer.HasMoreTokens()) + while (tokenizer.HasMoreTokens()) { key = tokenizer.NextToken(); m_HandlersHash.Delete(key); @@ -185,9 +186,9 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags) void wxHtmlParser::PopTagHandler() { wxNode *first; - - if (m_HandlersStack == NULL || - (first = m_HandlersStack->GetFirst()) == NULL) + + if (m_HandlersStack == NULL || + (first = m_HandlersStack->GetFirst()) == NULL) { wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack.")); return; @@ -218,7 +219,9 @@ wxHtmlEntitiesParser::wxHtmlEntitiesParser() wxHtmlEntitiesParser::~wxHtmlEntitiesParser() { +#if wxUSE_WCHAR_T && !wxUSE_UNICODE delete m_conv; +#endif } void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) @@ -238,7 +241,7 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input) const wxChar *c, *last; const wxChar *in_str = input.c_str(); wxString output; - + for (c = in_str, last = in_str; *c != wxT('\0'); c++) { if (*c == wxT('&')) @@ -269,7 +272,7 @@ struct wxHtmlEntityInfo unsigned code; }; -static int compar_entity(const void *key, const void *item) +static int LINKAGEMODE compar_entity(const void *key, const void *item) { return wxStrcmp((wxChar*)key, ((wxHtmlEntityInfo*)item)->name); } @@ -295,12 +298,12 @@ wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity) { unsigned code = 0; - + if (entity[0] == wxT('#')) { const wxChar *ent_s = entity.c_str(); const wxChar *format; - + if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X')) { format = wxT("%x"); @@ -570,20 +573,20 @@ wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity) { wxT("zwnj"),8204 }, {NULL, 0}}; static size_t substitutions_cnt = 0; - + if (substitutions_cnt == 0) while (substitutions[substitutions_cnt].code != 0) substitutions_cnt++; wxHtmlEntityInfo *info; - info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions, + info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions, substitutions_cnt, sizeof(wxHtmlEntityInfo), compar_entity); if (info) code = info->code; } - + if (code == 0) return wxT('?'); else