Skip to content

Commit ed927e9

Browse files
committed
tinyxml: update to latest git version 2af5679 (https://github.com/leethomason/tinyxml2).
1 parent b2288e5 commit ed927e9

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

externals/tinyxml/tinyxml2.cpp

100755100644
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ XMLError XMLDocument::LoadFile( const char* filename )
16681668
Clear();
16691669
FILE* fp = 0;
16701670

1671-
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
1671+
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
16721672
errno_t err = fopen_s(&fp, filename, "rb" );
16731673
if ( !fp || err) {
16741674
#else
@@ -1689,16 +1689,20 @@ XMLError XMLDocument::LoadFile( FILE* fp )
16891689
Clear();
16901690

16911691
fseek( fp, 0, SEEK_SET );
1692-
fgetc( fp );
1693-
if ( ferror( fp ) != 0 ) {
1692+
if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {
16941693
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
16951694
return _errorID;
16961695
}
16971696

16981697
fseek( fp, 0, SEEK_END );
1699-
size_t size = ftell( fp );
1698+
const long filelength = ftell( fp );
17001699
fseek( fp, 0, SEEK_SET );
1700+
if ( filelength == -1L ) {
1701+
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
1702+
return _errorID;
1703+
}
17011704

1705+
const size_t size = filelength;
17021706
if ( size == 0 ) {
17031707
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
17041708
return _errorID;
@@ -1729,7 +1733,7 @@ XMLError XMLDocument::LoadFile( FILE* fp )
17291733
XMLError XMLDocument::SaveFile( const char* filename, bool compact )
17301734
{
17311735
FILE* fp = 0;
1732-
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
1736+
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
17331737
errno_t err = fopen_s(&fp, filename, "w" );
17341738
if ( !fp || err) {
17351739
#else
@@ -1856,7 +1860,17 @@ void XMLPrinter::Print( const char* format, ... )
18561860
}
18571861
else {
18581862
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
1863+
#if defined(WINCE)
1864+
int len = 512;
1865+
do {
1866+
len = len*2;
1867+
char* str = new char[len]();
1868+
len = _vsnprintf(str, len, format, va);
1869+
delete[] str;
1870+
}while (len < 0);
1871+
#else
18591872
int len = _vscprintf( format, va );
1873+
#endif
18601874
#else
18611875
int len = vsnprintf( 0, 0, format, va );
18621876
#endif
@@ -1865,7 +1879,11 @@ void XMLPrinter::Print( const char* format, ... )
18651879
va_start( va, format );
18661880
char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.
18671881
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
1882+
#if defined(WINCE)
1883+
_vsnprintf( p, len+1, format, va );
1884+
#else
18681885
vsnprintf_s( p, len+1, _TRUNCATE, format, va );
1886+
#endif
18691887
#else
18701888
vsnprintf( p, len+1, format, va );
18711889
#endif

externals/tinyxml/tinyxml2.h

100755100644
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ distribution.
9191
#endif
9292

9393

94-
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
94+
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
9595
// Microsoft visual studio, version 2005 and higher.
9696
/*int _snprintf_s(
9797
char *buffer,
@@ -109,6 +109,9 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
109109
return result;
110110
}
111111
#define TIXML_SSCANF sscanf_s
112+
#elif defined WINCE
113+
#define TIXML_SNPRINTF _snprintf
114+
#define TIXML_SSCANF sscanf
112115
#else
113116
// GCC version 3 and higher
114117
//#warning( "Using sn* functions." )
@@ -367,7 +370,7 @@ class MemPoolT : public MemPool
367370
return;
368371
}
369372
--_currentAllocs;
370-
Chunk* chunk = (Chunk*)mem;
373+
Chunk* chunk = static_cast<Chunk*>( mem );
371374
#ifdef DEBUG
372375
memset( chunk, 0xfe, sizeof(Chunk) );
373376
#endif
@@ -2031,7 +2034,7 @@ class TINYXML2_LIB XMLPrinter : public XMLVisitor
20312034
}
20322035

20332036
protected:
2034-
virtual bool CompactMode( const XMLElement& ) { return _compactMode; };
2037+
virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
20352038

20362039
/** Prints out the space before an element. You may override to change
20372040
the space and tabs used. A PrintSpace() override should call Print().

0 commit comments

Comments
 (0)