2 Commits

2 changed files with 32 additions and 19 deletions

View File

@@ -62,6 +62,26 @@ if meson.version().version_compare('>= 0.54.0')
endif
if get_option('tests')
# Try to find a copy command. If this is windows we probably don't have cp,
# but if this is msys then we do, so make cp not required in that case, and
# try Xcopy if cp isn't found
prog_cp = find_program('cp', required : build_machine.system() != 'windows')
command = ['-r']
if not prog_cp.found()
prog_cp = find_program('Xcopy')
command = ['/E', '/I']
endif
# Copy the test resources into the build dir
run_command(
prog_cp,
[
command,
meson.current_source_dir() / 'resources',
meson.current_build_dir(),
],
)
test(
'xmltest',
executable(
@@ -69,7 +89,7 @@ if get_option('tests')
['xmltest.cpp'],
link_with : [lib_tinyxml2],
),
workdir : meson.current_source_dir(),
workdir : meson.current_build_dir(),
)
endif

View File

@@ -103,17 +103,10 @@ distribution.
#if defined(_WIN64)
#define TIXML_FSEEK _fseeki64
#define TIXML_FTELL _ftelli64
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || (__CYGWIN__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) \
|| defined(__NetBSD__) || defined(__DragonFly__) || defined(__ANDROID__)
#define TIXML_FSEEK fseeko
#define TIXML_FTELL ftello
#elif defined(__ANDROID__)
#if __ANDROID_API__ > 24
#define TIXML_FSEEK fseeko64
#define TIXML_FTELL ftello64
#else
#define TIXML_FSEEK fseeko
#define TIXML_FTELL ftello
#endif
#elif defined(__unix__) && defined(__x86_64__)
#define TIXML_FSEEK fseeko64
#define TIXML_FTELL ftello64
@@ -1784,11 +1777,11 @@ XMLError XMLElement::QueryInt64Text(int64_t* ival) const
}
XMLError XMLElement::QueryUnsigned64Text(uint64_t* uval) const
XMLError XMLElement::QueryUnsigned64Text(uint64_t* ival) const
{
if(FirstChild() && FirstChild()->ToText()) {
const char* t = FirstChild()->Value();
if(XMLUtil::ToUnsigned64(t, uval)) {
if(XMLUtil::ToUnsigned64(t, ival)) {
return XML_SUCCESS;
}
return XML_CAN_NOT_CONVERT_TEXT;
@@ -2420,21 +2413,21 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
}
XMLError XMLDocument::Parse( const char* xml, size_t nBytes )
XMLError XMLDocument::Parse( const char* p, size_t len )
{
Clear();
if ( nBytes == 0 || !xml || !*xml ) {
if ( len == 0 || !p || !*p ) {
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID;
}
if ( nBytes == static_cast<size_t>(-1) ) {
nBytes = strlen( xml );
if ( len == static_cast<size_t>(-1) ) {
len = strlen( p );
}
TIXMLASSERT( _charBuffer == 0 );
_charBuffer = new char[ nBytes+1 ];
memcpy( _charBuffer, xml, nBytes );
_charBuffer[nBytes] = 0;
_charBuffer = new char[ len+1 ];
memcpy( _charBuffer, p, len );
_charBuffer[len] = 0;
Parse();
if ( Error() ) {