X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69941f05864fa8b37856ccc1338124bfac756a2b..4c30035625ce9c4980e52db808704b377af12041:/src/html/htmlpars.cpp?ds=sidebyside diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 8692fccc95..5c07054f58 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -12,7 +12,7 @@ #pragma implementation #endif -#include +#include "wx/wxprec.h" #include "wx/defs.h" #if wxUSE_HTML @@ -22,7 +22,7 @@ #endif #ifndef WXPRECOMP -#include +#include "wx/wx.h" #endif #include "wx/tokenzr.h" @@ -69,11 +69,11 @@ void wxHtmlParser::DoneParser() -#define HTML_MAX_BUFLEN 1024 +#define wxHTML_MAX_BUFLEN 1024 void wxHtmlParser::DoParsing(int begin_pos, int end_pos) { - char temp[HTML_BUFLEN], c; + char temp[wxHTML_BUFLEN], c; int i; int templen; @@ -81,12 +81,12 @@ void wxHtmlParser::DoParsing(int begin_pos, int end_pos) i = begin_pos; while (i < end_pos) { - c = m_Source[i]; + c = m_Source[(unsigned int) i]; // continue building word: if (c != '<') { temp[templen++] = c; - if (templen == HTML_BUFLEN-1) { + if (templen == wxHTML_BUFLEN-1) { temp[templen] = 0; AddText(temp); templen = 0; @@ -137,11 +137,7 @@ void wxHtmlParser::AddTagHandler(wxHtmlTagHandler *handler) wxString s(handler -> GetSupportedTags()); wxStringTokenizer tokenizer(s, ", "); -#if (wxVERSION_NUMBER < 2100) - while (tokenizer.HasMoreToken()) -#else while (tokenizer.HasMoreTokens()) -#endif m_HandlersHash.Put(tokenizer.NextToken(), handler); if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND) @@ -152,8 +148,41 @@ void wxHtmlParser::AddTagHandler(wxHtmlTagHandler *handler) +void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags) +{ + wxStringTokenizer tokenizer(tags, ", "); + wxString key; + + if (m_HandlersStack == NULL) { + m_HandlersStack = new wxList; + m_HandlersStack -> DeleteContents(TRUE); + } + + m_HandlersStack -> Insert(new wxHashTable(m_HandlersHash)); + + while (tokenizer.HasMoreTokens()) { + key = tokenizer.NextToken(); + m_HandlersHash.Delete(key); + m_HandlersHash.Put(key, handler); + } +} + + + +void wxHtmlParser::PopTagHandler() +{ + wxNode *first; + + if (m_HandlersStack == NULL || (first = m_HandlersStack -> GetFirst()) == NULL) return; + m_HandlersHash = *((wxHashTable*) first -> GetData()); + m_HandlersStack -> DeleteNode(first); +} + + + wxHtmlParser::~wxHtmlParser() { + if (m_HandlersStack) delete m_HandlersStack; m_HandlersHash.Clear(); m_HandlersList.DeleteContents(TRUE); m_HandlersList.Clear(); @@ -166,5 +195,5 @@ wxHtmlParser::~wxHtmlParser() //----------------------------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxHtmlTagHandler,wxObject) +#endif -#endif \ No newline at end of file