| 1957 | |
| 1958 | |
| 1959 | char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) |
| 1960 | { |
| 1961 | XMLAttribute* prevAttribute = 0; |
| 1962 | |
| 1963 | // Read the attributes. |
| 1964 | while( p ) { |
| 1965 | p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); |
| 1966 | if ( !(*p) ) { |
| 1967 | _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() ); |
| 1968 | return 0; |
| 1969 | } |
| 1970 | |
| 1971 | // attribute. |
| 1972 | if (XMLUtil::IsNameStartChar( static_cast<unsigned char>(*p) ) ) { |
| 1973 | XMLAttribute* attrib = CreateAttribute(); |
| 1974 | TIXMLASSERT( attrib ); |
| 1975 | attrib->_parseLineNum = _document->_parseCurLineNum; |
| 1976 | |
| 1977 | const int attrLineNum = attrib->_parseLineNum; |
| 1978 | |
| 1979 | p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr ); |
| 1980 | if ( !p || Attribute( attrib->Name() ) ) { |
| 1981 | DeleteAttribute( attrib ); |
| 1982 | _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() ); |
| 1983 | return 0; |
| 1984 | } |
| 1985 | // There is a minor bug here: if the attribute in the source xml |
| 1986 | // document is duplicated, it will not be detected and the |
| 1987 | // attribute will be doubly added. However, tracking the 'prevAttribute' |
| 1988 | // avoids re-scanning the attribute list. Preferring performance for |
| 1989 | // now, may reconsider in the future. |
| 1990 | if ( prevAttribute ) { |
| 1991 | TIXMLASSERT( prevAttribute->_next == 0 ); |
| 1992 | prevAttribute->_next = attrib; |
| 1993 | } |
| 1994 | else { |
| 1995 | TIXMLASSERT( _rootAttribute == 0 ); |
| 1996 | _rootAttribute = attrib; |
| 1997 | } |
| 1998 | prevAttribute = attrib; |
| 1999 | } |
| 2000 | // end of the tag |
| 2001 | else if ( *p == '>' ) { |
| 2002 | ++p; |
| 2003 | break; |
| 2004 | } |
| 2005 | // end of the tag |
| 2006 | else if ( *p == '/' && *(p+1) == '>' ) { |
| 2007 | _closingType = CLOSED; |
| 2008 | return p+2; // done; sealed element. |
| 2009 | } |
| 2010 | else { |
| 2011 | _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 ); |
| 2012 | return 0; |
| 2013 | } |
| 2014 | } |
| 2015 | return p; |
| 2016 | } |
nothing calls this directly
no test coverage detected