libxml-ruby 2.6.0-x86-mingw32 → 2.7.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/HISTORY +14 -0
- data/ext/libxml/extconf.h +5 -5
- data/ext/libxml/extconf.rb +13 -11
- data/ext/libxml/ruby_libxml.h +1 -0
- data/ext/libxml/ruby_xml_dtd.c +14 -3
- data/ext/libxml/ruby_xml_error.c +47 -47
- data/ext/libxml/ruby_xml_node.c +15 -9
- data/ext/libxml/ruby_xml_schema.c +3 -0
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/ext/libxml/ruby_xml_writer.c +60 -57
- data/ext/libxml/ruby_xml_writer.h +5 -11
- data/ext/libxml/ruby_xml_xpath_object.c +4 -2
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/lib/libxml/error.rb +3 -1
- data/test/remove_test.rb +9 -0
- data/test/tc_dtd.rb +4 -0
- data/test/tc_html_parser.rb +2 -2
- data/test/tc_parser.rb +27 -2
- data/test/tc_parser.rb.orig +384 -0
- data/test/tc_sax_parser.rb +2 -2
- data/test/tc_writer.rb +1 -1
- data/test/tc_xpath.rb +12 -0
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjIzMWRiZWI5MWIzNmVmNmY3ZjUxZjc2MDU1YzNlZmY2MDZiNzJmMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDQxNDZmZDU2ZmM4ZTUxMjk2NzE4NGYzN2E3ZWU1MmEwMjliNTY2MA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2NkNjA3YzM3MjE3MDg1OWFlYjYwNWFiZTVjMzEzZWRkY2VlY2NiMjc2NjQ5
|
10
|
+
NWIzZjQ0YzNkM2FkZjk3Nzc3ZGVjNzlhNDZlMzBhMzQ0Mzc1NDI5MDc2ZTkz
|
11
|
+
NWNhZDMxY2JmNWU0ZGJmYzQ4MmQ2ZGU2NzllYmM1Y2MxNzk5NDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWQ4ZDRlOWZkMzM3ZjhjMmYyZmQxZGQ3YThmZmRmNTMwNThmMTQ2YjhlYmFm
|
14
|
+
NmQwZmU1Y2EzY2NjYjc3NDkzNWFjOTFjNjQwZjAwMTk5ZTY2ZWM3NDA3MGU2
|
15
|
+
NzE4ZWYxZTkzY2UwZjZkMWVmOTQyMTdjMzI5NGJhMDgyMTEwZWY=
|
data/HISTORY
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
= Release History
|
2
2
|
|
3
|
+
== 2.7.0 / 2013-08-03 Charlie Savage
|
4
|
+
|
5
|
+
* Do not call Ruby code during a GC cycle (Dirkjan Bussink)
|
6
|
+
* Fix thread error handling (Geoffrey Giesemann)
|
7
|
+
* Set libxml error handler when a libxml-ruby error handler is set (Geoffrey Giesemann)
|
8
|
+
* Fix tests for nil TypeErrors (Geoffrey Giesemann)
|
9
|
+
* Fix segmentation fault for issue #62. The deregisternode function was incorrectly
|
10
|
+
NULLing out a node's mark and free functions for nodes removed from a document tree (Charlie Savage)
|
11
|
+
* Cleanup writer code (Charlie Savage)
|
12
|
+
* Fix equality check of LibXML::XML::Error against other objects (Michał Szajbe)
|
13
|
+
* Fix XML::Writer.set_quote_char UT, wrong expected string (#63). (julp)
|
14
|
+
* Fix potential segfault when GC occurs while creating ns from xpath (Timothy Elliott)
|
15
|
+
* Fix segmentation fault after failing to load external schema (#59). (Clifford Heath)
|
16
|
+
|
3
17
|
== 2.6.0 / 2013-02-16 Charlie Savage
|
4
18
|
|
5
19
|
* Fix uninitialized constant LibXML::XML::Error::I18N (NameError) that occurred
|
data/ext/libxml/extconf.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef EXTCONF_H
|
2
|
-
#define EXTCONF_H
|
3
|
-
#define HAVE_ZLIB_H 1
|
4
|
-
#define HAVE_LIBXML_XMLVERSION_H 1
|
5
|
-
#endif
|
1
|
+
#ifndef EXTCONF_H
|
2
|
+
#define EXTCONF_H
|
3
|
+
#define HAVE_ZLIB_H 1
|
4
|
+
#define HAVE_LIBXML_XMLVERSION_H 1
|
5
|
+
#endif
|
data/ext/libxml/extconf.rb
CHANGED
@@ -4,17 +4,19 @@ require 'rbconfig'
|
|
4
4
|
|
5
5
|
require 'mkmf'
|
6
6
|
|
7
|
-
if defined?(CFLAGS)
|
8
|
-
if CFLAGS.index(CONFIG['CCDLFLAGS'])
|
9
|
-
$CFLAGS = CFLAGS + ' ' + CONFIG['CCDLFLAGS']
|
10
|
-
else
|
11
|
-
$CFLAGS = CFLAGS
|
12
|
-
end
|
13
|
-
else
|
14
|
-
$CFLAGS = CONFIG['CFLAGS']
|
15
|
-
end
|
16
|
-
|
17
|
-
|
7
|
+
#if defined?(CFLAGS)
|
8
|
+
# if CFLAGS.index(CONFIG['CCDLFLAGS'])
|
9
|
+
# $CFLAGS = CFLAGS + ' ' + CONFIG['CCDLFLAGS']
|
10
|
+
# else
|
11
|
+
# $CFLAGS = CFLAGS
|
12
|
+
# end
|
13
|
+
#else
|
14
|
+
# $CFLAGS = CONFIG['CFLAGS']
|
15
|
+
#end
|
16
|
+
#$LDFLAGS = CONFIG['LDFLAGS']
|
17
|
+
#$LDFLAGS = "-L/usr/local/lib"
|
18
|
+
#$LIBPATH.push(Config::CONFIG['libdir'])
|
19
|
+
$LDFLAGS = "-Lc:/mingw/local/lib"
|
18
20
|
|
19
21
|
def crash(str)
|
20
22
|
printf(" extconf failure: %s\n", str)
|
data/ext/libxml/ruby_libxml.h
CHANGED
data/ext/libxml/ruby_xml_dtd.c
CHANGED
@@ -47,7 +47,6 @@ void rxml_dtd_mark(xmlDtdPtr xdtd)
|
|
47
47
|
|
48
48
|
if (xdtd->_private == NULL)
|
49
49
|
{
|
50
|
-
rb_warning("XmlNode is not bound! (%s:%d)", __FILE__, __LINE__);
|
51
50
|
return;
|
52
51
|
}
|
53
52
|
|
@@ -123,13 +122,25 @@ static VALUE rxml_dtd_uri_get(VALUE self)
|
|
123
122
|
xmlDtdPtr xdtd;
|
124
123
|
Data_Get_Struct(self, xmlDtd, xdtd);
|
125
124
|
|
126
|
-
|
127
125
|
if (xdtd->SystemID == NULL)
|
128
126
|
return (Qnil);
|
129
127
|
else
|
130
128
|
return (rxml_new_cstr((const char*) xdtd->SystemID, NULL));
|
131
129
|
}
|
132
130
|
|
131
|
+
/*
|
132
|
+
* call-seq:
|
133
|
+
* node.type -> num
|
134
|
+
*
|
135
|
+
* Obtain this node's type identifier.
|
136
|
+
*/
|
137
|
+
static VALUE rxml_dtd_type(VALUE self)
|
138
|
+
{
|
139
|
+
xmlDtdPtr xdtd;
|
140
|
+
Data_Get_Struct(self, xmlDtd, xdtd);
|
141
|
+
return (INT2NUM(xdtd->type));
|
142
|
+
}
|
143
|
+
|
133
144
|
/*
|
134
145
|
* call-seq:
|
135
146
|
* XML::Dtd.new("DTD string") -> dtd
|
@@ -251,7 +262,7 @@ void rxml_init_dtd()
|
|
251
262
|
rb_define_method(cXMLDtd, "external_id", rxml_dtd_external_id_get, 0);
|
252
263
|
rb_define_method(cXMLDtd, "name", rxml_dtd_name_get, 0);
|
253
264
|
rb_define_method(cXMLDtd, "uri", rxml_dtd_uri_get, 0);
|
254
|
-
|
265
|
+
rb_define_method(cXMLDtd, "node_type", rxml_dtd_type, 0);
|
255
266
|
rb_define_alias(cXMLDtd, "system_id", "uri");
|
256
267
|
}
|
257
268
|
|
data/ext/libxml/ruby_xml_error.c
CHANGED
@@ -37,15 +37,6 @@ static ID ERROR_HANDLER_ID;
|
|
37
37
|
* XML::Error.reset_handler
|
38
38
|
*/
|
39
39
|
|
40
|
-
static void rxml_set_handler(VALUE self, VALUE block)
|
41
|
-
{
|
42
|
-
#ifdef RB_CVAR_SET_4ARGS
|
43
|
-
rb_cvar_set(self, ERROR_HANDLER_ID, block, 0);
|
44
|
-
#else
|
45
|
-
rb_cvar_set(self, ERROR_HANDLER_ID, block);
|
46
|
-
#endif
|
47
|
-
}
|
48
|
-
|
49
40
|
/*
|
50
41
|
* call-seq:
|
51
42
|
* Error.get_error_handler
|
@@ -59,41 +50,6 @@ static VALUE rxml_error_get_handler()
|
|
59
50
|
return block;
|
60
51
|
}
|
61
52
|
|
62
|
-
/*
|
63
|
-
* call-seq:
|
64
|
-
* Error.set_error_handler {|error| ... }
|
65
|
-
*
|
66
|
-
* Registers a block that will be called with an instance of
|
67
|
-
* XML::Error when libxml generates warning, error or fatal
|
68
|
-
* error messages.
|
69
|
-
*/
|
70
|
-
static VALUE rxml_error_set_handler(VALUE self)
|
71
|
-
{
|
72
|
-
VALUE block;
|
73
|
-
|
74
|
-
if (rb_block_given_p() == Qfalse)
|
75
|
-
rb_raise(rb_eRuntimeError, "No block given");
|
76
|
-
|
77
|
-
block = rb_block_proc();
|
78
|
-
|
79
|
-
/* Embed the block within the Error class to avoid it to be collected.
|
80
|
-
Previous handler will be overwritten if it exists. */
|
81
|
-
rxml_set_handler(self, block);
|
82
|
-
|
83
|
-
return self;
|
84
|
-
}
|
85
|
-
|
86
|
-
/*
|
87
|
-
* call-seq:
|
88
|
-
* Error.reset_error_handler
|
89
|
-
*
|
90
|
-
* Removes the current error handler. */
|
91
|
-
static VALUE rxml_error_reset_handler(VALUE self)
|
92
|
-
{
|
93
|
-
rxml_set_handler(self, Qnil);
|
94
|
-
return self;
|
95
|
-
}
|
96
|
-
|
97
53
|
VALUE rxml_error_wrap(xmlErrorPtr xerror)
|
98
54
|
{
|
99
55
|
VALUE result = Qnil;
|
@@ -155,6 +111,53 @@ static void structuredErrorFunc(void *userData, xmlErrorPtr xerror)
|
|
155
111
|
}
|
156
112
|
}
|
157
113
|
|
114
|
+
static void rxml_set_handler(VALUE self, VALUE block)
|
115
|
+
{
|
116
|
+
#ifdef RB_CVAR_SET_4ARGS
|
117
|
+
rb_cvar_set(self, ERROR_HANDLER_ID, block, 0);
|
118
|
+
#else
|
119
|
+
rb_cvar_set(self, ERROR_HANDLER_ID, block);
|
120
|
+
#endif
|
121
|
+
|
122
|
+
/* Intercept libxml error handlers */
|
123
|
+
xmlSetStructuredErrorFunc(NULL, structuredErrorFunc);
|
124
|
+
}
|
125
|
+
|
126
|
+
/*
|
127
|
+
* call-seq:
|
128
|
+
* Error.set_error_handler {|error| ... }
|
129
|
+
*
|
130
|
+
* Registers a block that will be called with an instance of
|
131
|
+
* XML::Error when libxml generates warning, error or fatal
|
132
|
+
* error messages.
|
133
|
+
*/
|
134
|
+
static VALUE rxml_error_set_handler(VALUE self)
|
135
|
+
{
|
136
|
+
VALUE block;
|
137
|
+
|
138
|
+
if (rb_block_given_p() == Qfalse)
|
139
|
+
rb_raise(rb_eRuntimeError, "No block given");
|
140
|
+
|
141
|
+
block = rb_block_proc();
|
142
|
+
|
143
|
+
/* Embed the block within the Error class to avoid it to be collected.
|
144
|
+
Previous handler will be overwritten if it exists. */
|
145
|
+
rxml_set_handler(self, block);
|
146
|
+
|
147
|
+
return self;
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
* call-seq:
|
152
|
+
* Error.reset_error_handler
|
153
|
+
*
|
154
|
+
* Removes the current error handler. */
|
155
|
+
static VALUE rxml_error_reset_handler(VALUE self)
|
156
|
+
{
|
157
|
+
rxml_set_handler(self, Qnil);
|
158
|
+
return self;
|
159
|
+
}
|
160
|
+
|
158
161
|
void rxml_raise(xmlErrorPtr xerror)
|
159
162
|
{
|
160
163
|
/* Wrap error up as Ruby object and send it off to ruby */
|
@@ -167,9 +170,6 @@ void rxml_init_error()
|
|
167
170
|
CALL_METHOD = rb_intern("call");
|
168
171
|
ERROR_HANDLER_ID = rb_intern("@@__error_handler_callback__");
|
169
172
|
|
170
|
-
/* Intercept libxml error handlers */
|
171
|
-
xmlSetStructuredErrorFunc(NULL, structuredErrorFunc);
|
172
|
-
|
173
173
|
/* Error class */
|
174
174
|
eXMLError = rb_define_class_under(mXML, "Error", rb_eStandardError);
|
175
175
|
rb_define_singleton_method(eXMLError, "get_handler", rxml_error_get_handler, 0);
|
data/ext/libxml/ruby_xml_node.c
CHANGED
@@ -46,7 +46,7 @@ static void rxml_node_deregisterNode(xmlNodePtr xnode)
|
|
46
46
|
if (xnode->_private)
|
47
47
|
{
|
48
48
|
/* Node was wrapped. Set the _private member to free and
|
49
|
-
then
|
49
|
+
then disable the dfree function so that Ruby will not
|
50
50
|
try to free the node a second time. */
|
51
51
|
VALUE node = (VALUE) xnode->_private;
|
52
52
|
RDATA(node)->data = NULL;
|
@@ -619,12 +619,12 @@ static VALUE rxml_node_to_s(int argc, VALUE *argv, VALUE self)
|
|
619
619
|
xmlNodeDumpOutput(output, xnode->doc, xnode, level, indent, xencoding);
|
620
620
|
xmlOutputBufferFlush(output);
|
621
621
|
|
622
|
-
#ifdef LIBXML2_NEW_BUFFER
|
623
|
-
if (output->conv)
|
624
|
-
result = rxml_new_cstr((const char*) xmlBufContent(output->conv), xencoding);
|
625
|
-
else
|
626
|
-
result = rxml_new_cstr((const char*) xmlBufContent(output->buffer), xencoding);
|
627
|
-
#else
|
622
|
+
#ifdef LIBXML2_NEW_BUFFER
|
623
|
+
if (output->conv)
|
624
|
+
result = rxml_new_cstr((const char*) xmlBufContent(output->conv), xencoding);
|
625
|
+
else
|
626
|
+
result = rxml_new_cstr((const char*) xmlBufContent(output->buffer), xencoding);
|
627
|
+
#else
|
628
628
|
if (output->conv)
|
629
629
|
result = rxml_new_cstr((const char*) output->conv->content, xencoding);
|
630
630
|
else
|
@@ -1144,8 +1144,14 @@ static VALUE rxml_node_remove_ex(VALUE self)
|
|
1144
1144
|
namespaces, etc. For a node to live on its own, it
|
1145
1145
|
needs to get its own copies of this information.*/
|
1146
1146
|
xresult = xmlDocCopyNode(xnode, NULL, 1);
|
1147
|
-
|
1148
|
-
/*
|
1147
|
+
|
1148
|
+
/* This ruby node object no longer points at the node.*/
|
1149
|
+
xnode->_private = NULL;
|
1150
|
+
RDATA(self)->data = NULL;
|
1151
|
+
|
1152
|
+
/* Now free the original node. This will call the deregister node
|
1153
|
+
callback which would reset the mark and free function except for
|
1154
|
+
the fact we set the _private field to null above*/
|
1149
1155
|
xmlFreeNode(xnode);
|
1150
1156
|
|
1151
1157
|
/* Now wrap the new node */
|
@@ -89,6 +89,9 @@ static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
|
|
89
89
|
xschema = xmlSchemaParse(xparser);
|
90
90
|
xmlSchemaFreeParserCtxt(xparser);
|
91
91
|
|
92
|
+
if (xschema == NULL)
|
93
|
+
return Qnil;
|
94
|
+
|
92
95
|
return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
|
93
96
|
}
|
94
97
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/* Don't nuke this block! It is used for automatically updating the
|
2
2
|
* versions below. VERSION = string formatting, VERNUM = numbered
|
3
3
|
* version for inline testing: increment both or none at all.*/
|
4
|
-
#define RUBY_LIBXML_VERSION "2.
|
5
|
-
#define RUBY_LIBXML_VERNUM
|
4
|
+
#define RUBY_LIBXML_VERSION "2.7.0"
|
5
|
+
#define RUBY_LIBXML_VERNUM 270
|
6
6
|
#define RUBY_LIBXML_VER_MAJ 2
|
7
|
-
#define RUBY_LIBXML_VER_MIN
|
7
|
+
#define RUBY_LIBXML_VER_MIN 7
|
8
8
|
#define RUBY_LIBXML_VER_MIC 0
|
9
9
|
#define RUBY_LIBXML_VER_PATCH 0
|
@@ -1,4 +1,8 @@
|
|
1
|
-
#include
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include "ruby_xml_writer.h"
|
3
|
+
|
4
|
+
VALUE cXMLWriter;
|
5
|
+
static VALUE sEncoding, sStandalone;
|
2
6
|
|
3
7
|
#ifdef LIBXML_WRITER_ENABLED
|
4
8
|
|
@@ -12,13 +16,8 @@
|
|
12
16
|
* For a more in depth tutorial, albeit in C, see http://xmlsoft.org/xmlwriter.html
|
13
17
|
*/
|
14
18
|
|
15
|
-
#
|
19
|
+
#include <libxml/xmlwriter.h>
|
16
20
|
|
17
|
-
# include "ruby_libxml.h"
|
18
|
-
# include "ruby_xml_writer.h"
|
19
|
-
|
20
|
-
VALUE cXMLWriter;
|
21
|
-
static VALUE sEncoding, sStandalone;
|
22
21
|
|
23
22
|
typedef enum {
|
24
23
|
RXMLW_OUTPUT_NONE,
|
@@ -29,42 +28,42 @@ typedef enum {
|
|
29
28
|
|
30
29
|
typedef struct {
|
31
30
|
VALUE output;
|
32
|
-
#
|
31
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
33
32
|
rb_encoding *encoding;
|
34
|
-
#
|
33
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
35
34
|
xmlBufferPtr buffer;
|
36
35
|
xmlTextWriterPtr writer;
|
37
36
|
rxmlw_output_type output_type;
|
38
37
|
} rxml_writer_object;
|
39
38
|
|
40
|
-
#
|
39
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
41
40
|
|
42
|
-
#
|
41
|
+
#define /*VALUE*/ rxml_writer_c_to_ruby_string(/*const xmlChar **/ string, /*long*/ string_len) \
|
43
42
|
rb_external_str_new_with_enc(string, string_len, rb_utf8_encoding())
|
44
43
|
|
45
|
-
#
|
44
|
+
#define /*VALUE*/ rxml_writer_ruby_string_to_utf8(/*VALUE*/ string) \
|
46
45
|
rb_str_conv_enc(string, rb_enc_get(string), rb_utf8_encoding())
|
47
46
|
// rb_str_export_to_enc(string, rb_utf8_encoding())
|
48
47
|
|
49
|
-
#
|
48
|
+
#define /*void*/ rxml_writer_free_utf8_string(/*VALUE*/ orig, /*VALUE*/ utf8) \
|
50
49
|
do { \
|
51
50
|
if (orig != utf8) { \
|
52
51
|
rb_str_free(utf8); \
|
53
52
|
} \
|
54
53
|
} while (0);
|
55
54
|
|
56
|
-
#
|
55
|
+
#else
|
57
56
|
|
58
|
-
#
|
57
|
+
#define /*VALUE*/ rxml_writer_c_to_ruby_string(/*const xmlChar **/ string, /*long*/ string_len) \
|
59
58
|
rb_str_new(string, string_len)
|
60
59
|
|
61
|
-
#
|
60
|
+
#define /*VALUE*/ rxml_writer_ruby_string_to_utf8(/*VALUE*/ string) \
|
62
61
|
string
|
63
62
|
|
64
|
-
#
|
63
|
+
#define /*void*/ rxml_writer_free_utf8_string(/*VALUE*/ orig, /*VALUE*/ utf8) \
|
65
64
|
/* NOP */
|
66
65
|
|
67
|
-
#
|
66
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
68
67
|
|
69
68
|
static void rxml_writer_free(rxml_writer_object *rwo)
|
70
69
|
{
|
@@ -123,9 +122,9 @@ xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char * name);
|
|
123
122
|
rwo = ALLOC(rxml_writer_object);
|
124
123
|
rwo->output = io;
|
125
124
|
rwo->buffer = NULL;
|
126
|
-
#
|
125
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
127
126
|
rwo->encoding = NULL;
|
128
|
-
#
|
127
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
129
128
|
rwo->output_type = RXMLW_OUTPUT_IO;
|
130
129
|
if (NULL == (out = xmlOutputBufferCreateIO(rxml_write_callback, NULL, (void *) io, NULL))) {
|
131
130
|
rxml_raise(&xmlLastError);
|
@@ -151,9 +150,9 @@ static VALUE rxml_writer_file(VALUE klass, VALUE filename)
|
|
151
150
|
rwo = ALLOC(rxml_writer_object);
|
152
151
|
rwo->output = Qnil;
|
153
152
|
rwo->buffer = NULL;
|
154
|
-
#
|
153
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
155
154
|
rwo->encoding = NULL;
|
156
|
-
#
|
155
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
157
156
|
rwo->output_type = RXMLW_OUTPUT_NONE;
|
158
157
|
if (NULL == (rwo->writer = xmlNewTextWriterFilename(StringValueCStr(filename), 0))) {
|
159
158
|
rxml_raise(&xmlLastError);
|
@@ -173,9 +172,9 @@ static VALUE rxml_writer_string(VALUE klass)
|
|
173
172
|
|
174
173
|
rwo = ALLOC(rxml_writer_object);
|
175
174
|
rwo->output = Qnil;
|
176
|
-
#
|
175
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
177
176
|
rwo->encoding = NULL;
|
178
|
-
#
|
177
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
179
178
|
rwo->output_type = RXMLW_OUTPUT_STRING;
|
180
179
|
if (NULL == (rwo->buffer = xmlBufferCreate())) {
|
181
180
|
rxml_raise(&xmlLastError);
|
@@ -201,9 +200,9 @@ static VALUE rxml_writer_doc(VALUE klass)
|
|
201
200
|
rwo = ALLOC(rxml_writer_object);
|
202
201
|
rwo->buffer = NULL;
|
203
202
|
rwo->output = Qnil;
|
204
|
-
#
|
203
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
205
204
|
rwo->encoding = NULL;
|
206
|
-
#
|
205
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
207
206
|
rwo->output_type = RXMLW_OUTPUT_DOC;
|
208
207
|
if (NULL == (rwo->writer = xmlNewTextWriterDoc(&doc, 0))) {
|
209
208
|
rxml_raise(&xmlLastError);
|
@@ -238,11 +237,11 @@ static VALUE rxml_writer_flush(int argc, VALUE *argv, VALUE self)
|
|
238
237
|
if (NULL != rwo->buffer) {
|
239
238
|
VALUE content;
|
240
239
|
|
241
|
-
#
|
240
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
242
241
|
content = rb_external_str_new_with_enc(rwo->buffer->content, rwo->buffer->use, rwo->encoding);
|
243
|
-
#
|
242
|
+
#else
|
244
243
|
content = rb_str_new(rwo->buffer->content, rwo->buffer->use);
|
245
|
-
#
|
244
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
246
245
|
if (NIL_P(empty) || RTEST(empty)) { /* nil = default value = true */
|
247
246
|
xmlBufferEmpty(rwo->buffer);
|
248
247
|
}
|
@@ -301,7 +300,7 @@ static VALUE numeric_rxml_writer_void(VALUE obj, int (*fn)(xmlTextWriterPtr))
|
|
301
300
|
return (-1 == ret ? Qfalse : Qtrue);
|
302
301
|
}
|
303
302
|
|
304
|
-
#
|
303
|
+
#define numeric_rxml_writer_string(/*VALUE*/ obj, /*VALUE*/ name_or_content, /*int (**/fn/*)(xmlTextWriterPtr, const xmlChar *)*/) \
|
305
304
|
numeric_rxml_writer_va_strings(obj, Qundef, 1, fn, name_or_content)
|
306
305
|
|
307
306
|
/**
|
@@ -312,7 +311,7 @@ static VALUE numeric_rxml_writer_void(VALUE obj, int (*fn)(xmlTextWriterPtr))
|
|
312
311
|
* - validate names
|
313
312
|
* and so on
|
314
313
|
**/
|
315
|
-
#
|
314
|
+
#define XMLWRITER_MAX_STRING_ARGS 5
|
316
315
|
static VALUE numeric_rxml_writer_va_strings(VALUE obj, VALUE pe, size_t strings_count, int (*fn)(ANYARGS), ...)
|
317
316
|
{
|
318
317
|
va_list ap;
|
@@ -392,20 +391,20 @@ static VALUE numeric_rxml_writer_va_strings(VALUE obj, VALUE pe, size_t strings_
|
|
392
391
|
break;
|
393
392
|
}
|
394
393
|
}
|
395
|
-
#
|
394
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
396
395
|
while (--strings_count > 0) {
|
397
396
|
if (!NIL_P(orig[strings_count])) {
|
398
397
|
rxml_writer_free_utf8_string(orig[strings_count], utf8[strings_count]);
|
399
398
|
}
|
400
399
|
}
|
401
|
-
#
|
400
|
+
#endif /* HAVE_RUBY_ENCODING_H */
|
402
401
|
|
403
402
|
return (-1 == ret ? Qfalse : Qtrue);
|
404
403
|
}
|
405
404
|
|
406
405
|
/* ===== public instance methods ===== */
|
407
406
|
|
408
|
-
#
|
407
|
+
#if LIBXML_VERSION >= 20605
|
409
408
|
/* call-seq:
|
410
409
|
* writer.set_indent(indentation) -> (true|false)
|
411
410
|
*
|
@@ -437,7 +436,7 @@ static VALUE rxml_writer_set_indent_string(VALUE self, VALUE indentation)
|
|
437
436
|
{
|
438
437
|
return numeric_rxml_writer_string(self, indentation, xmlTextWriterSetIndentString);
|
439
438
|
}
|
440
|
-
#
|
439
|
+
#endif /* LIBXML_VERSION >= 20605 */
|
441
440
|
|
442
441
|
/* ===== public full tag interface ===== */
|
443
442
|
|
@@ -491,7 +490,7 @@ static VALUE rxml_writer_write_element(int argc, VALUE *argv, VALUE self)
|
|
491
490
|
}
|
492
491
|
}
|
493
492
|
|
494
|
-
#
|
493
|
+
#define ARRAY_SIZE(array) \
|
495
494
|
(sizeof(array) / sizeof((array)[0]))
|
496
495
|
|
497
496
|
/* call-seq:
|
@@ -635,7 +634,7 @@ static VALUE rxml_writer_end_attribute(VALUE self)
|
|
635
634
|
return numeric_rxml_writer_void(self, xmlTextWriterEndAttribute);
|
636
635
|
}
|
637
636
|
|
638
|
-
#
|
637
|
+
#if LIBXML_VERSION >= 20607
|
639
638
|
/* call-seq:
|
640
639
|
* writer.start_comment -> (true|false)
|
641
640
|
*
|
@@ -657,7 +656,7 @@ static VALUE rxml_writer_end_comment(VALUE self)
|
|
657
656
|
{
|
658
657
|
return numeric_rxml_writer_void(self, xmlTextWriterEndComment);
|
659
658
|
}
|
660
|
-
#
|
659
|
+
#endif /* LIBXML_VERSION >= 20607 */
|
661
660
|
|
662
661
|
/* call-seq:
|
663
662
|
* writer.start_element(name) -> (true|false)
|
@@ -769,9 +768,9 @@ static VALUE rxml_writer_start_document(int argc, VALUE *argv, VALUE self)
|
|
769
768
|
}
|
770
769
|
}
|
771
770
|
rwo = rxml_textwriter_get(self);
|
772
|
-
#
|
771
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
773
772
|
rwo->encoding = rxml_figure_encoding(xencoding);
|
774
|
-
#
|
773
|
+
#endif /* !HAVE_RUBY_ENCODING_H */
|
775
774
|
ret = xmlTextWriterStartDocument(rwo->writer, NULL, xencoding, xstandalone);
|
776
775
|
|
777
776
|
return (-1 == ret ? Qfalse : Qtrue);
|
@@ -909,13 +908,13 @@ static VALUE rxml_writer_end_dtd_element(VALUE self)
|
|
909
908
|
*
|
910
909
|
* Examples:
|
911
910
|
* writer.write_dtd 'html'
|
912
|
-
*
|
911
|
+
* #=> <!DOCTYPE html>
|
913
912
|
* writer.write_dtd 'docbook', nil, 'http://www.docbook.org/xml/5.0/dtd/docbook.dtd'
|
914
|
-
*
|
913
|
+
* #=> <!DOCTYPE docbook SYSTEM "http://www.docbook.org/xml/5.0/dtd/docbook.dtd">
|
915
914
|
* writer.write_dtd 'html', '-//W3C//DTD XHTML 1.1//EN', 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
|
916
|
-
*
|
915
|
+
* #=> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
917
916
|
* writer.write_dtd 'person', nil, nil, '<!ELEMENT person (firstname,lastname)><!ELEMENT firstname (#PCDATA)><!ELEMENT lastname (#PCDATA)>'
|
918
|
-
*
|
917
|
+
* #=> <!DOCTYPE person [<!ELEMENT person (firstname,lastname)><!ELEMENT firstname (#PCDATA)><!ELEMENT lastname (#PCDATA)>]>
|
919
918
|
*/
|
920
919
|
static VALUE rxml_writer_write_dtd(int argc, VALUE *argv, VALUE self)
|
921
920
|
{
|
@@ -931,7 +930,7 @@ static VALUE rxml_writer_write_dtd(int argc, VALUE *argv, VALUE self)
|
|
931
930
|
*
|
932
931
|
* Writes a DTD attribute list, all at once. Returns +false+ on failure.
|
933
932
|
* writer.write_dtd_attlist 'id', 'ID #IMPLIED'
|
934
|
-
*
|
933
|
+
* #=> <!ATTLIST id ID #IMPLIED>
|
935
934
|
*/
|
936
935
|
static VALUE rxml_writer_write_dtd_attlist(VALUE self, VALUE name, VALUE content)
|
937
936
|
{
|
@@ -943,7 +942,7 @@ static VALUE rxml_writer_write_dtd_attlist(VALUE self, VALUE name, VALUE content
|
|
943
942
|
*
|
944
943
|
* Writes a full DTD element, all at once. Returns +false+ on failure.
|
945
944
|
* writer.write_dtd_element 'person', '(firstname,lastname)'
|
946
|
-
*
|
945
|
+
* #=> <!ELEMENT person (firstname,lastname)>
|
947
946
|
*/
|
948
947
|
static VALUE rxml_writer_write_dtd_element(VALUE self, VALUE name, VALUE content)
|
949
948
|
{
|
@@ -994,9 +993,9 @@ static VALUE rxml_writer_write_dtd_external_entity_contents(VALUE self, VALUE pu
|
|
994
993
|
*
|
995
994
|
* Examples:
|
996
995
|
* writer.write_dtd_entity 'Shape', '(rect|circle|poly|default)', true
|
997
|
-
*
|
996
|
+
* #=> <!ENTITY % Shape "(rect|circle|poly|default)">
|
998
997
|
* writer.write_dtd_entity 'delta', 'δ', false
|
999
|
-
*
|
998
|
+
* #=> <!ENTITY delta "δ">
|
1000
999
|
*/
|
1001
1000
|
static VALUE rxml_writer_write_dtd_internal_entity(VALUE self, VALUE name, VALUE content, VALUE pe)
|
1002
1001
|
{
|
@@ -1013,7 +1012,7 @@ static VALUE rxml_writer_write_dtd_notation(VALUE self, VALUE name, VALUE pubid,
|
|
1013
1012
|
return numeric_rxml_writer_va_strings(self, Qundef, 3, xmlTextWriterWriteDTDNotation, name, pubid, sysid);
|
1014
1013
|
}
|
1015
1014
|
|
1016
|
-
#
|
1015
|
+
#if LIBXML_VERSION >= 20900
|
1017
1016
|
/* call-seq:
|
1018
1017
|
* writer.set_quote_char(...) -> (true|false)
|
1019
1018
|
*
|
@@ -1035,7 +1034,10 @@ static VALUE rxml_writer_set_quote_char(VALUE self, VALUE quotechar)
|
|
1035
1034
|
|
1036
1035
|
return (-1 == ret ? Qfalse : Qtrue);
|
1037
1036
|
}
|
1038
|
-
#
|
1037
|
+
#endif /* LIBXML_VERSION >= 20900 */
|
1038
|
+
|
1039
|
+
#endif /* LIBXML_WRITER_ENABLED */
|
1040
|
+
|
1039
1041
|
|
1040
1042
|
/* grep -P 'xmlTextWriter(Start|End|Write)(?!DTD|V?Format)[^(]+' /usr/include/libxml2/libxml/xmlwriter.h */
|
1041
1043
|
void rxml_init_writer(void)
|
@@ -1045,19 +1047,20 @@ void rxml_init_writer(void)
|
|
1045
1047
|
|
1046
1048
|
cXMLWriter = rb_define_class_under(mXML, "Writer", rb_cObject);
|
1047
1049
|
|
1050
|
+
#ifdef LIBXML_WRITER_ENABLED
|
1048
1051
|
rb_define_singleton_method(cXMLWriter, "io", rxml_writer_io, 1);
|
1049
1052
|
rb_define_singleton_method(cXMLWriter, "file", rxml_writer_file, 1);
|
1050
1053
|
rb_define_singleton_method(cXMLWriter, "document", rxml_writer_doc, 0);
|
1051
1054
|
rb_define_singleton_method(cXMLWriter, "string", rxml_writer_string, 0);
|
1052
1055
|
|
1053
1056
|
/* misc */
|
1054
|
-
#
|
1057
|
+
#if LIBXML_VERSION >= 20605
|
1055
1058
|
rb_define_method(cXMLWriter, "set_indent", rxml_writer_set_indent, 1);
|
1056
1059
|
rb_define_method(cXMLWriter, "set_indent_string", rxml_writer_set_indent_string, 1);
|
1057
|
-
#
|
1058
|
-
#
|
1060
|
+
#endif /* LIBXML_VERSION >= 20605 */
|
1061
|
+
#if LIBXML_VERSION >= 20900
|
1059
1062
|
rb_define_method(cXMLWriter, "set_quote_char", rxml_writer_set_quote_char, 1);
|
1060
|
-
#
|
1063
|
+
#endif /* LIBXML_VERSION >= 20900 */
|
1061
1064
|
rb_define_method(cXMLWriter, "flush", rxml_writer_flush, -1);
|
1062
1065
|
rb_define_method(cXMLWriter, "start_dtd", rxml_writer_start_dtd, -1);
|
1063
1066
|
rb_define_method(cXMLWriter, "start_dtd_entity", rxml_writer_start_dtd_entity, -1);
|
@@ -1091,10 +1094,10 @@ void rxml_init_writer(void)
|
|
1091
1094
|
rb_define_method(cXMLWriter, "full_end_element", rxml_writer_full_end_element, 0);
|
1092
1095
|
rb_define_method(cXMLWriter, "start_document", rxml_writer_start_document, -1);
|
1093
1096
|
rb_define_method(cXMLWriter, "end_document", rxml_writer_end_document, 0);
|
1094
|
-
#
|
1097
|
+
#if LIBXML_VERSION >= 20607
|
1095
1098
|
rb_define_method(cXMLWriter, "start_comment", rxml_writer_start_comment, 0);
|
1096
1099
|
rb_define_method(cXMLWriter, "end_comment", rxml_writer_end_comment, 0);
|
1097
|
-
#
|
1100
|
+
#endif /* LIBXML_VERSION >= 20607 */
|
1098
1101
|
rb_define_method(cXMLWriter, "start_pi", rxml_writer_start_pi, 1);
|
1099
1102
|
rb_define_method(cXMLWriter, "end_pi", rxml_writer_end_pi, 0);
|
1100
1103
|
|
@@ -1110,6 +1113,6 @@ void rxml_init_writer(void)
|
|
1110
1113
|
rb_define_method(cXMLWriter, "result", rxml_writer_result, 0);
|
1111
1114
|
|
1112
1115
|
rb_undef_method(CLASS_OF(cXMLWriter), "new");
|
1116
|
+
#endif
|
1113
1117
|
}
|
1114
1118
|
|
1115
|
-
#endif /* LIBXML_WRITER_ENABLED */
|