| 1925 | |
| 1926 | |
| 1927 | char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) |
| 1928 | { |
| 1929 | XMLAttribute* prevAttribute = 0; |
| 1930 | |
| 1931 | // Read the attributes. |
| 1932 | while( p ) { |
| 1933 | p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); |
| 1934 | if ( !(*p) ) { |
| 1935 | _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() ); |
| 1936 | return 0; |
| 1937 | } |
| 1938 | |
| 1939 | // attribute. |
| 1940 | if (XMLUtil::IsNameStartChar( (unsigned char) *p ) ) { |
| 1941 | XMLAttribute* attrib = CreateAttribute(); |
| 1942 | TIXMLASSERT( attrib ); |
| 1943 | attrib->_parseLineNum = _document->_parseCurLineNum; |
| 1944 | |
| 1945 | const int attrLineNum = attrib->_parseLineNum; |
| 1946 | |
| 1947 | p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr ); |
| 1948 | if ( !p || Attribute( attrib->Name() ) ) { |
| 1949 | DeleteAttribute( attrib ); |
| 1950 | _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() ); |
| 1951 | return 0; |
| 1952 | } |
| 1953 | // There is a minor bug here: if the attribute in the source xml |
| 1954 | // document is duplicated, it will not be detected and the |
| 1955 | // attribute will be doubly added. However, tracking the 'prevAttribute' |
| 1956 | // avoids re-scanning the attribute list. Preferring performance for |
| 1957 | // now, may reconsider in the future. |
| 1958 | if ( prevAttribute ) { |
| 1959 | TIXMLASSERT( prevAttribute->_next == 0 ); |
| 1960 | prevAttribute->_next = attrib; |
| 1961 | } |
| 1962 | else { |
| 1963 | TIXMLASSERT( _rootAttribute == 0 ); |
| 1964 | _rootAttribute = attrib; |
| 1965 | } |
| 1966 | prevAttribute = attrib; |
| 1967 | } |
| 1968 | // end of the tag |
| 1969 | else if ( *p == '>' ) { |
| 1970 | ++p; |
| 1971 | break; |
| 1972 | } |
| 1973 | // end of the tag |
| 1974 | else if ( *p == '/' && *(p+1) == '>' ) { |
| 1975 | _closingType = CLOSED; |
| 1976 | return p+2; // done; sealed element. |
| 1977 | } |
| 1978 | else { |
| 1979 | _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 ); |
| 1980 | return 0; |
| 1981 | } |
| 1982 | } |
| 1983 | return p; |
| 1984 | } |
nothing calls this directly
no test coverage detected