From c435ed509a2837b43af7ec72cd5555c8f0e25b4f Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 18 Feb 2005 14:03:50 +0000 Subject: [PATCH] add comments parsing --- stepmania/src/XmlFile.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/stepmania/src/XmlFile.cpp b/stepmania/src/XmlFile.cpp index 88c5a603aa..5815211b5e 100644 --- a/stepmania/src/XmlFile.cpp +++ b/stepmania/src/XmlFile.cpp @@ -12,9 +12,11 @@ static const char chXMLTagOpen = '<'; static const char chXMLTagClose = '>'; -static const char chXMLTagQuestion = '?'; // used in checking for meta tags: "" +static const char chXMLQuestion = '?'; // used in checking for meta tags: "" static const char chXMLTagPre = '/'; static const char chXMLEscape = '\\'; // for value field escape +static const char chXMLExclamation = '!'; +static const char chXMLDash = '-'; static const XENTITY x_EntityTable[] = { @@ -185,7 +187,7 @@ char* XNode::LoadAttributes( const char* pszAttrs, PARSEINFO *pi /*= &piDefault* continue; // close tag - if( *xml == chXMLTagClose || *xml == chXMLTagPre || *xml == chXMLTagQuestion ) + if( *xml == chXMLTagClose || *xml == chXMLTagPre || *xml == chXMLQuestion || *xml == chXMLDash ) // wel-formed tag return xml; @@ -254,7 +256,7 @@ char* XNode::LoadAttributes( const char* pszAttrs, PARSEINFO *pi /*= &piDefault* } } - // not wel-formed tag + // not well-formed tag return NULL; } @@ -291,16 +293,24 @@ char* XNode::Load( const char* pszXml, PARSEINFO *pi /*= &piDefault*/ ) xml++; char* pTagEnd = strpbrk( xml, " \t\r\n/>" ); SetString( xml, pTagEnd, &m_sName ); + xml = pTagEnd; // Generate XML Attributte List xml = LoadAttributes( xml, pi ); if( xml == NULL ) return NULL; - // alone tag or - if( *xml == chXMLTagPre || *xml == chXMLTagQuestion ) + // alone tag or or + // current pointer: ^ ^ ^ + + if( *xml == chXMLTagPre || *xml == chXMLQuestion || *xml == chXMLDash ) { xml++; + + // skip over 2nd dash + if( *xml == chXMLDash ) + xml++; + if( *xml == chXMLTagClose ) { // well-formed tag @@ -309,7 +319,7 @@ char* XNode::Load( const char* pszXml, PARSEINFO *pi /*= &piDefault*/ ) // UGLY: We want to ignore all XML meta tags. So, since the Node we // just loaded is a meta tag, then Load ourself again using the rest // of the file until we reach a non-meta tag. - if( !m_sName.empty() && m_sName[0] == chXMLTagQuestion ) + if( !m_sName.empty() && (m_sName[0] == chXMLQuestion || m_sName[0] == chXMLExclamation) ) xml = Load( xml, pi ); return xml;