git: af36765e17ba - main - devel/tclxml: fix build with libxml2 >= 2.12

From: Pietro Cerutti <gahr_at_FreeBSD.org>
Date: Mon, 01 Jul 2024 06:50:59 UTC
The branch main has been updated by gahr:

URL: https://cgit.FreeBSD.org/ports/commit/?id=af36765e17ba36d0e86e95d4476b67f894209468

commit af36765e17ba36d0e86e95d4476b67f894209468
Author:     Pietro Cerutti <gahr@FreeBSD.org>
AuthorDate: 2024-07-01 06:39:47 +0000
Commit:     Pietro Cerutti <gahr@FreeBSD.org>
CommitDate: 2024-07-01 06:49:49 +0000

    devel/tclxml: fix build with libxml2 >= 2.12
    
    Version 2.12 of libxml2 introduced a backwards incompatible change in
    the signature of some functions, notably the second argument to
    xmlStructuredErrorFunc has gained a const qualifier, changing from
    `xmlError *error` to `const xmlError *error`.
    
    To make the signatures compatible with both pre- and post-2.12, I have
    introduced a check on LIBXML_VERSION.
    
    PR:             279968
    Reported by:    dizzy
---
 devel/tclxml/Makefile                              |  2 +-
 devel/tclxml/files/patch-Makefile.in               | 13 ++++++++-
 devel/tclxml/files/patch-configure                 | 19 ++++++++++---
 devel/tclxml/files/patch-docObj.c                  | 19 +++++++++++++
 ...ch-include_tclxml-libxml2_tclxml-libxml2Decls.h | 31 ++++++++++++++++++++++
 devel/tclxml/files/patch-tclxml.c                  | 11 ++++++++
 6 files changed, 90 insertions(+), 5 deletions(-)

diff --git a/devel/tclxml/Makefile b/devel/tclxml/Makefile
index 5a8b0cc25bf3..5e4a3caeb2a4 100644
--- a/devel/tclxml/Makefile
+++ b/devel/tclxml/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	tclxml
 PORTVERSION=	3.3
-PORTREVISION=	8
+PORTREVISION=	9
 CATEGORIES=	devel tcl
 MASTER_SITES=	LOCAL/bf SF/tclxml/TclXML/${PORTVERSION}
 
diff --git a/devel/tclxml/files/patch-Makefile.in b/devel/tclxml/files/patch-Makefile.in
index 60196004f4ba..48402ef0711f 100644
--- a/devel/tclxml/files/patch-Makefile.in
+++ b/devel/tclxml/files/patch-Makefile.in
@@ -1,6 +1,17 @@
 --- Makefile.in.orig	2013-03-30 17:17:07 UTC
 +++ Makefile.in
-@@ -423,13 +423,15 @@
+@@ -136,10 +136,6 @@ TCLLIBPATH      = $(top_builddir)
+ EXTRA_PATH	= $(top_builddir):$(TCL_BIN_DIR)
+ #EXTRA_PATH     = $(top_builddir):$(TCL_BIN_DIR):$(TK_BIN_DIR)
+ TCLLIBPATH      = $(top_builddir)
+-TCLSH_ENV	= TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library` \
+-		  @LD_LIBRARY_PATH_VAR@="$(EXTRA_PATH):$(@LD_LIBRARY_PATH_VAR@)" \
+-		  PATH="$(EXTRA_PATH):$(PATH)" \
+-		  TCLLIBPATH="$(TCLLIBPATH)"
+ #                 TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library`
+ 
+ TCLSH_PROG	= @TCLSH_PROG@
+@@ -423,13 +419,15 @@ install-lib-binaries:
  	@mkdir -p $(DESTDIR)$(pkglibdir)
  	@list='$(lib_BINARIES)'; for p in $$list; do \
  	  if test -f $$p; then \
diff --git a/devel/tclxml/files/patch-configure b/devel/tclxml/files/patch-configure
index c001f6a49e71..7ec514208aa8 100644
--- a/devel/tclxml/files/patch-configure
+++ b/devel/tclxml/files/patch-configure
@@ -1,7 +1,11 @@
---- configure.orig	2022-03-16 21:59:50 UTC
+--- configure.orig	2013-03-30 17:17:07 UTC
 +++ configure
-@@ -8580,14 +8580,14 @@ echo "${ECHO_T}$tcl_cv_ld_elf" >&6; }
- 	FreeBSD-*|DragonFly-*)
+@@ -8577,17 +8577,17 @@ echo "${ECHO_T}$tcl_cv_ld_elf" >&6; }
+ 	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
+ 	    TCL_LIB_VERSIONS_OK=nodots
+ 	    ;;
+-	FreeBSD-*)
++	FreeBSD-*|DragonFly-*)
  	    # FreeBSD 3.* and greater have ELF.
  	    SHLIB_CFLAGS="-fPIC"
 -	    SHLIB_LD="ld -Bshareable -x"
@@ -18,3 +22,12 @@
  	    if test "${TCL_THREADS}" = "1" ; then
  		# The -pthread needs to go in the CFLAGS, not LIBS
  		LIBS=`echo $LIBS | sed s/-pthread//`
+@@ -9267,7 +9267,7 @@ fi
+ 		    ;;
+ 		IRIX*)
+ 		    ;;
+-		NetBSD-*|FreeBSD-*)
++		NetBSD-*|FreeBSD-*|DragonFly-*)
+ 		    ;;
+ 		Darwin-*)
+ 		    ;;
diff --git a/devel/tclxml/files/patch-docObj.c b/devel/tclxml/files/patch-docObj.c
new file mode 100644
index 000000000000..59f57bf2fedf
--- /dev/null
+++ b/devel/tclxml/files/patch-docObj.c
@@ -0,0 +1,19 @@
+--- docObj.c.orig	2013-03-30 17:17:07 UTC
++++ docObj.c
+@@ -1852,9 +1852,13 @@ void
+ }
+ 
+ void
+-TclXML_libxml2_ErrorHandler (ctx, error)
+-     void *ctx; /* ignore - depends on context */
+-     xmlErrorPtr error;
++TclXML_libxml2_ErrorHandler (void *ctx,
++#if LIBXML_VERSION >= 21200
++        const xmlError *error
++#else
++        xmlError *error
++#endif
++        )
+ {
+   ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+   Tcl_Obj *objPtr;
diff --git a/devel/tclxml/files/patch-include_tclxml-libxml2_tclxml-libxml2Decls.h b/devel/tclxml/files/patch-include_tclxml-libxml2_tclxml-libxml2Decls.h
new file mode 100644
index 000000000000..2e8371bf6421
--- /dev/null
+++ b/devel/tclxml/files/patch-include_tclxml-libxml2_tclxml-libxml2Decls.h
@@ -0,0 +1,31 @@
+--- include/tclxml-libxml2/tclxml-libxml2Decls.h.orig	2013-03-30 17:17:07 UTC
++++ include/tclxml-libxml2/tclxml-libxml2Decls.h
+@@ -55,7 +55,12 @@ EXTERN void		TclXML_libxml2_ErrorHandler _ANSI_ARGS_((
+ 				TclXML_libxml2_DocumentHandling keep));
+ /* 10 */
+ EXTERN void		TclXML_libxml2_ErrorHandler _ANSI_ARGS_((void * ctx, 
+-				xmlErrorPtr error));
++#if LIBXML_VERSION >= 21200
++				const xmlError *error));
++#else
++				xmlError *error));
++#endif
++
+ /* 11 */
+ EXTERN void		TclXML_libxml2_ResetError _ANSI_ARGS_((
+ 				Tcl_Interp * interp));
+@@ -93,7 +98,13 @@ typedef struct Tclxml_libxml2Stubs {
+     int (*tclXML_libxml2_GetTclDocFromNode) _ANSI_ARGS_((Tcl_Interp * interp, xmlNodePtr nodePtr, TclXML_libxml2_Document ** tDocPtrPtr)); /* 7 */
+     void (*tclXML_libxml2_DestroyDocument) _ANSI_ARGS_((TclXML_libxml2_Document * tDocPtr)); /* 8 */
+     void (*tclXML_libxml2_DocKeep) _ANSI_ARGS_((Tcl_Obj * objPtr, TclXML_libxml2_DocumentHandling keep)); /* 9 */
+-    void (*tclXML_libxml2_ErrorHandler) _ANSI_ARGS_((void * ctx, xmlErrorPtr error)); /* 10 */
++    void (*tclXML_libxml2_ErrorHandler) _ANSI_ARGS_((void * ctx,
++#if LIBXML_VERSION >= 21200
++                const xmlError * error
++#else
++                xmlError * error
++#endif
++                )); /* 10 */
+     void (*tclXML_libxml2_ResetError) _ANSI_ARGS_((Tcl_Interp * interp)); /* 11 */
+     Tcl_Obj * (*tclXML_libxml2_GetErrorObj) _ANSI_ARGS_((Tcl_Interp * interp)); /* 12 */
+     void (*tclXML_libxml2_SetErrorNodeFunc) _ANSI_ARGS_((Tcl_Interp * interp, TclXML_ErrorNodeHandlerProc * proc)); /* 13 */
diff --git a/devel/tclxml/files/patch-tclxml.c b/devel/tclxml/files/patch-tclxml.c
new file mode 100644
index 000000000000..bb461a274c7b
--- /dev/null
+++ b/devel/tclxml/files/patch-tclxml.c
@@ -0,0 +1,11 @@
+--- tclxml.c.orig	2013-03-30 17:17:07 UTC
++++ tclxml.c
+@@ -20,6 +20,8 @@
+ #include <tclxslt/tclxslt.h>
+ #include <string.h>
+ 
++int Tcldom_libxml2_Init ( Tcl_Interp *interp );
++
+ #define TCL_DOES_STUBS \
+     (TCL_MAJOR_VERSION > 8 || TCL_MAJOR_VERSION == 8 && (TCL_MINOR_VERSION > 1 || \
+     (TCL_MINOR_VERSION == 1 && TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE)))