You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ni...@apache.org on 2019/03/01 16:07:44 UTC

svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Author: niq
Date: Fri Mar  1 16:07:44 2019
New Revision: 1854603

URL: http://svn.apache.org/viewvc?rev=1854603&view=rev
Log:
apr_xml: backport libxml2 support (r1084621) and build (r1085350)
with their subsequent minor patches.
First pass: this requires further followup work to backport subsequent
patches dealing with non-*X platform builds (not to mention testing).

Added:
    apr/apr-util/branches/1.7.x/build/xml.m4
    apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c
    apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h
    apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c
Modified:
    apr/apr-util/branches/1.7.x/build/apu-conf.m4
    apr/apr-util/branches/1.7.x/configure.in
    apr/apr-util/branches/1.7.x/include/apu.h.in
    apr/apr-util/branches/1.7.x/include/apu.hw
    apr/apr-util/branches/1.7.x/include/apu.hwc
    apr/apr-util/branches/1.7.x/xml/NWGNUmakefile
    apr/apr-util/branches/1.7.x/xml/apr_xml.c

Modified: apr/apr-util/branches/1.7.x/build/apu-conf.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/build/apu-conf.m4?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/build/apu-conf.m4 (original)
+++ apr/apr-util/branches/1.7.x/build/apu-conf.m4 Fri Mar  1 16:07:44 2019
@@ -46,120 +46,6 @@ AC_DEFUN([APU_FIND_APR], [
   AC_SUBST(APR_BUILD_DIR)
 ])
 
-dnl
-dnl APU_TRY_EXPAT_LINK(
-dnl      test-message, cache-var-name, hdrs, libs,
-dnl      [actions-on-success], [actions-on-failure])
-dnl         
-dnl Tests linking against expat with libraries 'libs' and includes
-dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
-dnl On success, sets $expat_libs to libs, sets $apu_have_expat to 1, 
-dnl and runs actions-on-success; on failure runs actions-on-failure.
-dnl
-AC_DEFUN([APU_TRY_EXPAT_LINK], [
-AC_CACHE_CHECK([$1], [$2], [
-  apu_expat_LIBS=$LIBS
-  LIBS="$LIBS $4"
-  AC_TRY_LINK([#include <stdlib.h>
-#include <$3>], [XML_ParserCreate(NULL);],
-    [$2=yes], [$2=no])
-  LIBS=$apu_expat_LIBS
-])
-
-if test $[$2] = yes; then
-   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
-             [Define if $3 is available])
-   apu_expat_libs="$4"
-   apu_has_expat=1
-   $5
-else
-   apu_has_expat=0
-   $6
-fi
-])
-
-dnl
-dnl APU_SYSTEM_EXPAT: tests for a system expat installation
-dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
-dnl appropriately.  This is mostly for compatibility with existing
-dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
-dnl be dropped later.
-dnl
-AC_DEFUN([APU_SYSTEM_EXPAT], [
- 
-  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system, 
-    [expat.h], [-lexpat])
-
-  if test $apu_has_expat = 0; then
-    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
-       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
-  fi
-
-  if test $apu_has_expat = 0; then
-    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
-       [xml/xmlparse.h], [-lexpat])
-  fi
-
-  if test $apu_has_expat = 0; then
-    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
-       [xmlparse/xmlparse.h], [-lexpat])
-  fi
-
-  if test $apu_has_expat = 0; then
-    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
-    APR_ADDTO(CPPFLAGS, [-I/usr/local/include])
- 
-    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local], 
-       apu_cv_expat_usrlocal, [expat.h], [-lexpat],
-       [APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/local/include])
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L/usr/local/lib])],[
-       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
-       APR_REMOVEFROM(CPPFLAGS, [-I/usr/local/include])
-      ])
-  fi
-])
-
-
-dnl
-dnl APU_FIND_EXPAT: figure out where EXPAT is located
-dnl
-AC_DEFUN([APU_FIND_EXPAT], [
-
-save_cppflags="$CPPFLAGS"
-save_ldflags="$LDFLAGS"
-
-apu_has_expat=0
-
-apu_try_external_expat=1
-
-AC_ARG_WITH([expat],
-[  --with-expat=DIR        specify Expat location], [
-  if test "$withval" = "yes"; then
-    AC_MSG_ERROR([a directory must be specified for --with-expat])
-  elif test "$withval" = "no"; then
-    AC_MSG_ERROR([Expat cannot be disabled (at this time)])
-  else
-    # Add given path to standard search paths if appropriate:
-    if test "$withval" != "/usr"; then
-      APR_ADDTO(LDFLAGS, [-L$withval/lib])
-      APR_ADDTO(CPPFLAGS, [-I$withval/include])
-      APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
-      APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
-    fi
-  fi
-])
-
-if test $apu_try_external_expat = 1; then
-  APU_SYSTEM_EXPAT
-fi
-
-APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
-APR_ADDTO(APRUTIL_LIBS, [$apu_expat_libs])
-
-CPPFLAGS=$save_cppflags
-LDFLAGS=$save_ldflags
-])
-
 
 dnl 
 dnl Find a particular LDAP library

