From 97646cb89a6767e31fd96a1a17b73d2712e453b6 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 24 Feb 2009 19:39:43 +0000 Subject: [PATCH] Minor XML fixes git-svn-id: svn://ultimatepp.org/upp/trunk@903 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/XML.cpp | 42 ++++++++++++++++++++++++------------------ uppsrc/Core/XML.h | 1 + 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/uppsrc/Core/XML.cpp b/uppsrc/Core/XML.cpp index f6275a391..615004eee 100644 --- a/uppsrc/Core/XML.cpp +++ b/uppsrc/Core/XML.cpp @@ -181,6 +181,23 @@ void XmlParser::SkipWhites() } } +void XmlParser::ReadAttr(StringBuffer& attrval, int c) +{ + term++; + while(*term && *term != c) + if(*term == '&') + Ent(attrval); + else { + const char *e = term; + while(*++e && *e != '&' && *e != c) + ; + attrval.Cat(term, (int)(e - term)); + term = e; + } + if(*term == c) + term++; +} + void XmlParser::Next() { nattr.Clear(); @@ -293,23 +310,13 @@ void XmlParser::Next() term++; SkipWhites(); StringBuffer attrval; - if(*term == '\"') { - term++; - while(*term && *term != '\"') - if(*term == '&') - Ent(attrval); - else { - const char *e = term; - while(*++e && *e != '&' && *e != '\"') - ; - attrval.Cat(term, (int)(e - term)); - term = e; - } - if(*term == '\"') - term++; - } - else { - while((byte)*term > ' ' && *term != '>') + if(*term == '\"') + ReadAttr(attrval, '\"'); + else + if(*term == '\'') + ReadAttr(attrval, '\''); + else + while((byte)*term > ' ' && *term != '>' && *term != '/') if(*term == '&') Ent(attrval); else { @@ -319,7 +326,6 @@ void XmlParser::Next() attrval.Cat(term,(int) (e - term)); term = e; } - } if(attr == "xml:space" && attrval.GetLength() == 8 && !memcmp(~attrval, "preserve", 8)) npreserve = true; String aval = FromUtf8(~attrval, attrval.GetLength()).ToString(); diff --git a/uppsrc/Core/XML.h b/uppsrc/Core/XML.h index c5543aa98..72db8ab2a 100644 --- a/uppsrc/Core/XML.h +++ b/uppsrc/Core/XML.h @@ -60,6 +60,7 @@ class XmlParser { void Ent(StringBuffer& out); void Next(); + void ReadAttr(StringBuffer& b, int c); public: void SkipWhites();