Merge pull request #2711 from DennisHeimbigner/xml2osx.dmh

Update tinyxml and allow its use under OS/X.
This commit is contained in:
Ward Fisher 2023-06-22 10:24:36 -06:00 committed by GitHub
commit ddc67c708f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 31 deletions

View File

@ -299,7 +299,7 @@ jobs:
- name: Configure
shell: bash -l {0}
run: CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ./configure --enable-hdf5 --enable-dap --disable-dap-remote-tests
run: CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ./configure --enable-hdf5 --enable-dap --disable-dap-remote-tests --disable-xml2
if: ${{ success() }}
- name: Look at config.log if error
@ -374,7 +374,7 @@ jobs:
run: |
mkdir build
cd build
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} cmake .. -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DENABLE_DAP=TRUE -DENABLE_HDF5=TRUE -DENABLE_NCZARR=TRUE -D ENABLE_DAP_LONG_TESTS=TRUE
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} cmake .. -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DENABLE_DAP=TRUE -DENABLE_HDF5=TRUE -DENABLE_NCZARR=TRUE -D ENABLE_DAP_LONG_TESTS=TRUE -DENABLE_XML2=FALSE
- name: Print Summary
shell: bash -l {0}

View File

@ -167,7 +167,7 @@ jobs:
- name: Configure
shell: bash -l {0}
run: CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ./configure --enable-hdf5 --enable-dap --disable-dap-remote-tests --enable-doxygen --enable-external-server-tests
run: CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ./configure --enable-hdf5 --enable-dap --disable-dap-remote-tests --enable-doxygen --enable-external-server-tests --disable-xml2
if: ${{ success() }}
- name: Look at config.log if error
@ -327,7 +327,7 @@ jobs:
run: |
mkdir build
cd build
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} cmake .. -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DENABLE_DAP=TRUE -DENABLE_HDF5=TRUE -DENABLE_NCZARR=TRUE -D ENABLE_DAP_LONG_TESTS=TRUE
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} cmake .. -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DENABLE_DAP=TRUE -DENABLE_HDF5=TRUE -DENABLE_NCZARR=TRUE -DENABLE_DAP_LONG_TESTS=TRUE -DENABLE_XML2=FALSE
- name: Print Summary
shell: bash -l {0}

View File

@ -565,18 +565,17 @@ CFLAGS="$SAVECFLAGS"
AC_MSG_CHECKING([whether to search for and use external libxml2])
AC_ARG_ENABLE([libxml2],
[AS_HELP_STRING([--disable-libxml2],
[disable detection and use of libxml2 in favor of the bundled ezxml interpreter])])
[disable detection and use of libxml2 in favor of the bundled xml parser])])
test "x$enable_libxml2" = xno || enable_libxml2=yes
AC_MSG_RESULT([$enable_libxml2])
# We can optionally use libxml2 for DAP4 and nch5comms, if enabled
have_libxml2=no
if test "x$enable_libxml2" = xyes; then
AC_CHECK_PROGS([NC_XML2_CONFIG], [xml2-config])
if test -z "$NC_XML2_CONFIG"; then
AC_MSG_ERROR([Cannot find xml2-config utility. Either install the libxml2 development package, or re-run configure with --disable-libxml2 to use the bundled xml2 parser])
fi
# We can optionally use libxml2 for DAP4 and nch5comms, if enabled
AC_CHECK_LIB([xml2],[xmlReadMemory],[have_libxml2=yes],[have_libxml2=no])
if test "x$have_libxml2" = "xyes" ; then
AC_SEARCH_LIBS([xmlReadMemory],[xml2 xml2.dll cygxml2.dll], [],[])
@ -1256,11 +1255,6 @@ if test "x$enable_hdf5" = "xno" ; then
enable_dap4=no
fi
if test "x$ISOSX" = xyes && test "x$have_libxml2" = xno && test "x$enable_dap4" = xyes ; then
AC_MSG_WARN([OSX requires libxml2 for DAP4 support; disabling DAP4])
enable_dap4=no
fi
if test "x$enable_dap4" = xyes; then
AC_DEFINE([ENABLE_DAP4], [1], [if true, build DAP4 Client])
fi

View File

@ -103,10 +103,17 @@ distribution.
#if defined(_WIN64)
#define TIXML_FSEEK _fseeki64
#define TIXML_FTELL _ftelli64
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) \
|| defined(__NetBSD__) || defined(__DragonFly__) || defined(__ANDROID__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || (__CYGWIN__)
#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
@ -1077,7 +1084,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
StrPair endTag;
p = node->ParseDeep( p, &endTag, curLineNumPtr );
if ( !p ) {
DeleteNode( node );
_document->DeleteNode( node );
if ( !_document->Error() ) {
_document->SetError( XML_ERROR_PARSING, initialLineNum, 0);
}
@ -1110,7 +1117,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
}
if ( !wellLocated ) {
_document->SetError( XML_ERROR_PARSING_DECLARATION, initialLineNum, "XMLDeclaration value=%s", decl->Value());
DeleteNode( node );
_document->DeleteNode( node );
break;
}
}
@ -1145,7 +1152,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
}
if ( mismatch ) {
_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, initialLineNum, "XMLElement name=%s", ele->Name());
DeleteNode( node );
_document->DeleteNode( node );
break;
}
}
@ -1777,11 +1784,11 @@ XMLError XMLElement::QueryInt64Text(int64_t* ival) const
}
XMLError XMLElement::QueryUnsigned64Text(uint64_t* ival) const
XMLError XMLElement::QueryUnsigned64Text(uint64_t* uval) const
{
if(FirstChild() && FirstChild()->ToText()) {
const char* t = FirstChild()->Value();
if(XMLUtil::ToUnsigned64(t, ival)) {
if(XMLUtil::ToUnsigned64(t, uval)) {
return XML_SUCCESS;
}
return XML_CAN_NOT_CONVERT_TEXT;
@ -2413,21 +2420,21 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
}
XMLError XMLDocument::Parse( const char* p, size_t len )
XMLError XMLDocument::Parse( const char* xml, size_t nBytes )
{
Clear();
if ( len == 0 || !p || !*p ) {
if ( nBytes == 0 || !xml || !*xml ) {
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID;
}
if ( len == static_cast<size_t>(-1) ) {
len = strlen( p );
if ( nBytes == static_cast<size_t>(-1) ) {
nBytes = strlen( xml );
}
TIXMLASSERT( _charBuffer == 0 );
_charBuffer = new char[ len+1 ];
memcpy( _charBuffer, p, len );
_charBuffer[len] = 0;
_charBuffer = new char[ nBytes+1 ];
memcpy( _charBuffer, xml, nBytes );
_charBuffer[nBytes] = 0;
Parse();
if ( Error() ) {

View File

@ -83,16 +83,16 @@ distribution.
#if defined(TINYXML2_DEBUG)
# if defined(_MSC_VER)
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
# define TIXMLASSERT( x ) do { if ( !((void)0,(x))) { __debugbreak(); } } while(false)
# elif defined (ANDROID_NDK)
# include <android/log.h>
# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
# define TIXMLASSERT( x ) do { if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } } while(false)
# else
# include <assert.h>
# define TIXMLASSERT assert
# endif
#else
# define TIXMLASSERT( x ) {}
# define TIXMLASSERT( x ) do {} while(false)
#endif
#endif
@ -112,7 +112,7 @@ static const int TIXML2_PATCH_VERSION = 0;
// system, and the capacity of the stack. On the other hand, it's a trivial
// attack that can result from ill, malicious, or even correctly formed XML,
// so there needs to be a limit in place.
static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
static const int TINYXML2_MAX_ELEMENT_DEPTH = 500;
namespace tinyxml2
{
@ -375,7 +375,7 @@ public:
virtual void* Alloc() {
if ( !_root ) {
// Need a new block.
Block* block = new Block();
Block* block = new Block;
_blockPtrs.Push( block );
Item* blockItems = block->items;