| @@ -1,43 +1,64 @@ | | | @@ -1,43 +1,64 @@ |
1 | $NetBSD: patch-lasso-xml-tools.c,v 1.1 2011/09/08 00:17:03 joerg Exp $ | | 1 | $NetBSD: patch-lasso-xml-tools.c,v 1.2 2012/09/28 11:59:18 obache Exp $ |
2 | | | 2 | |
3 | --- lasso/xml/tools.c.orig 2011-09-07 03:18:42.000000000 +0000 | | 3 | * XXX |
| | | 4 | * for libxml>=2.9.0 |
| | | 5 | |
| | | 6 | --- lasso/xml/tools.c.orig 2011-01-05 13:57:32.000000000 +0000 |
4 | +++ lasso/xml/tools.c | | 7 | +++ lasso/xml/tools.c |
5 | @@ -27,6 +27,7 @@ | | 8 | @@ -27,6 +27,7 @@ |
6 | /* permit importation of timegm for glibc2, wait for people to complain it does not work on their | | 9 | /* permit importation of timegm for glibc2, wait for people to complain it does not work on their |
7 | * system. */ | | 10 | * system. */ |
8 | #define _BSD_SOURCE | | 11 | #define _BSD_SOURCE |
9 | +#define _NETBSD_SOURCE | | 12 | +#define _NETBSD_SOURCE |
10 | #include "private.h" | | 13 | #include "private.h" |
11 | #include <string.h> | | 14 | #include <string.h> |
12 | #include <time.h> | | 15 | #include <time.h> |
| | | 16 | @@ -1063,7 +1064,7 @@ lasso_node_build_deflated_query(LassoNod |
| | | 17 | buf = xmlAllocOutputBuffer(handler); |
| | | 18 | xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 0, "utf-8"); |
| | | 19 | xmlOutputBufferFlush(buf); |
| | | 20 | - buffer = buf->conv ? buf->conv->content : buf->buffer->content; |
| | | 21 | + buffer = xmlBufferContent(buf->conv ? buf->conv : buf->buffer); |
| | | 22 | |
| | | 23 | xmlFreeNode(xmlnode); |
| | | 24 | xmlnode = NULL; |
13 | @@ -1196,6 +1197,11 @@ lasso_concat_url_query(const char *url, | | 25 | @@ -1196,6 +1197,11 @@ lasso_concat_url_query(const char *url, |
14 | * | | 26 | * |
15 | * Return value: TRUE if no error occurred during evaluation, FALSE otherwise. | | 27 | * Return value: TRUE if no error occurred during evaluation, FALSE otherwise. |
16 | */ | | 28 | */ |
17 | +static void | | 29 | +static void |
18 | +structuredErrorFunc (void *userData, xmlErrorPtr error) { | | 30 | +structuredErrorFunc (void *userData, xmlErrorPtr error) { |
19 | + *(int *)userData = error->code; | | 31 | + *(int *)userData = error->code; |
20 | +} | | 32 | +} |
21 | + | | 33 | + |
22 | gboolean | | 34 | gboolean |
23 | lasso_eval_xpath_expression(xmlXPathContextPtr xpath_ctx, const char *expression, | | 35 | lasso_eval_xpath_expression(xmlXPathContextPtr xpath_ctx, const char *expression, |
24 | xmlXPathObjectPtr *xpath_object_ptr, int *xpath_error_code) | | 36 | xmlXPathObjectPtr *xpath_object_ptr, int *xpath_error_code) |
25 | @@ -1205,10 +1211,6 @@ lasso_eval_xpath_expression(xmlXPathCont | | 37 | @@ -1205,10 +1211,6 @@ lasso_eval_xpath_expression(xmlXPathCont |
26 | xmlStructuredErrorFunc oldStructuredErrorFunc; | | 38 | xmlStructuredErrorFunc oldStructuredErrorFunc; |
27 | gboolean rc = TRUE; | | 39 | gboolean rc = TRUE; |
28 | | | 40 | |
29 | - void structuredErrorFunc (G_GNUC_UNUSED void *userData, xmlErrorPtr error) { | | 41 | - void structuredErrorFunc (G_GNUC_UNUSED void *userData, xmlErrorPtr error) { |
30 | - errorCode = error->code; | | 42 | - errorCode = error->code; |
31 | - } | | 43 | - } |
32 | - | | 44 | - |
33 | g_return_val_if_fail(xpath_ctx != NULL && expression != NULL, FALSE); | | 45 | g_return_val_if_fail(xpath_ctx != NULL && expression != NULL, FALSE); |
34 | | | 46 | |
35 | if (xpath_error_code) { /* reset */ | | 47 | if (xpath_error_code) { /* reset */ |
36 | @@ -1216,6 +1218,7 @@ lasso_eval_xpath_expression(xmlXPathCont | | 48 | @@ -1216,6 +1218,7 @@ lasso_eval_xpath_expression(xmlXPathCont |
37 | } | | 49 | } |
38 | oldStructuredErrorFunc = xpath_ctx->error; | | 50 | oldStructuredErrorFunc = xpath_ctx->error; |
39 | xpath_ctx->error = structuredErrorFunc; | | 51 | xpath_ctx->error = structuredErrorFunc; |
40 | + xpath_ctx->userData = &errorCode; | | 52 | + xpath_ctx->userData = &errorCode; |
41 | xpath_object = xmlXPathEvalExpression((xmlChar*)expression, xpath_ctx); | | 53 | xpath_object = xmlXPathEvalExpression((xmlChar*)expression, xpath_ctx); |
42 | xpath_ctx->error = oldStructuredErrorFunc; | | 54 | xpath_ctx->error = oldStructuredErrorFunc; |
43 | | | 55 | |
| | | 56 | @@ -2156,7 +2159,7 @@ lasso_xmlnode_to_string(xmlNode *node, g |
| | | 57 | buf = xmlAllocOutputBuffer(handler); |
| | | 58 | xmlNodeDumpOutput(buf, NULL, node, level, format ? 1 : 0, "utf-8"); |
| | | 59 | xmlOutputBufferFlush(buf); |
| | | 60 | - buffer = buf->conv ? buf->conv->content : buf->buffer->content; |
| | | 61 | + buffer = xmlBufferContent(buf->conv ? buf->conv : buf->buffer); |
| | | 62 | /* do not mix XML and GLib strings, so we must copy */ |
| | | 63 | str = g_strdup((char*)buffer); |
| | | 64 | xmlOutputBufferClose(buf); |