2 Commits

2 changed files with 32 additions and 12 deletions

View File

@@ -62,6 +62,26 @@ if meson.version().version_compare('>= 0.54.0')
endif endif
if get_option('tests') 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( test(
'xmltest', 'xmltest',
executable( executable(
@@ -69,7 +89,7 @@ if get_option('tests')
['xmltest.cpp'], ['xmltest.cpp'],
link_with : [lib_tinyxml2], link_with : [lib_tinyxml2],
), ),
workdir : meson.current_source_dir(), workdir : meson.current_build_dir(),
) )
endif endif

View File

@@ -103,8 +103,8 @@ distribution.
#if defined(_WIN64) #if defined(_WIN64)
#define TIXML_FSEEK _fseeki64 #define TIXML_FSEEK _fseeki64
#define TIXML_FTELL _ftelli64 #define TIXML_FTELL _ftelli64
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) \ #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) \
|| defined(__NetBSD__) || defined(__DragonFly__) || defined(__ANDROID__) || (__CYGWIN__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__ANDROID__)
#define TIXML_FSEEK fseeko #define TIXML_FSEEK fseeko
#define TIXML_FTELL ftello #define TIXML_FTELL ftello
#elif defined(__unix__) && defined(__x86_64__) #elif defined(__unix__) && defined(__x86_64__)
@@ -1777,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()) { if(FirstChild() && FirstChild()->ToText()) {
const char* t = FirstChild()->Value(); const char* t = FirstChild()->Value();
if(XMLUtil::ToUnsigned64(t, uval)) { if(XMLUtil::ToUnsigned64(t, ival)) {
return XML_SUCCESS; return XML_SUCCESS;
} }
return XML_CAN_NOT_CONVERT_TEXT; return XML_CAN_NOT_CONVERT_TEXT;
@@ -2413,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(); Clear();
if ( nBytes == 0 || !xml || !*xml ) { if ( len == 0 || !p || !*p ) {
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID; return _errorID;
} }
if ( nBytes == static_cast<size_t>(-1) ) { if ( len == static_cast<size_t>(-1) ) {
nBytes = strlen( xml ); len = strlen( p );
} }
TIXMLASSERT( _charBuffer == 0 ); TIXMLASSERT( _charBuffer == 0 );
_charBuffer = new char[ nBytes+1 ]; _charBuffer = new char[ len+1 ];
memcpy( _charBuffer, xml, nBytes ); memcpy( _charBuffer, p, len );
_charBuffer[nBytes] = 0; _charBuffer[len] = 0;
Parse(); Parse();
if ( Error() ) { if ( Error() ) {