diff options
author | ewew ukek <ewewukek@gmail.com> | 2024-03-28 07:20:16 +0000 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-28 07:20:16 +0000 |
commit | dac3832265fa17de8d3b9d3ea8d930b83efe9c17 (patch) | |
tree | bc6651d0dcea3463a1e5fc53a65ebc6d9df93966 | |
parent | df37e6a4dacfb969450dc9a3ff65e3f5fc03af20 (diff) | |
download | mana-dac3832265fa17de8d3b9d3ea8d930b83efe9c17.tar.gz mana-dac3832265fa17de8d3b9d3ea8d930b83efe9c17.tar.bz2 mana-dac3832265fa17de8d3b9d3ea8d930b83efe9c17.tar.xz mana-dac3832265fa17de8d3b9d3ea8d930b83efe9c17.zip |
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)
-rw-r--r-- | src/utils/xml.cpp | 44 | ||||
-rw-r--r-- | 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 <iostream> -#include <fstream> -#include <cstring> - #include <libxml/parser.h> #include <libxml/xmlerror.h> @@ -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<XMLContext*>(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<XMLContext*>(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 <libxml/parser.h> #include <libxml/tree.h> #include <string> |