nokogiri 1.13.6 → 1.16.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +43 -0
- data/LICENSE-DEPENDENCIES.md +830 -509
- data/LICENSE.md +1 -1
- data/README.md +21 -11
- data/dependencies.yml +34 -15
- data/ext/nokogiri/extconf.rb +167 -48
- data/ext/nokogiri/gumbo.c +21 -11
- data/ext/nokogiri/html4_document.c +3 -4
- data/ext/nokogiri/html4_element_description.c +20 -15
- data/ext/nokogiri/html4_entity_lookup.c +2 -2
- data/ext/nokogiri/html4_sax_parser_context.c +11 -22
- data/ext/nokogiri/html4_sax_push_parser.c +4 -4
- data/ext/nokogiri/nokogiri.c +84 -75
- data/ext/nokogiri/nokogiri.h +46 -16
- data/ext/nokogiri/test_global_handlers.c +2 -2
- data/ext/nokogiri/xml_attr.c +3 -3
- data/ext/nokogiri/xml_attribute_decl.c +5 -5
- data/ext/nokogiri/xml_cdata.c +31 -18
- data/ext/nokogiri/xml_comment.c +2 -2
- data/ext/nokogiri/xml_document.c +135 -38
- data/ext/nokogiri/xml_document_fragment.c +2 -2
- data/ext/nokogiri/xml_dtd.c +9 -9
- data/ext/nokogiri/xml_element_content.c +34 -31
- data/ext/nokogiri/xml_element_decl.c +10 -10
- data/ext/nokogiri/xml_encoding_handler.c +15 -7
- data/ext/nokogiri/xml_entity_decl.c +6 -6
- data/ext/nokogiri/xml_entity_reference.c +2 -2
- data/ext/nokogiri/xml_namespace.c +75 -14
- data/ext/nokogiri/xml_node.c +365 -87
- data/ext/nokogiri/xml_node_set.c +129 -111
- data/ext/nokogiri/xml_processing_instruction.c +2 -2
- data/ext/nokogiri/xml_reader.c +126 -64
- data/ext/nokogiri/xml_relax_ng.c +67 -82
- data/ext/nokogiri/xml_sax_parser.c +45 -20
- data/ext/nokogiri/xml_sax_parser_context.c +50 -30
- data/ext/nokogiri/xml_sax_push_parser.c +31 -12
- data/ext/nokogiri/xml_schema.c +95 -118
- data/ext/nokogiri/xml_syntax_error.c +4 -4
- data/ext/nokogiri/xml_text.c +27 -14
- data/ext/nokogiri/xml_xpath_context.c +213 -136
- data/ext/nokogiri/xslt_stylesheet.c +126 -67
- data/gumbo-parser/Makefile +28 -0
- data/gumbo-parser/src/attribute.h +1 -1
- data/gumbo-parser/src/error.c +10 -6
- data/gumbo-parser/src/error.h +1 -1
- data/gumbo-parser/src/foreign_attrs.c +15 -16
- data/gumbo-parser/src/foreign_attrs.gperf +1 -1
- data/gumbo-parser/src/{gumbo.h → nokogiri_gumbo.h} +1 -0
- data/gumbo-parser/src/parser.c +29 -10
- data/gumbo-parser/src/replacement.h +1 -1
- data/gumbo-parser/src/string_buffer.h +1 -1
- data/gumbo-parser/src/string_piece.c +1 -1
- data/gumbo-parser/src/svg_attrs.c +2 -2
- data/gumbo-parser/src/svg_tags.c +2 -2
- data/gumbo-parser/src/tag.c +2 -1
- data/gumbo-parser/src/tag_lookup.c +7 -7
- data/gumbo-parser/src/tag_lookup.gperf +1 -0
- data/gumbo-parser/src/tag_lookup.h +1 -1
- data/gumbo-parser/src/token_buffer.h +1 -1
- data/gumbo-parser/src/tokenizer.c +2 -1
- data/gumbo-parser/src/tokenizer.h +1 -1
- data/gumbo-parser/src/utf8.c +1 -1
- data/gumbo-parser/src/utf8.h +1 -1
- data/gumbo-parser/src/util.c +1 -3
- data/gumbo-parser/src/util.h +4 -0
- data/gumbo-parser/src/vector.h +1 -1
- data/lib/nokogiri/css/node.rb +2 -2
- data/lib/nokogiri/css/parser_extras.rb +1 -1
- data/lib/nokogiri/css/xpath_visitor.rb +8 -26
- data/lib/nokogiri/css.rb +6 -0
- data/lib/nokogiri/decorators/slop.rb +1 -1
- data/lib/nokogiri/encoding_handler.rb +57 -0
- data/lib/nokogiri/extension.rb +4 -3
- data/lib/nokogiri/html4/document.rb +3 -122
- data/lib/nokogiri/html4/document_fragment.rb +1 -1
- data/lib/nokogiri/html4/element_description_defaults.rb +1827 -365
- data/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/lib/nokogiri/html4.rb +1 -0
- data/lib/nokogiri/html5/document.rb +113 -36
- data/lib/nokogiri/html5/document_fragment.rb +10 -3
- data/lib/nokogiri/html5/node.rb +8 -5
- data/lib/nokogiri/html5.rb +74 -226
- data/lib/nokogiri/jruby/dependencies.rb +1 -19
- data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +16 -14
- data/lib/nokogiri/xml/attr.rb +49 -0
- data/lib/nokogiri/xml/attribute_decl.rb +4 -2
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +103 -56
- data/lib/nokogiri/xml/document_fragment.rb +50 -7
- data/lib/nokogiri/xml/element_content.rb +10 -2
- data/lib/nokogiri/xml/element_decl.rb +4 -2
- data/lib/nokogiri/xml/entity_decl.rb +4 -2
- data/lib/nokogiri/xml/namespace.rb +41 -0
- data/lib/nokogiri/xml/node/save_options.rb +14 -4
- data/lib/nokogiri/xml/node.rb +241 -70
- data/lib/nokogiri/xml/node_set.rb +90 -11
- data/lib/nokogiri/xml/parse_options.rb +129 -50
- data/lib/nokogiri/xml/pp/node.rb +28 -15
- data/lib/nokogiri/xml/processing_instruction.rb +2 -1
- data/lib/nokogiri/xml/reader.rb +16 -17
- data/lib/nokogiri/xml/sax/document.rb +1 -1
- data/lib/nokogiri/xml/sax/parser.rb +2 -3
- data/lib/nokogiri/xml/searchable.rb +21 -13
- data/lib/nokogiri/xml/syntax_error.rb +1 -1
- data/lib/nokogiri/xml.rb +1 -1
- data/lib/nokogiri/xslt/stylesheet.rb +29 -7
- data/lib/nokogiri/xslt.rb +75 -5
- data/lib/nokogiri.rb +15 -15
- data/lib/xsd/xmlparser/nokogiri.rb +4 -2
- data/patches/libxml2/0010-update-config.guess-and-config.sub-for-libxml2.patch +224 -0
- data/patches/libxml2/0011-rip-out-libxml2-s-libc_single_threaded-support.patch +30 -0
- data/patches/libxslt/0001-update-config.guess-and-config.sub-for-libxslt.patch +224 -0
- data/ports/archives/libxml2-2.12.9.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
- metadata +21 -248
- data/patches/libxml2/0004-use-glibc-strlen.patch +0 -53
- data/patches/libxml2/0005-avoid-isnan-isinf.patch +0 -81
- data/patches/libxml2/0006-update-automake-files-for-arm64.patch +0 -3040
- data/patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch +0 -61
- data/patches/libxslt/0001-update-automake-files-for-arm64.patch +0 -3037
- data/ports/archives/libxml2-2.9.14.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
@@ -195,40 +195,48 @@ comment_func(void *ctx, const xmlChar *value)
|
|
195
195
|
rb_funcall(doc, id_comment, 1, str);
|
196
196
|
}
|
197
197
|
|
198
|
+
PRINTFLIKE_DECL(2, 3)
|
198
199
|
static void
|
199
200
|
warning_func(void *ctx, const char *msg, ...)
|
200
201
|
{
|
201
202
|
VALUE self = NOKOGIRI_SAX_SELF(ctx);
|
202
203
|
VALUE doc = rb_iv_get(self, "@document");
|
203
|
-
|
204
|
-
VALUE ruby_message;
|
204
|
+
VALUE rb_message;
|
205
205
|
|
206
|
+
#ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
207
|
+
/* It is not currently possible to pass var args from native
|
208
|
+
functions to sulong, so we work around the issue here. */
|
209
|
+
rb_message = rb_sprintf("warning_func: %s", msg);
|
210
|
+
#else
|
206
211
|
va_list args;
|
207
212
|
va_start(args, msg);
|
208
|
-
|
213
|
+
rb_message = rb_vsprintf(msg, args);
|
209
214
|
va_end(args);
|
215
|
+
#endif
|
210
216
|
|
211
|
-
|
212
|
-
free(message);
|
213
|
-
rb_funcall(doc, id_warning, 1, ruby_message);
|
217
|
+
rb_funcall(doc, id_warning, 1, rb_message);
|
214
218
|
}
|
215
219
|
|
220
|
+
PRINTFLIKE_DECL(2, 3)
|
216
221
|
static void
|
217
222
|
error_func(void *ctx, const char *msg, ...)
|
218
223
|
{
|
219
224
|
VALUE self = NOKOGIRI_SAX_SELF(ctx);
|
220
225
|
VALUE doc = rb_iv_get(self, "@document");
|
221
|
-
|
222
|
-
VALUE ruby_message;
|
226
|
+
VALUE rb_message;
|
223
227
|
|
228
|
+
#ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
229
|
+
/* It is not currently possible to pass var args from native
|
230
|
+
functions to sulong, so we work around the issue here. */
|
231
|
+
rb_message = rb_sprintf("error_func: %s", msg);
|
232
|
+
#else
|
224
233
|
va_list args;
|
225
234
|
va_start(args, msg);
|
226
|
-
|
235
|
+
rb_message = rb_vsprintf(msg, args);
|
227
236
|
va_end(args);
|
237
|
+
#endif
|
228
238
|
|
229
|
-
|
230
|
-
free(message);
|
231
|
-
rb_funcall(doc, id_error, 1, ruby_message);
|
239
|
+
rb_funcall(doc, id_error, 1, rb_message);
|
232
240
|
}
|
233
241
|
|
234
242
|
static void
|
@@ -257,18 +265,27 @@ processing_instruction(void *ctx, const xmlChar *name, const xmlChar *content)
|
|
257
265
|
);
|
258
266
|
}
|
259
267
|
|
260
|
-
static
|
261
|
-
|
268
|
+
static size_t
|
269
|
+
memsize(const void *data)
|
262
270
|
{
|
263
|
-
|
264
|
-
free(handler);
|
265
|
-
NOKOGIRI_DEBUG_END(handler);
|
271
|
+
return sizeof(xmlSAXHandler);
|
266
272
|
}
|
267
273
|
|
274
|
+
/* Used by Nokogiri::XML::SAX::Parser and Nokogiri::HTML::SAX::Parser */
|
275
|
+
static const rb_data_type_t noko_sax_handler_type = {
|
276
|
+
.wrap_struct_name = "Nokogiri::SAXHandler",
|
277
|
+
.function = {
|
278
|
+
.dfree = RUBY_TYPED_DEFAULT_FREE,
|
279
|
+
.dsize = memsize
|
280
|
+
},
|
281
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
|
282
|
+
};
|
283
|
+
|
268
284
|
static VALUE
|
269
285
|
allocate(VALUE klass)
|
270
286
|
{
|
271
|
-
xmlSAXHandlerPtr handler
|
287
|
+
xmlSAXHandlerPtr handler;
|
288
|
+
VALUE self = TypedData_Make_Struct(klass, xmlSAXHandler, &noko_sax_handler_type, handler);
|
272
289
|
|
273
290
|
handler->startDocument = start_document;
|
274
291
|
handler->endDocument = end_document;
|
@@ -284,11 +301,19 @@ allocate(VALUE klass)
|
|
284
301
|
handler->processingInstruction = processing_instruction;
|
285
302
|
handler->initialized = XML_SAX2_MAGIC;
|
286
303
|
|
287
|
-
return
|
304
|
+
return self;
|
305
|
+
}
|
306
|
+
|
307
|
+
xmlSAXHandlerPtr
|
308
|
+
noko_sax_handler_unwrap(VALUE rb_sax_handler)
|
309
|
+
{
|
310
|
+
xmlSAXHandlerPtr c_sax_handler;
|
311
|
+
TypedData_Get_Struct(rb_sax_handler, xmlSAXHandler, &noko_sax_handler_type, c_sax_handler);
|
312
|
+
return c_sax_handler;
|
288
313
|
}
|
289
314
|
|
290
315
|
void
|
291
|
-
noko_init_xml_sax_parser()
|
316
|
+
noko_init_xml_sax_parser(void)
|
292
317
|
{
|
293
318
|
cNokogiriXmlSaxParser = rb_define_class_under(mNokogiriXmlSax, "Parser", rb_cObject);
|
294
319
|
|
@@ -5,17 +5,40 @@ VALUE cNokogiriXmlSaxParserContext ;
|
|
5
5
|
static ID id_read;
|
6
6
|
|
7
7
|
static void
|
8
|
-
|
8
|
+
xml_sax_parser_context_free(void *data)
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
xmlParserCtxtPtr ctxt = data;
|
12
11
|
ctxt->sax = NULL;
|
13
|
-
|
14
12
|
xmlFreeParserCtxt(ctxt);
|
13
|
+
}
|
15
14
|
|
16
|
-
|
15
|
+
/*
|
16
|
+
* note that htmlParserCtxtPtr == xmlParserCtxtPtr and xmlFreeParserCtxt() == htmlFreeParserCtxt()
|
17
|
+
* so we use this type for both XML::SAX::ParserContext and HTML::SAX::ParserContext
|
18
|
+
*/
|
19
|
+
static const rb_data_type_t xml_sax_parser_context_type = {
|
20
|
+
.wrap_struct_name = "Nokogiri::XML::SAX::ParserContext",
|
21
|
+
.function = {
|
22
|
+
.dfree = xml_sax_parser_context_free,
|
23
|
+
},
|
24
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
25
|
+
};
|
26
|
+
|
27
|
+
xmlParserCtxtPtr
|
28
|
+
noko_xml_sax_parser_context_unwrap(VALUE rb_context)
|
29
|
+
{
|
30
|
+
xmlParserCtxtPtr c_context;
|
31
|
+
TypedData_Get_Struct(rb_context, xmlParserCtxt, &xml_sax_parser_context_type, c_context);
|
32
|
+
return c_context;
|
17
33
|
}
|
18
34
|
|
35
|
+
VALUE
|
36
|
+
noko_xml_sax_parser_context_wrap(VALUE klass, xmlParserCtxtPtr c_context)
|
37
|
+
{
|
38
|
+
return TypedData_Wrap_Struct(klass, &xml_sax_parser_context_type, c_context);
|
39
|
+
}
|
40
|
+
|
41
|
+
|
19
42
|
/*
|
20
43
|
* call-seq:
|
21
44
|
* parse_io(io, encoding)
|
@@ -36,12 +59,16 @@ parse_io(VALUE klass, VALUE io, VALUE encoding)
|
|
36
59
|
(xmlInputReadCallback)noko_io_read,
|
37
60
|
(xmlInputCloseCallback)noko_io_close,
|
38
61
|
(void *)io, enc);
|
62
|
+
if (!ctxt) {
|
63
|
+
rb_raise(rb_eRuntimeError, "failed to create xml sax parser context");
|
64
|
+
}
|
65
|
+
|
39
66
|
if (ctxt->sax) {
|
40
67
|
xmlFree(ctxt->sax);
|
41
68
|
ctxt->sax = NULL;
|
42
69
|
}
|
43
70
|
|
44
|
-
return
|
71
|
+
return noko_xml_sax_parser_context_wrap(klass, ctxt);
|
45
72
|
}
|
46
73
|
|
47
74
|
/*
|
@@ -54,7 +81,13 @@ static VALUE
|
|
54
81
|
parse_file(VALUE klass, VALUE filename)
|
55
82
|
{
|
56
83
|
xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(StringValueCStr(filename));
|
57
|
-
|
84
|
+
|
85
|
+
if (ctxt->sax) {
|
86
|
+
xmlFree(ctxt->sax);
|
87
|
+
ctxt->sax = NULL;
|
88
|
+
}
|
89
|
+
|
90
|
+
return noko_xml_sax_parser_context_wrap(klass, ctxt);
|
58
91
|
}
|
59
92
|
|
60
93
|
/*
|
@@ -81,7 +114,7 @@ parse_memory(VALUE klass, VALUE data)
|
|
81
114
|
ctxt->sax = NULL;
|
82
115
|
}
|
83
116
|
|
84
|
-
return
|
117
|
+
return noko_xml_sax_parser_context_wrap(klass, ctxt);
|
85
118
|
}
|
86
119
|
|
87
120
|
static VALUE
|
@@ -121,13 +154,8 @@ parse_with(VALUE self, VALUE sax_handler)
|
|
121
154
|
rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::SAX::Parser");
|
122
155
|
}
|
123
156
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
/* Free the sax handler since we'll assign our own */
|
128
|
-
if (ctxt->sax && ctxt->sax != (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) {
|
129
|
-
xmlFree(ctxt->sax);
|
130
|
-
}
|
157
|
+
ctxt = noko_xml_sax_parser_context_unwrap(self);
|
158
|
+
sax = noko_sax_handler_unwrap(sax_handler);
|
131
159
|
|
132
160
|
ctxt->sax = sax;
|
133
161
|
ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
|
@@ -149,8 +177,7 @@ parse_with(VALUE self, VALUE sax_handler)
|
|
149
177
|
static VALUE
|
150
178
|
set_replace_entities(VALUE self, VALUE value)
|
151
179
|
{
|
152
|
-
xmlParserCtxtPtr ctxt;
|
153
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
180
|
+
xmlParserCtxtPtr ctxt = noko_xml_sax_parser_context_unwrap(self);
|
154
181
|
|
155
182
|
if (Qfalse == value) {
|
156
183
|
ctxt->replaceEntities = 0;
|
@@ -171,8 +198,7 @@ set_replace_entities(VALUE self, VALUE value)
|
|
171
198
|
static VALUE
|
172
199
|
get_replace_entities(VALUE self)
|
173
200
|
{
|
174
|
-
xmlParserCtxtPtr ctxt;
|
175
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
201
|
+
xmlParserCtxtPtr ctxt = noko_xml_sax_parser_context_unwrap(self);
|
176
202
|
|
177
203
|
if (0 == ctxt->replaceEntities) {
|
178
204
|
return Qfalse;
|
@@ -189,10 +215,8 @@ get_replace_entities(VALUE self)
|
|
189
215
|
static VALUE
|
190
216
|
line(VALUE self)
|
191
217
|
{
|
192
|
-
xmlParserCtxtPtr ctxt;
|
193
218
|
xmlParserInputPtr io;
|
194
|
-
|
195
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
219
|
+
xmlParserCtxtPtr ctxt = noko_xml_sax_parser_context_unwrap(self);
|
196
220
|
|
197
221
|
io = ctxt->input;
|
198
222
|
if (io) {
|
@@ -210,11 +234,9 @@ line(VALUE self)
|
|
210
234
|
static VALUE
|
211
235
|
column(VALUE self)
|
212
236
|
{
|
213
|
-
xmlParserCtxtPtr ctxt;
|
237
|
+
xmlParserCtxtPtr ctxt = noko_xml_sax_parser_context_unwrap(self);
|
214
238
|
xmlParserInputPtr io;
|
215
239
|
|
216
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
217
|
-
|
218
240
|
io = ctxt->input;
|
219
241
|
if (io) {
|
220
242
|
return INT2NUM(io->col);
|
@@ -233,8 +255,7 @@ column(VALUE self)
|
|
233
255
|
static VALUE
|
234
256
|
set_recovery(VALUE self, VALUE value)
|
235
257
|
{
|
236
|
-
xmlParserCtxtPtr ctxt;
|
237
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
258
|
+
xmlParserCtxtPtr ctxt = noko_xml_sax_parser_context_unwrap(self);
|
238
259
|
|
239
260
|
if (value == Qfalse) {
|
240
261
|
ctxt->recovery = 0;
|
@@ -255,8 +276,7 @@ set_recovery(VALUE self, VALUE value)
|
|
255
276
|
static VALUE
|
256
277
|
get_recovery(VALUE self)
|
257
278
|
{
|
258
|
-
xmlParserCtxtPtr ctxt;
|
259
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
279
|
+
xmlParserCtxtPtr ctxt = noko_xml_sax_parser_context_unwrap(self);
|
260
280
|
|
261
281
|
if (ctxt->recovery == 0) {
|
262
282
|
return Qfalse;
|
@@ -266,7 +286,7 @@ get_recovery(VALUE self)
|
|
266
286
|
}
|
267
287
|
|
268
288
|
void
|
269
|
-
noko_init_xml_sax_parser_context()
|
289
|
+
noko_init_xml_sax_parser_context(void)
|
270
290
|
{
|
271
291
|
cNokogiriXmlSaxParserContext = rb_define_class_under(mNokogiriXmlSax, "ParserContext", rb_cObject);
|
272
292
|
|
@@ -3,20 +3,35 @@
|
|
3
3
|
VALUE cNokogiriXmlSaxPushParser ;
|
4
4
|
|
5
5
|
static void
|
6
|
-
|
6
|
+
xml_sax_push_parser_free(void *data)
|
7
7
|
{
|
8
|
-
|
8
|
+
xmlParserCtxtPtr ctx = data;
|
9
9
|
if (ctx != NULL) {
|
10
10
|
NOKOGIRI_SAX_TUPLE_DESTROY(ctx->userData);
|
11
11
|
xmlFreeParserCtxt(ctx);
|
12
12
|
}
|
13
|
-
NOKOGIRI_DEBUG_END(ctx);
|
14
13
|
}
|
15
14
|
|
15
|
+
static const rb_data_type_t xml_sax_push_parser_type = {
|
16
|
+
.wrap_struct_name = "Nokogiri::XML::SAX::PushParser",
|
17
|
+
.function = {
|
18
|
+
.dfree = xml_sax_push_parser_free,
|
19
|
+
},
|
20
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
21
|
+
};
|
22
|
+
|
16
23
|
static VALUE
|
17
24
|
allocate(VALUE klass)
|
18
25
|
{
|
19
|
-
return
|
26
|
+
return TypedData_Wrap_Struct(klass, &xml_sax_push_parser_type, NULL);
|
27
|
+
}
|
28
|
+
|
29
|
+
xmlParserCtxtPtr
|
30
|
+
noko_xml_sax_push_parser_unwrap(VALUE rb_parser)
|
31
|
+
{
|
32
|
+
xmlParserCtxtPtr c_parser;
|
33
|
+
TypedData_Get_Struct(rb_parser, xmlParserCtxt, &xml_sax_push_parser_type, c_parser);
|
34
|
+
return c_parser;
|
20
35
|
}
|
21
36
|
|
22
37
|
/*
|
@@ -33,7 +48,7 @@ native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
|
|
33
48
|
int size = 0;
|
34
49
|
|
35
50
|
|
36
|
-
|
51
|
+
ctx = noko_xml_sax_push_parser_unwrap(self);
|
37
52
|
|
38
53
|
if (Qnil != _chunk) {
|
39
54
|
chunk = StringValuePtr(_chunk);
|
@@ -44,7 +59,7 @@ native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
|
|
44
59
|
|
45
60
|
if (xmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
|
46
61
|
if (!(ctx->options & XML_PARSE_RECOVER)) {
|
47
|
-
|
62
|
+
xmlErrorConstPtr e = xmlCtxtGetLastError(ctx);
|
48
63
|
Nokogiri_error_raise(NULL, e);
|
49
64
|
}
|
50
65
|
}
|
@@ -65,7 +80,7 @@ initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename)
|
|
65
80
|
const char *filename = NULL;
|
66
81
|
xmlParserCtxtPtr ctx;
|
67
82
|
|
68
|
-
|
83
|
+
sax = noko_sax_handler_unwrap(_xml_sax);
|
69
84
|
|
70
85
|
if (_filename != Qnil) { filename = StringValueCStr(_filename); }
|
71
86
|
|
@@ -91,7 +106,8 @@ static VALUE
|
|
91
106
|
get_options(VALUE self)
|
92
107
|
{
|
93
108
|
xmlParserCtxtPtr ctx;
|
94
|
-
|
109
|
+
|
110
|
+
ctx = noko_xml_sax_push_parser_unwrap(self);
|
95
111
|
|
96
112
|
return INT2NUM(ctx->options);
|
97
113
|
}
|
@@ -100,7 +116,8 @@ static VALUE
|
|
100
116
|
set_options(VALUE self, VALUE options)
|
101
117
|
{
|
102
118
|
xmlParserCtxtPtr ctx;
|
103
|
-
|
119
|
+
|
120
|
+
ctx = noko_xml_sax_push_parser_unwrap(self);
|
104
121
|
|
105
122
|
if (xmlCtxtUseOptions(ctx, (int)NUM2INT(options)) != 0) {
|
106
123
|
rb_raise(rb_eRuntimeError, "Cannot set XML parser context options");
|
@@ -120,7 +137,8 @@ static VALUE
|
|
120
137
|
get_replace_entities(VALUE self)
|
121
138
|
{
|
122
139
|
xmlParserCtxtPtr ctx;
|
123
|
-
|
140
|
+
|
141
|
+
ctx = noko_xml_sax_push_parser_unwrap(self);
|
124
142
|
|
125
143
|
if (0 == ctx->replaceEntities) {
|
126
144
|
return Qfalse;
|
@@ -140,7 +158,8 @@ static VALUE
|
|
140
158
|
set_replace_entities(VALUE self, VALUE value)
|
141
159
|
{
|
142
160
|
xmlParserCtxtPtr ctx;
|
143
|
-
|
161
|
+
|
162
|
+
ctx = noko_xml_sax_push_parser_unwrap(self);
|
144
163
|
|
145
164
|
if (Qfalse == value) {
|
146
165
|
ctx->replaceEntities = 0;
|
@@ -152,7 +171,7 @@ set_replace_entities(VALUE self, VALUE value)
|
|
152
171
|
}
|
153
172
|
|
154
173
|
void
|
155
|
-
noko_init_xml_sax_push_parser()
|
174
|
+
noko_init_xml_sax_push_parser(void)
|
156
175
|
{
|
157
176
|
cNokogiriXmlSaxPushParser = rb_define_class_under(mNokogiriXmlSax, "PushParser", rb_cObject);
|
158
177
|
|