Skip to content

Instantly share code, notes, and snippets.

@sidgwick
Created May 10, 2016 03:08
Show Gist options
  • Save sidgwick/ebe99cd7fd0da1b648dbfc073713cd69 to your computer and use it in GitHub Desktop.
Save sidgwick/ebe99cd7fd0da1b648dbfc073713cd69 to your computer and use it in GitHub Desktop.
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index 08be3fc..5ce8a29 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -205,7 +205,11 @@ int dom_documenttype_internal_subset_read(dom_object *obj, zval **retval TSRMLS_
if (buff != NULL) {
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
xmlOutputBufferFlush(buff);
+#ifdef LIBXML2_NEW_BUFFER
+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), xmlOutputBufferGetSize(buff), 1);
+#else
ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
+#endif
(void)xmlOutputBufferClose(buff);
return SUCCESS;
}
diff --git a/ext/dom/node.c b/ext/dom/node.c
index a89026a..5fc3a31 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -1900,9 +1900,17 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
RETVAL_FALSE;
} else {
if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ ret = xmlOutputBufferGetSize(buf);
+#else
ret = buf->buffer->use;
+#endif
if (ret > 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1);
+#else
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
+#endif
} else {
RETVAL_EMPTY_STRING();
}
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 4301307..1daa568 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1385,7 +1385,11 @@ SXE_METHOD(asXML)
xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding);
xmlOutputBufferFlush(outbuf);
+#ifdef LIBXML2_NEW_BUFFER
+ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), xmlOutputBufferGetSize(outbuf), 1);
+#else
RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1);
+#endif
xmlOutputBufferClose(outbuf);
}
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment