tinyxml: update to latest git version 59b9aae (https://github.com/leethomason/tinyxml2).

This commit is contained in:
Matthias Krüger 2014-08-26 13:53:16 +02:00
parent b14ebb791b
commit 95bf96c980
1 changed files with 27 additions and 24 deletions

View File

@ -112,7 +112,7 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags )
{
TIXMLASSERT( endTag && *endTag );
char* start = p; // fixme: hides a member
char* start = p;
char endChar = *endTag;
size_t length = strlen( endTag );
@ -150,6 +150,8 @@ char* StrPair::ParseName( char* p )
void StrPair::CollapseWhitespace()
{
// Adjusting _start would cause undefined behavior on delete[]
TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 );
// Trim leading space.
_start = XMLUtil::SkipWhiteSpace( _start );
@ -214,13 +216,14 @@ const char* StrPair::GetStr()
// 中 or 中
if ( *(p+1) == '#' ) {
char buf[10] = { 0 };
int len;
const int buflen = 10;
char buf[buflen] = { 0 };
int len = 0;
p = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
for( int i=0; i<len; ++i ) {
*q++ = buf[i];
}
TIXMLASSERT( q <= p );
TIXMLASSERT( 0 <= len && len <= buflen );
TIXMLASSERT( q + len <= p );
memcpy( q, buf, len );
q += len;
}
else {
int i=0;
@ -1662,19 +1665,25 @@ XMLUnknown* XMLDocument::NewUnknown( const char* str )
return unk;
}
static FILE* callfopen( const char* filepath, const char* mode )
{
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
FILE* fp = 0;
errno_t err = fopen_s( &fp, filepath, mode );
if ( err ) {
return 0;
}
#else
FILE* fp = fopen( filepath, mode );
#endif
return fp;
}
XMLError XMLDocument::LoadFile( const char* filename )
{
Clear();
FILE* fp = 0;
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
errno_t err = fopen_s(&fp, filename, "rb" );
if ( !fp || err) {
#else
fp = fopen( filename, "rb" );
if ( !fp) {
#endif
FILE* fp = callfopen( filename, "rb" );
if ( !fp ) {
SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 );
return _errorID;
}
@ -1732,14 +1741,8 @@ XMLError XMLDocument::LoadFile( FILE* fp )
XMLError XMLDocument::SaveFile( const char* filename, bool compact )
{
FILE* fp = 0;
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
errno_t err = fopen_s(&fp, filename, "w" );
if ( !fp || err) {
#else
fp = fopen( filename, "w" );
if ( !fp) {
#endif
FILE* fp = callfopen( filename, "w" );
if ( !fp ) {
SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 );
return _errorID;
}