Skip to content

Commit 0164512

Browse files
committed
Merge branch 'tinyxml2.dmh' of https://github.com/DennisHeimbigner/netcdf-c into gh2170.wif
2 parents 9273aaf + 6d44ec3 commit 0164512

File tree

18 files changed

+5674
-1318
lines changed

18 files changed

+5674
-1318
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,9 @@ IF(NOT FOUND_CURL)
12511251
ENDIF(NOT FOUND_CURL)
12521252

12531253

1254-
OPTION(ENABLE_LIBXML2 "Link against libxml2 if it is available, use the packaged ezxml parser otherwise." ON)
1255-
SET(XMLPARSER "ezxml (bundled)")
1254+
OPTION(ENABLE_LIBXML2 "Link against libxml2 if it is available, use the packaged tinyxml2 parser otherwise." ON)
1255+
SET(XMLPARSER "tinyxml2 (bundled)")
1256+
12561257
# see if we have libxml2
12571258

12581259
IF(ENABLE_LIBXML2)
@@ -1794,6 +1795,7 @@ CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
17941795
CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
17951796
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
17961797
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
1798+
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
17971799
CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)
17981800
CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
17991801
CHECK_FUNCTION_EXISTS(mktemp HAVE_MKTEMP)

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This file contains a high-level description of this package's evolution. Release
88
## 4.8.2 - TBD
99

