]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmltag.cpp
use quotes around SRCROOT to handle the case when it contains spaces (patch 1912354)
[wxWidgets.git] / src / html / htmltag.cpp
index 4365a26554316d4165255e2fb0322b4403650d9c..cd172656983647c5995139c5eac3b8dc16645f9d 100644 (file)
@@ -69,8 +69,8 @@ bool wxIsCDATAElement(const wxChar *tag)
 
 bool wxIsCDATAElement(const wxString& tag)
 {
-    return (wxStrcmp(tag.wx_str(), wxSTRING_TEXT("SCRIPT")) == 0) ||
-           (wxStrcmp(tag.wx_str(), wxSTRING_TEXT("STYLE")) == 0);
+    return (wxStrcmp(tag.wx_str(), wxS("SCRIPT")) == 0) ||
+           (wxStrcmp(tag.wx_str(), wxS("STYLE")) == 0);
 }
 
 wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source)
@@ -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;
+    }
 }
 
 
@@ -431,12 +449,12 @@ bool wxHtmlTag::HasParam(const wxString& par) const
     return (m_ParamNames.Index(par, false) != wxNOT_FOUND);
 }
 
-wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
+wxString wxHtmlTag::GetParam(const wxString& par, bool with_quotes) const
 {
     int index = m_ParamNames.Index(par, false);
     if (index == wxNOT_FOUND)
         return wxGetEmptyString();
-    if (with_commas)
+    if (with_quotes)
     {
         // VS: backward compatibility, seems to be never used by wxHTML...
         wxString s;
@@ -472,8 +490,8 @@ bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const
     // handle colours defined in HTML 4.0 first:
     if (str.length() > 1 && str[0] != _T('#'))
     {
-        #define HTML_COLOUR(name, r, g, b)                        \
-            if (str.IsSameAs(wxSTRING_TEXT(name), false))         \
+        #define HTML_COLOUR(name, r, g, b)              \
+            if (str.IsSameAs(wxS(name), false))         \
                 { clr->Set(r, g, b); return true; }
         HTML_COLOUR("black",   0x00,0x00,0x00)
         HTML_COLOUR("silver",  0xC0,0xC0,0xC0)