Skip to content

Commit

Permalink
Fix compilation with libxml2 2.12.0 (#417)
Browse files Browse the repository at this point in the history
Fixes #418
  • Loading branch information
KNnut committed Nov 30, 2023
1 parent bc5fa30 commit e4a54ae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# xml2 (development version)

* Now compatible with limxml2 2.12.0 and later (@KNnut).

* Fix format string issues detected in R-devel.

* `xml_serialize()` now includes the document type so that `xml_unserialize()` works also for HTML documents (#407, @HenrikBengtsson).
Expand Down
11 changes: 11 additions & 0 deletions src/xml2_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
#include <string>
#include "xml2_utils.h"

/* * *
* Author: Nick Wellnhofer <wellnhofer@aevum.de>
* Date: Tue, 24 Oct 2023 15:02:36 +0200
* https://github.com/GNOME/libxml2/commit/61034116d0a3c8b295c6137956adc3ae55720711
*
* error: Make more xmlError structs constant
*/
#if defined(LIBXML_VERSION) && (LIBXML_VERSION >= 21200)
void handleStructuredError(void* userData, const xmlError* error) {
#else
void handleStructuredError(void* userData, xmlError* error) {
#endif

BEGIN_CPP
std::string message = std::string(error->message);
Expand Down
13 changes: 11 additions & 2 deletions src/xml2_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
#include "xml2_types.h"
#include "xml2_utils.h"

/* * *
* Author: Nick Wellnhofer <wellnhofer@aevum.de>
* Date: Tue, 24 Oct 2023 15:02:36 +0200
* https://github.com/GNOME/libxml2/commit/61034116d0a3c8b295c6137956adc3ae55720711
*
* error: Make more xmlError structs constant
*/
#if defined(LIBXML_VERSION) && (LIBXML_VERSION >= 21200)
void handleSchemaError(void* userData, const xmlError* error) {
#else
void handleSchemaError(void* userData, xmlError* error) {
#endif
std::vector<std::string> * vec = (std::vector<std::string> *) userData;
std::string message = std::string(error->message);
message.resize(message.size() - 1);
Expand All @@ -22,8 +33,6 @@ extern "C" SEXP doc_validate(SEXP doc_sxp, SEXP schema_sxp) {
XPtrDoc doc(doc_sxp);
XPtrDoc schema(schema_sxp);

xmlLineNumbersDefault(1);

BEGIN_CPP

std::vector<std::string> vec;
Expand Down

0 comments on commit e4a54ae

Please sign in to comment.