#include <stdarg.h>
-
-
//-----------------------------------------------------------------------------
// wxHtmlTagsCache
//-----------------------------------------------------------------------------
+struct wxHtmlCacheItem
+{
+ // this is "pos" value passed to wxHtmlTag's constructor.
+ // it is position of '<' character of the tag
+ int Key;
+
+ // end positions for the tag:
+ // end1 is '<' of ending tag,
+ // end2 is '>' or both are
+ // -1 if there is no ending tag for this one...
+ // or -2 if this is ending tag </...>
+ int End1, End2;
+
+ // name of this tag
+ wxChar *Name;
+};
+
+
IMPLEMENT_CLASS(wxHtmlTagsCache,wxObject)
#define CACHE_INCREMENT 64
if (src[pos] == wxT('<')) // tag found:
{
if (m_CacheSize % CACHE_INCREMENT == 0)
- m_Cache = (sCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(sCacheItem));
+ m_Cache = (wxHtmlCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(wxHtmlCacheItem));
tg = m_CacheSize++;
m_Cache[tg].Key = stpos = pos++;
dummy[0] = 0; i = 0;
if (source[i] == '/') { m_Ending = TRUE; i++; }
else m_Ending = FALSE;
+ // find tag's name and convert it to uppercase:
while ((i < end_pos) &&
((c = source[i++]) != ' ' && c != '\r' && c != '\n' && c != '\t' &&
c != '>'))
m_Name += c;
}
+ // if the tag has parameters, read them and "normalize" them,
+ // i.e. convert to uppercase, replace whitespaces by spaces and
+ // remove whitespaces around '=':
if (source[i-1] != '>')
while ((i < end_pos) && ((c = source[i++]) != '>'))
{
m_Params += c;
if (c == '"')
{
+ // remove spaces around the '=' character:
+ if (m_Params.Length() > 1 &&
+ m_Params[m_Params.Length()-2] == ' ')
+ {
+ m_Params.RemoveLast();
+ while (m_Params.Length() > 0 && m_Params.Last() == ' ')
+ m_Params.RemoveLast();
+ m_Params += '"';
+ }
+ while ((i < end_pos) && (source[i++] == ' ')) {}
+ if (i < end_pos) i--;
+
+ // ...and copy the value to m_Params:
while ((i < end_pos) && ((c = source[i++]) != '"')) m_Params += c;
m_Params += c;
}