diff --git a/gb.xml/src/element.cpp b/gb.xml/src/element.cpp index 64b3d316a..7a15425bb 100644 --- a/gb.xml/src/element.cpp +++ b/gb.xml/src/element.cpp @@ -28,10 +28,10 @@ /*************************************** Element ***************************************/ -const char* Element::singleElements = "br\0hr\0area\0base\0br\0co\0command\0embed\0hr\0img\0input\0keygen\0link\0meta\0param\0source\0track\0wbr\0\0"; -#define LEN_SINGLEELEMENTS 89 +const char* Element::singleElements = "br\0img\0meta\0input\0area\0base\0co\0command\0embed\0hr\0keygen\0link\0param\0source\0track\0wbr\0\0"; +#define LEN_SINGLEELEMENTS 84 -Element::Element() : Node() +Element::Element() : Node(), single(undefined) { tagName = 0; lenTagName = 0; @@ -44,7 +44,7 @@ Element::Element() : Node() lenLocalName = 0; } -Element::Element(const char *ntagName, size_t nlenTagName) : Node() +Element::Element(const char *ntagName, size_t nlenTagName) : Node(), single(undefined) { tagName = 0; lenTagName = 0; @@ -101,8 +101,8 @@ void Element::setTagName(const char *ntagName, size_t nlenTagName) lenTagName = nlenTagName; tagName = (char*)realloc(tagName, sizeof(char) * lenTagName); memcpy(tagName, ntagName, lenTagName); - -refreshPrefix(); + single = undefined; + refreshPrefix(); } @@ -162,6 +162,7 @@ void Element::refreshPrefix() bool Element::isSingle() { + if(single != undefined) return single; const char *start = Element::singleElements; char *end = (char*)memchr(start, 0, LEN_SINGLEELEMENTS); unsigned char lenTag = end - start; @@ -172,6 +173,7 @@ bool Element::isSingle() { if(!memcmp(tagName, start, lenTagName)) { + single = true; return true; } } @@ -180,7 +182,8 @@ bool Element::isSingle() end = (char*)memchr(start, 0, LEN_SINGLEELEMENTS - (singleElements - start)); lenTag = end - start; } - + + single = false; return false; } diff --git a/gb.xml/src/element.h b/gb.xml/src/element.h index 1ec7a900b..951b1c007 100644 --- a/gb.xml/src/element.h +++ b/gb.xml/src/element.h @@ -63,6 +63,7 @@ public: bool isSingle(); char *tagName; size_t lenTagName; + undefbool single; void setPrefix(const char *nprefix, size_t nlenPrefix); char *prefix; diff --git a/gb.xml/src/utils.h b/gb.xml/src/utils.h index 0cea83a84..baf035ed3 100644 --- a/gb.xml/src/utils.h +++ b/gb.xml/src/utils.h @@ -27,6 +27,10 @@ typedef unsigned int uint; +typedef char undefbool;//A boolean with an "undefined" state + +#define undefined 2//The "undefined" state of an undefbool + #define DELETE(_ob) if(_ob) {delete _ob; _ob = 0;} #define UNREF(_ob) if(_ob) GB.Unref(POINTER(&(_ob)))