mirror of https://github.com/AxioDL/tinyxml2.git
Patch for Visual Studio 2003 and earlier.
This patch will be easy to extend in the future.
This commit is contained in:
parent
2b2649e1e4
commit
1527cf4b2f
30
tinyxml2.cpp
30
tinyxml2.cpp
|
@ -2038,39 +2038,13 @@ void XMLPrinter::Print( const char* format, ... )
|
|||
vfprintf( _fp, format, va );
|
||||
}
|
||||
else {
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||
#if defined(WINCE)
|
||||
int len = 512;
|
||||
for (;;) {
|
||||
len = len*2;
|
||||
char* str = new char[len]();
|
||||
const int required = _vsnprintf(str, len, format, va);
|
||||
delete[] str;
|
||||
if ( required != -1 ) {
|
||||
len = required;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int len = _vscprintf( format, va );
|
||||
#endif
|
||||
#else
|
||||
int len = vsnprintf( 0, 0, format, va );
|
||||
#endif
|
||||
int len = TIXML_VSCPRINTF( format, va );
|
||||
// Close out and re-start the va-args
|
||||
va_end( va );
|
||||
va_start( va, format );
|
||||
TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 );
|
||||
char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.
|
||||
#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 );
|
||||
#endif
|
||||
#else
|
||||
vsnprintf( p, len+1, format, va );
|
||||
#endif
|
||||
TIXML_VSNPRINTF( p, len+1, format, va );
|
||||
}
|
||||
va_end( va );
|
||||
}
|
||||
|
|
39
tinyxml2.h
39
tinyxml2.h
|
@ -92,7 +92,7 @@ distribution.
|
|||
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
||||
// Microsoft visual studio, version 2005 and higher.
|
||||
// Microsoft visual studio, version 2005 and higher. Not WinCE.
|
||||
/*int _snprintf_s(
|
||||
char *buffer,
|
||||
size_t sizeOfBuffer,
|
||||
|
@ -108,14 +108,49 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
|||
va_end( va );
|
||||
return result;
|
||||
}
|
||||
inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
|
||||
{
|
||||
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
||||
return result;
|
||||
}
|
||||
#define TIXML_VSCPRINTF _vscprintf
|
||||
#define TIXML_SSCANF sscanf_s
|
||||
#elif defined WINCE
|
||||
#elif defined _MSC_VER
|
||||
// Microsoft Visual Studio 2003 and earlier or WinCE
|
||||
#define TIXML_SNPRINTF _snprintf
|
||||
#define TIXML_VSNPRINTF _vsnprintf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#if (_MSC_VER == 1300 ) && (!defined WINCE)
|
||||
// Microsoft Visual Studio 2003 and not WinCE.
|
||||
#define TIXML_VSCPRINTF _vscprintf //VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
|
||||
#else
|
||||
// Microsoft Visual Studio 2003 and earlier or WinCE.
|
||||
inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
||||
{
|
||||
int len = 512;
|
||||
for (;;) {
|
||||
len = len*2;
|
||||
char* str = new char[len]();
|
||||
const int required = _vsnprintf(str, len, format, va);
|
||||
delete[] str;
|
||||
if ( required != -1 ) {
|
||||
len = required;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// GCC version 3 and higher
|
||||
//#warning( "Using sn* functions." )
|
||||
#define TIXML_SNPRINTF snprintf
|
||||
#define TIXML_VSNPRINTF vsnprintf
|
||||
inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
||||
{
|
||||
int len = vsnprintf( 0, 0, format, va );
|
||||
return len;
|
||||
}
|
||||
#define TIXML_SSCANF sscanf
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue