tinyxml: update to latest git version 2af5679 (https://github.com/leethomason/tinyxml2).
This commit is contained in:
parent
b2288e5ada
commit
ed927e9b60
|
@ -1668,7 +1668,7 @@ XMLError XMLDocument::LoadFile( const char* filename )
|
||||||
Clear();
|
Clear();
|
||||||
FILE* fp = 0;
|
FILE* fp = 0;
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
||||||
errno_t err = fopen_s(&fp, filename, "rb" );
|
errno_t err = fopen_s(&fp, filename, "rb" );
|
||||||
if ( !fp || err) {
|
if ( !fp || err) {
|
||||||
#else
|
#else
|
||||||
|
@ -1689,16 +1689,20 @@ XMLError XMLDocument::LoadFile( FILE* fp )
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
fseek( fp, 0, SEEK_SET );
|
fseek( fp, 0, SEEK_SET );
|
||||||
fgetc( fp );
|
if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {
|
||||||
if ( ferror( fp ) != 0 ) {
|
|
||||||
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
|
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
|
||||||
return _errorID;
|
return _errorID;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek( fp, 0, SEEK_END );
|
fseek( fp, 0, SEEK_END );
|
||||||
size_t size = ftell( fp );
|
const long filelength = ftell( fp );
|
||||||
fseek( fp, 0, SEEK_SET );
|
fseek( fp, 0, SEEK_SET );
|
||||||
|
if ( filelength == -1L ) {
|
||||||
|
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
|
||||||
|
return _errorID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t size = filelength;
|
||||||
if ( size == 0 ) {
|
if ( size == 0 ) {
|
||||||
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
|
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
|
||||||
return _errorID;
|
return _errorID;
|
||||||
|
@ -1729,7 +1733,7 @@ XMLError XMLDocument::LoadFile( FILE* fp )
|
||||||
XMLError XMLDocument::SaveFile( const char* filename, bool compact )
|
XMLError XMLDocument::SaveFile( const char* filename, bool compact )
|
||||||
{
|
{
|
||||||
FILE* fp = 0;
|
FILE* fp = 0;
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
||||||
errno_t err = fopen_s(&fp, filename, "w" );
|
errno_t err = fopen_s(&fp, filename, "w" );
|
||||||
if ( !fp || err) {
|
if ( !fp || err) {
|
||||||
#else
|
#else
|
||||||
|
@ -1856,7 +1860,17 @@ void XMLPrinter::Print( const char* format, ... )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||||
|
#if defined(WINCE)
|
||||||
|
int len = 512;
|
||||||
|
do {
|
||||||
|
len = len*2;
|
||||||
|
char* str = new char[len]();
|
||||||
|
len = _vsnprintf(str, len, format, va);
|
||||||
|
delete[] str;
|
||||||
|
}while (len < 0);
|
||||||
|
#else
|
||||||
int len = _vscprintf( format, va );
|
int len = _vscprintf( format, va );
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
int len = vsnprintf( 0, 0, format, va );
|
int len = vsnprintf( 0, 0, format, va );
|
||||||
#endif
|
#endif
|
||||||
|
@ -1865,7 +1879,11 @@ void XMLPrinter::Print( const char* format, ... )
|
||||||
va_start( va, format );
|
va_start( va, format );
|
||||||
char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.
|
char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||||
|
#if defined(WINCE)
|
||||||
|
_vsnprintf( p, len+1, format, va );
|
||||||
|
#else
|
||||||
vsnprintf_s( p, len+1, _TRUNCATE, format, va );
|
vsnprintf_s( p, len+1, _TRUNCATE, format, va );
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vsnprintf( p, len+1, format, va );
|
vsnprintf( p, len+1, format, va );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,7 +91,7 @@ distribution.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
||||||
// Microsoft visual studio, version 2005 and higher.
|
// Microsoft visual studio, version 2005 and higher.
|
||||||
/*int _snprintf_s(
|
/*int _snprintf_s(
|
||||||
char *buffer,
|
char *buffer,
|
||||||
|
@ -109,6 +109,9 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#define TIXML_SSCANF sscanf_s
|
#define TIXML_SSCANF sscanf_s
|
||||||
|
#elif defined WINCE
|
||||||
|
#define TIXML_SNPRINTF _snprintf
|
||||||
|
#define TIXML_SSCANF sscanf
|
||||||
#else
|
#else
|
||||||
// GCC version 3 and higher
|
// GCC version 3 and higher
|
||||||
//#warning( "Using sn* functions." )
|
//#warning( "Using sn* functions." )
|
||||||
|
@ -367,7 +370,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--_currentAllocs;
|
--_currentAllocs;
|
||||||
Chunk* chunk = (Chunk*)mem;
|
Chunk* chunk = static_cast<Chunk*>( mem );
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
memset( chunk, 0xfe, sizeof(Chunk) );
|
memset( chunk, 0xfe, sizeof(Chunk) );
|
||||||
#endif
|
#endif
|
||||||
|
@ -2031,7 +2034,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool CompactMode( const XMLElement& ) { return _compactMode; };
|
virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
|
||||||
|
|
||||||
/** Prints out the space before an element. You may override to change
|
/** Prints out the space before an element. You may override to change
|
||||||
the space and tabs used. A PrintSpace() override should call Print().
|
the space and tabs used. A PrintSpace() override should call Print().
|
||||||
|
|
Loading…
Reference in New Issue