From b66ce0bba83febe2f4d119097a0391f5d886c3b4 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue, 1 Mar 2022 12:39:02 +0100
Subject: [PATCH] Don't include ICU headers in public headers

There's no need to make these implementation details public.
---
 configure.ac              |  2 --
 encoding.c                | 14 ++++++++++++++
 include/libxml/encoding.h | 21 +++------------------
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/encoding.c b/encoding.c
index 0847934a..bfa5a304 100644
--- encoding.c
+++ encoding.c
@@ -48,6 +48,20 @@
 #include "buf.h"
 #include "enc.h"
 
+#ifdef LIBXML_ICU_ENABLED
+#include <unicode/ucnv.h>
+/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
+#define ICU_PIVOT_BUF_SIZE 1024
+typedef struct _uconv_t uconv_t;
+struct _uconv_t {
+  UConverter *uconv; /* for conversion between an encoding and UTF-16 */
+  UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
+  UChar      pivot_buf[ICU_PIVOT_BUF_SIZE];
+  UChar      *pivot_source;
+  UChar      *pivot_target;
+};
+#endif
+
 static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
 static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
 
diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h
index c875af6f..77f137f4 100644
--- include/libxml/encoding.h
+++ include/libxml/encoding.h
@@ -27,9 +27,7 @@
 #ifdef LIBXML_ICONV_ENABLED
 #include <iconv.h>
 #endif
-#ifdef LIBXML_ICU_ENABLED
-#include <unicode/ucnv.h>
-#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -128,19 +126,6 @@ typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
  * Block defining the handlers for non UTF-8 encodings.
  * If iconv is supported, there are two extra fields.
  */
-#ifdef LIBXML_ICU_ENABLED
-/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
-#define ICU_PIVOT_BUF_SIZE 1024
-struct _uconv_t {
-  UConverter *uconv; /* for conversion between an encoding and UTF-16 */
-  UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
-  UChar      pivot_buf[ICU_PIVOT_BUF_SIZE];
-  UChar      *pivot_source;
-  UChar      *pivot_target;
-};
-typedef struct _uconv_t uconv_t;
-#endif
-
 typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
 typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
 struct _xmlCharEncodingHandler {
@@ -152,8 +137,8 @@ struct _xmlCharEncodingHandler {
     iconv_t                    iconv_out;
 #endif /* LIBXML_ICONV_ENABLED */
 #ifdef LIBXML_ICU_ENABLED
-    uconv_t                    *uconv_in;
-    uconv_t                    *uconv_out;
+    struct _uconv_t            *uconv_in;
+    struct _uconv_t            *uconv_out;
 #endif /* LIBXML_ICU_ENABLED */
 };
 
-- 
GitLab

