From 4391c86e452290eb095c8c3cc83db136209d4fde Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 13 Aug 2003 00:55:13 +0000 Subject: [PATCH] Fixed two errors in reading an xml file. 1) empty child xml elements had an extra / character being added onto the end of their name 2) comments with beginning and ending white space were being copied with an extra space added on to the front and end of the string. --- Cantera/src/xml.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Cantera/src/xml.cpp b/Cantera/src/xml.cpp index b9ebb1105..2316bcfb5 100755 --- a/Cantera/src/xml.cpp +++ b/Cantera/src/xml.cpp @@ -191,10 +191,12 @@ namespace Cantera { string attr, val; string s = strip(tag); iloc = s.find(' '); - if (iloc > 0) { + if (iloc != string::npos) { name = s.substr(0, iloc); s = strip(s.substr(iloc+1,s.size())); - if (s[s.size()-1] == '/') name += "/"; + if (s[s.size()-1] == '/') { + name += "/"; + } // get attributes while (1) { iloc = s.find('='); @@ -252,12 +254,6 @@ namespace Cantera { return tag; } else { -#ifdef DEBUG_HKM - //cout << "tag fed to parseTag = " << tag << endl; - //if (tag == "standardConc model=\"molar volume\" /") { - // cout << "we are here" << endl; - //} -#endif parseTag(tag, name, attribs); return name; } @@ -587,8 +583,22 @@ namespace Cantera { m_level = level; string indent(level, ' '); if (m_iscomment) { - s << endl << indent << ""; - return; + /* + * In the comment section, we test to see if there + * already is a space beginning and ending the comment. + * If there already is one, we don't add another one. + */ + s << endl << indent << ""; + return; } s << indent << "<" << m_name;