Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 9 additions & 40 deletions tinyxml2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ distribution.
#include "tinyxml2.h"

#include <new> // yes, this one new style header, is in the Android SDK.
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) || defined(__CC_ARM)
#if defined(ANDROID_NDK)
# include <stddef.h>
# include <stdarg.h>
#else
Expand All @@ -40,9 +40,7 @@ distribution.
# define __has_cpp_attribute(x) 0
#endif

#if defined(_MSC_VER)
# define TIXML_FALLTHROUGH (void(0))
#elif (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
#if (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
# define TIXML_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
# define TIXML_FALLTHROUGH [[clang::fallthrough]]
Expand All @@ -53,15 +51,8 @@ distribution.
#endif


#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
// Microsoft Visual Studio, version 2005 and higher. Not WinCE.
/*int _snprintf_s(
char *buffer,
size_t sizeOfBuffer,
size_t count,
const char *format [,
argument] ...
);*/
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
// Microsoft Visual Studio, version 2005 and higher.
static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
{
va_list va;
Expand All @@ -80,33 +71,11 @@ distribution.
#define TIXML_VSCPRINTF _vscprintf
#define TIXML_SSCANF sscanf_s
#elif defined _MSC_VER
// Microsoft Visual Studio 2003 and earlier or WinCE
// Microsoft Visual Studio 2003 and earlier.
#define TIXML_SNPRINTF _snprintf
#define TIXML_VSNPRINTF _vsnprintf
#define TIXML_SSCANF sscanf
#if (_MSC_VER < 1400 ) && (!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.
static 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 ) {
TIXMLASSERT( required >= 0 );
len = required;
break;
}
}
TIXMLASSERT( len >= 0 );
return len;
}
#endif
#define TIXML_VSCPRINTF _vscprintf
#else
// GCC version 3 and higher
//#warning( "Using sn* functions." )
Expand All @@ -121,7 +90,7 @@ distribution.
#define TIXML_SSCANF sscanf
#endif

#if defined(_WIN64)
#if defined(_MSC_VER)
#define TIXML_FSEEK _fseeki64
#define TIXML_FTELL _ftelli64
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__)
Expand Down Expand Up @@ -2257,7 +2226,7 @@ void XMLDocument::Clear()
delete [] _charBuffer;
_charBuffer = 0;
_parsingDepth = 0;

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains stray whitespace on an otherwise blank line. This can cause noisy diffs and may violate whitespace/formatting checks; remove the trailing spaces (leave it as a truly empty line or delete the blank line).

Copilot uses AI. Check for mistakes.
#if 0
_textPool.Trace( "text" );
_elementPool.Trace( "element" );
Expand Down Expand Up @@ -2332,7 +2301,7 @@ static FILE* callfopen( const char* filepath, const char* mode )
{
TIXMLASSERT( filepath );
TIXMLASSERT( mode );
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
FILE* fp = 0;
const errno_t err = fopen_s( &fp, filepath, mode );
if ( err ) {
Expand Down
13 changes: 1 addition & 12 deletions tinyxml2.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ distribution.
#ifndef TINYXML2_INCLUDED
#define TINYXML2_INCLUDED

#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
#if defined(ANDROID_NDK)
# include <ctype.h>
# include <limits.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# if defined(__PS3__)
# include <stddef.h>
# endif
#else
# include <cctype>
# include <climits>
Expand All @@ -42,14 +39,6 @@ distribution.
#endif
#include <stdint.h>

/*
gcc:
g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe

Formatting, Artistic Style:
AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
*/

#if defined( _DEBUG ) || defined (__DEBUG__)
# ifndef TINYXML2_DEBUG
# define TINYXML2_DEBUG
Expand Down