From dac3832265fa17de8d3b9d3ea8d930b83efe9c17 Mon Sep 17 00:00:00 2001 From: ewew ukek Date: Thu, 28 Mar 2024 07:20:16 +0000 Subject: Fixed compile against libxml2 2.12 Quote from Fedora mailing lists: The latest released versions of libxml2 have a couple of important changes in header files that have unintentionally caused some packages to fail to build without modification, including: * several functions now accept or return a const xmlError struct * cyclic dependencies in header files were fixed (by dropping some includes) --- src/utils/xml.cpp | 44 +++++++++++++++++++++----------------------- src/utils/xml.h | 1 + 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index fea5589f..252a9bd2 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -21,10 +21,6 @@ #include "utils/xml.h" -#include -#include -#include - #include #include @@ -37,14 +33,33 @@ namespace XML { - static void xmlLogger(void *ctx, xmlErrorPtr error); - struct XMLContext { std::string file; bool resman; }; +#if LIBXML_VERSION >= 21200 + static void xmlLogger(void *ctx, const xmlError *error) +#else + static void xmlLogger(void *ctx, xmlErrorPtr error) +#endif + { + auto *context = static_cast(ctx); + + if (context) + logger->log("Error in XML file '%s' on line %d", + context->file.c_str(), error->line); + else + logger->log("Error in unknown xml file on line %d", + error->line); + + logger->log("%s", error->message); + + // No need to keep errors around + xmlCtxtResetLastError(error->ctxt); + } + Document::Document(const std::string &filename, bool useResman): mDoc(nullptr) { @@ -160,23 +175,6 @@ namespace XML return nullptr; } - static void xmlLogger(void *ctx, xmlErrorPtr error) - { - auto *context = static_cast(ctx); - - if (context) - logger->log("Error in XML file '%s' on line %d", - context->file.c_str(), error->line); - else - logger->log("Error in unknown xml file on line %d", - error->line); - - logger->log("%s", error->message); - - // No need to keep errors around - xmlCtxtResetLastError(error->ctxt); - } - void init() { // Initialize libxml2 and check for potential ABI mismatches between diff --git a/src/utils/xml.h b/src/utils/xml.h index df8dd1bd..256a964b 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -22,6 +22,7 @@ #ifndef XML_H #define XML_H +#include #include #include -- cgit v1.2.3-60-g2f50