X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d9359369af901bf2146b5ad6575f7aae13389a15..7735b2ea691f41d7a7f007befbe969386873b86e:/src/html/htmltag.cpp diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index d3e277c150..4cd0412e95 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -63,8 +63,8 @@ class wxHtmlTagsCacheData : public wxVector bool wxIsCDATAElement(const wxChar *tag) { - return (wxStrcmp(tag, _T("SCRIPT")) == 0) || - (wxStrcmp(tag, _T("STYLE")) == 0); + return (wxStrcmp(tag, wxT("SCRIPT")) == 0) || + (wxStrcmp(tag, wxT("STYLE")) == 0); } bool wxIsCDATAElement(const wxString& tag) @@ -103,7 +103,7 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source) { tagBuffer[i] = (wxChar)wxToupper(*pos); } - tagBuffer[i] = _T('\0'); + tagBuffer[i] = wxT('\0'); Cache()[tg].Name = new wxChar[i+1]; memcpy(Cache()[tg].Name, tagBuffer, (i+1)*sizeof(wxChar)); @@ -246,9 +246,27 @@ void wxHtmlTagsCache::QueryTag(const wxString::const_iterator& at, } while (Cache()[m_CachePos].Key != at); } - *end1 = Cache()[m_CachePos].End1; - *end2 = Cache()[m_CachePos].End2; - *hasEnding = (Cache()[m_CachePos].type == wxHtmlCacheItem::Type_Normal); + + switch ( Cache()[m_CachePos].type ) + { + case wxHtmlCacheItem::Type_Normal: + *end1 = Cache()[m_CachePos].End1; + *end2 = Cache()[m_CachePos].End2; + *hasEnding = true; + break; + + case wxHtmlCacheItem::Type_EndingTag: + wxFAIL_MSG("QueryTag called for ending tag - can't be"); + // but if it does happen, fall through, better than crashing + + case wxHtmlCacheItem::Type_NoMatchingEndingTag: + // If input HTML is invalid and there's no closing tag for this + // one, pretend that it runs all the way to the end of input + *end1 = inputEnd; + *end2 = inputEnd; + *hasEnding = false; + break; + } } @@ -284,7 +302,7 @@ wxHtmlTag::wxHtmlTag(wxHtmlTag *parent, /* Find parameters and their values: */ - wxChar c; + wxChar c wxDUMMY_INITIALIZE(0); // fill-in name, params and begin pos: wxString::const_iterator i(pos+1); @@ -293,7 +311,7 @@ wxHtmlTag::wxHtmlTag(wxHtmlTag *parent, while ((i < end_pos) && ((c = *(i++)) != wxT(' ') && c != wxT('\r') && c != wxT('\n') && c != wxT('\t') && - c != wxT('>'))) + c != wxT('>') && c != wxT('/'))) { if ((c >= wxT('a')) && (c <= wxT('z'))) c -= (wxT('a') - wxT('A')); @@ -465,12 +483,12 @@ int wxHtmlTag::ScanParam(const wxString& par, bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const { - wxCHECK_MSG( clr, false, _T("invalid colour argument") ); + wxCHECK_MSG( clr, false, wxT("invalid colour argument") ); wxString str = GetParam(par); // handle colours defined in HTML 4.0 first: - if (str.length() > 1 && str[0] != _T('#')) + if (str.length() > 1 && str[0] != wxT('#')) { #define HTML_COLOUR(name, r, g, b) \ if (str.IsSameAs(wxS(name), false)) \ @@ -506,11 +524,15 @@ bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const bool wxHtmlTag::GetParamAsInt(const wxString& par, int *clr) const { - if (!HasParam(par)) return false; + if ( !HasParam(par) ) + return false; + long i; - bool succ = GetParam(par).ToLong(&i); + if ( !GetParam(par).ToLong(&i) ) + return false; + *clr = (int)i; - return succ; + return true; } wxString wxHtmlTag::GetAllParams() const