Added: apr/apr-util/branches/1.7.x/build/xml.m4
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/build/xml.m4?rev=1854603&view=auto
==============================================================================
--- apr/apr-util/branches/1.7.x/build/xml.m4 (added)
+++ apr/apr-util/branches/1.7.x/build/xml.m4 Fri Mar  1 16:07:44 2019
@@ -0,0 +1,211 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Licensed to the Apache Software Foundation (ASF) under one or more
+dnl contributor license agreements.  See the NOTICE file distributed with
+dnl this work for additional information regarding copyright ownership.
+dnl The ASF licenses this file to You under the Apache License, Version 2.0
+dnl (the "License"); you may not use this file except in compliance with
+dnl the License.  You may obtain a copy of the License at
+dnl
+dnl     http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+
+
+dnl
+dnl APU_TRY_EXPAT_LINK(
+dnl      test-message, cache-var-name, hdrs, libs,
+dnl      [actions-on-success], [actions-on-failure])
+dnl         
+dnl Tests linking against expat with libraries 'libs' and includes
+dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
+dnl On success, sets $expat_libs to libs, sets $apu_has_expat to 1, 
+dnl and runs actions-on-success; on failure runs actions-on-failure.
+dnl
+AC_DEFUN([APU_TRY_EXPAT_LINK], [
+AC_CACHE_CHECK([$1], [$2], [
+  apu_expat_LIBS=$LIBS
+  apu_expat_CPPFLAGS=$CPPFLAGS
+  LIBS="$LIBS $4"
+  CPPFLAGS="$CPPFLAGS $INCLUDES"
+  AC_TRY_LINK([#include <stdlib.h>
+#include <$3>], [XML_ParserCreate(NULL);],
+    [$2=yes], [$2=no])
+  LIBS=$apu_expat_LIBS
+  CPPFLAGS=$apu_expat_CPPFLAGS
+])
+
+if test $[$2] = yes; then
+   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
+             [Define if $3 is available])
+   apu_expat_libs="$4"
+   apu_has_expat=1
+   $5
+   AC_SUBST(apu_has_expat)
+else
+   apu_has_expat=0
+   $6
+fi
+])
+
+dnl
+dnl APU_SYSTEM_EXPAT: tests for a system expat installation
+dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
+dnl appropriately.  This is mostly for compatibility with existing
+dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
+dnl be dropped later.
+dnl
+AC_DEFUN([APU_SYSTEM_EXPAT], [
+ 
+  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system, 
+    [expat.h], [-lexpat])
+
+  if test $apu_has_expat = 0; then
+    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
+       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
+  fi
+
+  if test $apu_has_expat = 0; then
+    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
+       [xml/xmlparse.h], [-lexpat])
+  fi
+
+  if test $apu_has_expat = 0; then
+    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
+       [xmlparse/xmlparse.h], [-lexpat])
+  fi
+
+  if test $apu_has_expat = 0; then
+    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
+    APR_ADDTO(INCLUDES, [-I/usr/local/include])
+ 
+    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local], 
+       apu_cv_expat_usrlocal, [expat.h], [-lexpat], [], [
+       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
+       APR_REMOVEFROM(INCLUDES, [-I/usr/local/include])
+      ])
+  fi
+])
+
+
+dnl
+dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
+dnl
+AC_DEFUN([APU_FIND_EXPAT], [
+
+save_cppflags="$CPPFLAGS"
+
+apu_has_expat=0
+
+AC_ARG_WITH([expat],
+[  --with-expat=DIR        specify Expat location], [
+  if test "$withval" = "yes"; then
+    AC_MSG_ERROR([a directory must be specified for --with-expat])
+  elif test "$withval" = "no"; then
+    if test "$apu_has_libxml2" != "1"; then
+      AC_MSG_ERROR([An XML parser is required!  If you disable expat, you must select --with-libxml2])
+    fi
+  else
+    # Add given path to standard search paths if appropriate:
+    if test "$apu_has_libxml2" = "1"; then
+      AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
+    fi
+    if test "$withval" != "/usr"; then
+      APR_ADDTO(INCLUDES, [-I$withval/include])
+      APR_ADDTO(LDFLAGS, [-L$withval/lib])
+    fi
+  fi
+])
+
+if test "$apu_has_libxml2" != "1"; then
+  APU_SYSTEM_EXPAT
+
+  APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
+  APR_ADDTO(LIBS, [$apu_expat_libs])
+
+  APR_XML_DIR=$bundled_subdir
+  AC_SUBST(APR_XML_DIR)
+fi
+
+CPPFLAGS=$save_cppflags
+])
+
+
+dnl
+dnl APU_FIND_LIBXML2: figure out where LIBXML2 is located (or use bundled)
+dnl
+AC_DEFUN([APU_FIND_LIBXML2], [
+
+save_cppflags="$CPPFLAGS"
+
+apu_has_libxml2=0
+apu_try_libxml2=0
+
+AC_ARG_WITH([libxml2],
+[  --with-libxml2=DIR      specify libxml2 location], [
+  if test "$withval" = "yes"; then
+    apu_try_libxml2=1
+    APR_ADDTO(INCLUDES, [-I/usr/include/libxml2])
+  elif test "$withval" != "no"; then
+    apu_try_libxml2=1
+    APR_ADDTO(INCLUDES, [-I$withval/include/libxml2])
+    if test "$withval" != "/usr"; then
+      APR_ADDTO(LDFLAGS, [-L$withval/lib])
+    fi
+  fi
+  if test ${apu_try_libxml2} = "1" ; then
+
+    #test for libxml2
+    AC_CACHE_CHECK([libxml2], [apu_cv_libxml2], [
+      apu_libxml2_CPPFLAGS=$CPPFLAGS
+      apu_libxml2_LIBS="$LIBS -lxml2"
+      CPPFLAGS="$CPPFLAGS $INCLUDES"
+      LIBS="$LIBS -lxml2"
+      AC_TRY_LINK(
+        [#include <libxml/parser.h>],
+        [xmlSAXHandler sax; xmlCreatePushParserCtxt(&sax, NULL, NULL, 0, NULL);],
+        [apu_cv_libxml2=yes],
+        [apu_cv_libxml2=no],
+      )
+      CPPFLAGS=$apu_libxml2_CPPFLAGS
+      LIBS=$apu_libxml2_LIBS
+    ])
+    if test $apu_cv_libxml2 = yes ; then
+      AC_DEFINE([HAVE_LIBXML2_H], 1, [libxml2 found])
+      apu_has_libxml2=1
+    else
+      apu_has_libxml2=0
+    fi
+  fi
+])
+AC_SUBST(apu_has_libxml2)
+
+if test ${apu_has_libxml2} = "1" ; then
+  APR_ADDTO(APRUTIL_EXPORT_LIBS, [-lxml2])
+  APR_ADDTO(LIBS, [-lxml2])
+fi
+
+CPPFLAGS=$save_cppflags
+])
+
+dnl
+dnl APU_FIND_XML: Find an XML library
+dnl
+dnl Logic: we need exactly one but not both XML libraries
+dnl        Make expat the default for back-compatibility.
+dnl        Use libxml2 if a --with-libxml2 is specified (and works),
+dnl        otherwise expat.
+dnl
+AC_DEFUN([APU_FIND_XML], [
+APU_FIND_LIBXML2
+APU_FIND_EXPAT
+
+if test ${apu_has_expat} = "1" && test ${apu_has_libxml2} = "1" ; then
+  AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
+elif test ${apu_has_expat} != "1" && test ${apu_has_libxml2} != "1" ; then
+  AC_MSG_ERROR(No XML parser found!  Please specify --with-expat or --with-libxml2)
+fi
+])

Modified: apr/apr-util/branches/1.7.x/configure.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/configure.in?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/configure.in (original)
+++ apr/apr-util/branches/1.7.x/configure.in Fri Mar  1 16:07:44 2019
@@ -9,6 +9,7 @@ AC_CONFIG_HEADER(include/private/apu_con
 AC_CONFIG_AUX_DIR(build)
 
 sinclude(build/apu-conf.m4)
+sinclude(build/xml.m4)
 sinclude(build/apu-iconv.m4)
 sinclude(build/apu-hints.m4)
 sinclude(build/apr_common.m4)
@@ -166,7 +167,7 @@ APU_CHECK_DBD_SQLITE3
 APU_CHECK_DBD_SQLITE2
 APU_CHECK_DBD_ORACLE
 APU_CHECK_DBD_ODBC
-APU_FIND_EXPAT
+APU_FIND_XML
 APU_FIND_ICONV
 
 dnl Enable DSO build; must be last:

Modified: apr/apr-util/branches/1.7.x/include/apu.h.in
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apu.h.in?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/include/apu.h.in (original)
+++ apr/apr-util/branches/1.7.x/include/apu.h.in Fri Mar  1 16:07:44 2019
@@ -125,5 +125,8 @@
 #define APU_HAVE_ICONV         @have_iconv@
 #define APR_HAS_XLATE          (APU_HAVE_APR_ICONV || APU_HAVE_ICONV)
 
+#define APU_USE_EXPAT          @apu_has_expat@
+#define APU_USE_LIBXML2        @apu_has_libxml2@
+
 #endif /* APU_H */
 /** @} */

Modified: apr/apr-util/branches/1.7.x/include/apu.hw
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apu.hw?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/include/apu.hw (original)
+++ apr/apr-util/branches/1.7.x/include/apu.hw Fri Mar  1 16:07:44 2019
@@ -142,5 +142,8 @@
 #define APU_HAVE_ICONV          0
 #define APR_HAS_XLATE           (APU_HAVE_APR_ICONV || APU_HAVE_ICONV)
 
+#define APU_USE_EXPAT           1
+#define APU_USE_LIBXML2         0
+
 #endif /* APU_H */
 /** @} */

Modified: apr/apr-util/branches/1.7.x/include/apu.hwc
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apu.hwc?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/include/apu.hwc (original)
+++ apr/apr-util/branches/1.7.x/include/apu.hwc Fri Mar  1 16:07:44 2019
@@ -141,5 +141,8 @@
 #define APU_HAVE_ICONV          0
 #define APR_HAS_XLATE           (APU_HAVE_APR_ICONV || APU_HAVE_ICONV)
 
+#define APU_USE_EXPAT           @apu_use_expat_10@
+#define APU_USE_LIBXML2         @apu_use_libxml2_10@
+
 #endif /* APU_H */
 /** @} */

Modified: apr/apr-util/branches/1.7.x/xml/NWGNUmakefile
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/NWGNUmakefile?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/xml/NWGNUmakefile (original)
+++ apr/apr-util/branches/1.7.x/xml/NWGNUmakefile Fri Mar  1 16:07:44 2019
@@ -3,7 +3,7 @@
 #
 
 SUBDIRS = \
-	$(EOLIST)
+	$(EOLIST) 
 
 #
 # Get the 'head' of the build environment.  This includes default targets and
@@ -19,31 +19,68 @@ include $(APR_WORK)/build/NWGNUhead.inc
 # Make sure all needed macro's are defined
 #
 
+ifdef EXPATSRC
+
+ifeq "$(wildcard $(EXPATSRC)/lib/expat.h.in)" "$(EXPATSRC)/lib/expat.h.in"
+EXPAT_prebuild_headers += $(EXPATSRC)/lib/expat.h
+endif
+ifeq "$(wildcard $(EXPATSRC)/lib/config.hnw)" "$(EXPATSRC)/lib/config.hnw"
+EXPAT_prebuild_headers += $(EXPATSRC)/lib/config.h
+endif
+ifeq "$(wildcard $(EXPATSRC)/expat_config.h.in)" "$(EXPATSRC)/expat_config.h.in"
+EXPAT_prebuild_headers += $(EXPATSRC)/lib/expat_config.h
+endif
+
+$(EXPATSRC)/lib/%.h: $(EXPATSRC)/lib/%.hnw
+	@echo Creating $@
+	$(call COPY,$<,$@)
+
+$(EXPATSRC)/lib/%.h: $(EXPATSRC)/lib/%.h.in
+	@echo Creating $@
+	$(call COPY,$<,$@)
+
+$(EXPATSRC)/lib/expat_config.h:
+	@echo Creating $@
+	@echo $(DL)/* $(notdir $@) for NetWare platform */$(DL)>>$@
+	@echo $(DL)#ifndef NETWARE$(DL)>>$@
+	@echo $(DL)#error This $(notdir $@) is for NetWare platform!$(DL)>>$@
+	@echo $(DL)#endif$(DL)>>$@
+	@echo $(DL)#ifndef EXPAT_CONFIG_H$(DL)>>$@
+	@echo $(DL)#define EXPAT_CONFIG_H$(DL)>>$@
+	@echo $(DL)#define HAVE_MEMMOVE 1$(DL)>>$@
+	@echo $(DL)#define XML_NS 1$(DL)>>$@
+	@echo $(DL)#define XML_DTD 1$(DL)>>$@
+	@echo $(DL)#define XML_BYTE_ORDER 1234$(DL)>>$@
+	@echo $(DL)#define XML_CONTEXT_BYTES 1024$(DL)>>$@
+	@echo $(DL)#endif /* EXPAT_CONFIG_H */$(DL)>>$@
+
+vpath %.c $(EXPATSRC)/lib
+
+endif
+
 #
 # These directories will be at the beginning of the include list, followed by
 # INCDIRS
 #
 XINCDIRS	+= \
+			$(EXPAT_INC) \
 			$(APR)/include \
-			$(APR)/include/arch/NetWare \
-			$(APU)/include \
-			$(APU)/uri \
-			$(APU)/dbm/sdbm \
-			$(APU)/include/private \
-			$(APUXML)/expat/lib \
+			$(APR)/include/private \
+			$(APR)/include/arch/netware \
 			$(EOLIST)
 
 #
 # These flags will come after CFLAGS
 #
 XCFLAGS		+= \
-			-DHAVE_EXPAT_CONFIG_H \
 			$(EOLIST)
 
 #
 # These defines will come after DEFINES
 #
 XDEFINES	+= \
+			-DAPU_USE_EXPAT=1 \
+			-DHAVE_EXPAT_CONFIG_H \
 			$(EOLIST)
 
 #
@@ -103,21 +140,21 @@ endif
 # This is used by the link 'name' directive to name the nlm.  If left blank
 # TARGET_nlm (see below) will be used.
 #
-NLM_NAME	=
+NLM_NAME	= 
 
 #
-# This is used by the link '-desc ' directive.
+# This is used by the link '-desc ' directive. 
 # If left blank, NLM_NAME will be used.
 #
-NLM_DESCRIPTION	=
+NLM_DESCRIPTION	= 
 
 #
 # This is used by the '-threadname' directive.  If left blank,
 # NLM_NAME Thread will be used.
 #
-NLM_THREAD_NAME	=
+NLM_THREAD_NAME	= 
 #
-# If this is specified, it will override VERSION value in
+# If this is specified, it will override VERSION value in 
 # $(APR_WORK)/build/NWGNUenvironment.inc
 #
 NLM_VERSION	=
@@ -125,17 +162,17 @@ NLM_VERSION	=
 #
 # If this is specified, it will override the default of 64K
 #
-NLM_STACK_SIZE	=
+NLM_STACK_SIZE	= 
 
 #
 # If this is specified it will be used by the link '-entry' directive
 #
-NLM_ENTRY_SYM	=
+NLM_ENTRY_SYM	= 
 
 #
 # If this is specified it will be used by the link '-exit' directive
 #
-NLM_EXIT_SYM	=
+NLM_EXIT_SYM	= 
 
 #
 # If this is specified it will be used by the link '-check' directive
@@ -146,13 +183,13 @@ NLM_CHECK_SYM	=
 # If this is specified it will be used by the link '-flags' directive
 #
 NLM_FLAGS	=
-
+ 
 #
-# If this is specified it will be linked in with the XDCData option in the def
-# file instead of the default of $(APR)/misc/netware/apache.xdc.  XDCData can
+# If this is specified it will be linked in with the XDCData option in the def 
+# file instead of the default of $(APR)/misc/netware/apache.xdc.  XDCData can 
 # be disabled by setting APACHE_UNIPROC in the environment
 #
-XDCDATA		=
+XDCDATA		= 
 
 #
 # Declare all target files (you must add your files here)
@@ -168,7 +205,7 @@ TARGET_nlm = \
 # If there is an LIB target, put it here
 #
 TARGET_lib = \
-	$(OBJDIR)/apuxml.lib \
+	$(OBJDIR)/xml.lib \
 	$(EOLIST)
 
 #
@@ -196,7 +233,7 @@ FILES_nlm_modules = \
 # If the nlm has a msg file, put it's path here
 #
 FILE_nlm_msg =
-
+ 
 #
 # If the nlm has a hlp file put it's path here
 #
@@ -212,44 +249,51 @@ FILE_nlm_copyright =
 #
 FILES_nlm_Ximports = \
 	$(EOLIST)
-
-#
+ 
+#   
 # Any symbols exported to here
 #
 FILES_nlm_exports = \
 	$(EOLIST)
 
-#
+#   
 # These are the OBJ files needed to create the LIB target above.
 # Paths must all use the '/' character
 #
 FILES_lib_objs = \
 	$(OBJDIR)/apr_xml.o \
+	$(OBJDIR)/apr_xml_expat.o \
+	$(EOLIST)
+
+ifdef EXPATSRC
+FILES_lib_objs += \
 	$(OBJDIR)/xmlparse.o \
 	$(OBJDIR)/xmlrole.o \
 	$(OBJDIR)/xmltok.o \
 	$(EOLIST)
+endif
 
 #
 # implement targets and dependancies (leave this section alone)
 #
 
-libs :: $(OBJDIR) $(TARGET_lib)
+libs :: $(OBJDIR) $(EXPAT_prebuild_headers) $(TARGET_lib)
 
 nlms :: libs $(TARGET_nlm)
 
 #
-# Updated this target to create necessary directories and copy files to the
+# Updated this target to create necessary directories and copy files to the 
 # correct place.  (See $(APR_WORK)/build/NWGNUhead.inc for examples)
 #
 install :: nlms FORCE
 
+clean ::
+	$(foreach file,$(EXPAT_prebuild_headers),$(call DEL,$(file)))
+
 #
 # Any specialized rules here
 #
 
-vpath %.c expat/lib
-
 #
 # Include the 'tail' makefile that has targets that depend on variables defined
 # in this makefile

Modified: apr/apr-util/branches/1.7.x/xml/apr_xml.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml.c?rev=1854603&r1=1854602&r2=1854603&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/xml/apr_xml.c (original)
+++ apr/apr-util/branches/1.7.x/xml/apr_xml.c Fri Mar  1 16:07:44 2019
@@ -15,6 +15,7 @@
  */
 
 #include "apr.h"
+#include "apr_private.h"
 #include "apr_strings.h"
 
 #define APR_WANT_STDIO          /* for sprintf() */
@@ -22,24 +23,15 @@
 #include "apr_want.h"
 
 #include "apr_xml.h"
-
-#include "apu_config.h"
-
-#if defined(HAVE_XMLPARSE_XMLPARSE_H)
-#include <xmlparse/xmlparse.h>
-#elif defined(HAVE_XMLTOK_XMLPARSE_H)
-#include <xmltok/xmlparse.h>
-#elif defined(HAVE_XML_XMLPARSE_H)
-#include <xml/xmlparse.h>
-#else
-#include <expat.h>
-#endif
+typedef void* XML_Parser;
+typedef int XML_Error;
+typedef unsigned char XML_Char;
+#include "apr_xml_internal.h"
 
 #define DEBUG_CR "\r\n"
 
 static const char APR_KW_xmlns[] = { 0x78, 0x6D, 0x6C, 0x6E, 0x73, '\0' };
 static const char APR_KW_xmlns_lang[] = { 0x78, 0x6D, 0x6C, 0x3A, 0x6C, 0x61, 0x6E, 0x67, '\0' };
-static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
 
 /* errors related to namespace processing */
 #define APR_XML_NS_ERROR_UNKNOWN_PREFIX (-1000)
@@ -47,32 +39,17 @@ static const char APR_KW_DAV[] = { 0x44,
 
 /* test for a namespace prefix that begins with [Xx][Mm][Ll] */
 #define APR_XML_NS_IS_RESERVED(name) \
-	( (name[0] == 0x58 || name[0] == 0x78) && \
-	  (name[1] == 0x4D || name[1] == 0x6D) && \
-	  (name[2] == 0x4C || name[2] == 0x6C) )
-
-
-/* the real (internal) definition of the parser context */
-struct apr_xml_parser {
-    apr_xml_doc *doc;		/* the doc we're parsing */
-    apr_pool_t *p;		/* the pool we allocate from */
-    apr_xml_elem *cur_elem;	/* current element */
-
-    int error;			/* an error has occurred */
-#define APR_XML_ERROR_EXPAT             1
-#define APR_XML_ERROR_PARSE_DONE        2
-/* also: public APR_XML_NS_ERROR_* values (if any) */
-
-    XML_Parser xp;              /* the actual (Expat) XML parser */
-    enum XML_Error xp_err;      /* stored Expat error code */
-};
+        ( (name[0] == 0x58 || name[0] == 0x78) && \
+          (name[1] == 0x4D || name[1] == 0x6D) && \
+          (name[2] == 0x4C || name[2] == 0x6C) )
+
 
 /* struct for scoping namespace declarations */
 typedef struct apr_xml_ns_scope {
-    const char *prefix;		/* prefix used for this ns */
-    int ns;			/* index into namespace table */
-    int emptyURI;		/* the namespace URI is the empty string */
-    struct apr_xml_ns_scope *next;	/* next scoped namespace */
+    const char *prefix;         /* prefix used for this ns */
+    int ns;                     /* index into namespace table */
+    int emptyURI;               /* the namespace URI is the empty string */
+    struct apr_xml_ns_scope *next;      /* next scoped namespace */
 } apr_xml_ns_scope;
 
 
@@ -86,23 +63,23 @@ static int find_prefix(apr_xml_parser *p
     ** prefix.
     */
     for (; elem; elem = elem->parent) {
-	apr_xml_ns_scope *ns_scope;
+        apr_xml_ns_scope *ns_scope;
+
+        for (ns_scope = elem->ns_scope; ns_scope; ns_scope = ns_scope->next) {
+            if (strcmp(prefix, ns_scope->prefix) == 0) {
+                if (ns_scope->emptyURI) {
+                    /*
+                    ** It is possible to set the default namespace to an
+                    ** empty URI string; this resets the default namespace
+                    ** to mean "no namespace." We just found the prefix
+                    ** refers to an empty URI, so return "no namespace."
+                    */
+                    return APR_XML_NS_NONE;
+                }
 
-	for (ns_scope = elem->ns_scope; ns_scope; ns_scope = ns_scope->next) {
-	    if (strcmp(prefix, ns_scope->prefix) == 0) {
-		if (ns_scope->emptyURI) {
-		    /*
-		    ** It is possible to set the default namespace to an
-		    ** empty URI string; this resets the default namespace
-		    ** to mean "no namespace." We just found the prefix
-		    ** refers to an empty URI, so return "no namespace."
-		    */
-		    return APR_XML_NS_NONE;
-		}
-
-		return ns_scope->ns;
-	    }
-	}
+                return ns_scope->ns;
+            }
+        }
     }
 
     /*
@@ -113,7 +90,7 @@ static int find_prefix(apr_xml_parser *p
      * has "no namespace". We have a reserved value for this.
      */
     if (*prefix == '\0') {
-	return APR_XML_NS_NONE;
+        return APR_XML_NS_NONE;
     }
 
     /* not found */
@@ -128,18 +105,17 @@ static const char * find_prefix_name(con
     ** prefix.
     */
     for (; elem; elem = parent ? elem->parent : NULL) {
-	apr_xml_ns_scope *ns_scope = elem->ns_scope;
+       apr_xml_ns_scope *ns_scope = elem->ns_scope;
 
-	for (; ns_scope; ns_scope = ns_scope->next) {
-	    if (ns_scope->ns == ns)
-		return ns_scope->prefix;
-	}
+       for (; ns_scope; ns_scope = ns_scope->next) {
+           if (ns_scope->ns == ns)
+               return ns_scope->prefix;
+       }
     }
     /* not found */
     return "";
 }
 
-
 static void start_handler(void *userdata, const char *name, const char **attrs)
 {
     apr_xml_parser *parser = userdata;
@@ -152,7 +128,7 @@ static void start_handler(void *userdata
 
     /* punt once we find an error */
     if (parser->error)
-	return;
+        return;
 
     elem = apr_pcalloc(parser->p, sizeof(*elem));
 
@@ -160,97 +136,97 @@ static void start_handler(void *userdata
     elem->name = elem_name = apr_pstrdup(parser->p, name);
 
     /* fill in the attributes (note: ends up in reverse order) */
-    while (*attrs) {
-	attr = apr_palloc(parser->p, sizeof(*attr));
-	attr->name = apr_pstrdup(parser->p, *attrs++);
-	attr->value = apr_pstrdup(parser->p, *attrs++);
-	attr->next = elem->attr;
-	elem->attr = attr;
+    while (attrs && *attrs) {
+        attr = apr_palloc(parser->p, sizeof(*attr));
+        attr->name = apr_pstrdup(parser->p, *attrs++);
+        attr->value = apr_pstrdup(parser->p, *attrs++);
+        attr->next = elem->attr;
+        elem->attr = attr;
     }
 
     /* hook the element into the tree */
     if (parser->cur_elem == NULL) {
-	/* no current element; this also becomes the root */
-	parser->cur_elem = parser->doc->root = elem;
+        /* no current element; this also becomes the root */
+        parser->cur_elem = parser->doc->root = elem;
     }
     else {
-	/* this element appeared within the current elem */
-	elem->parent = parser->cur_elem;
+        /* this element appeared within the current elem */
+        elem->parent = parser->cur_elem;
 
-	/* set up the child/sibling links */
-	if (elem->parent->last_child == NULL) {
-	    /* no first child either */
-	    elem->parent->first_child = elem->parent->last_child = elem;
-	}
-	else {
-	    /* hook onto the end of the parent's children */
-	    elem->parent->last_child->next = elem;
-	    elem->parent->last_child = elem;
-	}
+        /* set up the child/sibling links */
+        if (elem->parent->last_child == NULL) {
+            /* no first child either */
+            elem->parent->first_child = elem->parent->last_child = elem;
+        }
+        else {
+            /* hook onto the end of the parent's children */
+            elem->parent->last_child->next = elem;
+            elem->parent->last_child = elem;
+        }
 
-	/* this element is now the current element */
-	parser->cur_elem = elem;
+        /* this element is now the current element */
+        parser->cur_elem = elem;
     }
 
     /* scan the attributes for namespace declarations */
     for (prev = NULL, attr = elem->attr;
-	 attr;
-	 attr = attr->next) {
-	if (strncmp(attr->name, APR_KW_xmlns, 5) == 0) {
-	    const char *prefix = &attr->name[5];
-	    apr_xml_ns_scope *ns_scope;
+         attr;
+         attr = attr->next) {
+        if (strncmp(attr->name, APR_KW_xmlns, 5) == 0) {
+            const char *prefix = &attr->name[5];
+            apr_xml_ns_scope *ns_scope;
 
-	    /* test for xmlns:foo= form and xmlns= form */
-	    if (*prefix == 0x3A) {
+            /* test for xmlns:foo= form and xmlns= form */
+            if (*prefix == 0x3A) {
                 /* a namespace prefix declaration must have a
                    non-empty value. */
                 if (attr->value[0] == '\0') {
                     parser->error = APR_XML_NS_ERROR_INVALID_DECL;
                     return;
                 }
-		++prefix;
+                ++prefix;
             }
-	    else if (*prefix != '\0') {
-		/* advance "prev" since "attr" is still present */
-		prev = attr;
-		continue;
-	    }
-
-	    /* quote the URI before we ever start working with it */
-	    quoted = apr_xml_quote_string(parser->p, attr->value, 1);
-
-	    /* build and insert the new scope */
-	    ns_scope = apr_pcalloc(parser->p, sizeof(*ns_scope));
-	    ns_scope->prefix = prefix;
-	    ns_scope->ns = apr_xml_insert_uri(parser->doc->namespaces, quoted);
-	    ns_scope->emptyURI = *quoted == '\0';
-	    ns_scope->next = elem->ns_scope;
-	    elem->ns_scope = ns_scope;
-
-	    /* remove this attribute from the element */
-	    if (prev == NULL)
-		elem->attr = attr->next;
-	    else
-		prev->next = attr->next;
-
-	    /* Note: prev will not be advanced since we just removed "attr" */
-	}
-	else if (strcmp(attr->name, APR_KW_xmlns_lang) == 0) {
-	    /* save away the language (in quoted form) */
-	    elem->lang = apr_xml_quote_string(parser->p, attr->value, 1);
-
-	    /* remove this attribute from the element */
-	    if (prev == NULL)
-		elem->attr = attr->next;
-	    else
-		prev->next = attr->next;
-
-	    /* Note: prev will not be advanced since we just removed "attr" */
-	}
-	else {
-	    /* advance "prev" since "attr" is still present */
-	    prev = attr;
-	}
+            else if (*prefix != '\0') {
+                /* advance "prev" since "attr" is still present */
+                prev = attr;
+                continue;
+            }
+
+            /* quote the URI before we ever start working with it */
+            quoted = apr_xml_quote_string(parser->p, attr->value, 1);
+
+            /* build and insert the new scope */
+            ns_scope = apr_pcalloc(parser->p, sizeof(*ns_scope));
+            ns_scope->prefix = prefix;
+            ns_scope->ns = apr_xml_insert_uri(parser->doc->namespaces, quoted);
+            ns_scope->emptyURI = *quoted == '\0';
+            ns_scope->next = elem->ns_scope;
+            elem->ns_scope = ns_scope;
+
+            /* remove this attribute from the element */
+            if (prev == NULL)
+                elem->attr = attr->next;
+            else
+                prev->next = attr->next;
+
+            /* Note: prev will not be advanced since we just removed "attr" */
+        }
+        else if (strcmp(attr->name, APR_KW_xmlns_lang) == 0) {
+            /* save away the language (in quoted form) */
+            elem->lang = apr_xml_quote_string(parser->p, attr->value, 1);
+
+            /* remove this attribute from the element */
+            if (prev == NULL)
+                elem->attr = attr->next;
+            else
+                prev->next = attr->next;
+
+            /* Note: prev will not be advanced since we just removed "attr" */
+        }
+        else {
+            /* advance "prev" since "attr" is still present */
+            prev = attr;
+        }
     }
 
     /*
@@ -260,30 +236,30 @@ static void start_handler(void *userdata
     ** NOTE: elem_size() *depends* upon this pointer equality.
     */
     if (elem->lang == NULL && elem->parent != NULL)
-	elem->lang = elem->parent->lang;
+        elem->lang = elem->parent->lang;
 
     /* adjust the element's namespace */
     colon = strchr(elem_name, 0x3A);
     if (colon == NULL) {
-	/*
-	 * The element is using the default namespace, which will always
-	 * be found. Either it will be "no namespace", or a default
-	 * namespace URI has been specified at some point.
-	 */
-	elem->ns = find_prefix(parser, "");
+        /*
+         * The element is using the default namespace, which will always
+         * be found. Either it will be "no namespace", or a default
+         * namespace URI has been specified at some point.
+         */
+        elem->ns = find_prefix(parser, "");
     }
     else if (APR_XML_NS_IS_RESERVED(elem->name)) {
-	elem->ns = APR_XML_NS_NONE;
+        elem->ns = APR_XML_NS_NONE;
     }
     else {
-	*colon = '\0';
-	elem->ns = find_prefix(parser, elem->name);
-	elem->name = colon + 1;
-
-	if (APR_XML_NS_IS_ERROR(elem->ns)) {
-	    parser->error = elem->ns;
-	    return;
-	}
+        *colon = '\0';
+        elem->ns = find_prefix(parser, elem->name);
+        elem->name = colon + 1;
+
+        if (APR_XML_NS_IS_ERROR(elem->ns)) {
+            parser->error = elem->ns;
+            return;
+        }
     }
 
     /* adjust all remaining attributes' namespaces */
@@ -295,27 +271,27 @@ static void start_handler(void *userdata
          */
         char *attr_name = (char *)attr->name;
 
-	colon = strchr(attr_name, 0x3A);
-	if (colon == NULL) {
-	    /*
-	     * Attributes do NOT use the default namespace. Therefore,
-	     * we place them into the "no namespace" category.
-	     */
-	    attr->ns = APR_XML_NS_NONE;
-	}
-	else if (APR_XML_NS_IS_RESERVED(attr->name)) {
-	    attr->ns = APR_XML_NS_NONE;
-	}
-	else {
-	    *colon = '\0';
-	    attr->ns = find_prefix(parser, attr->name);
-	    attr->name = colon + 1;
-
-	    if (APR_XML_NS_IS_ERROR(attr->ns)) {
-		parser->error = attr->ns;
-		return;
-	    }
-	}
+        colon = strchr(attr_name, 0x3A);
+        if (colon == NULL) {
+            /*
+             * Attributes do NOT use the default namespace. Therefore,
+             * we place them into the "no namespace" category.
+             */
+            attr->ns = APR_XML_NS_NONE;
+        }
+        else if (APR_XML_NS_IS_RESERVED(attr->name)) {
+            attr->ns = APR_XML_NS_NONE;
+        }
+        else {
+            *colon = '\0';
+            attr->ns = find_prefix(parser, attr->name);
+            attr->name = colon + 1;
+
+            if (APR_XML_NS_IS_ERROR(attr->ns)) {
+                parser->error = attr->ns;
+                return;
+            }
+        }
     }
 }
 
@@ -325,7 +301,7 @@ static void end_handler(void *userdata,
 
     /* punt once we find an error */
     if (parser->error)
-	return;
+        return;
 
     /* pop up one level */
     parser->cur_elem = parser->cur_elem->parent;
@@ -340,128 +316,43 @@ static void cdata_handler(void *userdata
 
     /* punt once we find an error */
     if (parser->error)
-	return;
+        return;
 
     elem = parser->cur_elem;
     s = apr_pstrndup(parser->p, data, len);
 
     if (elem->last_child == NULL) {
-	/* no children yet. this cdata follows the start tag */
-	hdr = &elem->first_cdata;
+        /* no children yet. this cdata follows the start tag */
+        hdr = &elem->first_cdata;
     }
     else {
-	/* child elements exist. this cdata follows the last child. */
-	hdr = &elem->last_child->following_cdata;
+        /* child elements exist. this cdata follows the last child. */
+        hdr = &elem->last_child->following_cdata;
     }
 
     apr_text_append(parser->p, hdr, s);
 }
 
-static apr_status_t cleanup_parser(void *ctx)
-{
-    apr_xml_parser *parser = ctx;
-
-    XML_ParserFree(parser->xp);
-    parser->xp = NULL;
-
-    return APR_SUCCESS;
-}
-
-#if XML_MAJOR_VERSION > 1
-/* Stop the parser if an entity declaration is hit. */
-static void entity_declaration(void *userData, const XML_Char *entityName,
-                               int is_parameter_entity, const XML_Char *value,
-                               int value_length, const XML_Char *base,
-                               const XML_Char *systemId, const XML_Char *publicId,
-                               const XML_Char *notationName)
-{
-    apr_xml_parser *parser = userData;
-
-    XML_StopParser(parser->xp, XML_FALSE);
-}
-#else
-/* A noop default_handler. */
-static void default_handler(void *userData, const XML_Char *s, int len)
+APR_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool)
 {
+    return apr_xml_parser_create_internal(pool, &start_handler, &end_handler, &cdata_handler);
 }
-#endif
-
-APU_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool)
-{
-    apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
-
-    parser->p = pool;
-    parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
-
-    parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
-
-    /* ### is there a way to avoid hard-coding this? */
-    apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
-
-    parser->xp = XML_ParserCreate(NULL);
-    if (parser->xp == NULL) {
-        (*apr_pool_abort_get(pool))(APR_ENOMEM);
-        return NULL;
-    }
-
-    apr_pool_cleanup_register(pool, parser, cleanup_parser,
-                              apr_pool_cleanup_null);
-
-    XML_SetUserData(parser->xp, parser);
-    XML_SetElementHandler(parser->xp, start_handler, end_handler);
-    XML_SetCharacterDataHandler(parser->xp, cdata_handler);
-
-    /* Prevent the "billion laughs" attack against expat by disabling
-     * internal entity expansion.  With 2.x, forcibly stop the parser
-     * if an entity is declared - this is safer and a more obvious
-     * failure mode.  With older versions, installing a noop
-     * DefaultHandler means that internal entities will be expanded as
-     * the empty string, which is also sufficient to prevent the
-     * attack. */
-#if XML_MAJOR_VERSION > 1
-    XML_SetEntityDeclHandler(parser->xp, entity_declaration);
-#else
-    XML_SetDefaultHandler(parser->xp, default_handler);
-#endif
 
-    return parser;
-}
-
-static apr_status_t do_parse(apr_xml_parser *parser,
-                             const char *data, apr_size_t len,
-                             int is_final)
-{
-    if (parser->xp == NULL) {
-        parser->error = APR_XML_ERROR_PARSE_DONE;
-    }
-    else {
-        int rv = XML_Parse(parser->xp, data, (int)len, is_final);
-
-        if (rv == 0) {
-            parser->error = APR_XML_ERROR_EXPAT;
-            parser->xp_err = XML_GetErrorCode(parser->xp);
-        }
-    }
-
-    /* ### better error code? */
-    return parser->error ? APR_EGENERAL : APR_SUCCESS;
-}
-
-APU_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser,
+APR_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser,
                                               const char *data,
                                               apr_size_t len)
 {
-    return do_parse(parser, data, len, 0 /* is_final */);
+    return parser->impl->Parse(parser, data, len, 0 /* is_final */);
 }
 
-APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser,
+APR_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser,
                                               apr_xml_doc **pdoc)
 {
     char end;
-    apr_status_t status = do_parse(parser, &end, 0, 1 /* is_final */);
+    apr_status_t status = parser->impl->Parse(parser, &end, 0, 1 /* is_final */);
 
     /* get rid of the parser */
-    (void) apr_pool_cleanup_run(parser->p, parser, cleanup_parser);
+    (void) apr_pool_cleanup_run(parser->p, parser, parser->impl->cleanup);
 
     if (status)
         return status;
@@ -471,7 +362,7 @@ APU_DECLARE(apr_status_t) apr_xml_parser
     return APR_SUCCESS;
 }
 
-APU_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser,
+APR_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser,
                                             char *errbuf,
                                             apr_size_t errbufsize)
 {
@@ -497,7 +388,7 @@ APU_DECLARE(char *) apr_xml_parser_geter
     case APR_XML_ERROR_EXPAT:
         (void) apr_snprintf(errbuf, errbufsize,
                             "XML parser error code: %s (%d)",
-                            XML_ErrorString(parser->xp_err), parser->xp_err);
+                            parser->xp_msg, parser->xp_err);
         return errbuf;
 
     case APR_XML_ERROR_PARSE_DONE:
@@ -513,7 +404,7 @@ APU_DECLARE(char *) apr_xml_parser_geter
     return errbuf;
 }
 
-APU_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p,
+APR_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p,
                                              apr_xml_parser **parser,
                                              apr_xml_doc **ppdoc,
                                              apr_file_t *xmlfd,
@@ -551,7 +442,7 @@ APU_DECLARE(apr_status_t) apr_xml_parse_
     return rv;
 }
 
-APU_DECLARE(void) apr_text_append(apr_pool_t * p, apr_text_header *hdr,
+APR_DECLARE(void) apr_text_append(apr_pool_t * p, apr_text_header *hdr,
                                   const char *text)
 {
     apr_text *t = apr_palloc(p, sizeof(*t));
@@ -560,13 +451,13 @@ APU_DECLARE(void) apr_text_append(apr_po
     t->next = NULL;
 
     if (hdr->first == NULL) {
-	/* no text elements yet */
-	hdr->first = hdr->last = t;
+        /* no text elements yet */
+        hdr->first = hdr->last = t;
     }
     else {
-	/* append to the last text element */
-	hdr->last->next = t;
-	hdr->last = t;
+        /* append to the last text element */
+        hdr->last->next = t;
+        hdr->last = t;
     }
 }
 
@@ -585,7 +476,7 @@ APU_DECLARE(void) apr_text_append(apr_po
 ** quotes is typically set to true for XML strings that will occur within
 ** double quotes -- attribute values.
 */
-APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
+APR_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
                                                int quotes)
 {
     const char *scan;
@@ -596,50 +487,50 @@ APU_DECLARE(const char *) apr_xml_quote_
     char c;
 
     for (scan = s; (c = *scan) != '\0'; ++scan, ++len) {
-	if (c == '<' || c == '>')
-	    extra += 3;		/* &lt; or &gt; */
-	else if (c == '&')
-	    extra += 4;		/* &amp; */
-	else if (quotes && c == '"')
-	    extra += 5;		/* &quot; */
+        if (c == '<' || c == '>')
+            extra += 3;         /* &lt; or &gt; */
+        else if (c == '&')
+            extra += 4;         /* &amp; */
+        else if (quotes && c == '"')
+            extra += 5;         /* &quot; */
     }
 
     /* nothing to do? */
     if (extra == 0)
-	return s;
+        return s;
 
     qstr = apr_palloc(p, len + extra + 1);
     for (scan = s, qscan = qstr; (c = *scan) != '\0'; ++scan) {
-	if (c == '<') {
-	    *qscan++ = '&';
-	    *qscan++ = 'l';
-	    *qscan++ = 't';
-	    *qscan++ = ';';
-	}
-	else if (c == '>') {
-	    *qscan++ = '&';
-	    *qscan++ = 'g';
-	    *qscan++ = 't';
-	    *qscan++ = ';';
-	}
-	else if (c == '&') {
-	    *qscan++ = '&';
-	    *qscan++ = 'a';
-	    *qscan++ = 'm';
-	    *qscan++ = 'p';
-	    *qscan++ = ';';
-	}
-	else if (quotes && c == '"') {
-	    *qscan++ = '&';
-	    *qscan++ = 'q';
-	    *qscan++ = 'u';
-	    *qscan++ = 'o';
-	    *qscan++ = 't';
-	    *qscan++ = ';';
-	}
-	else {
-	    *qscan++ = c;
-	}
+        if (c == '<') {
+            *qscan++ = '&';
+            *qscan++ = 'l';
+            *qscan++ = 't';
+            *qscan++ = ';';
+        }
+        else if (c == '>') {
+            *qscan++ = '&';
+            *qscan++ = 'g';
+            *qscan++ = 't';
+            *qscan++ = ';';
+        }
+        else if (c == '&') {
+            *qscan++ = '&';
+            *qscan++ = 'a';
+            *qscan++ = 'm';
+            *qscan++ = 'p';
+            *qscan++ = ';';
+        }
+        else if (quotes && c == '"') {
+            *qscan++ = '&';
+            *qscan++ = 'q';
+            *qscan++ = 'u';
+            *qscan++ = 'o';
+            *qscan++ = 't';
+            *qscan++ = ';';
+        }
+        else {
+            *qscan++ = c;
+        }
     }
 
     *qscan = '\0';
@@ -657,7 +548,7 @@ static apr_size_t text_size(const apr_te
     apr_size_t size = 0;
 
     for (; t; t = t->next)
-	size += strlen(t->text);
+        size += strlen(t->text);
     return size;
 }
 
@@ -667,117 +558,117 @@ static apr_size_t elem_size(const apr_xm
     apr_size_t size;
 
     if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG ||
-	style == APR_XML_X2T_PARSED) {
-	const apr_xml_attr *attr;
+        style == APR_XML_X2T_PARSED) {
+        const apr_xml_attr *attr;
+
+        size = 0;
+
+        if (style == APR_XML_X2T_FULL_NS_LANG) {
+            int i;
 
-	size = 0;
+            /*
+            ** The outer element will contain xmlns:ns%d="%s" attributes
+            ** and an xml:lang attribute, if applicable.
+            */
+
+            for (i = namespaces->nelts; i--;) {
+                /* compute size of: ' xmlns:ns%d="%s"' */
+                size += (9 + APR_XML_NS_LEN(i) + 2 +
+                         strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1);
+            }
+
+            if (elem->lang != NULL) {
+                /* compute size of: ' xml:lang="%s"' */
+                size += 11 + strlen(elem->lang) + 1;
+            }
+        }
+        else if (style == APR_XML_X2T_PARSED) {
+            apr_xml_ns_scope *ns_scope = elem->ns_scope;
 
-	if (style == APR_XML_X2T_FULL_NS_LANG) {
-	    int i;
+            /* compute size of: ' xmlns:%s="%s"' */
+            for (; ns_scope; ns_scope = ns_scope->next) {
+                size += 10 + strlen(find_prefix_name(elem, ns_scope->ns, 0)) +
+                             strlen(APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
+            }
+
+            if (elem->lang != NULL) {
+                /* compute size of: ' xml:lang="%s"' */
+                size += 11 + strlen(elem->lang) + 1;
+            }
+        }
+
+        if (elem->ns == APR_XML_NS_NONE) {
+            /* compute size of: <%s> */
+            size += 1 + strlen(elem->name) + 1;
+        }
+        else if (style == APR_XML_X2T_PARSED) {
+            /* compute size of: <%s:%s> */
+            size += 3 + strlen(find_prefix_name(elem, elem->ns, 1)) + strlen(elem->name);
+        }
+        else {
+            int ns = ns_map ? ns_map[elem->ns] : elem->ns;
 
-	    /*
-	    ** The outer element will contain xmlns:ns%d="%s" attributes
-	    ** and an xml:lang attribute, if applicable.
-	    */
-
-	    for (i = namespaces->nelts; i--;) {
-		/* compute size of: ' xmlns:ns%d="%s"' */
-		size += (9 + APR_XML_NS_LEN(i) + 2 +
-			 strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1);
-	    }
-
-	    if (elem->lang != NULL) {
-		/* compute size of: ' xml:lang="%s"' */
-		size += 11 + strlen(elem->lang) + 1;
-	    }
-	}
-	else if (style == APR_XML_X2T_PARSED) {
-	    apr_xml_ns_scope *ns_scope = elem->ns_scope;
-
-	    /* compute size of: ' xmlns:%s="%s"' */
-	    for (; ns_scope; ns_scope = ns_scope->next) {
-		size += 10 + strlen(find_prefix_name(elem, ns_scope->ns, 0)) +
-			     strlen(APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
-	    }
-
-	    if (elem->lang != NULL) {
-		/* compute size of: ' xml:lang="%s"' */
-		size += 11 + strlen(elem->lang) + 1;
-	    }
-	}
-
-	if (elem->ns == APR_XML_NS_NONE) {
-	    /* compute size of: <%s> */
-	    size += 1 + strlen(elem->name) + 1;
-	}
-	else if (style == APR_XML_X2T_PARSED) {
-	    /* compute size of: <%s:%s> */
-	    size += 3 + strlen(find_prefix_name(elem, elem->ns, 1)) + strlen(elem->name);
-	}
-	else {
-	    int ns = ns_map ? ns_map[elem->ns] : elem->ns;
-
-	    /* compute size of: <ns%d:%s> */
-	    size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1;
-	}
-
-	if (APR_XML_ELEM_IS_EMPTY(elem)) {
-	    /* insert a closing "/" */
-	    size += 1;
-	}
-	else {
-	    /*
-	     * two of above plus "/":
-	     *     <ns%d:%s> ... </ns%d:%s>
-	     * OR  <%s> ... </%s>
-	     */
-	    size = 2 * size + 1;
-	}
-
-	for (attr = elem->attr; attr; attr = attr->next) {
-	    if (attr->ns == APR_XML_NS_NONE) {
-		/* compute size of: ' %s="%s"' */
-		size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
-	    }
-	    else if (style == APR_XML_X2T_PARSED) {
-		/* compute size of: ' %s:%s="%s"' */
-		size += 5 + strlen(find_prefix_name(elem, attr->ns, 1)) + strlen(attr->name) + strlen(attr->value);
-	    }
-	    else {
-		/* compute size of: ' ns%d:%s="%s"' */
+            /* compute size of: <ns%d:%s> */
+            size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1;
+        }
+
+        if (APR_XML_ELEM_IS_EMPTY(elem)) {
+            /* insert a closing "/" */
+            size += 1;
+        }
+        else {
+            /*
+             * two of above plus "/":
+             *     <ns%d:%s> ... </ns%d:%s>
+             * OR  <%s> ... </%s>
+             */
+            size = 2 * size + 1;
+        }
+
+        for (attr = elem->attr; attr; attr = attr->next) {
+            if (attr->ns == APR_XML_NS_NONE) {
+                /* compute size of: ' %s="%s"' */
+                size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
+            }
+            else if (style == APR_XML_X2T_PARSED) {
+                /* compute size of: ' %s:%s="%s"' */
+                size += 5 + strlen(find_prefix_name(elem, attr->ns, 1)) + strlen(attr->name) + strlen(attr->value);
+            }
+            else {
+                /* compute size of: ' ns%d:%s="%s"' */
                 int ns = ns_map ? ns_map[attr->ns] : attr->ns;
                 size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
-	    }
-	}
+            }
+        }
 
-	/*
-	** If the element has an xml:lang value that is *different* from
-	** its parent, then add the thing in: ' xml:lang="%s"'.
-	**
-	** NOTE: we take advantage of the pointer equality established by
-	** the parsing for "inheriting" the xml:lang values from parents.
-	*/
-	if (elem->lang != NULL &&
-	    (elem->parent == NULL || elem->lang != elem->parent->lang)) {
-	    size += 11 + strlen(elem->lang) + 1;
-	}
+        /*
+        ** If the element has an xml:lang value that is *different* from
+        ** its parent, then add the thing in: ' xml:lang="%s"'.
+        **
+        ** NOTE: we take advantage of the pointer equality established by
+        ** the parsing for "inheriting" the xml:lang values from parents.
+        */
+        if (elem->lang != NULL &&
+            (elem->parent == NULL || elem->lang != elem->parent->lang)) {
+            size += 11 + strlen(elem->lang) + 1;
+        }
     }
     else if (style == APR_XML_X2T_LANG_INNER) {
-	/*
-	 * This style prepends the xml:lang value plus a null terminator.
-	 * If a lang value is not present, then we insert a null term.
-	 */
-	size = elem->lang ? strlen(elem->lang) + 1 : 1;
+        /*
+         * This style prepends the xml:lang value plus a null terminator.
+         * If a lang value is not present, then we insert a null term.
+         */
+        size = elem->lang ? strlen(elem->lang) + 1 : 1;
     }
     else
-	size = 0;
+        size = 0;
 
     size += text_size(elem->first_cdata.first);
 
     for (elem = elem->first_child; elem; elem = elem->next) {
-	/* the size of the child element plus the CDATA that follows it */
-	size += (elem_size(elem, style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL, NULL, ns_map) +
-		 text_size(elem->following_cdata.first));
+        /* the size of the child element plus the CDATA that follows it */
+        size += (elem_size(elem, style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL, NULL, ns_map) +
+                 text_size(elem->following_cdata.first));
     }
 
     return size;
@@ -786,125 +677,133 @@ static apr_size_t elem_size(const apr_xm
 static char *write_text(char *s, const apr_text *t)
 {
     for (; t; t = t->next) {
-	apr_size_t len = strlen(t->text);
-	memcpy(s, t->text, len);
-	s += len;
+        apr_size_t len = strlen(t->text);
+        memcpy(s, t->text, len);
+        s += len;
     }
     return s;
 }
 
 static char *write_elem(char *s, const apr_xml_elem *elem, int style,
-			apr_array_header_t *namespaces, int *ns_map)
+                        apr_array_header_t *namespaces, int *ns_map)
 {
     const apr_xml_elem *child;
     apr_size_t len;
     int ns;
 
     if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG ||
-	style == APR_XML_X2T_PARSED) {
-	int empty = APR_XML_ELEM_IS_EMPTY(elem);
-	const apr_xml_attr *attr;
-
-	if (elem->ns == APR_XML_NS_NONE)
-	    len = sprintf(s, "<%s", elem->name);
-	else if (style == APR_XML_X2T_PARSED)
-	    len = sprintf(s, "<%s:%s", find_prefix_name(elem, elem->ns, 1), elem->name);
-	else {
-	    ns = ns_map ? ns_map[elem->ns] : elem->ns;
-	    len = sprintf(s, "<ns%d:%s", ns, elem->name);
-	}
-	s += len;
-
-	for (attr = elem->attr; attr; attr = attr->next) {
-	    if (attr->ns == APR_XML_NS_NONE)
-		len = sprintf(s, " %s=\"%s\"", attr->name, attr->value);
-	    else if (style == APR_XML_X2T_PARSED)
-		len = sprintf(s, " %s:%s=\"%s\"",
-			      find_prefix_name(elem, attr->ns, 1), attr->name, attr->value);
-	    else {
-		ns = ns_map ? ns_map[attr->ns] : attr->ns;
-		len = sprintf(s, " ns%d:%s=\"%s\"", ns, attr->name, attr->value);
-	    }
-	    s += len;
-	}
-
-	/* add the xml:lang value if necessary */
-	if (elem->lang != NULL &&
-	    (style == APR_XML_X2T_FULL_NS_LANG ||
-	     elem->parent == NULL ||
-	     elem->lang != elem->parent->lang)) {
-	    len = sprintf(s, " xml:lang=\"%s\"", elem->lang);
-	    s += len;
-	}
-
-	/* add namespace definitions, if required */
-	if (style == APR_XML_X2T_FULL_NS_LANG) {
-	    int i;
-
-	    for (i = namespaces->nelts; i--;) {
-		len = sprintf(s, " xmlns:ns%d=\"%s\"", i,
-			      APR_XML_GET_URI_ITEM(namespaces, i));
-		s += len;
-	    }
-	}
-	else if (style == APR_XML_X2T_PARSED) {
-	    apr_xml_ns_scope *ns_scope = elem->ns_scope;
-
-	    for (; ns_scope; ns_scope = ns_scope->next) {
-		const char *prefix = find_prefix_name(elem, ns_scope->ns, 0);
-
-		len = sprintf(s, " xmlns%s%s=\"%s\"",
-			      *prefix ? ":" : "", *prefix ? prefix : "",
-			      APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
-		s += len;
-	    }
-	}
-
-	/* no more to do. close it up and go. */
-	if (empty) {
-	    *s++ = '/';
-	    *s++ = '>';
-	    return s;
-	}
+        style == APR_XML_X2T_PARSED) {
+        int empty = APR_XML_ELEM_IS_EMPTY(elem);
+        const apr_xml_attr *attr;
+
+        if (elem->ns == APR_XML_NS_NONE) {
+            len = sprintf(s, "<%s", elem->name);
+        }
+        else if (style == APR_XML_X2T_PARSED) {
+            len = sprintf(s, "<%s:%s", find_prefix_name(elem, elem->ns, 1), elem->name);
+        }
+        else {
+            ns = ns_map ? ns_map[elem->ns] : elem->ns;
+            len = sprintf(s, "<ns%d:%s", ns, elem->name);
+        }
+        s += len;
+
+        for (attr = elem->attr; attr; attr = attr->next) {
+            if (attr->ns == APR_XML_NS_NONE) {
+                len = sprintf(s, " %s=\"%s\"", attr->name, attr->value);
+            }
+            else if (style == APR_XML_X2T_PARSED) {
+                len = sprintf(s, " %s:%s=\"%s\"",
+                              find_prefix_name(elem, attr->ns, 1), attr->name, attr->value);
+            }
+            else {
+                ns = ns_map ? ns_map[attr->ns] : attr->ns;
+                len = sprintf(s, " ns%d:%s=\"%s\"", ns, attr->name, attr->value);
+            }
+            s += len;
+        }
+
+        /* add the xml:lang value if necessary */
+        if (elem->lang != NULL &&
+            (style == APR_XML_X2T_FULL_NS_LANG ||
+             elem->parent == NULL ||
+             elem->lang != elem->parent->lang)) {
+            len = sprintf(s, " xml:lang=\"%s\"", elem->lang);
+            s += len;
+        }
+
+        /* add namespace definitions, if required */
+        if (style == APR_XML_X2T_FULL_NS_LANG) {
+            int i;
+
+            for (i = namespaces->nelts; i--;) {
+                len = sprintf(s, " xmlns:ns%d=\"%s\"", i,
+                              APR_XML_GET_URI_ITEM(namespaces, i));
+                s += len;
+            }
+        }
+
+        else if (style == APR_XML_X2T_PARSED) {
+            apr_xml_ns_scope *ns_scope = elem->ns_scope;
+
+            for (; ns_scope; ns_scope = ns_scope->next) {
+                const char *prefix = find_prefix_name(elem, ns_scope->ns, 0);
 
-	/* just close it */
-	*s++ = '>';
+                len = sprintf(s, " xmlns%s%s=\"%s\"",
+                              *prefix ? ":" : "", *prefix ? prefix : "",
+                              APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
+                s += len;
+            }
+        }
+
+        /* no more to do. close it up and go. */
+        if (empty) {
+            *s++ = '/';
+            *s++ = '>';
+            return s;
+        }
+
+        /* just close it */
+        *s++ = '>';
     }
     else if (style == APR_XML_X2T_LANG_INNER) {
-	/* prepend the xml:lang value */
-	if (elem->lang != NULL) {
-	    len = strlen(elem->lang);
-	    memcpy(s, elem->lang, len);
-	    s += len;
-	}
-	*s++ = '\0';
+        /* prepend the xml:lang value */
+        if (elem->lang != NULL) {
+            len = strlen(elem->lang);
+            memcpy(s, elem->lang, len);
+            s += len;
+        }
+        *s++ = '\0';
     }
 
     s = write_text(s, elem->first_cdata.first);
 
     for (child = elem->first_child; child; child = child->next) {
-	s = write_elem(s, child,
-		       style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL,
-		       NULL, ns_map);
-	s = write_text(s, child->following_cdata.first);
-    }
-
-    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG || style == APR_XML_X2T_PARSED) {
-	if (elem->ns == APR_XML_NS_NONE)
-	    len = sprintf(s, "</%s>", elem->name);
-	else if (style == APR_XML_X2T_PARSED)
-	    len = sprintf(s, "</%s:%s>", find_prefix_name(elem, elem->ns, 1), elem->name);
-	else {
-	    ns = ns_map ? ns_map[elem->ns] : elem->ns;
-	    len = sprintf(s, "</ns%d:%s>", ns, elem->name);
-	}
-	s += len;
+        s = write_elem(s, child,
+                       style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL,
+                       NULL, ns_map);
+        s = write_text(s, child->following_cdata.first);
+    }
+
+    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG ||
+        style == APR_XML_X2T_PARSED) {
+        if (elem->ns == APR_XML_NS_NONE) {
+            len = sprintf(s, "</%s>", elem->name);
+        }
+        else if (style == APR_XML_X2T_PARSED) {
+            len = sprintf(s, "</%s:%s>", find_prefix_name(elem, elem->ns, 1), elem->name);
+        }
+        else {
+            ns = ns_map ? ns_map[elem->ns] : elem->ns;
+            len = sprintf(s, "</ns%d:%s>", ns, elem->name);
+        }
+        s += len;
     }
 
     return s;
 }
 
-APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem)
+APR_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem)
 {
     apr_text *scan_txt;
     apr_xml_attr *scan_attr;
@@ -912,33 +811,33 @@ APU_DECLARE(void) apr_xml_quote_elem(apr
 
     /* convert the element's text */
     for (scan_txt = elem->first_cdata.first;
-	 scan_txt != NULL;
-	 scan_txt = scan_txt->next) {
-	scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
+         scan_txt != NULL;
+         scan_txt = scan_txt->next) {
+        scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
     }
     for (scan_txt = elem->following_cdata.first;
-	 scan_txt != NULL;
-	 scan_txt = scan_txt->next) {
-	scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
+         scan_txt != NULL;
+         scan_txt = scan_txt->next) {
+        scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
     }
 
     /* convert the attribute values */
     for (scan_attr = elem->attr;
-	 scan_attr != NULL;
-	 scan_attr = scan_attr->next) {
-	scan_attr->value = apr_xml_quote_string(p, scan_attr->value, 1);
+         scan_attr != NULL;
+         scan_attr = scan_attr->next) {
+        scan_attr->value = apr_xml_quote_string(p, scan_attr->value, 1);
     }
 
     /* convert the child elements */
     for (scan_elem = elem->first_child;
-	 scan_elem != NULL;
-	 scan_elem = scan_elem->next) {
-	apr_xml_quote_elem(p, scan_elem);
+         scan_elem != NULL;
+         scan_elem = scan_elem->next) {
+        apr_xml_quote_elem(p, scan_elem);
     }
 }
 
 /* convert an element to a text string */
-APU_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem,
+APR_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem,
                                   int style, apr_array_header_t *namespaces,
                                   int *ns_map, const char **pbuf,
                                   apr_size_t *psize)
@@ -952,25 +851,25 @@ APU_DECLARE(void) apr_xml_to_text(apr_po
 
     *pbuf = s;
     if (psize)
-	*psize = size;
+        *psize = size;
 }
 
-APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t * p,
+APR_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t * p,
                                              const apr_xml_elem *elem)
 {
     if (elem->ns == APR_XML_NS_NONE) {
-	/*
-	 * The prefix (xml...) is already within the prop name, or
-	 * the element simply has no prefix.
-	 */
-	return apr_psprintf(p, "<%s/>" DEBUG_CR, elem->name);
+        /*
+         * The prefix (xml...) is already within the prop name, or
+         * the element simply has no prefix.
+         */
+        return apr_psprintf(p, "<%s/>" DEBUG_CR, elem->name);
     }
 
     return apr_psprintf(p, "<ns%d:%s/>" DEBUG_CR, elem->ns, elem->name);
 }
 
 /* return the URI's (existing) index, or insert it and return a new index */
-APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
+APR_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
                                     const char *uri)
 {
     int i;
@@ -978,15 +877,15 @@ APU_DECLARE(int) apr_xml_insert_uri(apr_
 
     /* never insert an empty URI; this index is always APR_XML_NS_NONE */
     if (*uri == '\0')
-        return APR_XML_NS_NONE;  
+        return APR_XML_NS_NONE;
 
     for (i = uri_array->nelts; i--;) {
-	if (strcmp(uri, APR_XML_GET_URI_ITEM(uri_array, i)) == 0)
-	    return i;
+        if (strcmp(uri, APR_XML_GET_URI_ITEM(uri_array, i)) == 0)
+            return i;
     }
 
     pelt = apr_array_push(uri_array);
-    *pelt = uri;		/* assume uri is const or in a pool */
+    *pelt = uri;                /* assume uri is const or in a pool */
     return uri_array->nelts - 1;
 }
 
@@ -1046,7 +945,7 @@ static apr_status_t apr_xml_parser_conve
 }
 
 /* convert the whole document to EBCDIC */
-APU_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *pool,
+APR_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *pool,
                                                      apr_xml_doc *pdoc,
                                                      apr_xlate_t *convset)
 {

Added: apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c?rev=1854603&view=auto
==============================================================================
--- apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c (added)
+++ apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c Fri Mar  1 16:07:44 2019
@@ -0,0 +1,137 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+
+#if APU_USE_EXPAT
+#include "apr_xml.h"
+
+#if defined(HAVE_XMLPARSE_XMLPARSE_H)
+#include <xmlparse/xmlparse.h>
+#elif defined(HAVE_XMLTOK_XMLPARSE_H)
+#include <xmltok/xmlparse.h>
+#elif defined(HAVE_XML_XMLPARSE_H)
+#include <xml/xmlparse.h>
+#else
+#include <expat.h>
+#endif
+
+typedef enum XML_Error XML_Error;
+
+#include "apr_xml_internal.h"
+
+static apr_status_t cleanup_parser(void *ctx)
+{
+    apr_xml_parser *parser = ctx;
+
+    XML_ParserFree(parser->xp);
+    parser->xp = NULL;
+
+    return APR_SUCCESS;
+}
+static apr_status_t do_parse(apr_xml_parser *parser,
+                             const char *data, apr_size_t len,
+                             int is_final)
+{
+    if (parser->xp == NULL) {
+        parser->error = APR_XML_ERROR_PARSE_DONE;
+    }
+    else {
+        int rv = XML_Parse(parser->xp, data, (int)len, is_final);
+
+        if (rv == 0) {
+            parser->error = APR_XML_ERROR_EXPAT;
+            parser->xp_err = XML_GetErrorCode(parser->xp);
+            parser->xp_msg = XML_ErrorString(parser->xp_err);
+        }
+    }
+
+    /* ### better error code? */
+    return parser->error ? APR_EGENERAL : APR_SUCCESS;
+}
+
+
+static XMLParserImpl xml_parser_expat = {
+    do_parse,
+    cleanup_parser
+};
+
+XMLParserImpl* apr_xml_get_parser_impl(void) { return &xml_parser_expat; }
+static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
+
+#if XML_MAJOR_VERSION > 1
+/* Stop the parser if an entity declaration is hit. */
+static void entity_declaration(void *userData, const XML_Char *entityName,
+                               int is_parameter_entity, const XML_Char *value,
+                               int value_length, const XML_Char *base,
+                               const XML_Char *systemId, const XML_Char *publicId,
+                               const XML_Char *notationName)
+{
+    apr_xml_parser *parser = userData;
+
+    XML_StopParser(parser->xp, XML_FALSE);
+}
+#else
+/* A noop default_handler. */
+static void default_handler(void *userData, const XML_Char *s, int len)
+{
+}
+#endif
+
+apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t *pool,
+    void *start_func, void *end_func, void *cdata_func)
+{
+    apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
+
+    parser->impl = apr_xml_get_parser_impl();
+
+    parser->p = pool;
+    parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
+
+    parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
+
+    /* ### is there a way to avoid hard-coding this? */
+    apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
+
+    parser->xp = XML_ParserCreate(NULL);
+    if (parser->xp == NULL) {
+        (*apr_pool_abort_get(pool))(APR_ENOMEM);
+        return NULL;
+    }
+
+    apr_pool_cleanup_register(pool, parser, cleanup_parser,
+                              apr_pool_cleanup_null);
+
+    XML_SetUserData(parser->xp, parser);
+    XML_SetElementHandler(parser->xp, start_func, end_func);
+    XML_SetCharacterDataHandler(parser->xp, cdata_func);
+
+    /* Prevent the "billion laughs" attack against expat by disabling
+     * internal entity expansion.  With 2.x, forcibly stop the parser
+     * if an entity is declared - this is safer and a more obvious
+     * failure mode.  With older versions, installing a noop
+     * DefaultHandler means that internal entities will be expanded as
+     * the empty string, which is also sufficient to prevent the
+     * attack. */
+#if XML_MAJOR_VERSION > 1
+    XML_SetEntityDeclHandler(parser->xp, entity_declaration);
+#else
+    XML_SetDefaultHandler(parser->xp, default_handler);
+#endif
+
+    return parser;
+}
+#endif

Added: apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h?rev=1854603&view=auto
==============================================================================
--- apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h (added)
+++ apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h Fri Mar  1 16:07:44 2019
@@ -0,0 +1,57 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_XML_INTERNAL_H
+#define APR_XML_INTERNAL_H
+
+
+struct XMLParserImpl {
+    /** parse callback */
+    apr_status_t (*Parse)(apr_xml_parser*, const char*, apr_size_t, int);
+    /** cleanup callback */
+    apr_status_t (*cleanup)(void*);
+};
+typedef struct XMLParserImpl XMLParserImpl;
+XMLParserImpl* apr_xml_get_parser_impl(void);
+
+
+/* the real (internal) definition of the parser context */
+struct apr_xml_parser {
+    /** the doc we're parsing */
+    apr_xml_doc *doc;
+    /** the pool we allocate from */
+    apr_pool_t *p;
+    /** current element */
+    apr_xml_elem *cur_elem;
+    /** an error has occurred */
+    int error;
+#define APR_XML_ERROR_EXPAT             1
+#define APR_XML_ERROR_PARSE_DONE        2
+/* also: public APR_XML_NS_ERROR_* values (if any) */
+
+    /** the actual (Expat) XML parser */
+    XML_Parser xp;
+    /** stored Expat error code */
+    XML_Error xp_err;
+    /** message */
+    const char *xp_msg;
+    /** XML parser implementation */
+    XMLParserImpl *impl;
+};
+
+apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t*, void*, void*, void*);
+
+#endif

