Improved const correctness of local variables. There are no functional changes intended.
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index fd27f78..1c74279 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -45,14 +45,14 @@
{
va_list va;
va_start( va, format );
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
+ const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
va_end( va );
return result;
}
static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
{
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
+ const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
return result;
}
@@ -197,7 +197,7 @@
TIXMLASSERT(curLineNumPtr);
char* start = p;
- char endChar = *endTag;
+ const char endChar = *endTag;
size_t length = strlen( endTag );
// Inner loop of text parsing.
@@ -310,7 +310,7 @@
const int buflen = 10;
char buf[buflen] = { 0 };
int len = 0;
- char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
+ const char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
if ( adjusted == 0 ) {
*q = *p;
++p;
@@ -1017,7 +1017,7 @@
break;
}
- int initialLineNum = node->_parseLineNum;
+ const int initialLineNum = node->_parseLineNum;
StrPair endTag;
p = node->ParseDeep( p, &endTag, curLineNumPtr );
@@ -1029,7 +1029,7 @@
break;
}
- XMLDeclaration* decl = node->ToDeclaration();
+ const XMLDeclaration* const decl = node->ToDeclaration();
if ( decl ) {
// Declarations are only allowed at document level
//
@@ -1038,7 +1038,7 @@
//
// Optimized due to a security test case. If the first node is
// a declaration, and the last node is a declaration, then only
- // declarations have so far been addded.
+ // declarations have so far been added.
bool wellLocated = false;
if (ToDocument()) {
@@ -1373,7 +1373,7 @@
return 0;
}
- char endTag[2] = { *p, 0 };
+ const char endTag[2] = { *p, 0 };
++p; // move past opening quote
p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES, curLineNumPtr );
@@ -1830,7 +1830,7 @@
TIXMLASSERT( attrib );
attrib->_parseLineNum = _document->_parseCurLineNum;
- int attrLineNum = attrib->_parseLineNum;
+ const int attrLineNum = attrib->_parseLineNum;
p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );
if ( !p || Attribute( attrib->Name() ) ) {
@@ -2136,7 +2136,7 @@
TIXMLASSERT( mode );
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
FILE* fp = 0;
- errno_t err = fopen_s( &fp, filepath, mode );
+ const errno_t err = fopen_s( &fp, filepath, mode );
if ( err ) {
return 0;
}
@@ -2239,7 +2239,7 @@
const size_t size = filelength;
TIXMLASSERT( _charBuffer == 0 );
_charBuffer = new char[size+1];
- size_t read = fread( _charBuffer, 1, size, fp );
+ const size_t read = fread( _charBuffer, 1, size, fp );
if ( read != size ) {
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
return _errorID;
@@ -2332,7 +2332,7 @@
_errorLineNum = lineNum;
_errorStr.Reset();
- size_t BUFFER_SIZE = 1000;
+ const size_t BUFFER_SIZE = 1000;
char* buffer = new char[BUFFER_SIZE];
TIXMLASSERT(sizeof(error) <= sizeof(int));