1010
* [Enhancement] Improve filter support. More specifically (1) add nc_inq_filter_avail to check if a filter is available, (2) add the notion of standard filters, (3) cleanup szip support to fix interaction with NCZarr. See [Github #2245](https://github.com/Unidata/netcdf-c/pull/2245).
11+
* [Enhancement] Switch to tinyxml2 as the default xml parser implementation. See [Github #2170](https://github.com/Unidata/netcdf-c/pull/2170).
1112
* [Bug Fix] Require that the type of the variable in nc_def_var_filter is not variable length. See [Github #/2231](https://github.com/Unidata/netcdf-c/pull/2231).
1213
* [File Change] Apply HDF5 v1.8 format compatibility when writing to previous files, as well as when creating new files. The superblock version remains at 2 for newly created files. Full backward read/write compatibility for netCDF-4 is maintained in all cases. See [Github #2176](https://github.com/Unidata/netcdf-c/issues/2176).
1314
* [Enhancement] Add ability to set dataset alignment for netcdf-4/HDF5 files. See [Github #2206](https://github.com/Unidata/netcdf-c/pull/2206).

config.h.cmake.in

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ are set when opening a binary file on Windows. */
299299
#cmakedefine HAVE_LIBPNETCDF 1
300300

301301
/* Define to 1 if you have the libxml2 library. */
302-
#cmakedefine HAVE_LIBXML2 1
302+
#cmakedefine ENABLE_LIBXML2 1
303303

304304
/* Define to 1 if you have the <locale.h> header file. */
305305
#cmakedefine HAVE_LOCALE_H 1
@@ -358,12 +358,6 @@ are set when opening a binary file on Windows. */
358358
/* Define to 1 if you have the <stdlib.h> header file. */
359359
#cmakedefine HAVE_STDLIB_H 1
360360

361-
/* Define to 1 if you have the `strdup' function. */
362-
#cmakedefine HAVE_STRDUP 1
363-
364-
/* Define to 1 if you have the `strndup` function. */
365-
#cmakedefine HAVE_STRNDUP
366-
367361
/* Define to 1 if you have the <strings.h> header file. */
368362
#cmakedefine HAVE_STRINGS_H 1
369363

@@ -379,6 +373,15 @@ are set when opening a binary file on Windows. */
379373
/* Define to 1 if you have the <libgen.h> header file. */
380374
#cmakedefine HAVE_LIBGEN_H 1
381375

376+
/* Define to 1 if you have the `strdup' function. */
377+
#cmakedefine HAVE_STRDUP 1
378+
379+
/* Define to 1 if you have the `strndup` function. */
380+
#cmakedefine HAVE_STRNDUP
381+
382+
/* Define to 1 if you have the `strcasecmp` function. */
383+
#cmakedefine HAVE_STRCASECMP
384+
382385
/* Define to 1 if you have the `strlcat' function. */
383386
#cmakedefine HAVE_STRLCAT 1
384387

configure.ac

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,45 @@ fi
523523

524524
CFLAGS="$SAVECFLAGS"
525525

526+
###
527+
# Libxml2 control block.
528+
###
529+
530+
AC_MSG_CHECKING([whether to search for and use external libxml2])
531+
AC_ARG_ENABLE([libxml2],
532+
[AS_HELP_STRING([--disable-libxml2],
533+
[disable detection and use of libxml2 in favor of the bundled ezxml interpreter])])
534+
test "x$enable_libxml2" = xno || enable_libxml2=yes
535+
AC_MSG_RESULT([$enable_libxml2])
536+
537+
have_libxml2=no
538+
if test "x$enable_libxml2" = xyes; then
539+
# We can optionally use libxml2 for DAP4, if available
540+
AC_CHECK_LIB([xml2],[xmlReadMemory],[have_libxml2=yes],[have_libxml2=no])
541+
if test "x$have_libxml2" = "xyes" ; then
542+
AC_SEARCH_LIBS([xmlReadMemory],[xml2 xml2.dll cygxml2.dll], [],[])
543+
fi
544+
if test "x$have_libxml2" = xyes; then
545+
XML2FLAGS=`xml2-config --cflags`
546+
AC_SUBST([XML2FLAGS],${XML2FLAGS})
547+
AC_DEFINE([HAVE_LIBXML2], [1], [if true, use libxml2])
548+
fi
549+
fi
550+
551+
if test "x$enable_libxml2" = xyes; then
552+
XMLPARSER="libxml2"
553+
else
554+
XMLPARSER="tinyxml2 (bundled)"
555+
fi
556+
557+
# Need a condition and subst for this
558+
AM_CONDITIONAL(ENABLE_LIBXML2, [test "x$enable_libxml2" = xyes])
559+
AC_SUBST([XMLPARSER],[${XMLPARSER}])
560+
561+
###
562+
# End Libxml2 block
563+
###
564+
526565
# --enable-dap => enable-dap4
527566
enable_dap4=$enable_dap
528567
AC_MSG_CHECKING([whether dap remote testing should be enabled])
@@ -1094,51 +1133,21 @@ AC_CHECK_FUNCS([strlcat snprintf strcasecmp fileno \
10941133
AC_CHECK_FUNCS([clock_gettime])
10951134
AC_CHECK_TYPES([struct timespec])
10961135

1097-
# disable dap4 if netcdf-4 is disabled
1098-
#if test "x$enable_netcdf_4" = "xno" ; then
1136+
# disable dap4 if hdf5 is disabled
10991137
if test "x$enable_hdf5" = "xno" ; then
11001138
AC_MSG_WARN([netcdf-4 not enabled; disabling DAP4])
11011139
enable_dap4=no
11021140
fi
11031141

1104-
if test "x$enable_dap4" = xyes; then
1105-
AC_DEFINE([ENABLE_DAP4], [1], [if true, build DAP4 Client])
1142+
if test "x$ISOSX" = xyes && "x$have_libxml2" = xno ; then
1143+
AC_MSG_ERROR([Error: OSX requires libxml2 => --disable-dap4.])
1144+
enable_dap4=no
11061145
fi
11071146

1108-
###
1109-
# Libxml2 control block.
1110-
###
1111-
1112-
AC_MSG_CHECKING([whether to search for and use external libxml2])
1113-
AC_ARG_ENABLE([libxml2],
1114-
[AS_HELP_STRING([--disable-libxml2],
1115-
[disable detection and use of libxml2 in favor of the bundled ezxml interpreter])])
1116-
test "x$disable_libxml2" = xyes && enable_libxml2=no
1117-
AC_MSG_RESULT($enable_libxml2)
1118-
1119-
AC_SUBST([XMLPARSER],"ezxml")
1120-
if test "x$enable_libxml2" = xyes; then
1121-
# We can optionally use libxml2 for DAP4, if available
1122-
AC_CHECK_LIB([xml2],[xmlReadMemory],[have_libxml2=yes],[have_libxml2=no])
1123-
if test "x$have_libxml2" = "xyes" ; then
1124-
AC_SEARCH_LIBS([xmlReadMemory],[xml2 xml2.dll cygxml2.dll], [],[])
1125-
AC_SUBST([XMLPARSER],"libxml2")
1126-
fi
1127-
if test "x$have_libxml2" = xyes; then
1128-
XML2FLAGS=`xml2-config --cflags`
1129-
AC_SUBST([XML2FLAGS],${XML2FLAGS})
1130-
AC_DEFINE([HAVE_LIBXML2], [1], [if true, use libxml2])
1131-
fi
1132-
1147+
if test "x$enable_dap4" = xyes; then
1148+
AC_DEFINE([ENABLE_DAP4], [1], [if true, build DAP4 Client])
11331149
fi
11341150

1135-
# Need a condition for this
1136-
AM_CONDITIONAL(HAVE_LIBXML2, [test "x$have_libxml2" = xyes])
1137-
1138-
###
1139-
# End Libxml2 block
1140-
###
1141-
11421151
# check for useful, but not essential, memio support
11431152
AC_CHECK_FUNCS([memmove getpagesize sysconf])
11441153

@@ -1257,7 +1266,7 @@ AC_FUNC_ALLOCA
12571266
AC_CHECK_DECLS([isnan, isinf, isfinite],,,[#include <math.h>])
12581267
AC_STRUCT_ST_BLKSIZE
12591268
UD_CHECK_IEEE
1260-
AC_CHECK_TYPES([size_t, ssize_t, schar, uchar, longlong, ushort, uint, int64, uint64, size64_t, ssize64_t, _off64_t, uint64_t])
1269+
AC_CHECK_TYPES([size_t, ssize_t, schar, uchar, longlong, ushort, uint, int64, uint64, size64_t, ssize64_t, _off64_t, uint64_t, ptrdiff_t])
12611270
AC_TYPE_OFF_T
12621271
AC_TYPE_UINTPTR_T
12631272
AC_C_CHAR_UNSIGNED

dap4_test/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include $(top_srcdir)/lib_flags.am
1010
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
1111
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
1212
#TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
13+
#TESTS_ENVIRONMENT = export SETX=1;
1314

1415
# Note which tests depend on other tests. Necessary for make -j check.
1516
TEST_EXTENSIONS = .sh

dap4_test/test_data.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ main(int argc, char** argv)
4141
}
4242

4343
/* build the url */
44-
snprintf(url,sizeof(url),"file://%s#dap4&debug=copy",argv[0]);
45-
if(argc >= 3) {
46-
strlcat(url,"&substratename=",sizeof(url));
47-
strlcat(url,argv[1],sizeof(url));
48-
}
44+
snprintf(url,sizeof(url),"file://%s#dap4&debug=copy%s%s%s",
45+
argv[0],
46+
(argc >= 3 ? "&substratename=" : ""),
47+
(argc >= 3 ? argv[1] : ""),
4948
#ifdef DEBUG
50-
strlcat(url,"&log",sizeof(url));
49+
"&log"
50+
#else
51+
""
5152
#endif
53+
);
5254

5355
#ifdef DEBUG
5456
fprintf(stderr,"test_data url=%s\n",url);

include/ncconfigure.h

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#ifndef NCCONFIGURE_H
1111
#define NCCONFIGURE_H 1
1212

13+
#ifdef HAVE_CONFIG_H
14+
#include "config.h"
15+
#endif
16+
1317
#ifdef HAVE_STDLIB_H
1418
#include <stdlib.h>
1519
#endif
@@ -41,24 +45,49 @@ typedef SSIZE_T ssize_t;
4145
#ifndef _WIN32
4246
#if __STDC__ == 1 /*supposed to be same as -ansi flag */
4347

48+
#if defined(__cplusplus)
49+
extern "C" {
50+
#endif
51+
4452
/* WARNING: in some systems, these functions may be defined as macros, so check */
53+
#ifndef HAVE_STRDUP
4554
#ifndef strdup
46-
extern char* strdup(const char*);
55+
char* strdup(const char*);
56+
#endif
4757
#endif
58+
59+
#ifndef HAVE_STRLCAT
4860
#ifndef strlcat
49-
extern size_t strlcat(char*,const char*,size_t);
61+
size_t strlcat(char*,const char*,size_t);
62+
#endif
5063
#endif
64+
65+
#ifndef HAVE_SNPRINTF
5166
#ifndef snprintf
52-
extern int snprintf(char*, size_t, const char*, ...);
67+
int snprintf(char*, size_t, const char*, ...);
68+
#endif
5369
#endif
70+
71+
#ifndef HAVE_STRCASECMP
5472
#ifndef strcasecmp
5573
extern int strcasecmp(const char*, const char*);
5674
#endif
75+
#endif
76+
77+
#ifndef HAVE_STRTOLL
5778
#ifndef strtoll
58-
extern long long int strtoll(const char*, char**, int);
79+
long long int strtoll(const char*, char**, int);
5980
#endif
81+
#endif
82+
83+
#ifndef HAVE_STRTOULL
6084
#ifndef strtoull
61-
extern unsigned long long int strtoull(const char*, char**, int);
85+
unsigned long long int strtoull(const char*, char**, int);
86+
#endif
87+
#endif
88+
89+
#if defined(__cplusplus)
90+
}
6291
#endif
6392

6493
#endif /*STDC*/
@@ -145,6 +174,10 @@ typedef unsigned long long uint64_t;
145174
typedef unsigned long long size64_t;
146175
#endif
147176

177+
#ifndef HAVE_PTRDIFF_T
178+
typedef long ptrdiff_t;
179+
#endif
180+
148181
/* Provide a fixed size alternative to off_t or off64_t */
149182
typedef long long fileoffset_t;
150183

lib_flags.am

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ if USE_DAP
1313
AM_CPPFLAGS += -I${top_srcdir}/oc2
1414
endif
1515

16+
1617
if ENABLE_NCZARR
1718
AM_CPPFLAGS += -I${top_srcdir}/libnczarr
1819
endif
1920

20-
if ENABLE_S3_SDK
21+
22+
if ENABLE_S3_SDK
23+
AM_LDFLAGS += -lstdc++
24+
endif
25+
26+
if ! ENABLE_LIBXML2
27+
# => tinyxml2
2128
AM_LDFLAGS += -lstdc++
2229
endif
2330

libdap4/d4parser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ NCD4_parse(NCD4meta* metadata)
184184
done:
185185
if(doc != NULL)
186186
ncxml_free(doc);
187+
doc = NULL;
187188
reclaimParser(parser);
188189
return THROW(ret);
189190
}

libncxml/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
IF(HAVE_LIBXML2)
22
SET(libncxml_SOURCES ncxml_xml2.c)
33
ELSE()
4-
SET(libncxml_SOURCES ncxml_ezxml.c ezxml.c ezxml.h)
4+
SET(libncxml_SOURCES ncxml_tinyxml2.cpp tinyxml2.cpp tinyxml2.h)
55
ENDIF()
66

77
add_library(ncxml OBJECT ${libncxml_SOURCES})

0 commit comments

Comments
 (0)