From 4b71a27cb68fea391888b5ebb2d8d1377caf788f Mon Sep 17 00:00:00 2001 From: KNnut <9387720+KNnut@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:04:05 +0800 Subject: [PATCH 1/6] Fix xml2_init.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xml2_init.cpp: In function ‘SEXPREC* init_libxml2()’: xml2_init.cpp:46:35: error: invalid conversion from ‘void (*)(void*, xmlError*)’ {aka ‘void (*)(void*, _xmlError*)’} to ‘xmlStructuredErrorFunc’ {aka ‘void (*)(void*, const _xmlError*)’} [-fpermissive] 46 | xmlSetStructuredErrorFunc(NULL, handleStructuredError); | ^~~~~~~~~~~~~~~~~~~~~ | | | void (*)(void*, xmlError*) {aka void (*)(void*, _xmlError*)} In file included from xml2_init.cpp:8: /usr/include/libxml2/libxml/xmlerror.h:898:57: note: initializing argument 2 of ‘void xmlSetStructuredErrorFunc(void*, xmlStructuredErrorFunc)’ 898 | xmlStructuredErrorFunc handler); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ make: *** [/usr/lib64/R/etc/Makeconf:200: xml2_init.o] Error 1 ERROR: compilation failed for package ‘xml2’ --- src/xml2_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xml2_init.cpp b/src/xml2_init.cpp index b89c64aa..146d802c 100644 --- a/src/xml2_init.cpp +++ b/src/xml2_init.cpp @@ -10,7 +10,7 @@ #include #include "xml2_utils.h" -void handleStructuredError(void* userData, xmlError* error) { +void handleStructuredError(void* userData, const xmlError* error) { BEGIN_CPP std::string message = std::string(error->message); From a55c225dc12ea2e0665c25d3b4257d371e202caf Mon Sep 17 00:00:00 2001 From: KNnut <9387720+KNnut@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:08:05 +0800 Subject: [PATCH 2/6] Fix xml2_schema.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xml2_schema.cpp: In function ‘SEXPREC* doc_validate(SEXP, SEXP)’: xml2_schema.cpp:25:3: error: ‘xmlLineNumbersDefault’ was not declared in this scope 25 | xmlLineNumbersDefault(1); | ^~~~~~~~~~~~~~~~~~~~~ xml2_schema.cpp:33:44: error: invalid conversion from ‘void (*)(void*, xmlError*)’ {aka ‘void (*)(void*, _xmlError*)’} to ‘xmlStructuredErrorFunc’ {aka ‘void (*)(void*, const _xmlError*)’} [-fpermissive] 33 | xmlSchemaSetParserStructuredErrors(cptr, handleSchemaError, &vec); | ^~~~~~~~~~~~~~~~~ | | | void (*)(void*, xmlError*) {aka void (*)(void*, _xmlError*)} In file included from xml2_schema.cpp:5: /usr/include/libxml2/libxml/xmlschemas.h:156:65: note: initializing argument 2 of ‘void xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr, xmlStructuredErrorFunc, void*)’ 156 | xmlStructuredErrorFunc serror, | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ xml2_schema.cpp:39:43: error: invalid conversion from ‘void (*)(void*, xmlError*)’ {aka ‘void (*)(void*, _xmlError*)’} to ‘xmlStructuredErrorFunc’ {aka ‘void (*)(void*, const _xmlError*)’} [-fpermissive] 39 | xmlSchemaSetValidStructuredErrors(vptr, handleSchemaError, &vec); | ^~~~~~~~~~~~~~~~~ | | | void (*)(void*, xmlError*) {aka void (*)(void*, _xmlError*)} /usr/include/libxml2/libxml/xmlschemas.h:185:65: note: initializing argument 2 of ‘void xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr, xmlStructuredErrorFunc, void*)’ 185 | xmlStructuredErrorFunc serror, | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ make: *** [/usr/lib64/R/etc/Makeconf:200: xml2_schema.o] Error 1 xml2_schema.cpp: In function ‘SEXPREC* doc_validate(SEXP, SEXP)’: xml2_schema.cpp:25:3: error: ‘xmlLineNumbersDefault’ was not declared in this scope 25 | xmlLineNumbersDefault(1); | ^~~~~~~~~~~~~~~~~~~~~ make: *** [/usr/lib64/R/etc/Makeconf:200: xml2_schema.o] Error 1 --- src/xml2_schema.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xml2_schema.cpp b/src/xml2_schema.cpp index 345ca502..14b8936e 100644 --- a/src/xml2_schema.cpp +++ b/src/xml2_schema.cpp @@ -2,6 +2,7 @@ #include #undef R_NO_REMAP +#include #include #include #include @@ -9,7 +10,7 @@ #include "xml2_types.h" #include "xml2_utils.h" -void handleSchemaError(void* userData, xmlError* error) { +void handleSchemaError(void* userData, const xmlError* error) { std::vector * vec = (std::vector *) userData; std::string message = std::string(error->message); message.resize(message.size() - 1); From a7f5adba0123fed3cbcdb65965280b615fa1443c Mon Sep 17 00:00:00 2001 From: KNnut <9387720+KNnut@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:56:35 +0800 Subject: [PATCH 3/6] also works in older version libxml2 --- src/xml2_init.cpp | 11 +++++++++++ src/xml2_schema.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/xml2_init.cpp b/src/xml2_init.cpp index 146d802c..779157fe 100644 --- a/src/xml2_init.cpp +++ b/src/xml2_init.cpp @@ -10,7 +10,18 @@ #include #include "xml2_utils.h" +/* * * + * Author: Nick Wellnhofer + * Date: Thu, 21 Sep 2023 23:52:52 +0200 + * /~https://github.com/GNOME/libxml2/commit/45470611b047db78106dcb2fdbd4164163c15ab7 + * + * error: Make xmlGetLastError return a const error + */ +#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); diff --git a/src/xml2_schema.cpp b/src/xml2_schema.cpp index 14b8936e..dfc35502 100644 --- a/src/xml2_schema.cpp +++ b/src/xml2_schema.cpp @@ -10,7 +10,18 @@ #include "xml2_types.h" #include "xml2_utils.h" +/* * * + * Author: Nick Wellnhofer + * Date: Thu, 21 Sep 2023 23:52:52 +0200 + * /~https://github.com/GNOME/libxml2/commit/45470611b047db78106dcb2fdbd4164163c15ab7 + * + * error: Make xmlGetLastError return a const error + */ +#if defined(LIBXML_VERSION) && (LIBXML_VERSION >= 21200) void handleSchemaError(void* userData, const xmlError* error) { +#else +void handleSchemaError(void* userData, xmlError* error) { +#endif std::vector * vec = (std::vector *) userData; std::string message = std::string(error->message); message.resize(message.size() - 1); From 745eb4db19ce09900bef72be936a937ee9e0ec19 Mon Sep 17 00:00:00 2001 From: KNnut <9387720+KNnut@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:49:58 +0800 Subject: [PATCH 4/6] better info --- src/xml2_init.cpp | 6 +++--- src/xml2_schema.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/xml2_init.cpp b/src/xml2_init.cpp index 779157fe..74ddd36e 100644 --- a/src/xml2_init.cpp +++ b/src/xml2_init.cpp @@ -12,10 +12,10 @@ /* * * * Author: Nick Wellnhofer - * Date: Thu, 21 Sep 2023 23:52:52 +0200 - * /~https://github.com/GNOME/libxml2/commit/45470611b047db78106dcb2fdbd4164163c15ab7 + * Date: Tue, 24 Oct 2023 15:02:36 +0200 + * /~https://github.com/GNOME/libxml2/commit/61034116d0a3c8b295c6137956adc3ae55720711 * - * error: Make xmlGetLastError return a const error + * error: Make more xmlError structs constant */ #if defined(LIBXML_VERSION) && (LIBXML_VERSION >= 21200) void handleStructuredError(void* userData, const xmlError* error) { diff --git a/src/xml2_schema.cpp b/src/xml2_schema.cpp index dfc35502..f7a9a274 100644 --- a/src/xml2_schema.cpp +++ b/src/xml2_schema.cpp @@ -12,10 +12,10 @@ /* * * * Author: Nick Wellnhofer - * Date: Thu, 21 Sep 2023 23:52:52 +0200 - * /~https://github.com/GNOME/libxml2/commit/45470611b047db78106dcb2fdbd4164163c15ab7 + * Date: Tue, 24 Oct 2023 15:02:36 +0200 + * /~https://github.com/GNOME/libxml2/commit/61034116d0a3c8b295c6137956adc3ae55720711 * - * error: Make xmlGetLastError return a const error + * error: Make more xmlError structs constant */ #if defined(LIBXML_VERSION) && (LIBXML_VERSION >= 21200) void handleSchemaError(void* userData, const xmlError* error) { From 5d5b67efa854d89b39f45ef9b00d3aa738e620ca Mon Sep 17 00:00:00 2001 From: KNnut <9387720+KNnut@users.noreply.github.com> Date: Mon, 27 Nov 2023 13:02:00 +0800 Subject: [PATCH 5/6] unnecessary to call xmlLineNumbersDefault see /~https://github.com/GNOME/libxml2/commit/db8b9722cb2a1f7dca7374ec38ecaa4936ab3869 --- src/xml2_schema.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/xml2_schema.cpp b/src/xml2_schema.cpp index f7a9a274..3870e761 100644 --- a/src/xml2_schema.cpp +++ b/src/xml2_schema.cpp @@ -2,7 +2,6 @@ #include #undef R_NO_REMAP -#include #include #include #include @@ -34,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 vec; From 2f444f9950d9b9258543375afaf07a5f83e727aa Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 30 Nov 2023 07:52:24 -0600 Subject: [PATCH 6/6] Add news bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index b50ddb44..b119b53d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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).