Added: apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c?rev=1854603&view=auto
==============================================================================
--- apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c (added)
+++ apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c Fri Mar  1 16:07:44 2019
@@ -0,0 +1,99 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+
+#if APU_USE_LIBXML2
+#include "apr_xml.h"
+
+#include <libxml/parser.h>
+#include <libxml/xmlerror.h>
+
+typedef xmlParserCtxtPtr XML_Parser;
+typedef xmlParserErrors XML_Error;
+
+#include "apr_xml_internal.h"
+
+static apr_status_t cleanup_parser(void *ctx)
+{
+    apr_xml_parser *parser = ctx;
+
+    xmlFreeParserCtxt(parser->xp);
+    parser->xp = NULL;
+
+    return APR_SUCCESS;
+}
+static int libxml2_parse(apr_xml_parser* parser, const char* data,
+                         apr_size_t sz, int final)
+{
+    parser->xp_err = xmlParseChunk(parser->xp, data, sz, final);
+    if (parser->xp_err != 0) {
+        xmlErrorPtr errptr = xmlCtxtGetLastError(parser->xp);
+        parser->xp_msg = errptr->message;
+        /* this misnomer is used as a test for (any) parser error. */
+        parser->error = APR_XML_ERROR_EXPAT;
+    }
+    return parser->xp_err;
+}
+static XMLParserImpl xml_parser_libxml2 = {
+    libxml2_parse,
+    cleanup_parser
+};
+
+static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
+
+XMLParserImpl* apr_xml_get_parser_impl(void)
+{
+    return &xml_parser_libxml2;
+}
+
+
+apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t *pool,
+    void *start_func, void *end_func, void *cdata_func)
+{
+    apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
+    /* FIXME: This is a mismatch.  We should create a single global
+     * sax instance and re-use it for every parser.  That means we
+     * need an up-front initialisation function.
+     */
+    xmlSAXHandlerPtr sax = apr_pcalloc(pool, sizeof(xmlSAXHandler));
+    sax->startElement = start_func;
+    sax->endElement = end_func;
+    sax->characters = cdata_func;
+    sax->initialized = 1;
+
+    parser->impl = apr_xml_get_parser_impl();
+
+    parser->p = pool;
+    parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
+
+    parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
+
+    /* ### is there a way to avoid hard-coding this? */
+    apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
+
+    parser->xp = xmlCreatePushParserCtxt(sax, parser, NULL, 0, NULL);
+    if (parser->xp == NULL) {
+        (*apr_pool_abort_get(pool))(APR_ENOMEM);
+        return NULL;
+    }
+
+    apr_pool_cleanup_register(pool, parser, cleanup_parser,
+                              apr_pool_cleanup_null);
+
+    return parser;
+}
+#endif



Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by William A Rowe Jr <wr...@rowe-clan.net>.
On Sat, Mar 30, 2019 at 8:32 AM Rainer Jung <ra...@kippdata.de> wrote:

> Hi Nick,
>
> Am 27.03.2019 um 23:42 schrieb Nick Kew:
> >
> >> On 27 Mar 2019, at 17:55, Rainer Jung <ra...@kippdata.de> wrote:
> >>
> >> This breaks 1.7 apu compilation using non-system expat for me. The
> expat detection sets INCLUDES but during compilation INCLUDES isn't used
> anywhere, so expat.h can't be found.
> >
> > OK, I need to return to that.  Thanks for the reminder!
> >
> > Does trunk compile for you in the same circumstances?
> > This is supposed to be a backport!
>
> Trunk is APR which adds INCLUDES to EXTRA_INCLUDES and uses those during
> build. APU doesn't use EXTRA_INCLUDES anywhere but uses the
> APRUTIL_PRIV_INCLUDES and APRUTIL_INCLUDES variables, none of which the
> expat flags gets added to. dbd seems to use APRUTIL_PRIV_INCLUDES, all
> other dependencies seem to use APRUTIL_INCLUDES ...
>

Confirmed, the odd nature of needing to include not "include/" but
"include/libxml2/" to pick up "libxml/" (blame that bizzare quirk on their
maintainers) means that what has been working perfectly well for
speculative apr-2 builds is broken in apr-util/branches/1.7.x/. Because I
throw all of the dependencies into one target tree, I'd rarely pick up on
such errors because some other component's lib/ and include/ tree
resolution solves it for the few broken ones.

Is anyone a commit away from a fix before I attempt to help untangle? This
has been dangling breakage for some time now.

Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Nick Kew <ni...@apache.org>.

> On 25 Jul 2020, at 10:10, Graham Leggett <mi...@sharp.fm> wrote:
> 
> On 24 Jul 2020, at 17:03, Nick Kew <ni...@apache.org> wrote:
> 
>>> Another ping on this one - the apr-util 1.7 build is still broken.
>> 
>> Whoops!  I'd completely forgotten that.
>> 
>> Thanks for the partial patch.  Do you want to commit it?
> 
> I’ve just committed http://svn.apache.org/viewvc?rev=1880286&view=rev and http://svn.apache.org/viewvc?rev=1880287&view=rev - it Works For Me(TM) on MacOS and CentOS8, can you give it a try?

Thanks.  All works cleanly for me on both my platforms (Debian and
MacOSX/homebrew) with either XML parser option.

I note that it's building both apr_xml_expat.o and apr_xml_libxml2.o,
but that the one not selected is empty.  Are we bothered by that?
An alternative would be to #include the expat and libxml2 source
files into apr_xml.c, with the existing #ifdefs to select which gets used.


-- 
Nick Kew

Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 24 Jul 2020, at 17:03, Nick Kew <ni...@apache.org> wrote:

>> Another ping on this one - the apr-util 1.7 build is still broken.
> 
> Whoops!  I'd completely forgotten that.
> 
> Thanks for the partial patch.  Do you want to commit it?

I’ve just committed http://svn.apache.org/viewvc?rev=1880286&view=rev <http://svn.apache.org/viewvc?rev=1880286&view=rev> and http://svn.apache.org/viewvc?rev=1880287&view=rev <http://svn.apache.org/viewvc?rev=1880287&view=rev> - it Works For Me(TM) on MacOS and CentOS8, can you give it a try?

Regards,
Graham
—


Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Nick Kew <ni...@apache.org>.
On Fri, 24 Jul 2020 14:11:10 +0200
Graham Leggett <mi...@sharp.fm> wrote:

> On 06 Aug 2019, at 15:55, Rainer Jung <ra...@kippdata.de> wrote:
> 
> > Just a reminder, that APR-UTIL 1.7.x still doesn't compile due to
> > the wrong handling of INCLUDES.
> 
> Another ping on this one - the apr-util 1.7 build is still broken.

Whoops!  I'd completely forgotten that.

Thanks for the partial patch.  Do you want to commit it?

-- 
Nick Kew


Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 06 Aug 2019, at 15:55, Rainer Jung <ra...@kippdata.de> wrote:

> Just a reminder, that APR-UTIL 1.7.x still doesn't compile due to the wrong handling of INCLUDES.

Another ping on this one - the apr-util 1.7 build is still broken.

Tried a number of options to fix it, the includes sort of works if you try the patch below, but the LIBS are very broken. For some reason autoconf tries to bind to both the expat and libxml2 libs, but then ultimately includes neither of them.

Index: build/xml.m4
===================================================================
--- build/xml.m4	(revision 1880261)
+++ build/xml.m4	(working copy)
@@ -148,12 +148,12 @@
 [  --with-libxml2=DIR      specify libxml2 location], [
   if test "$withval" = "yes"; then
     apu_try_libxml2=1
-    APR_ADDTO(INCLUDES, [-I/usr/include/libxml2])
+    APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/include/libxml2])
   elif test "$withval" != "no"; then
     apu_try_libxml2=1
-    APR_ADDTO(INCLUDES, [-I$withval/include/libxml2])
+    APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/libxml2])
     if test "$withval" != "/usr"; then
-      APR_ADDTO(LDFLAGS, [-L$withval/lib])
+      APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
     fi
   fi
   if test ${apu_try_libxml2} = "1" ; then

Regards,
Graham
—


Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Rainer Jung <ra...@kippdata.de>.
Just a reminder, that APR-UTIL 1.7.x still doesn't compile due to the 
wrong handling of INCLUDES.

Am 30.03.2019 um 14:31 schrieb Rainer Jung:
> Hi Nick,
> 
> Am 27.03.2019 um 23:42 schrieb Nick Kew:
>>
>>
>>> On 27 Mar 2019, at 17:55, Rainer Jung <ra...@kippdata.de> wrote:
>>>
>>> This breaks 1.7 apu compilation using non-system expat for me. The 
>>> expat detection sets INCLUDES but during compilation INCLUDES isn't 
>>> used anywhere, so expat.h can't be found.
>>
>> OK, I need to return to that.  Thanks for the reminder!
>>
>> Does trunk compile for you in the same circumstances?
>> This is supposed to be a backport!
> 
> Trunk is APR which adds INCLUDES to EXTRA_INCLUDES and uses those during 
> build. APU doesn't use EXTRA_INCLUDES anywhere but uses the 
> APRUTIL_PRIV_INCLUDES and APRUTIL_INCLUDES variables, none of which the 
> expat flags gets added to. dbd seems to use APRUTIL_PRIV_INCLUDES, all 
> other dependencies seem to use APRUTIL_INCLUDES ...
> 
> Regards,
> 
> Rainer

Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Nick,

Am 27.03.2019 um 23:42 schrieb Nick Kew:
> 
> 
>> On 27 Mar 2019, at 17:55, Rainer Jung <ra...@kippdata.de> wrote:
>>
>> This breaks 1.7 apu compilation using non-system expat for me. The expat detection sets INCLUDES but during compilation INCLUDES isn't used anywhere, so expat.h can't be found.
> 
> OK, I need to return to that.  Thanks for the reminder!
> 
> Does trunk compile for you in the same circumstances?
> This is supposed to be a backport!

Trunk is APR which adds INCLUDES to EXTRA_INCLUDES and uses those during 
build. APU doesn't use EXTRA_INCLUDES anywhere but uses the 
APRUTIL_PRIV_INCLUDES and APRUTIL_INCLUDES variables, none of which the 
expat flags gets added to. dbd seems to use APRUTIL_PRIV_INCLUDES, all 
other dependencies seem to use APRUTIL_INCLUDES ...

Regards,

Rainer


Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Nick Kew <ni...@apache.org>.

