MCPcopy Create free account
hub / github.com/avast/retdec / ParseAttributes

Method ParseAttributes

deps/tinyxml2/tinyxml2.cpp:1885–1942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1883
1884
1885char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
1886{
1887 XMLAttribute* prevAttribute = 0;
1888
1889 // Read the attributes.
1890 while( p ) {
1891 p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr );
1892 if ( !(*p) ) {
1893 _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() );
1894 return 0;
1895 }
1896
1897 // attribute.
1898 if (XMLUtil::IsNameStartChar( *p ) ) {
1899 XMLAttribute* attrib = CreateAttribute();
1900 TIXMLASSERT( attrib );
1901 attrib->_parseLineNum = _document->_parseCurLineNum;
1902
1903 const int attrLineNum = attrib->_parseLineNum;
1904
1905 p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );
1906 if ( !p || Attribute( attrib->Name() ) ) {
1907 DeleteAttribute( attrib );
1908 _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() );
1909 return 0;
1910 }
1911 // There is a minor bug here: if the attribute in the source xml
1912 // document is duplicated, it will not be detected and the
1913 // attribute will be doubly added. However, tracking the 'prevAttribute'
1914 // avoids re-scanning the attribute list. Preferring performance for
1915 // now, may reconsider in the future.
1916 if ( prevAttribute ) {
1917 TIXMLASSERT( prevAttribute->_next == 0 );
1918 prevAttribute->_next = attrib;
1919 }
1920 else {
1921 TIXMLASSERT( _rootAttribute == 0 );
1922 _rootAttribute = attrib;
1923 }
1924 prevAttribute = attrib;
1925 }
1926 // end of the tag
1927 else if ( *p == '>' ) {
1928 ++p;
1929 break;
1930 }
1931 // end of the tag
1932 else if ( *p == '/' && *(p+1) == '>' ) {
1933 _closingType = CLOSED;
1934 return p+2; // done; sealed element.
1935 }
1936 else {
1937 _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 );
1938 return 0;
1939 }
1940 }
1941 return p;
1942}

Callers

nothing calls this directly

Calls 6

SkipWhiteSpaceFunction · 0.85
NameClass · 0.85
IsNameStartCharFunction · 0.85
SetErrorMethod · 0.80
ParseDeepMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected