72 lines
1.8 KiB
Diff
72 lines
1.8 KiB
Diff
|
From af05f9b3179c19d8dcba641b38d76309631985ff Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
|
||
|
Date: Fri, 6 Dec 2013 02:00:56 +0100
|
||
|
Subject: [PATCH 3/4] perl: make it compatible with recent libxml2
|
||
|
|
||
|
---
|
||
|
bindings/perl/glist_handling.c | 32 ++++++++++++++++++++++----------
|
||
|
1 file changed, 22 insertions(+), 10 deletions(-)
|
||
|
|
||
|
diff --git a/bindings/perl/glist_handling.c b/bindings/perl/glist_handling.c
|
||
|
index e51cc6cb9302b11f4f0ef07c10dde228b8fa83d8..01deb2746941832a1bb2fd75c0e2ac748908f26b 100644
|
||
|
--- a/bindings/perl/glist_handling.c
|
||
|
+++ b/bindings/perl/glist_handling.c
|
||
|
@@ -28,6 +28,25 @@
|
||
|
#include <lasso/utils.h>
|
||
|
#include "../utils.c"
|
||
|
|
||
|
+static xmlBuffer*
|
||
|
+xmlnode_to_xmlbuffer(xmlNode *node)
|
||
|
+{
|
||
|
+ xmlOutputBufferPtr output_buffer;
|
||
|
+ xmlBuffer *buffer;
|
||
|
+
|
||
|
+ if (! node)
|
||
|
+ return NULL;
|
||
|
+
|
||
|
+ buffer = xmlBufferCreate();
|
||
|
+ output_buffer = xmlOutputBufferCreateBuffer(buffer, NULL);
|
||
|
+ xmlNodeDumpOutput(output_buffer, NULL, node, 0, 0, NULL);
|
||
|
+ xmlOutputBufferClose(output_buffer);
|
||
|
+ xmlBufferAdd(buffer, BAD_CAST "", 1);
|
||
|
+
|
||
|
+ return buffer;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
/**
|
||
|
* xmlnode_to_pv:
|
||
|
* @node: an xmlNode* object
|
||
|
@@ -38,25 +57,18 @@
|
||
|
static SV*
|
||
|
xmlnode_to_pv(xmlNode *node, gboolean do_free)
|
||
|
{
|
||
|
- xmlOutputBufferPtr buf;
|
||
|
+ xmlBuffer *buf;
|
||
|
SV *pestring = NULL;
|
||
|
|
||
|
if (node == NULL) {
|
||
|
return &PL_sv_undef;
|
||
|
}
|
||
|
|
||
|
- buf = xmlAllocOutputBuffer(NULL);
|
||
|
+ buf = xmlnode_to_xmlbuffer(node);
|
||
|
if (buf == NULL) {
|
||
|
pestring = &PL_sv_undef;
|
||
|
} else {
|
||
|
- xmlNodeDumpOutput(buf, NULL, node, 0, 1, NULL);
|
||
|
- xmlOutputBufferFlush(buf);
|
||
|
- if (buf->conv == NULL) {
|
||
|
- pestring = newSVpv((char*)buf->buffer->content, 0);
|
||
|
- } else {
|
||
|
- pestring = newSVpv((char*)buf->conv->content, 0);
|
||
|
- }
|
||
|
- xmlOutputBufferClose(buf);
|
||
|
+ pestring = newSVpv((char*)xmlBufferContent(buf), 0);
|
||
|
}
|
||
|
if (do_free) {
|
||
|
lasso_release_xml_node(node);
|
||
|
--
|
||
|
1.8.4.2
|
||
|
|