> On 27 Mar 2019, at 17:55, Rainer Jung <ra...@kippdata.de> wrote:
> 
> This breaks 1.7 apu compilation using non-system expat for me. The expat detection sets INCLUDES but during compilation INCLUDES isn't used anywhere, so expat.h can't be found.

OK, I need to return to that.  Thanks for the reminder!

Does trunk compile for you in the same circumstances?
This is supposed to be a backport!

-- 
Nick Kew

Re: svn commit: r1854603 - in /apr/apr-util/branches/1.7.x: build/apu-conf.m4 build/xml.m4 configure.in include/apu.h.in include/apu.hw include/apu.hwc xml/NWGNUmakefile xml/apr_xml.c xml/apr_xml_expat.c xml/apr_xml_internal.h xml/apr_xml_libxml2.c

Posted by Rainer Jung <ra...@kippdata.de>.
This breaks 1.7 apu compilation using non-system expat for me. The expat 
detection sets INCLUDES but during compilation INCLUDES isn't used 
anywhere, so expat.h can't be found.

Regards,

Rainer

Am 01.03.2019 um 17:07 schrieb niq@apache.org:
> Author: niq
> Date: Fri Mar  1 16:07:44 2019
> New Revision: 1854603
> 
> URL: http://svn.apache.org/viewvc?rev=1854603&view=rev
> Log:
> apr_xml: backport libxml2 support (r1084621) and build (r1085350)
> with their subsequent minor patches.
> First pass: this requires further followup work to backport subsequent
> patches dealing with non-*X platform builds (not to mention testing).
> 
> Added:
>      apr/apr-util/branches/1.7.x/build/xml.m4
>      apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c
>      apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h
>      apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c
> Modified:
>      apr/apr-util/branches/1.7.x/build/apu-conf.m4
>      apr/apr-util/branches/1.7.x/configure.in
>      apr/apr-util/branches/1.7.x/include/apu.h.in
>      apr/apr-util/branches/1.7.x/include/apu.hw
>      apr/apr-util/branches/1.7.x/include/apu.hwc
>      apr/apr-util/branches/1.7.x/xml/NWGNUmakefile
>      apr/apr-util/branches/1.7.x/xml/apr_xml.c
> 
> Modified: apr/apr-util/branches/1.7.x/build/apu-conf.m4
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/build/apu-conf.m4?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/build/apu-conf.m4 (original)
> +++ apr/apr-util/branches/1.7.x/build/apu-conf.m4 Fri Mar  1 16:07:44 2019
> @@ -46,120 +46,6 @@ AC_DEFUN([APU_FIND_APR], [
>     AC_SUBST(APR_BUILD_DIR)
>   ])
>   
> -dnl
> -dnl APU_TRY_EXPAT_LINK(
> -dnl      test-message, cache-var-name, hdrs, libs,
> -dnl      [actions-on-success], [actions-on-failure])
> -dnl
> -dnl Tests linking against expat with libraries 'libs' and includes
> -dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
> -dnl On success, sets $expat_libs to libs, sets $apu_have_expat to 1,
> -dnl and runs actions-on-success; on failure runs actions-on-failure.
> -dnl
> -AC_DEFUN([APU_TRY_EXPAT_LINK], [
> -AC_CACHE_CHECK([$1], [$2], [
> -  apu_expat_LIBS=$LIBS
> -  LIBS="$LIBS $4"
> -  AC_TRY_LINK([#include <stdlib.h>
> -#include <$3>], [XML_ParserCreate(NULL);],
> -    [$2=yes], [$2=no])
> -  LIBS=$apu_expat_LIBS
> -])
> -
> -if test $[$2] = yes; then
> -   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
> -             [Define if $3 is available])
> -   apu_expat_libs="$4"
> -   apu_has_expat=1
> -   $5
> -else
> -   apu_has_expat=0
> -   $6
> -fi
> -])
> -
> -dnl
> -dnl APU_SYSTEM_EXPAT: tests for a system expat installation
> -dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
> -dnl appropriately.  This is mostly for compatibility with existing
> -dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
> -dnl be dropped later.
> -dnl
> -AC_DEFUN([APU_SYSTEM_EXPAT], [
> -
> -  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system,
> -    [expat.h], [-lexpat])
> -
> -  if test $apu_has_expat = 0; then
> -    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
> -       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
> -  fi
> -
> -  if test $apu_has_expat = 0; then
> -    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
> -       [xml/xmlparse.h], [-lexpat])
> -  fi
> -
> -  if test $apu_has_expat = 0; then
> -    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
> -       [xmlparse/xmlparse.h], [-lexpat])
> -  fi
> -
> -  if test $apu_has_expat = 0; then
> -    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
> -    APR_ADDTO(CPPFLAGS, [-I/usr/local/include])
> -
> -    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local],
> -       apu_cv_expat_usrlocal, [expat.h], [-lexpat],
> -       [APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/local/include])
> -        APR_ADDTO(APRUTIL_LDFLAGS, [-L/usr/local/lib])],[
> -       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
> -       APR_REMOVEFROM(CPPFLAGS, [-I/usr/local/include])
> -      ])
> -  fi
> -])
> -
> -
> -dnl
> -dnl APU_FIND_EXPAT: figure out where EXPAT is located
> -dnl
> -AC_DEFUN([APU_FIND_EXPAT], [
> -
> -save_cppflags="$CPPFLAGS"
> -save_ldflags="$LDFLAGS"
> -
> -apu_has_expat=0
> -
> -apu_try_external_expat=1
> -
> -AC_ARG_WITH([expat],
> -[  --with-expat=DIR        specify Expat location], [
> -  if test "$withval" = "yes"; then
> -    AC_MSG_ERROR([a directory must be specified for --with-expat])
> -  elif test "$withval" = "no"; then
> -    AC_MSG_ERROR([Expat cannot be disabled (at this time)])
> -  else
> -    # Add given path to standard search paths if appropriate:
> -    if test "$withval" != "/usr"; then
> -      APR_ADDTO(LDFLAGS, [-L$withval/lib])
> -      APR_ADDTO(CPPFLAGS, [-I$withval/include])
> -      APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
> -      APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
> -    fi
> -  fi
> -])
> -
> -if test $apu_try_external_expat = 1; then
> -  APU_SYSTEM_EXPAT
> -fi
> -
> -APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
> -APR_ADDTO(APRUTIL_LIBS, [$apu_expat_libs])
> -
> -CPPFLAGS=$save_cppflags
> -LDFLAGS=$save_ldflags
> -])
> -
>   
>   dnl
>   dnl Find a particular LDAP library
> 
> Added: apr/apr-util/branches/1.7.x/build/xml.m4
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/build/xml.m4?rev=1854603&view=auto
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/build/xml.m4 (added)
> +++ apr/apr-util/branches/1.7.x/build/xml.m4 Fri Mar  1 16:07:44 2019
> @@ -0,0 +1,211 @@
> +dnl -------------------------------------------------------- -*- autoconf -*-
> +dnl Licensed to the Apache Software Foundation (ASF) under one or more
> +dnl contributor license agreements.  See the NOTICE file distributed with
> +dnl this work for additional information regarding copyright ownership.
> +dnl The ASF licenses this file to You under the Apache License, Version 2.0
> +dnl (the "License"); you may not use this file except in compliance with
> +dnl the License.  You may obtain a copy of the License at
> +dnl
> +dnl     http://www.apache.org/licenses/LICENSE-2.0
> +dnl
> +dnl Unless required by applicable law or agreed to in writing, software
> +dnl distributed under the License is distributed on an "AS IS" BASIS,
> +dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +dnl See the License for the specific language governing permissions and
> +dnl limitations under the License.
> +
> +
> +dnl
> +dnl APU_TRY_EXPAT_LINK(
> +dnl      test-message, cache-var-name, hdrs, libs,
> +dnl      [actions-on-success], [actions-on-failure])
> +dnl
> +dnl Tests linking against expat with libraries 'libs' and includes
> +dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
> +dnl On success, sets $expat_libs to libs, sets $apu_has_expat to 1,
> +dnl and runs actions-on-success; on failure runs actions-on-failure.
> +dnl
> +AC_DEFUN([APU_TRY_EXPAT_LINK], [
> +AC_CACHE_CHECK([$1], [$2], [
> +  apu_expat_LIBS=$LIBS
> +  apu_expat_CPPFLAGS=$CPPFLAGS
> +  LIBS="$LIBS $4"
> +  CPPFLAGS="$CPPFLAGS $INCLUDES"
> +  AC_TRY_LINK([#include <stdlib.h>
> +#include <$3>], [XML_ParserCreate(NULL);],
> +    [$2=yes], [$2=no])
> +  LIBS=$apu_expat_LIBS
> +  CPPFLAGS=$apu_expat_CPPFLAGS
> +])
> +
> +if test $[$2] = yes; then
> +   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
> +             [Define if $3 is available])
> +   apu_expat_libs="$4"
> +   apu_has_expat=1
> +   $5
> +   AC_SUBST(apu_has_expat)
> +else
> +   apu_has_expat=0
> +   $6
> +fi
> +])
> +
> +dnl
> +dnl APU_SYSTEM_EXPAT: tests for a system expat installation
> +dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
> +dnl appropriately.  This is mostly for compatibility with existing
> +dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
> +dnl be dropped later.
> +dnl
> +AC_DEFUN([APU_SYSTEM_EXPAT], [
> +
> +  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system,
> +    [expat.h], [-lexpat])
> +
> +  if test $apu_has_expat = 0; then
> +    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
> +       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
> +  fi
> +
> +  if test $apu_has_expat = 0; then
> +    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
> +       [xml/xmlparse.h], [-lexpat])
> +  fi
> +
> +  if test $apu_has_expat = 0; then
> +    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
> +       [xmlparse/xmlparse.h], [-lexpat])
> +  fi
> +
> +  if test $apu_has_expat = 0; then
> +    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
> +    APR_ADDTO(INCLUDES, [-I/usr/local/include])
> +
> +    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local],
> +       apu_cv_expat_usrlocal, [expat.h], [-lexpat], [], [
> +       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
> +       APR_REMOVEFROM(INCLUDES, [-I/usr/local/include])
> +      ])
> +  fi
> +])
> +
> +
> +dnl
> +dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled)
> +dnl
> +AC_DEFUN([APU_FIND_EXPAT], [
> +
> +save_cppflags="$CPPFLAGS"
> +
> +apu_has_expat=0
> +
> +AC_ARG_WITH([expat],
> +[  --with-expat=DIR        specify Expat location], [
> +  if test "$withval" = "yes"; then
> +    AC_MSG_ERROR([a directory must be specified for --with-expat])
> +  elif test "$withval" = "no"; then
> +    if test "$apu_has_libxml2" != "1"; then
> +      AC_MSG_ERROR([An XML parser is required!  If you disable expat, you must select --with-libxml2])
> +    fi
> +  else
> +    # Add given path to standard search paths if appropriate:
> +    if test "$apu_has_libxml2" = "1"; then
> +      AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
> +    fi
> +    if test "$withval" != "/usr"; then
> +      APR_ADDTO(INCLUDES, [-I$withval/include])
> +      APR_ADDTO(LDFLAGS, [-L$withval/lib])
> +    fi
> +  fi
> +])
> +
> +if test "$apu_has_libxml2" != "1"; then
> +  APU_SYSTEM_EXPAT
> +
> +  APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
> +  APR_ADDTO(LIBS, [$apu_expat_libs])
> +
> +  APR_XML_DIR=$bundled_subdir
> +  AC_SUBST(APR_XML_DIR)
> +fi
> +
> +CPPFLAGS=$save_cppflags
> +])
> +
> +
> +dnl
> +dnl APU_FIND_LIBXML2: figure out where LIBXML2 is located (or use bundled)
> +dnl
> +AC_DEFUN([APU_FIND_LIBXML2], [
> +
> +save_cppflags="$CPPFLAGS"
> +
> +apu_has_libxml2=0
> +apu_try_libxml2=0
> +
> +AC_ARG_WITH([libxml2],
> +[  --with-libxml2=DIR      specify libxml2 location], [
> +  if test "$withval" = "yes"; then
> +    apu_try_libxml2=1
> +    APR_ADDTO(INCLUDES, [-I/usr/include/libxml2])
> +  elif test "$withval" != "no"; then
> +    apu_try_libxml2=1
> +    APR_ADDTO(INCLUDES, [-I$withval/include/libxml2])
> +    if test "$withval" != "/usr"; then
> +      APR_ADDTO(LDFLAGS, [-L$withval/lib])
> +    fi
> +  fi
> +  if test ${apu_try_libxml2} = "1" ; then
> +
> +    #test for libxml2
> +    AC_CACHE_CHECK([libxml2], [apu_cv_libxml2], [
> +      apu_libxml2_CPPFLAGS=$CPPFLAGS
> +      apu_libxml2_LIBS="$LIBS -lxml2"
> +      CPPFLAGS="$CPPFLAGS $INCLUDES"
> +      LIBS="$LIBS -lxml2"
> +      AC_TRY_LINK(
> +        [#include <libxml/parser.h>],
> +        [xmlSAXHandler sax; xmlCreatePushParserCtxt(&sax, NULL, NULL, 0, NULL);],
> +        [apu_cv_libxml2=yes],
> +        [apu_cv_libxml2=no],
> +      )
> +      CPPFLAGS=$apu_libxml2_CPPFLAGS
> +      LIBS=$apu_libxml2_LIBS
> +    ])
> +    if test $apu_cv_libxml2 = yes ; then
> +      AC_DEFINE([HAVE_LIBXML2_H], 1, [libxml2 found])
> +      apu_has_libxml2=1
> +    else
> +      apu_has_libxml2=0
> +    fi
> +  fi
> +])
> +AC_SUBST(apu_has_libxml2)
> +
> +if test ${apu_has_libxml2} = "1" ; then
> +  APR_ADDTO(APRUTIL_EXPORT_LIBS, [-lxml2])
> +  APR_ADDTO(LIBS, [-lxml2])
> +fi
> +
> +CPPFLAGS=$save_cppflags
> +])
> +
> +dnl
> +dnl APU_FIND_XML: Find an XML library
> +dnl
> +dnl Logic: we need exactly one but not both XML libraries
> +dnl        Make expat the default for back-compatibility.
> +dnl        Use libxml2 if a --with-libxml2 is specified (and works),
> +dnl        otherwise expat.
> +dnl
> +AC_DEFUN([APU_FIND_XML], [
> +APU_FIND_LIBXML2
> +APU_FIND_EXPAT
> +
> +if test ${apu_has_expat} = "1" && test ${apu_has_libxml2} = "1" ; then
> +  AC_MSG_ERROR(Cannot build with both expat and libxml2 - please select one)
> +elif test ${apu_has_expat} != "1" && test ${apu_has_libxml2} != "1" ; then
> +  AC_MSG_ERROR(No XML parser found!  Please specify --with-expat or --with-libxml2)
> +fi
> +])
> 
> Modified: apr/apr-util/branches/1.7.x/configure.in
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/configure.in?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/configure.in (original)
> +++ apr/apr-util/branches/1.7.x/configure.in Fri Mar  1 16:07:44 2019
> @@ -9,6 +9,7 @@ AC_CONFIG_HEADER(include/private/apu_con
>   AC_CONFIG_AUX_DIR(build)
>   
>   sinclude(build/apu-conf.m4)
> +sinclude(build/xml.m4)
>   sinclude(build/apu-iconv.m4)
>   sinclude(build/apu-hints.m4)
>   sinclude(build/apr_common.m4)
> @@ -166,7 +167,7 @@ APU_CHECK_DBD_SQLITE3
>   APU_CHECK_DBD_SQLITE2
>   APU_CHECK_DBD_ORACLE
>   APU_CHECK_DBD_ODBC
> -APU_FIND_EXPAT
> +APU_FIND_XML
>   APU_FIND_ICONV
>   
>   dnl Enable DSO build; must be last:
> 
> Modified: apr/apr-util/branches/1.7.x/include/apu.h.in
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apu.h.in?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/include/apu.h.in (original)
> +++ apr/apr-util/branches/1.7.x/include/apu.h.in Fri Mar  1 16:07:44 2019
> @@ -125,5 +125,8 @@
>   #define APU_HAVE_ICONV         @have_iconv@
>   #define APR_HAS_XLATE          (APU_HAVE_APR_ICONV || APU_HAVE_ICONV)
>   
> +#define APU_USE_EXPAT          @apu_has_expat@
> +#define APU_USE_LIBXML2        @apu_has_libxml2@
> +
>   #endif /* APU_H */
>   /** @} */
> 
> Modified: apr/apr-util/branches/1.7.x/include/apu.hw
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apu.hw?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/include/apu.hw (original)
> +++ apr/apr-util/branches/1.7.x/include/apu.hw Fri Mar  1 16:07:44 2019
> @@ -142,5 +142,8 @@
>   #define APU_HAVE_ICONV          0
>   #define APR_HAS_XLATE           (APU_HAVE_APR_ICONV || APU_HAVE_ICONV)
>   
> +#define APU_USE_EXPAT           1
> +#define APU_USE_LIBXML2         0
> +
>   #endif /* APU_H */
>   /** @} */
> 
> Modified: apr/apr-util/branches/1.7.x/include/apu.hwc
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apu.hwc?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/include/apu.hwc (original)
> +++ apr/apr-util/branches/1.7.x/include/apu.hwc Fri Mar  1 16:07:44 2019
> @@ -141,5 +141,8 @@
>   #define APU_HAVE_ICONV          0
>   #define APR_HAS_XLATE           (APU_HAVE_APR_ICONV || APU_HAVE_ICONV)
>   
> +#define APU_USE_EXPAT           @apu_use_expat_10@
> +#define APU_USE_LIBXML2         @apu_use_libxml2_10@
> +
>   #endif /* APU_H */
>   /** @} */
> 
> Modified: apr/apr-util/branches/1.7.x/xml/NWGNUmakefile
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/NWGNUmakefile?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/xml/NWGNUmakefile (original)
> +++ apr/apr-util/branches/1.7.x/xml/NWGNUmakefile Fri Mar  1 16:07:44 2019
> @@ -3,7 +3,7 @@
>   #
>   
>   SUBDIRS = \
> -	$(EOLIST)
> +	$(EOLIST)
>   
>   #
>   # Get the 'head' of the build environment.  This includes default targets and
> @@ -19,31 +19,68 @@ include $(APR_WORK)/build/NWGNUhead.inc
>   # Make sure all needed macro's are defined
>   #
>   
> +ifdef EXPATSRC
> +
> +ifeq "$(wildcard $(EXPATSRC)/lib/expat.h.in)" "$(EXPATSRC)/lib/expat.h.in"
> +EXPAT_prebuild_headers += $(EXPATSRC)/lib/expat.h
> +endif
> +ifeq "$(wildcard $(EXPATSRC)/lib/config.hnw)" "$(EXPATSRC)/lib/config.hnw"
> +EXPAT_prebuild_headers += $(EXPATSRC)/lib/config.h
> +endif
> +ifeq "$(wildcard $(EXPATSRC)/expat_config.h.in)" "$(EXPATSRC)/expat_config.h.in"
> +EXPAT_prebuild_headers += $(EXPATSRC)/lib/expat_config.h
> +endif
> +
> +$(EXPATSRC)/lib/%.h: $(EXPATSRC)/lib/%.hnw
> +	@echo Creating $@
> +	$(call COPY,$<,$@)
> +
> +$(EXPATSRC)/lib/%.h: $(EXPATSRC)/lib/%.h.in
> +	@echo Creating $@
> +	$(call COPY,$<,$@)
> +
> +$(EXPATSRC)/lib/expat_config.h:
> +	@echo Creating $@
> +	@echo $(DL)/* $(notdir $@) for NetWare platform */$(DL)>>$@
> +	@echo $(DL)#ifndef NETWARE$(DL)>>$@
> +	@echo $(DL)#error This $(notdir $@) is for NetWare platform!$(DL)>>$@
> +	@echo $(DL)#endif$(DL)>>$@
> +	@echo $(DL)#ifndef EXPAT_CONFIG_H$(DL)>>$@
> +	@echo $(DL)#define EXPAT_CONFIG_H$(DL)>>$@
> +	@echo $(DL)#define HAVE_MEMMOVE 1$(DL)>>$@
> +	@echo $(DL)#define XML_NS 1$(DL)>>$@
> +	@echo $(DL)#define XML_DTD 1$(DL)>>$@
> +	@echo $(DL)#define XML_BYTE_ORDER 1234$(DL)>>$@
> +	@echo $(DL)#define XML_CONTEXT_BYTES 1024$(DL)>>$@
> +	@echo $(DL)#endif /* EXPAT_CONFIG_H */$(DL)>>$@
> +
> +vpath %.c $(EXPATSRC)/lib
> +
> +endif
> +
>   #
>   # These directories will be at the beginning of the include list, followed by
>   # INCDIRS
>   #
>   XINCDIRS	+= \
> +			$(EXPAT_INC) \
>   			$(APR)/include \
> -			$(APR)/include/arch/NetWare \
> -			$(APU)/include \
> -			$(APU)/uri \
> -			$(APU)/dbm/sdbm \
> -			$(APU)/include/private \
> -			$(APUXML)/expat/lib \
> +			$(APR)/include/private \
> +			$(APR)/include/arch/netware \
>   			$(EOLIST)
>   
>   #
>   # These flags will come after CFLAGS
>   #
>   XCFLAGS		+= \
> -			-DHAVE_EXPAT_CONFIG_H \
>   			$(EOLIST)
>   
>   #
>   # These defines will come after DEFINES
>   #
>   XDEFINES	+= \
> +			-DAPU_USE_EXPAT=1 \
> +			-DHAVE_EXPAT_CONFIG_H \
>   			$(EOLIST)
>   
>   #
> @@ -103,21 +140,21 @@ endif
>   # This is used by the link 'name' directive to name the nlm.  If left blank
>   # TARGET_nlm (see below) will be used.
>   #
> -NLM_NAME	=
> +NLM_NAME	=
>   
>   #
> -# This is used by the link '-desc ' directive.
> +# This is used by the link '-desc ' directive.
>   # If left blank, NLM_NAME will be used.
>   #
> -NLM_DESCRIPTION	=
> +NLM_DESCRIPTION	=
>   
>   #
>   # This is used by the '-threadname' directive.  If left blank,
>   # NLM_NAME Thread will be used.
>   #
> -NLM_THREAD_NAME	=
> +NLM_THREAD_NAME	=
>   #
> -# If this is specified, it will override VERSION value in
> +# If this is specified, it will override VERSION value in
>   # $(APR_WORK)/build/NWGNUenvironment.inc
>   #
>   NLM_VERSION	=
> @@ -125,17 +162,17 @@ NLM_VERSION	=
>   #
>   # If this is specified, it will override the default of 64K
>   #
> -NLM_STACK_SIZE	=
> +NLM_STACK_SIZE	=
>   
>   #
>   # If this is specified it will be used by the link '-entry' directive
>   #
> -NLM_ENTRY_SYM	=
> +NLM_ENTRY_SYM	=
>   
>   #
>   # If this is specified it will be used by the link '-exit' directive
>   #
> -NLM_EXIT_SYM	=
> +NLM_EXIT_SYM	=
>   
>   #
>   # If this is specified it will be used by the link '-check' directive
> @@ -146,13 +183,13 @@ NLM_CHECK_SYM	=
>   # If this is specified it will be used by the link '-flags' directive
>   #
>   NLM_FLAGS	=
> -
> +
>   #
> -# If this is specified it will be linked in with the XDCData option in the def
> -# file instead of the default of $(APR)/misc/netware/apache.xdc.  XDCData can
> +# If this is specified it will be linked in with the XDCData option in the def
> +# file instead of the default of $(APR)/misc/netware/apache.xdc.  XDCData can
>   # be disabled by setting APACHE_UNIPROC in the environment
>   #
> -XDCDATA		=
> +XDCDATA		=
>   
>   #
>   # Declare all target files (you must add your files here)
> @@ -168,7 +205,7 @@ TARGET_nlm = \
>   # If there is an LIB target, put it here
>   #
>   TARGET_lib = \
> -	$(OBJDIR)/apuxml.lib \
> +	$(OBJDIR)/xml.lib \
>   	$(EOLIST)
>   
>   #
> @@ -196,7 +233,7 @@ FILES_nlm_modules = \
>   # If the nlm has a msg file, put it's path here
>   #
>   FILE_nlm_msg =
> -
> +
>   #
>   # If the nlm has a hlp file put it's path here
>   #
> @@ -212,44 +249,51 @@ FILE_nlm_copyright =
>   #
>   FILES_nlm_Ximports = \
>   	$(EOLIST)
> -
> -#
> +
> +#
>   # Any symbols exported to here
>   #
>   FILES_nlm_exports = \
>   	$(EOLIST)
>   
> -#
> +#
>   # These are the OBJ files needed to create the LIB target above.
>   # Paths must all use the '/' character
>   #
>   FILES_lib_objs = \
>   	$(OBJDIR)/apr_xml.o \
> +	$(OBJDIR)/apr_xml_expat.o \
> +	$(EOLIST)
> +
> +ifdef EXPATSRC
> +FILES_lib_objs += \
>   	$(OBJDIR)/xmlparse.o \
>   	$(OBJDIR)/xmlrole.o \
>   	$(OBJDIR)/xmltok.o \
>   	$(EOLIST)
> +endif
>   
>   #
>   # implement targets and dependancies (leave this section alone)
>   #
>   
> -libs :: $(OBJDIR) $(TARGET_lib)
> +libs :: $(OBJDIR) $(EXPAT_prebuild_headers) $(TARGET_lib)
>   
>   nlms :: libs $(TARGET_nlm)
>   
>   #
> -# Updated this target to create necessary directories and copy files to the
> +# Updated this target to create necessary directories and copy files to the
>   # correct place.  (See $(APR_WORK)/build/NWGNUhead.inc for examples)
>   #
>   install :: nlms FORCE
>   
> +clean ::
> +	$(foreach file,$(EXPAT_prebuild_headers),$(call DEL,$(file)))
> +
>   #
>   # Any specialized rules here
>   #
>   
> -vpath %.c expat/lib
> -
>   #
>   # Include the 'tail' makefile that has targets that depend on variables defined
>   # in this makefile
> 
> Modified: apr/apr-util/branches/1.7.x/xml/apr_xml.c
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml.c?rev=1854603&r1=1854602&r2=1854603&view=diff
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/xml/apr_xml.c (original)
> +++ apr/apr-util/branches/1.7.x/xml/apr_xml.c Fri Mar  1 16:07:44 2019
> @@ -15,6 +15,7 @@
>    */
>   
>   #include "apr.h"
> +#include "apr_private.h"
>   #include "apr_strings.h"
>   
>   #define APR_WANT_STDIO          /* for sprintf() */
> @@ -22,24 +23,15 @@
>   #include "apr_want.h"
>   
>   #include "apr_xml.h"
> -
> -#include "apu_config.h"
> -
> -#if defined(HAVE_XMLPARSE_XMLPARSE_H)
> -#include <xmlparse/xmlparse.h>
> -#elif defined(HAVE_XMLTOK_XMLPARSE_H)
> -#include <xmltok/xmlparse.h>
> -#elif defined(HAVE_XML_XMLPARSE_H)
> -#include <xml/xmlparse.h>
> -#else
> -#include <expat.h>
> -#endif
> +typedef void* XML_Parser;
> +typedef int XML_Error;
> +typedef unsigned char XML_Char;
> +#include "apr_xml_internal.h"
>   
>   #define DEBUG_CR "\r\n"
>   
>   static const char APR_KW_xmlns[] = { 0x78, 0x6D, 0x6C, 0x6E, 0x73, '\0' };
>   static const char APR_KW_xmlns_lang[] = { 0x78, 0x6D, 0x6C, 0x3A, 0x6C, 0x61, 0x6E, 0x67, '\0' };
> -static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
>   
>   /* errors related to namespace processing */
>   #define APR_XML_NS_ERROR_UNKNOWN_PREFIX (-1000)
> @@ -47,32 +39,17 @@ static const char APR_KW_DAV[] = { 0x44,
>   
>   /* test for a namespace prefix that begins with [Xx][Mm][Ll] */
>   #define APR_XML_NS_IS_RESERVED(name) \
> -	( (name[0] == 0x58 || name[0] == 0x78) && \
> -	  (name[1] == 0x4D || name[1] == 0x6D) && \
> -	  (name[2] == 0x4C || name[2] == 0x6C) )
> -
> -
> -/* the real (internal) definition of the parser context */
> -struct apr_xml_parser {
> -    apr_xml_doc *doc;		/* the doc we're parsing */
> -    apr_pool_t *p;		/* the pool we allocate from */
> -    apr_xml_elem *cur_elem;	/* current element */
> -
> -    int error;			/* an error has occurred */
> -#define APR_XML_ERROR_EXPAT             1
> -#define APR_XML_ERROR_PARSE_DONE        2
> -/* also: public APR_XML_NS_ERROR_* values (if any) */
> -
> -    XML_Parser xp;              /* the actual (Expat) XML parser */
> -    enum XML_Error xp_err;      /* stored Expat error code */
> -};
> +        ( (name[0] == 0x58 || name[0] == 0x78) && \
> +          (name[1] == 0x4D || name[1] == 0x6D) && \
> +          (name[2] == 0x4C || name[2] == 0x6C) )
> +
>   
>   /* struct for scoping namespace declarations */
>   typedef struct apr_xml_ns_scope {
> -    const char *prefix;		/* prefix used for this ns */
> -    int ns;			/* index into namespace table */
> -    int emptyURI;		/* the namespace URI is the empty string */
> -    struct apr_xml_ns_scope *next;	/* next scoped namespace */
> +    const char *prefix;         /* prefix used for this ns */
> +    int ns;                     /* index into namespace table */
> +    int emptyURI;               /* the namespace URI is the empty string */
> +    struct apr_xml_ns_scope *next;      /* next scoped namespace */
>   } apr_xml_ns_scope;
>   
>   
> @@ -86,23 +63,23 @@ static int find_prefix(apr_xml_parser *p
>       ** prefix.
>       */
>       for (; elem; elem = elem->parent) {
> -	apr_xml_ns_scope *ns_scope;
> +        apr_xml_ns_scope *ns_scope;
> +
> +        for (ns_scope = elem->ns_scope; ns_scope; ns_scope = ns_scope->next) {
> +            if (strcmp(prefix, ns_scope->prefix) == 0) {
> +                if (ns_scope->emptyURI) {
> +                    /*
> +                    ** It is possible to set the default namespace to an
> +                    ** empty URI string; this resets the default namespace
> +                    ** to mean "no namespace." We just found the prefix
> +                    ** refers to an empty URI, so return "no namespace."
> +                    */
> +                    return APR_XML_NS_NONE;
> +                }
>   
> -	for (ns_scope = elem->ns_scope; ns_scope; ns_scope = ns_scope->next) {
> -	    if (strcmp(prefix, ns_scope->prefix) == 0) {
> -		if (ns_scope->emptyURI) {
> -		    /*
> -		    ** It is possible to set the default namespace to an
> -		    ** empty URI string; this resets the default namespace
> -		    ** to mean "no namespace." We just found the prefix
> -		    ** refers to an empty URI, so return "no namespace."
> -		    */
> -		    return APR_XML_NS_NONE;
> -		}
> -
> -		return ns_scope->ns;
> -	    }
> -	}
> +                return ns_scope->ns;
> +            }
> +        }
>       }
>   
>       /*
> @@ -113,7 +90,7 @@ static int find_prefix(apr_xml_parser *p
>        * has "no namespace". We have a reserved value for this.
>        */
>       if (*prefix == '\0') {
> -	return APR_XML_NS_NONE;
> +        return APR_XML_NS_NONE;
>       }
>   
>       /* not found */
> @@ -128,18 +105,17 @@ static const char * find_prefix_name(con
>       ** prefix.
>       */
>       for (; elem; elem = parent ? elem->parent : NULL) {
> -	apr_xml_ns_scope *ns_scope = elem->ns_scope;
> +       apr_xml_ns_scope *ns_scope = elem->ns_scope;
>   
> -	for (; ns_scope; ns_scope = ns_scope->next) {
> -	    if (ns_scope->ns == ns)
> -		return ns_scope->prefix;
> -	}
> +       for (; ns_scope; ns_scope = ns_scope->next) {
> +           if (ns_scope->ns == ns)
> +               return ns_scope->prefix;
> +       }
>       }
>       /* not found */
>       return "";
>   }
>   
> -
>   static void start_handler(void *userdata, const char *name, const char **attrs)
>   {
>       apr_xml_parser *parser = userdata;
> @@ -152,7 +128,7 @@ static void start_handler(void *userdata
>   
>       /* punt once we find an error */
>       if (parser->error)
> -	return;
> +        return;
>   
>       elem = apr_pcalloc(parser->p, sizeof(*elem));
>   
> @@ -160,97 +136,97 @@ static void start_handler(void *userdata
>       elem->name = elem_name = apr_pstrdup(parser->p, name);
>   
>       /* fill in the attributes (note: ends up in reverse order) */
> -    while (*attrs) {
> -	attr = apr_palloc(parser->p, sizeof(*attr));
> -	attr->name = apr_pstrdup(parser->p, *attrs++);
> -	attr->value = apr_pstrdup(parser->p, *attrs++);
> -	attr->next = elem->attr;
> -	elem->attr = attr;
> +    while (attrs && *attrs) {
> +        attr = apr_palloc(parser->p, sizeof(*attr));
> +        attr->name = apr_pstrdup(parser->p, *attrs++);
> +        attr->value = apr_pstrdup(parser->p, *attrs++);
> +        attr->next = elem->attr;
> +        elem->attr = attr;
>       }
>   
>       /* hook the element into the tree */
>       if (parser->cur_elem == NULL) {
> -	/* no current element; this also becomes the root */
> -	parser->cur_elem = parser->doc->root = elem;
> +        /* no current element; this also becomes the root */
> +        parser->cur_elem = parser->doc->root = elem;
>       }
>       else {
> -	/* this element appeared within the current elem */
> -	elem->parent = parser->cur_elem;
> +        /* this element appeared within the current elem */
> +        elem->parent = parser->cur_elem;
>   
> -	/* set up the child/sibling links */
> -	if (elem->parent->last_child == NULL) {
> -	    /* no first child either */
> -	    elem->parent->first_child = elem->parent->last_child = elem;
> -	}
> -	else {
> -	    /* hook onto the end of the parent's children */
> -	    elem->parent->last_child->next = elem;
> -	    elem->parent->last_child = elem;
> -	}
> +        /* set up the child/sibling links */
> +        if (elem->parent->last_child == NULL) {
> +            /* no first child either */
> +            elem->parent->first_child = elem->parent->last_child = elem;
> +        }
> +        else {
> +            /* hook onto the end of the parent's children */
> +            elem->parent->last_child->next = elem;
> +            elem->parent->last_child = elem;
> +        }
>   
> -	/* this element is now the current element */
> -	parser->cur_elem = elem;
> +        /* this element is now the current element */
> +        parser->cur_elem = elem;
>       }
>   
>       /* scan the attributes for namespace declarations */
>       for (prev = NULL, attr = elem->attr;
> -	 attr;
> -	 attr = attr->next) {
> -	if (strncmp(attr->name, APR_KW_xmlns, 5) == 0) {
> -	    const char *prefix = &attr->name[5];
> -	    apr_xml_ns_scope *ns_scope;
> +         attr;
> +         attr = attr->next) {
> +        if (strncmp(attr->name, APR_KW_xmlns, 5) == 0) {
> +            const char *prefix = &attr->name[5];
> +            apr_xml_ns_scope *ns_scope;
>   
> -	    /* test for xmlns:foo= form and xmlns= form */
> -	    if (*prefix == 0x3A) {
> +            /* test for xmlns:foo= form and xmlns= form */
> +            if (*prefix == 0x3A) {
>                   /* a namespace prefix declaration must have a
>                      non-empty value. */
>                   if (attr->value[0] == '\0') {
>                       parser->error = APR_XML_NS_ERROR_INVALID_DECL;
>                       return;
>                   }
> -		++prefix;
> +                ++prefix;
>               }
> -	    else if (*prefix != '\0') {
> -		/* advance "prev" since "attr" is still present */
> -		prev = attr;
> -		continue;
> -	    }
> -
> -	    /* quote the URI before we ever start working with it */
> -	    quoted = apr_xml_quote_string(parser->p, attr->value, 1);
> -
> -	    /* build and insert the new scope */
> -	    ns_scope = apr_pcalloc(parser->p, sizeof(*ns_scope));
> -	    ns_scope->prefix = prefix;
> -	    ns_scope->ns = apr_xml_insert_uri(parser->doc->namespaces, quoted);
> -	    ns_scope->emptyURI = *quoted == '\0';
> -	    ns_scope->next = elem->ns_scope;
> -	    elem->ns_scope = ns_scope;
> -
> -	    /* remove this attribute from the element */
> -	    if (prev == NULL)
> -		elem->attr = attr->next;
> -	    else
> -		prev->next = attr->next;
> -
> -	    /* Note: prev will not be advanced since we just removed "attr" */
> -	}
> -	else if (strcmp(attr->name, APR_KW_xmlns_lang) == 0) {
> -	    /* save away the language (in quoted form) */
> -	    elem->lang = apr_xml_quote_string(parser->p, attr->value, 1);
> -
> -	    /* remove this attribute from the element */
> -	    if (prev == NULL)
> -		elem->attr = attr->next;
> -	    else
> -		prev->next = attr->next;
> -
> -	    /* Note: prev will not be advanced since we just removed "attr" */
> -	}
> -	else {
> -	    /* advance "prev" since "attr" is still present */
> -	    prev = attr;
> -	}
> +            else if (*prefix != '\0') {
> +                /* advance "prev" since "attr" is still present */
> +                prev = attr;
> +                continue;
> +            }
> +
> +            /* quote the URI before we ever start working with it */
> +            quoted = apr_xml_quote_string(parser->p, attr->value, 1);
> +
> +            /* build and insert the new scope */
> +            ns_scope = apr_pcalloc(parser->p, sizeof(*ns_scope));
> +            ns_scope->prefix = prefix;
> +            ns_scope->ns = apr_xml_insert_uri(parser->doc->namespaces, quoted);
> +            ns_scope->emptyURI = *quoted == '\0';
> +            ns_scope->next = elem->ns_scope;
> +            elem->ns_scope = ns_scope;
> +
> +            /* remove this attribute from the element */
> +            if (prev == NULL)
> +                elem->attr = attr->next;
> +            else
> +                prev->next = attr->next;
> +
> +            /* Note: prev will not be advanced since we just removed "attr" */
> +        }
> +        else if (strcmp(attr->name, APR_KW_xmlns_lang) == 0) {
> +            /* save away the language (in quoted form) */
> +            elem->lang = apr_xml_quote_string(parser->p, attr->value, 1);
> +
> +            /* remove this attribute from the element */
> +            if (prev == NULL)
> +                elem->attr = attr->next;
> +            else
> +                prev->next = attr->next;
> +
> +            /* Note: prev will not be advanced since we just removed "attr" */
> +        }
> +        else {
> +            /* advance "prev" since "attr" is still present */
> +            prev = attr;
> +        }
>       }
>   
>       /*
> @@ -260,30 +236,30 @@ static void start_handler(void *userdata
>       ** NOTE: elem_size() *depends* upon this pointer equality.
>       */
>       if (elem->lang == NULL && elem->parent != NULL)
> -	elem->lang = elem->parent->lang;
> +        elem->lang = elem->parent->lang;
>   
>       /* adjust the element's namespace */
>       colon = strchr(elem_name, 0x3A);
>       if (colon == NULL) {
> -	/*
> -	 * The element is using the default namespace, which will always
> -	 * be found. Either it will be "no namespace", or a default
> -	 * namespace URI has been specified at some point.
> -	 */
> -	elem->ns = find_prefix(parser, "");
> +        /*
> +         * The element is using the default namespace, which will always
> +         * be found. Either it will be "no namespace", or a default
> +         * namespace URI has been specified at some point.
> +         */
> +        elem->ns = find_prefix(parser, "");
>       }
>       else if (APR_XML_NS_IS_RESERVED(elem->name)) {
> -	elem->ns = APR_XML_NS_NONE;
> +        elem->ns = APR_XML_NS_NONE;
>       }
>       else {
> -	*colon = '\0';
> -	elem->ns = find_prefix(parser, elem->name);
> -	elem->name = colon + 1;
> -
> -	if (APR_XML_NS_IS_ERROR(elem->ns)) {
> -	    parser->error = elem->ns;
> -	    return;
> -	}
> +        *colon = '\0';
> +        elem->ns = find_prefix(parser, elem->name);
> +        elem->name = colon + 1;
> +
> +        if (APR_XML_NS_IS_ERROR(elem->ns)) {
> +            parser->error = elem->ns;
> +            return;
> +        }
>       }
>   
>       /* adjust all remaining attributes' namespaces */
> @@ -295,27 +271,27 @@ static void start_handler(void *userdata
>            */
>           char *attr_name = (char *)attr->name;
>   
> -	colon = strchr(attr_name, 0x3A);
> -	if (colon == NULL) {
> -	    /*
> -	     * Attributes do NOT use the default namespace. Therefore,
> -	     * we place them into the "no namespace" category.
> -	     */
> -	    attr->ns = APR_XML_NS_NONE;
> -	}
> -	else if (APR_XML_NS_IS_RESERVED(attr->name)) {
> -	    attr->ns = APR_XML_NS_NONE;
> -	}
> -	else {
> -	    *colon = '\0';
> -	    attr->ns = find_prefix(parser, attr->name);
> -	    attr->name = colon + 1;
> -
> -	    if (APR_XML_NS_IS_ERROR(attr->ns)) {
> -		parser->error = attr->ns;
> -		return;
> -	    }
> -	}
> +        colon = strchr(attr_name, 0x3A);
> +        if (colon == NULL) {
> +            /*
> +             * Attributes do NOT use the default namespace. Therefore,
> +             * we place them into the "no namespace" category.
> +             */
> +            attr->ns = APR_XML_NS_NONE;
> +        }
> +        else if (APR_XML_NS_IS_RESERVED(attr->name)) {
> +            attr->ns = APR_XML_NS_NONE;
> +        }
> +        else {
> +            *colon = '\0';
> +            attr->ns = find_prefix(parser, attr->name);
> +            attr->name = colon + 1;
> +
> +            if (APR_XML_NS_IS_ERROR(attr->ns)) {
> +                parser->error = attr->ns;
> +                return;
> +            }
> +        }
>       }
>   }
>   
> @@ -325,7 +301,7 @@ static void end_handler(void *userdata,
>   
>       /* punt once we find an error */
>       if (parser->error)
> -	return;
> +        return;
>   
>       /* pop up one level */
>       parser->cur_elem = parser->cur_elem->parent;
> @@ -340,128 +316,43 @@ static void cdata_handler(void *userdata
>   
>       /* punt once we find an error */
>       if (parser->error)
> -	return;
> +        return;
>   
>       elem = parser->cur_elem;
>       s = apr_pstrndup(parser->p, data, len);
>   
>       if (elem->last_child == NULL) {
> -	/* no children yet. this cdata follows the start tag */
> -	hdr = &elem->first_cdata;
> +        /* no children yet. this cdata follows the start tag */
> +        hdr = &elem->first_cdata;
>       }
>       else {
> -	/* child elements exist. this cdata follows the last child. */
> -	hdr = &elem->last_child->following_cdata;
> +        /* child elements exist. this cdata follows the last child. */
> +        hdr = &elem->last_child->following_cdata;
>       }
>   
>       apr_text_append(parser->p, hdr, s);
>   }
>   
> -static apr_status_t cleanup_parser(void *ctx)
> -{
> -    apr_xml_parser *parser = ctx;
> -
> -    XML_ParserFree(parser->xp);
> -    parser->xp = NULL;
> -
> -    return APR_SUCCESS;
> -}
> -
> -#if XML_MAJOR_VERSION > 1
> -/* Stop the parser if an entity declaration is hit. */
> -static void entity_declaration(void *userData, const XML_Char *entityName,
> -                               int is_parameter_entity, const XML_Char *value,
> -                               int value_length, const XML_Char *base,
> -                               const XML_Char *systemId, const XML_Char *publicId,
> -                               const XML_Char *notationName)
> -{
> -    apr_xml_parser *parser = userData;
> -
> -    XML_StopParser(parser->xp, XML_FALSE);
> -}
> -#else
> -/* A noop default_handler. */
> -static void default_handler(void *userData, const XML_Char *s, int len)
> +APR_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool)
>   {
> +    return apr_xml_parser_create_internal(pool, &start_handler, &end_handler, &cdata_handler);
>   }
> -#endif
> -
> -APU_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool)
> -{
> -    apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
> -
> -    parser->p = pool;
> -    parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
> -
> -    parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
> -
> -    /* ### is there a way to avoid hard-coding this? */
> -    apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
> -
> -    parser->xp = XML_ParserCreate(NULL);
> -    if (parser->xp == NULL) {
> -        (*apr_pool_abort_get(pool))(APR_ENOMEM);
> -        return NULL;
> -    }
> -
> -    apr_pool_cleanup_register(pool, parser, cleanup_parser,
> -                              apr_pool_cleanup_null);
> -
> -    XML_SetUserData(parser->xp, parser);
> -    XML_SetElementHandler(parser->xp, start_handler, end_handler);
> -    XML_SetCharacterDataHandler(parser->xp, cdata_handler);
> -
> -    /* Prevent the "billion laughs" attack against expat by disabling
> -     * internal entity expansion.  With 2.x, forcibly stop the parser
> -     * if an entity is declared - this is safer and a more obvious
> -     * failure mode.  With older versions, installing a noop
> -     * DefaultHandler means that internal entities will be expanded as
> -     * the empty string, which is also sufficient to prevent the
> -     * attack. */
> -#if XML_MAJOR_VERSION > 1
> -    XML_SetEntityDeclHandler(parser->xp, entity_declaration);
> -#else
> -    XML_SetDefaultHandler(parser->xp, default_handler);
> -#endif
>   
> -    return parser;
> -}
> -
> -static apr_status_t do_parse(apr_xml_parser *parser,
> -                             const char *data, apr_size_t len,
> -                             int is_final)
> -{
> -    if (parser->xp == NULL) {
> -        parser->error = APR_XML_ERROR_PARSE_DONE;
> -    }
> -    else {
> -        int rv = XML_Parse(parser->xp, data, (int)len, is_final);
> -
> -        if (rv == 0) {
> -            parser->error = APR_XML_ERROR_EXPAT;
> -            parser->xp_err = XML_GetErrorCode(parser->xp);
> -        }
> -    }
> -
> -    /* ### better error code? */
> -    return parser->error ? APR_EGENERAL : APR_SUCCESS;
> -}
> -
> -APU_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser,
> +APR_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser,
>                                                 const char *data,
>                                                 apr_size_t len)
>   {
> -    return do_parse(parser, data, len, 0 /* is_final */);
> +    return parser->impl->Parse(parser, data, len, 0 /* is_final */);
>   }
>   
> -APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser,
> +APR_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser,
>                                                 apr_xml_doc **pdoc)
>   {
>       char end;
> -    apr_status_t status = do_parse(parser, &end, 0, 1 /* is_final */);
> +    apr_status_t status = parser->impl->Parse(parser, &end, 0, 1 /* is_final */);
>   
>       /* get rid of the parser */
> -    (void) apr_pool_cleanup_run(parser->p, parser, cleanup_parser);
> +    (void) apr_pool_cleanup_run(parser->p, parser, parser->impl->cleanup);
>   
>       if (status)
>           return status;
> @@ -471,7 +362,7 @@ APU_DECLARE(apr_status_t) apr_xml_parser
>       return APR_SUCCESS;
>   }
>   
> -APU_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser,
> +APR_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser,
>                                               char *errbuf,
>                                               apr_size_t errbufsize)
>   {
> @@ -497,7 +388,7 @@ APU_DECLARE(char *) apr_xml_parser_geter
>       case APR_XML_ERROR_EXPAT:
>           (void) apr_snprintf(errbuf, errbufsize,
>                               "XML parser error code: %s (%d)",
> -                            XML_ErrorString(parser->xp_err), parser->xp_err);
> +                            parser->xp_msg, parser->xp_err);
>           return errbuf;
>   
>       case APR_XML_ERROR_PARSE_DONE:
> @@ -513,7 +404,7 @@ APU_DECLARE(char *) apr_xml_parser_geter
>       return errbuf;
>   }
>   
> -APU_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p,
> +APR_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p,
>                                                apr_xml_parser **parser,
>                                                apr_xml_doc **ppdoc,
>                                                apr_file_t *xmlfd,
> @@ -551,7 +442,7 @@ APU_DECLARE(apr_status_t) apr_xml_parse_
>       return rv;
>   }
>   
> -APU_DECLARE(void) apr_text_append(apr_pool_t * p, apr_text_header *hdr,
> +APR_DECLARE(void) apr_text_append(apr_pool_t * p, apr_text_header *hdr,
>                                     const char *text)
>   {
>       apr_text *t = apr_palloc(p, sizeof(*t));
> @@ -560,13 +451,13 @@ APU_DECLARE(void) apr_text_append(apr_po
>       t->next = NULL;
>   
>       if (hdr->first == NULL) {
> -	/* no text elements yet */
> -	hdr->first = hdr->last = t;
> +        /* no text elements yet */
> +        hdr->first = hdr->last = t;
>       }
>       else {
> -	/* append to the last text element */
> -	hdr->last->next = t;
> -	hdr->last = t;
> +        /* append to the last text element */
> +        hdr->last->next = t;
> +        hdr->last = t;
>       }
>   }
>   
> @@ -585,7 +476,7 @@ APU_DECLARE(void) apr_text_append(apr_po
>   ** quotes is typically set to true for XML strings that will occur within
>   ** double quotes -- attribute values.
>   */
> -APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
> +APR_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
>                                                  int quotes)
>   {
>       const char *scan;
> @@ -596,50 +487,50 @@ APU_DECLARE(const char *) apr_xml_quote_
>       char c;
>   
>       for (scan = s; (c = *scan) != '\0'; ++scan, ++len) {
> -	if (c == '<' || c == '>')
> -	    extra += 3;		/* &lt; or &gt; */
> -	else if (c == '&')
> -	    extra += 4;		/* &amp; */
> -	else if (quotes && c == '"')
> -	    extra += 5;		/* &quot; */
> +        if (c == '<' || c == '>')
> +            extra += 3;         /* &lt; or &gt; */
> +        else if (c == '&')
> +            extra += 4;         /* &amp; */
> +        else if (quotes && c == '"')
> +            extra += 5;         /* &quot; */
>       }
>   
>       /* nothing to do? */
>       if (extra == 0)
> -	return s;
> +        return s;
>   
>       qstr = apr_palloc(p, len + extra + 1);
>       for (scan = s, qscan = qstr; (c = *scan) != '\0'; ++scan) {
> -	if (c == '<') {
> -	    *qscan++ = '&';
> -	    *qscan++ = 'l';
> -	    *qscan++ = 't';
> -	    *qscan++ = ';';
> -	}
> -	else if (c == '>') {
> -	    *qscan++ = '&';
> -	    *qscan++ = 'g';
> -	    *qscan++ = 't';
> -	    *qscan++ = ';';
> -	}
> -	else if (c == '&') {
> -	    *qscan++ = '&';
> -	    *qscan++ = 'a';
> -	    *qscan++ = 'm';
> -	    *qscan++ = 'p';
> -	    *qscan++ = ';';
> -	}
> -	else if (quotes && c == '"') {
> -	    *qscan++ = '&';
> -	    *qscan++ = 'q';
> -	    *qscan++ = 'u';
> -	    *qscan++ = 'o';
> -	    *qscan++ = 't';
> -	    *qscan++ = ';';
> -	}
> -	else {
> -	    *qscan++ = c;
> -	}
> +        if (c == '<') {
> +            *qscan++ = '&';
> +            *qscan++ = 'l';
> +            *qscan++ = 't';
> +            *qscan++ = ';';
> +        }
> +        else if (c == '>') {
> +            *qscan++ = '&';
> +            *qscan++ = 'g';
> +            *qscan++ = 't';
> +            *qscan++ = ';';
> +        }
> +        else if (c == '&') {
> +            *qscan++ = '&';
> +            *qscan++ = 'a';
> +            *qscan++ = 'm';
> +            *qscan++ = 'p';
> +            *qscan++ = ';';
> +        }
> +        else if (quotes && c == '"') {
> +            *qscan++ = '&';
> +            *qscan++ = 'q';
> +            *qscan++ = 'u';
> +            *qscan++ = 'o';
> +            *qscan++ = 't';
> +            *qscan++ = ';';
> +        }
> +        else {
> +            *qscan++ = c;
> +        }
>       }
>   
>       *qscan = '\0';
> @@ -657,7 +548,7 @@ static apr_size_t text_size(const apr_te
>       apr_size_t size = 0;
>   
>       for (; t; t = t->next)
> -	size += strlen(t->text);
> +        size += strlen(t->text);
>       return size;
>   }
>   
> @@ -667,117 +558,117 @@ static apr_size_t elem_size(const apr_xm
>       apr_size_t size;
>   
>       if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG ||
> -	style == APR_XML_X2T_PARSED) {
> -	const apr_xml_attr *attr;
> +        style == APR_XML_X2T_PARSED) {
> +        const apr_xml_attr *attr;
> +
> +        size = 0;
> +
> +        if (style == APR_XML_X2T_FULL_NS_LANG) {
> +            int i;
>   
> -	size = 0;
> +            /*
> +            ** The outer element will contain xmlns:ns%d="%s" attributes
> +            ** and an xml:lang attribute, if applicable.
> +            */
> +
> +            for (i = namespaces->nelts; i--;) {
> +                /* compute size of: ' xmlns:ns%d="%s"' */
> +                size += (9 + APR_XML_NS_LEN(i) + 2 +
> +                         strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1);
> +            }
> +
> +            if (elem->lang != NULL) {
> +                /* compute size of: ' xml:lang="%s"' */
> +                size += 11 + strlen(elem->lang) + 1;
> +            }
> +        }
> +        else if (style == APR_XML_X2T_PARSED) {
> +            apr_xml_ns_scope *ns_scope = elem->ns_scope;
>   
> -	if (style == APR_XML_X2T_FULL_NS_LANG) {
> -	    int i;
> +            /* compute size of: ' xmlns:%s="%s"' */
> +            for (; ns_scope; ns_scope = ns_scope->next) {
> +                size += 10 + strlen(find_prefix_name(elem, ns_scope->ns, 0)) +
> +                             strlen(APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
> +            }
> +
> +            if (elem->lang != NULL) {
> +                /* compute size of: ' xml:lang="%s"' */
> +                size += 11 + strlen(elem->lang) + 1;
> +            }
> +        }
> +
> +        if (elem->ns == APR_XML_NS_NONE) {
> +            /* compute size of: <%s> */
> +            size += 1 + strlen(elem->name) + 1;
> +        }
> +        else if (style == APR_XML_X2T_PARSED) {
> +            /* compute size of: <%s:%s> */
> +            size += 3 + strlen(find_prefix_name(elem, elem->ns, 1)) + strlen(elem->name);
> +        }
> +        else {
> +            int ns = ns_map ? ns_map[elem->ns] : elem->ns;
>   
> -	    /*
> -	    ** The outer element will contain xmlns:ns%d="%s" attributes
> -	    ** and an xml:lang attribute, if applicable.
> -	    */
> -
> -	    for (i = namespaces->nelts; i--;) {
> -		/* compute size of: ' xmlns:ns%d="%s"' */
> -		size += (9 + APR_XML_NS_LEN(i) + 2 +
> -			 strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1);
> -	    }
> -
> -	    if (elem->lang != NULL) {
> -		/* compute size of: ' xml:lang="%s"' */
> -		size += 11 + strlen(elem->lang) + 1;
> -	    }
> -	}
> -	else if (style == APR_XML_X2T_PARSED) {
> -	    apr_xml_ns_scope *ns_scope = elem->ns_scope;
> -
> -	    /* compute size of: ' xmlns:%s="%s"' */
> -	    for (; ns_scope; ns_scope = ns_scope->next) {
> -		size += 10 + strlen(find_prefix_name(elem, ns_scope->ns, 0)) +
> -			     strlen(APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
> -	    }
> -
> -	    if (elem->lang != NULL) {
> -		/* compute size of: ' xml:lang="%s"' */
> -		size += 11 + strlen(elem->lang) + 1;
> -	    }
> -	}
> -
> -	if (elem->ns == APR_XML_NS_NONE) {
> -	    /* compute size of: <%s> */
> -	    size += 1 + strlen(elem->name) + 1;
> -	}
> -	else if (style == APR_XML_X2T_PARSED) {
> -	    /* compute size of: <%s:%s> */
> -	    size += 3 + strlen(find_prefix_name(elem, elem->ns, 1)) + strlen(elem->name);
> -	}
> -	else {
> -	    int ns = ns_map ? ns_map[elem->ns] : elem->ns;
> -
> -	    /* compute size of: <ns%d:%s> */
> -	    size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1;
> -	}
> -
> -	if (APR_XML_ELEM_IS_EMPTY(elem)) {
> -	    /* insert a closing "/" */
> -	    size += 1;
> -	}
> -	else {
> -	    /*
> -	     * two of above plus "/":
> -	     *     <ns%d:%s> ... </ns%d:%s>
> -	     * OR  <%s> ... </%s>
> -	     */
> -	    size = 2 * size + 1;
> -	}
> -
> -	for (attr = elem->attr; attr; attr = attr->next) {
> -	    if (attr->ns == APR_XML_NS_NONE) {
> -		/* compute size of: ' %s="%s"' */
> -		size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
> -	    }
> -	    else if (style == APR_XML_X2T_PARSED) {
> -		/* compute size of: ' %s:%s="%s"' */
> -		size += 5 + strlen(find_prefix_name(elem, attr->ns, 1)) + strlen(attr->name) + strlen(attr->value);
> -	    }
> -	    else {
> -		/* compute size of: ' ns%d:%s="%s"' */
> +            /* compute size of: <ns%d:%s> */
> +            size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1;
> +        }
> +
> +        if (APR_XML_ELEM_IS_EMPTY(elem)) {
> +            /* insert a closing "/" */
> +            size += 1;
> +        }
> +        else {
> +            /*
> +             * two of above plus "/":
> +             *     <ns%d:%s> ... </ns%d:%s>
> +             * OR  <%s> ... </%s>
> +             */
> +            size = 2 * size + 1;
> +        }
> +
> +        for (attr = elem->attr; attr; attr = attr->next) {
> +            if (attr->ns == APR_XML_NS_NONE) {
> +                /* compute size of: ' %s="%s"' */
> +                size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
> +            }
> +            else if (style == APR_XML_X2T_PARSED) {
> +                /* compute size of: ' %s:%s="%s"' */
> +                size += 5 + strlen(find_prefix_name(elem, attr->ns, 1)) + strlen(attr->name) + strlen(attr->value);
> +            }
> +            else {
> +                /* compute size of: ' ns%d:%s="%s"' */
>                   int ns = ns_map ? ns_map[attr->ns] : attr->ns;
>                   size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
> -	    }
> -	}
> +            }
> +        }
>   
> -	/*
> -	** If the element has an xml:lang value that is *different* from
> -	** its parent, then add the thing in: ' xml:lang="%s"'.
> -	**
> -	** NOTE: we take advantage of the pointer equality established by
> -	** the parsing for "inheriting" the xml:lang values from parents.
> -	*/
> -	if (elem->lang != NULL &&
> -	    (elem->parent == NULL || elem->lang != elem->parent->lang)) {
> -	    size += 11 + strlen(elem->lang) + 1;
> -	}
> +        /*
> +        ** If the element has an xml:lang value that is *different* from
> +        ** its parent, then add the thing in: ' xml:lang="%s"'.
> +        **
> +        ** NOTE: we take advantage of the pointer equality established by
> +        ** the parsing for "inheriting" the xml:lang values from parents.
> +        */
> +        if (elem->lang != NULL &&
> +            (elem->parent == NULL || elem->lang != elem->parent->lang)) {
> +            size += 11 + strlen(elem->lang) + 1;
> +        }
>       }
>       else if (style == APR_XML_X2T_LANG_INNER) {
> -	/*
> -	 * This style prepends the xml:lang value plus a null terminator.
> -	 * If a lang value is not present, then we insert a null term.
> -	 */
> -	size = elem->lang ? strlen(elem->lang) + 1 : 1;
> +        /*
> +         * This style prepends the xml:lang value plus a null terminator.
> +         * If a lang value is not present, then we insert a null term.
> +         */
> +        size = elem->lang ? strlen(elem->lang) + 1 : 1;
>       }
>       else
> -	size = 0;
> +        size = 0;
>   
>       size += text_size(elem->first_cdata.first);
>   
>       for (elem = elem->first_child; elem; elem = elem->next) {
> -	/* the size of the child element plus the CDATA that follows it */
> -	size += (elem_size(elem, style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL, NULL, ns_map) +
> -		 text_size(elem->following_cdata.first));
> +        /* the size of the child element plus the CDATA that follows it */
> +        size += (elem_size(elem, style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL, NULL, ns_map) +
> +                 text_size(elem->following_cdata.first));
>       }
>   
>       return size;
> @@ -786,125 +677,133 @@ static apr_size_t elem_size(const apr_xm
>   static char *write_text(char *s, const apr_text *t)
>   {
>       for (; t; t = t->next) {
> -	apr_size_t len = strlen(t->text);
> -	memcpy(s, t->text, len);
> -	s += len;
> +        apr_size_t len = strlen(t->text);
> +        memcpy(s, t->text, len);
> +        s += len;
>       }
>       return s;
>   }
>   
>   static char *write_elem(char *s, const apr_xml_elem *elem, int style,
> -			apr_array_header_t *namespaces, int *ns_map)
> +                        apr_array_header_t *namespaces, int *ns_map)
>   {
>       const apr_xml_elem *child;
>       apr_size_t len;
>       int ns;
>   
>       if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG ||
> -	style == APR_XML_X2T_PARSED) {
> -	int empty = APR_XML_ELEM_IS_EMPTY(elem);
> -	const apr_xml_attr *attr;
> -
> -	if (elem->ns == APR_XML_NS_NONE)
> -	    len = sprintf(s, "<%s", elem->name);
> -	else if (style == APR_XML_X2T_PARSED)
> -	    len = sprintf(s, "<%s:%s", find_prefix_name(elem, elem->ns, 1), elem->name);
> -	else {
> -	    ns = ns_map ? ns_map[elem->ns] : elem->ns;
> -	    len = sprintf(s, "<ns%d:%s", ns, elem->name);
> -	}
> -	s += len;
> -
> -	for (attr = elem->attr; attr; attr = attr->next) {
> -	    if (attr->ns == APR_XML_NS_NONE)
> -		len = sprintf(s, " %s=\"%s\"", attr->name, attr->value);
> -	    else if (style == APR_XML_X2T_PARSED)
> -		len = sprintf(s, " %s:%s=\"%s\"",
> -			      find_prefix_name(elem, attr->ns, 1), attr->name, attr->value);
> -	    else {
> -		ns = ns_map ? ns_map[attr->ns] : attr->ns;
> -		len = sprintf(s, " ns%d:%s=\"%s\"", ns, attr->name, attr->value);
> -	    }
> -	    s += len;
> -	}
> -
> -	/* add the xml:lang value if necessary */
> -	if (elem->lang != NULL &&
> -	    (style == APR_XML_X2T_FULL_NS_LANG ||
> -	     elem->parent == NULL ||
> -	     elem->lang != elem->parent->lang)) {
> -	    len = sprintf(s, " xml:lang=\"%s\"", elem->lang);
> -	    s += len;
> -	}
> -
> -	/* add namespace definitions, if required */
> -	if (style == APR_XML_X2T_FULL_NS_LANG) {
> -	    int i;
> -
> -	    for (i = namespaces->nelts; i--;) {
> -		len = sprintf(s, " xmlns:ns%d=\"%s\"", i,
> -			      APR_XML_GET_URI_ITEM(namespaces, i));
> -		s += len;
> -	    }
> -	}
> -	else if (style == APR_XML_X2T_PARSED) {
> -	    apr_xml_ns_scope *ns_scope = elem->ns_scope;
> -
> -	    for (; ns_scope; ns_scope = ns_scope->next) {
> -		const char *prefix = find_prefix_name(elem, ns_scope->ns, 0);
> -
> -		len = sprintf(s, " xmlns%s%s=\"%s\"",
> -			      *prefix ? ":" : "", *prefix ? prefix : "",
> -			      APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
> -		s += len;
> -	    }
> -	}
> -
> -	/* no more to do. close it up and go. */
> -	if (empty) {
> -	    *s++ = '/';
> -	    *s++ = '>';
> -	    return s;
> -	}
> +        style == APR_XML_X2T_PARSED) {
> +        int empty = APR_XML_ELEM_IS_EMPTY(elem);
> +        const apr_xml_attr *attr;
> +
> +        if (elem->ns == APR_XML_NS_NONE) {
> +            len = sprintf(s, "<%s", elem->name);
> +        }
> +        else if (style == APR_XML_X2T_PARSED) {
> +            len = sprintf(s, "<%s:%s", find_prefix_name(elem, elem->ns, 1), elem->name);
> +        }
> +        else {
> +            ns = ns_map ? ns_map[elem->ns] : elem->ns;
> +            len = sprintf(s, "<ns%d:%s", ns, elem->name);
> +        }
> +        s += len;
> +
> +        for (attr = elem->attr; attr; attr = attr->next) {
> +            if (attr->ns == APR_XML_NS_NONE) {
> +                len = sprintf(s, " %s=\"%s\"", attr->name, attr->value);
> +            }
> +            else if (style == APR_XML_X2T_PARSED) {
> +                len = sprintf(s, " %s:%s=\"%s\"",
> +                              find_prefix_name(elem, attr->ns, 1), attr->name, attr->value);
> +            }
> +            else {
> +                ns = ns_map ? ns_map[attr->ns] : attr->ns;
> +                len = sprintf(s, " ns%d:%s=\"%s\"", ns, attr->name, attr->value);
> +            }
> +            s += len;
> +        }
> +
> +        /* add the xml:lang value if necessary */
> +        if (elem->lang != NULL &&
> +            (style == APR_XML_X2T_FULL_NS_LANG ||
> +             elem->parent == NULL ||
> +             elem->lang != elem->parent->lang)) {
> +            len = sprintf(s, " xml:lang=\"%s\"", elem->lang);
> +            s += len;
> +        }
> +
> +        /* add namespace definitions, if required */
> +        if (style == APR_XML_X2T_FULL_NS_LANG) {
> +            int i;
> +
> +            for (i = namespaces->nelts; i--;) {
> +                len = sprintf(s, " xmlns:ns%d=\"%s\"", i,
> +                              APR_XML_GET_URI_ITEM(namespaces, i));
> +                s += len;
> +            }
> +        }
> +
> +        else if (style == APR_XML_X2T_PARSED) {
> +            apr_xml_ns_scope *ns_scope = elem->ns_scope;
> +
> +            for (; ns_scope; ns_scope = ns_scope->next) {
> +                const char *prefix = find_prefix_name(elem, ns_scope->ns, 0);
>   
> -	/* just close it */
> -	*s++ = '>';
> +                len = sprintf(s, " xmlns%s%s=\"%s\"",
> +                              *prefix ? ":" : "", *prefix ? prefix : "",
> +                              APR_XML_GET_URI_ITEM(namespaces, ns_scope->ns));
> +                s += len;
> +            }
> +        }
> +
> +        /* no more to do. close it up and go. */
> +        if (empty) {
> +            *s++ = '/';
> +            *s++ = '>';
> +            return s;
> +        }
> +
> +        /* just close it */
> +        *s++ = '>';
>       }
>       else if (style == APR_XML_X2T_LANG_INNER) {
> -	/* prepend the xml:lang value */
> -	if (elem->lang != NULL) {
> -	    len = strlen(elem->lang);
> -	    memcpy(s, elem->lang, len);
> -	    s += len;
> -	}
> -	*s++ = '\0';
> +        /* prepend the xml:lang value */
> +        if (elem->lang != NULL) {
> +            len = strlen(elem->lang);
> +            memcpy(s, elem->lang, len);
> +            s += len;
> +        }
> +        *s++ = '\0';
>       }
>   
>       s = write_text(s, elem->first_cdata.first);
>   
>       for (child = elem->first_child; child; child = child->next) {
> -	s = write_elem(s, child,
> -		       style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL,
> -		       NULL, ns_map);
> -	s = write_text(s, child->following_cdata.first);
> -    }
> -
> -    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG || style == APR_XML_X2T_PARSED) {
> -	if (elem->ns == APR_XML_NS_NONE)
> -	    len = sprintf(s, "</%s>", elem->name);
> -	else if (style == APR_XML_X2T_PARSED)
> -	    len = sprintf(s, "</%s:%s>", find_prefix_name(elem, elem->ns, 1), elem->name);
> -	else {
> -	    ns = ns_map ? ns_map[elem->ns] : elem->ns;
> -	    len = sprintf(s, "</ns%d:%s>", ns, elem->name);
> -	}
> -	s += len;
> +        s = write_elem(s, child,
> +                       style == APR_XML_X2T_PARSED ? APR_XML_X2T_PARSED : APR_XML_X2T_FULL,
> +                       NULL, ns_map);
> +        s = write_text(s, child->following_cdata.first);
> +    }
> +
> +    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG ||
> +        style == APR_XML_X2T_PARSED) {
> +        if (elem->ns == APR_XML_NS_NONE) {
> +            len = sprintf(s, "</%s>", elem->name);
> +        }
> +        else if (style == APR_XML_X2T_PARSED) {
> +            len = sprintf(s, "</%s:%s>", find_prefix_name(elem, elem->ns, 1), elem->name);
> +        }
> +        else {
> +            ns = ns_map ? ns_map[elem->ns] : elem->ns;
> +            len = sprintf(s, "</ns%d:%s>", ns, elem->name);
> +        }
> +        s += len;
>       }
>   
>       return s;
>   }
>   
> -APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem)
> +APR_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem)
>   {
>       apr_text *scan_txt;
>       apr_xml_attr *scan_attr;
> @@ -912,33 +811,33 @@ APU_DECLARE(void) apr_xml_quote_elem(apr
>   
>       /* convert the element's text */
>       for (scan_txt = elem->first_cdata.first;
> -	 scan_txt != NULL;
> -	 scan_txt = scan_txt->next) {
> -	scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
> +         scan_txt != NULL;
> +         scan_txt = scan_txt->next) {
> +        scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
>       }
>       for (scan_txt = elem->following_cdata.first;
> -	 scan_txt != NULL;
> -	 scan_txt = scan_txt->next) {
> -	scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
> +         scan_txt != NULL;
> +         scan_txt = scan_txt->next) {
> +        scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
>       }
>   
>       /* convert the attribute values */
>       for (scan_attr = elem->attr;
> -	 scan_attr != NULL;
> -	 scan_attr = scan_attr->next) {
> -	scan_attr->value = apr_xml_quote_string(p, scan_attr->value, 1);
> +         scan_attr != NULL;
> +         scan_attr = scan_attr->next) {
> +        scan_attr->value = apr_xml_quote_string(p, scan_attr->value, 1);
>       }
>   
>       /* convert the child elements */
>       for (scan_elem = elem->first_child;
> -	 scan_elem != NULL;
> -	 scan_elem = scan_elem->next) {
> -	apr_xml_quote_elem(p, scan_elem);
> +         scan_elem != NULL;
> +         scan_elem = scan_elem->next) {
> +        apr_xml_quote_elem(p, scan_elem);
>       }
>   }
>   
>   /* convert an element to a text string */
> -APU_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem,
> +APR_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem,
>                                     int style, apr_array_header_t *namespaces,
>                                     int *ns_map, const char **pbuf,
>                                     apr_size_t *psize)
> @@ -952,25 +851,25 @@ APU_DECLARE(void) apr_xml_to_text(apr_po
>   
>       *pbuf = s;
>       if (psize)
> -	*psize = size;
> +        *psize = size;
>   }
>   
> -APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t * p,
> +APR_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t * p,
>                                                const apr_xml_elem *elem)
>   {
>       if (elem->ns == APR_XML_NS_NONE) {
> -	/*
> -	 * The prefix (xml...) is already within the prop name, or
> -	 * the element simply has no prefix.
> -	 */
> -	return apr_psprintf(p, "<%s/>" DEBUG_CR, elem->name);
> +        /*
> +         * The prefix (xml...) is already within the prop name, or
> +         * the element simply has no prefix.
> +         */
> +        return apr_psprintf(p, "<%s/>" DEBUG_CR, elem->name);
>       }
>   
>       return apr_psprintf(p, "<ns%d:%s/>" DEBUG_CR, elem->ns, elem->name);
>   }
>   
>   /* return the URI's (existing) index, or insert it and return a new index */
> -APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
> +APR_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
>                                       const char *uri)
>   {
>       int i;
> @@ -978,15 +877,15 @@ APU_DECLARE(int) apr_xml_insert_uri(apr_
>   
>       /* never insert an empty URI; this index is always APR_XML_NS_NONE */
>       if (*uri == '\0')
> -        return APR_XML_NS_NONE;
> +        return APR_XML_NS_NONE;
>   
>       for (i = uri_array->nelts; i--;) {
> -	if (strcmp(uri, APR_XML_GET_URI_ITEM(uri_array, i)) == 0)
> -	    return i;
> +        if (strcmp(uri, APR_XML_GET_URI_ITEM(uri_array, i)) == 0)
> +            return i;
>       }
>   
>       pelt = apr_array_push(uri_array);
> -    *pelt = uri;		/* assume uri is const or in a pool */
> +    *pelt = uri;                /* assume uri is const or in a pool */
>       return uri_array->nelts - 1;
>   }
>   
> @@ -1046,7 +945,7 @@ static apr_status_t apr_xml_parser_conve
>   }
>   
>   /* convert the whole document to EBCDIC */
> -APU_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *pool,
> +APR_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *pool,
>                                                        apr_xml_doc *pdoc,
>                                                        apr_xlate_t *convset)
>   {
> 
> Added: apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c?rev=1854603&view=auto
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c (added)
> +++ apr/apr-util/branches/1.7.x/xml/apr_xml_expat.c Fri Mar  1 16:07:44 2019
> @@ -0,0 +1,137 @@
> +/* Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#include "apr.h"
> +
> +#if APU_USE_EXPAT
> +#include "apr_xml.h"
> +
> +#if defined(HAVE_XMLPARSE_XMLPARSE_H)
> +#include <xmlparse/xmlparse.h>
> +#elif defined(HAVE_XMLTOK_XMLPARSE_H)
> +#include <xmltok/xmlparse.h>
> +#elif defined(HAVE_XML_XMLPARSE_H)
> +#include <xml/xmlparse.h>
> +#else
> +#include <expat.h>
> +#endif
> +
> +typedef enum XML_Error XML_Error;
> +
> +#include "apr_xml_internal.h"
> +
> +static apr_status_t cleanup_parser(void *ctx)
> +{
> +    apr_xml_parser *parser = ctx;
> +
> +    XML_ParserFree(parser->xp);
> +    parser->xp = NULL;
> +
> +    return APR_SUCCESS;
> +}
> +static apr_status_t do_parse(apr_xml_parser *parser,
> +                             const char *data, apr_size_t len,
> +                             int is_final)
> +{
> +    if (parser->xp == NULL) {
> +        parser->error = APR_XML_ERROR_PARSE_DONE;
> +    }
> +    else {
> +        int rv = XML_Parse(parser->xp, data, (int)len, is_final);
> +
> +        if (rv == 0) {
> +            parser->error = APR_XML_ERROR_EXPAT;
> +            parser->xp_err = XML_GetErrorCode(parser->xp);
> +            parser->xp_msg = XML_ErrorString(parser->xp_err);
> +        }
> +    }
> +
> +    /* ### better error code? */
> +    return parser->error ? APR_EGENERAL : APR_SUCCESS;
> +}
> +
> +
> +static XMLParserImpl xml_parser_expat = {
> +    do_parse,
> +    cleanup_parser
> +};
> +
> +XMLParserImpl* apr_xml_get_parser_impl(void) { return &xml_parser_expat; }
> +static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
> +
> +#if XML_MAJOR_VERSION > 1
> +/* Stop the parser if an entity declaration is hit. */
> +static void entity_declaration(void *userData, const XML_Char *entityName,
> +                               int is_parameter_entity, const XML_Char *value,
> +                               int value_length, const XML_Char *base,
> +                               const XML_Char *systemId, const XML_Char *publicId,
> +                               const XML_Char *notationName)
> +{
> +    apr_xml_parser *parser = userData;
> +
> +    XML_StopParser(parser->xp, XML_FALSE);
> +}
> +#else
> +/* A noop default_handler. */
> +static void default_handler(void *userData, const XML_Char *s, int len)
> +{
> +}
> +#endif
> +
> +apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t *pool,
> +    void *start_func, void *end_func, void *cdata_func)
> +{
> +    apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
> +
> +    parser->impl = apr_xml_get_parser_impl();
> +
> +    parser->p = pool;
> +    parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
> +
> +    parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
> +
> +    /* ### is there a way to avoid hard-coding this? */
> +    apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
> +
> +    parser->xp = XML_ParserCreate(NULL);
> +    if (parser->xp == NULL) {
> +        (*apr_pool_abort_get(pool))(APR_ENOMEM);
> +        return NULL;
> +    }
> +
> +    apr_pool_cleanup_register(pool, parser, cleanup_parser,
> +                              apr_pool_cleanup_null);
> +
> +    XML_SetUserData(parser->xp, parser);
> +    XML_SetElementHandler(parser->xp, start_func, end_func);
> +    XML_SetCharacterDataHandler(parser->xp, cdata_func);
> +
> +    /* Prevent the "billion laughs" attack against expat by disabling
> +     * internal entity expansion.  With 2.x, forcibly stop the parser
> +     * if an entity is declared - this is safer and a more obvious
> +     * failure mode.  With older versions, installing a noop
> +     * DefaultHandler means that internal entities will be expanded as
> +     * the empty string, which is also sufficient to prevent the
> +     * attack. */
> +#if XML_MAJOR_VERSION > 1
> +    XML_SetEntityDeclHandler(parser->xp, entity_declaration);
> +#else
> +    XML_SetDefaultHandler(parser->xp, default_handler);
> +#endif
> +
> +    return parser;
> +}
> +#endif
> 
> Added: apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h?rev=1854603&view=auto
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h (added)
> +++ apr/apr-util/branches/1.7.x/xml/apr_xml_internal.h Fri Mar  1 16:07:44 2019
> @@ -0,0 +1,57 @@
> +/* Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#ifndef APR_XML_INTERNAL_H
> +#define APR_XML_INTERNAL_H
> +
> +
> +struct XMLParserImpl {
> +    /** parse callback */
> +    apr_status_t (*Parse)(apr_xml_parser*, const char*, apr_size_t, int);
> +    /** cleanup callback */
> +    apr_status_t (*cleanup)(void*);
> +};
> +typedef struct XMLParserImpl XMLParserImpl;
> +XMLParserImpl* apr_xml_get_parser_impl(void);
> +
> +
> +/* the real (internal) definition of the parser context */
> +struct apr_xml_parser {
> +    /** the doc we're parsing */
> +    apr_xml_doc *doc;
> +    /** the pool we allocate from */
> +    apr_pool_t *p;
> +    /** current element */
> +    apr_xml_elem *cur_elem;
> +    /** an error has occurred */
> +    int error;
> +#define APR_XML_ERROR_EXPAT             1
> +#define APR_XML_ERROR_PARSE_DONE        2
> +/* also: public APR_XML_NS_ERROR_* values (if any) */
> +
> +    /** the actual (Expat) XML parser */
> +    XML_Parser xp;
> +    /** stored Expat error code */
> +    XML_Error xp_err;
> +    /** message */
> +    const char *xp_msg;
> +    /** XML parser implementation */
> +    XMLParserImpl *impl;
> +};
> +
> +apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t*, void*, void*, void*);
> +
> +#endif
> 
> Added: apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c
> URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c?rev=1854603&view=auto
> ==============================================================================
> --- apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c (added)
> +++ apr/apr-util/branches/1.7.x/xml/apr_xml_libxml2.c Fri Mar  1 16:07:44 2019
> @@ -0,0 +1,99 @@
> +/* Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#include "apr.h"
> +
> +#if APU_USE_LIBXML2
> +#include "apr_xml.h"
> +
> +#include <libxml/parser.h>
> +#include <libxml/xmlerror.h>
> +
> +typedef xmlParserCtxtPtr XML_Parser;
> +typedef xmlParserErrors XML_Error;
> +
> +#include "apr_xml_internal.h"
> +
> +static apr_status_t cleanup_parser(void *ctx)
> +{
> +    apr_xml_parser *parser = ctx;
> +
> +    xmlFreeParserCtxt(parser->xp);
> +    parser->xp = NULL;
> +
> +    return APR_SUCCESS;
> +}
> +static int libxml2_parse(apr_xml_parser* parser, const char* data,
> +                         apr_size_t sz, int final)
> +{
> +    parser->xp_err = xmlParseChunk(parser->xp, data, sz, final);
> +    if (parser->xp_err != 0) {
> +        xmlErrorPtr errptr = xmlCtxtGetLastError(parser->xp);
> +        parser->xp_msg = errptr->message;
> +        /* this misnomer is used as a test for (any) parser error. */
> +        parser->error = APR_XML_ERROR_EXPAT;
> +    }
> +    return parser->xp_err;
> +}
> +static XMLParserImpl xml_parser_libxml2 = {
> +    libxml2_parse,
> +    cleanup_parser
> +};
> +
> +static const char APR_KW_DAV[] = { 0x44, 0x41, 0x56, 0x3A, '\0' };
> +
> +XMLParserImpl* apr_xml_get_parser_impl(void)
> +{
> +    return &xml_parser_libxml2;
> +}
> +
> +
> +apr_xml_parser* apr_xml_parser_create_internal(apr_pool_t *pool,
> +    void *start_func, void *end_func, void *cdata_func)
> +{
> +    apr_xml_parser *parser = apr_pcalloc(pool, sizeof(*parser));
> +    /* FIXME: This is a mismatch.  We should create a single global
> +     * sax instance and re-use it for every parser.  That means we
> +     * need an up-front initialisation function.
> +     */
> +    xmlSAXHandlerPtr sax = apr_pcalloc(pool, sizeof(xmlSAXHandler));
> +    sax->startElement = start_func;
> +    sax->endElement = end_func;
> +    sax->characters = cdata_func;
> +    sax->initialized = 1;
> +
> +    parser->impl = apr_xml_get_parser_impl();
> +
> +    parser->p = pool;
> +    parser->doc = apr_pcalloc(pool, sizeof(*parser->doc));
> +
> +    parser->doc->namespaces = apr_array_make(pool, 5, sizeof(const char *));
> +
> +    /* ### is there a way to avoid hard-coding this? */
> +    apr_xml_insert_uri(parser->doc->namespaces, APR_KW_DAV);
> +
> +    parser->xp = xmlCreatePushParserCtxt(sax, parser, NULL, 0, NULL);
> +    if (parser->xp == NULL) {
> +        (*apr_pool_abort_get(pool))(APR_ENOMEM);
> +        return NULL;
> +    }
> +
> +    apr_pool_cleanup_register(pool, parser, cleanup_parser,
> +                              apr_pool_cleanup_null);
> +
> +    return parser;
> +}
> +#endif