nokogiri 1.13.6 → 1.14.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +39 -0
- data/LICENSE-DEPENDENCIES.md +830 -509
- data/LICENSE.md +1 -1
- data/README.md +18 -11
- data/dependencies.yml +33 -15
- data/ext/nokogiri/extconf.rb +100 -24
- data/ext/nokogiri/gumbo.c +21 -11
- data/ext/nokogiri/html4_document.c +2 -2
- data/ext/nokogiri/html4_element_description.c +1 -1
- data/ext/nokogiri/html4_entity_lookup.c +2 -2
- data/ext/nokogiri/html4_sax_parser_context.c +1 -6
- data/ext/nokogiri/html4_sax_push_parser.c +1 -1
- data/ext/nokogiri/nokogiri.c +38 -51
- data/ext/nokogiri/nokogiri.h +26 -14
- data/ext/nokogiri/test_global_handlers.c +1 -1
- data/ext/nokogiri/xml_attr.c +3 -3
- data/ext/nokogiri/xml_attribute_decl.c +5 -5
- data/ext/nokogiri/xml_cdata.c +3 -3
- data/ext/nokogiri/xml_comment.c +1 -1
- data/ext/nokogiri/xml_document.c +23 -14
- data/ext/nokogiri/xml_document_fragment.c +1 -1
- data/ext/nokogiri/xml_dtd.c +9 -9
- data/ext/nokogiri/xml_element_content.c +3 -3
- data/ext/nokogiri/xml_element_decl.c +5 -5
- data/ext/nokogiri/xml_encoding_handler.c +3 -3
- data/ext/nokogiri/xml_entity_decl.c +6 -6
- data/ext/nokogiri/xml_entity_reference.c +1 -1
- data/ext/nokogiri/xml_namespace.c +80 -14
- data/ext/nokogiri/xml_node.c +363 -82
- data/ext/nokogiri/xml_node_set.c +4 -6
- data/ext/nokogiri/xml_processing_instruction.c +1 -1
- data/ext/nokogiri/xml_reader.c +97 -22
- data/ext/nokogiri/xml_relax_ng.c +1 -3
- data/ext/nokogiri/xml_sax_parser.c +23 -17
- data/ext/nokogiri/xml_sax_parser_context.c +1 -6
- data/ext/nokogiri/xml_sax_push_parser.c +1 -3
- data/ext/nokogiri/xml_schema.c +4 -6
- data/ext/nokogiri/xml_syntax_error.c +1 -1
- data/ext/nokogiri/xml_text.c +2 -2
- data/ext/nokogiri/xml_xpath_context.c +91 -84
- data/ext/nokogiri/xslt_stylesheet.c +15 -14
- data/gumbo-parser/Makefile +10 -0
- data/gumbo-parser/src/attribute.h +1 -1
- data/gumbo-parser/src/error.c +2 -2
- data/gumbo-parser/src/error.h +1 -1
- data/gumbo-parser/src/foreign_attrs.c +2 -2
- data/gumbo-parser/src/{gumbo.h → nokogiri_gumbo.h} +1 -0
- data/gumbo-parser/src/parser.c +8 -5
- 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 +1 -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/xpath_visitor.rb +5 -3
- 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 +3 -2
- data/lib/nokogiri/html4/document.rb +2 -121
- data/lib/nokogiri/html4/element_description_defaults.rb +6 -12
- 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 +9 -2
- data/lib/nokogiri/html5/node.rb +3 -5
- data/lib/nokogiri/html5.rb +127 -216
- 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 +11 -10
- data/lib/nokogiri/xml/attr.rb +49 -0
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +103 -55
- data/lib/nokogiri/xml/document_fragment.rb +49 -6
- data/lib/nokogiri/xml/namespace.rb +42 -0
- data/lib/nokogiri/xml/node/save_options.rb +6 -4
- data/lib/nokogiri/xml/node.rb +190 -35
- data/lib/nokogiri/xml/node_set.rb +88 -9
- data/lib/nokogiri/xml/parse_options.rb +129 -50
- data/lib/nokogiri/xml/pp/node.rb +6 -4
- data/lib/nokogiri/xml/processing_instruction.rb +2 -1
- data/lib/nokogiri/xml/reader.rb +6 -8
- data/lib/nokogiri/xml/sax/parser.rb +2 -3
- data/lib/nokogiri/xslt.rb +1 -1
- data/lib/nokogiri.rb +3 -11
- data/lib/xsd/xmlparser/nokogiri.rb +3 -1
- data/ports/archives/libxml2-2.10.3.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.37.tar.xz +0 -0
- metadata +11 -242
- 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/ports/archives/libxml2-2.9.14.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
data/ext/nokogiri/xml_node_set.c
CHANGED
@@ -88,13 +88,11 @@ deallocate(xmlNodeSetPtr node_set)
|
|
88
88
|
* For reasons outlined in xml_namespace.c, here we reproduce xmlXPathFreeNodeSet() except for the
|
89
89
|
* offending call to xmlXPathNodeSetFreeNs().
|
90
90
|
*/
|
91
|
-
NOKOGIRI_DEBUG_START(node_set) ;
|
92
91
|
if (node_set->nodeTab != NULL) {
|
93
92
|
xmlFree(node_set->nodeTab);
|
94
93
|
}
|
95
94
|
|
96
95
|
xmlFree(node_set);
|
97
|
-
NOKOGIRI_DEBUG_END(node_set) ;
|
98
96
|
}
|
99
97
|
|
100
98
|
|
@@ -156,7 +154,7 @@ push(VALUE self, VALUE rb_node)
|
|
156
154
|
Check_Node_Set_Node_Type(rb_node);
|
157
155
|
|
158
156
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
159
|
-
|
157
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, node);
|
160
158
|
|
161
159
|
xmlXPathNodeSetAdd(node_set, node);
|
162
160
|
|
@@ -179,7 +177,7 @@ delete (VALUE self, VALUE rb_node)
|
|
179
177
|
Check_Node_Set_Node_Type(rb_node);
|
180
178
|
|
181
179
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
182
|
-
|
180
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, node);
|
183
181
|
|
184
182
|
if (xmlXPathNodeSetContains(node_set, node)) {
|
185
183
|
xpath_node_set_del(node_set, node);
|
@@ -228,7 +226,7 @@ include_eh(VALUE self, VALUE rb_node)
|
|
228
226
|
Check_Node_Set_Node_Type(rb_node);
|
229
227
|
|
230
228
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
231
|
-
|
229
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, node);
|
232
230
|
|
233
231
|
return (xmlXPathNodeSetContains(node_set, node) ? Qtrue : Qfalse);
|
234
232
|
}
|
@@ -430,7 +428,7 @@ unlink_nodeset(VALUE self)
|
|
430
428
|
xmlNodePtr node_ptr;
|
431
429
|
node = noko_xml_node_wrap(Qnil, node_set->nodeTab[j]);
|
432
430
|
rb_funcall(node, rb_intern("unlink"), 0); /* modifies the C struct out from under the object */
|
433
|
-
|
431
|
+
Noko_Node_Get_Struct(node, xmlNode, node_ptr);
|
434
432
|
node_set->nodeTab[j] = node_ptr ;
|
435
433
|
}
|
436
434
|
}
|
data/ext/nokogiri/xml_reader.c
CHANGED
@@ -5,9 +5,7 @@ VALUE cNokogiriXmlReader;
|
|
5
5
|
static void
|
6
6
|
dealloc(xmlTextReaderPtr reader)
|
7
7
|
{
|
8
|
-
NOKOGIRI_DEBUG_START(reader);
|
9
8
|
xmlFreeTextReader(reader);
|
10
|
-
NOKOGIRI_DEBUG_END(reader);
|
11
9
|
}
|
12
10
|
|
13
11
|
static int
|
@@ -31,6 +29,7 @@ has_attributes(xmlTextReaderPtr reader)
|
|
31
29
|
return (0);
|
32
30
|
}
|
33
31
|
|
32
|
+
// TODO: merge this function into the `namespaces` method implementation
|
34
33
|
static void
|
35
34
|
Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash)
|
36
35
|
{
|
@@ -125,32 +124,47 @@ attributes_eh(VALUE self)
|
|
125
124
|
* Get a hash of namespaces for this Node
|
126
125
|
*/
|
127
126
|
static VALUE
|
128
|
-
|
127
|
+
rb_xml_reader_namespaces(VALUE rb_reader)
|
129
128
|
{
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
Data_Get_Struct(self, xmlTextReader, reader);
|
129
|
+
VALUE rb_namespaces = rb_hash_new() ;
|
130
|
+
xmlTextReaderPtr c_reader;
|
131
|
+
xmlNodePtr c_node;
|
132
|
+
VALUE rb_errors;
|
135
133
|
|
136
|
-
|
134
|
+
Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
|
137
135
|
|
138
|
-
if (! has_attributes(
|
139
|
-
return
|
136
|
+
if (! has_attributes(c_reader)) {
|
137
|
+
return rb_namespaces ;
|
140
138
|
}
|
141
139
|
|
142
|
-
|
143
|
-
|
140
|
+
rb_errors = rb_funcall(rb_reader, rb_intern("errors"), 0);
|
141
|
+
|
142
|
+
xmlSetStructuredErrorFunc((void *)rb_errors, Nokogiri_error_array_pusher);
|
143
|
+
c_node = xmlTextReaderExpand(c_reader);
|
144
|
+
xmlSetStructuredErrorFunc(NULL, NULL);
|
145
|
+
|
146
|
+
if (c_node == NULL) {
|
147
|
+
if (RARRAY_LEN(rb_errors) > 0) {
|
148
|
+
VALUE rb_error = rb_ary_entry(rb_errors, 0);
|
149
|
+
VALUE exception_message = rb_funcall(rb_error, rb_intern("to_s"), 0);
|
150
|
+
rb_exc_raise(rb_class_new_instance(1, &exception_message, cNokogiriXmlSyntaxError));
|
151
|
+
}
|
152
|
+
return Qnil;
|
153
|
+
}
|
144
154
|
|
145
|
-
Nokogiri_xml_node_namespaces(
|
155
|
+
Nokogiri_xml_node_namespaces(c_node, rb_namespaces);
|
146
156
|
|
147
|
-
return
|
157
|
+
return rb_namespaces ;
|
148
158
|
}
|
149
159
|
|
150
160
|
/*
|
151
161
|
:call-seq: attribute_nodes() → Array<Nokogiri::XML::Attr>
|
152
162
|
|
153
|
-
Get the attributes of the current node as an Array of Attr
|
163
|
+
Get the attributes of the current node as an Array of XML:Attr
|
164
|
+
|
165
|
+
⚠ This method is deprecated and unsafe to use. It will be removed in a future version of Nokogiri.
|
166
|
+
|
167
|
+
See related: #attribute_hash, #attributes
|
154
168
|
*/
|
155
169
|
static VALUE
|
156
170
|
rb_xml_reader_attribute_nodes(VALUE rb_reader)
|
@@ -160,6 +174,10 @@ rb_xml_reader_attribute_nodes(VALUE rb_reader)
|
|
160
174
|
VALUE attr_nodes;
|
161
175
|
int j;
|
162
176
|
|
177
|
+
// TODO: deprecated, remove in Nokogiri v1.15, see https://github.com/sparklemotion/nokogiri/issues/2598
|
178
|
+
// After removal, we can also remove all the "node_has_a_document" special handling from xml_node.c
|
179
|
+
NOKO_WARN_DEPRECATION("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead.");
|
180
|
+
|
163
181
|
Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
|
164
182
|
|
165
183
|
if (! has_attributes(c_reader)) {
|
@@ -181,6 +199,62 @@ rb_xml_reader_attribute_nodes(VALUE rb_reader)
|
|
181
199
|
return attr_nodes;
|
182
200
|
}
|
183
201
|
|
202
|
+
/*
|
203
|
+
:call-seq: attribute_hash() → Hash<String ⇒ String>
|
204
|
+
|
205
|
+
Get the attributes of the current node as a Hash of names and values.
|
206
|
+
|
207
|
+
See related: #attributes and #namespaces
|
208
|
+
*/
|
209
|
+
static VALUE
|
210
|
+
rb_xml_reader_attribute_hash(VALUE rb_reader)
|
211
|
+
{
|
212
|
+
VALUE rb_attributes = rb_hash_new();
|
213
|
+
xmlTextReaderPtr c_reader;
|
214
|
+
xmlNodePtr c_node;
|
215
|
+
xmlAttrPtr c_property;
|
216
|
+
VALUE rb_errors;
|
217
|
+
|
218
|
+
Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
|
219
|
+
|
220
|
+
if (!has_attributes(c_reader)) {
|
221
|
+
return rb_attributes;
|
222
|
+
}
|
223
|
+
|
224
|
+
rb_errors = rb_funcall(rb_reader, rb_intern("errors"), 0);
|
225
|
+
|
226
|
+
xmlSetStructuredErrorFunc((void *)rb_errors, Nokogiri_error_array_pusher);
|
227
|
+
c_node = xmlTextReaderExpand(c_reader);
|
228
|
+
xmlSetStructuredErrorFunc(NULL, NULL);
|
229
|
+
|
230
|
+
if (c_node == NULL) {
|
231
|
+
if (RARRAY_LEN(rb_errors) > 0) {
|
232
|
+
VALUE rb_error = rb_ary_entry(rb_errors, 0);
|
233
|
+
VALUE exception_message = rb_funcall(rb_error, rb_intern("to_s"), 0);
|
234
|
+
rb_exc_raise(rb_class_new_instance(1, &exception_message, cNokogiriXmlSyntaxError));
|
235
|
+
}
|
236
|
+
return Qnil;
|
237
|
+
}
|
238
|
+
|
239
|
+
c_property = c_node->properties;
|
240
|
+
while (c_property != NULL) {
|
241
|
+
VALUE rb_name = NOKOGIRI_STR_NEW2(c_property->name);
|
242
|
+
VALUE rb_value = Qnil;
|
243
|
+
xmlChar *c_value = xmlNodeGetContent((xmlNode *)c_property);
|
244
|
+
|
245
|
+
if (c_value) {
|
246
|
+
rb_value = NOKOGIRI_STR_NEW2(c_value);
|
247
|
+
xmlFree(c_value);
|
248
|
+
}
|
249
|
+
|
250
|
+
rb_hash_aset(rb_attributes, rb_name, rb_value);
|
251
|
+
|
252
|
+
c_property = c_property->next;
|
253
|
+
}
|
254
|
+
|
255
|
+
return rb_attributes;
|
256
|
+
}
|
257
|
+
|
184
258
|
/*
|
185
259
|
* call-seq:
|
186
260
|
* attribute_at(index)
|
@@ -252,7 +326,7 @@ attribute_count(VALUE self)
|
|
252
326
|
count = xmlTextReaderAttributeCount(reader);
|
253
327
|
if (count == -1) { return Qnil; }
|
254
328
|
|
255
|
-
return INT2NUM(
|
329
|
+
return INT2NUM(count);
|
256
330
|
}
|
257
331
|
|
258
332
|
/*
|
@@ -271,7 +345,7 @@ depth(VALUE self)
|
|
271
345
|
depth = xmlTextReaderDepth(reader);
|
272
346
|
if (depth == -1) { return Qnil; }
|
273
347
|
|
274
|
-
return INT2NUM(
|
348
|
+
return INT2NUM(depth);
|
275
349
|
}
|
276
350
|
|
277
351
|
/*
|
@@ -444,7 +518,7 @@ state(VALUE self)
|
|
444
518
|
{
|
445
519
|
xmlTextReaderPtr reader;
|
446
520
|
Data_Get_Struct(self, xmlTextReader, reader);
|
447
|
-
return INT2NUM(
|
521
|
+
return INT2NUM(xmlTextReaderReadState(reader));
|
448
522
|
}
|
449
523
|
|
450
524
|
/*
|
@@ -458,7 +532,7 @@ node_type(VALUE self)
|
|
458
532
|
{
|
459
533
|
xmlTextReaderPtr reader;
|
460
534
|
Data_Get_Struct(self, xmlTextReader, reader);
|
461
|
-
return INT2NUM(
|
535
|
+
return INT2NUM(xmlTextReaderNodeType(reader));
|
462
536
|
}
|
463
537
|
|
464
538
|
/*
|
@@ -678,7 +752,7 @@ rb_xml_reader_encoding(VALUE rb_reader)
|
|
678
752
|
}
|
679
753
|
|
680
754
|
void
|
681
|
-
noko_init_xml_reader()
|
755
|
+
noko_init_xml_reader(void)
|
682
756
|
{
|
683
757
|
/*
|
684
758
|
* The Reader parser allows you to effectively pull parse an XML document.
|
@@ -696,6 +770,7 @@ noko_init_xml_reader()
|
|
696
770
|
rb_define_method(cNokogiriXmlReader, "attribute_at", attribute_at, 1);
|
697
771
|
rb_define_method(cNokogiriXmlReader, "attribute_count", attribute_count, 0);
|
698
772
|
rb_define_method(cNokogiriXmlReader, "attribute_nodes", rb_xml_reader_attribute_nodes, 0);
|
773
|
+
rb_define_method(cNokogiriXmlReader, "attribute_hash", rb_xml_reader_attribute_hash, 0);
|
699
774
|
rb_define_method(cNokogiriXmlReader, "attributes?", attributes_eh, 0);
|
700
775
|
rb_define_method(cNokogiriXmlReader, "base_uri", rb_xml_reader_base_uri, 0);
|
701
776
|
rb_define_method(cNokogiriXmlReader, "default?", default_eh, 0);
|
@@ -707,7 +782,7 @@ noko_init_xml_reader()
|
|
707
782
|
rb_define_method(cNokogiriXmlReader, "local_name", local_name, 0);
|
708
783
|
rb_define_method(cNokogiriXmlReader, "name", name, 0);
|
709
784
|
rb_define_method(cNokogiriXmlReader, "namespace_uri", namespace_uri, 0);
|
710
|
-
rb_define_method(cNokogiriXmlReader, "namespaces",
|
785
|
+
rb_define_method(cNokogiriXmlReader, "namespaces", rb_xml_reader_namespaces, 0);
|
711
786
|
rb_define_method(cNokogiriXmlReader, "node_type", node_type, 0);
|
712
787
|
rb_define_method(cNokogiriXmlReader, "outer_xml", outer_xml, 0);
|
713
788
|
rb_define_method(cNokogiriXmlReader, "prefix", prefix, 0);
|
data/ext/nokogiri/xml_relax_ng.c
CHANGED
@@ -5,9 +5,7 @@ VALUE cNokogiriXmlRelaxNG;
|
|
5
5
|
static void
|
6
6
|
dealloc(xmlRelaxNGPtr schema)
|
7
7
|
{
|
8
|
-
NOKOGIRI_DEBUG_START(schema);
|
9
8
|
xmlRelaxNGFree(schema);
|
10
|
-
NOKOGIRI_DEBUG_END(schema);
|
11
9
|
}
|
12
10
|
|
13
11
|
/*
|
@@ -173,7 +171,7 @@ from_document(int argc, VALUE *argv, VALUE klass)
|
|
173
171
|
}
|
174
172
|
|
175
173
|
void
|
176
|
-
noko_init_xml_relax_ng()
|
174
|
+
noko_init_xml_relax_ng(void)
|
177
175
|
{
|
178
176
|
assert(cNokogiriXmlSchema);
|
179
177
|
cNokogiriXmlRelaxNG = rb_define_class_under(mNokogiriXml, "RelaxNG", cNokogiriXmlSchema);
|
@@ -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
|
@@ -260,15 +268,13 @@ processing_instruction(void *ctx, const xmlChar *name, const xmlChar *content)
|
|
260
268
|
static void
|
261
269
|
deallocate(xmlSAXHandlerPtr handler)
|
262
270
|
{
|
263
|
-
|
264
|
-
free(handler);
|
265
|
-
NOKOGIRI_DEBUG_END(handler);
|
271
|
+
ruby_xfree(handler);
|
266
272
|
}
|
267
273
|
|
268
274
|
static VALUE
|
269
275
|
allocate(VALUE klass)
|
270
276
|
{
|
271
|
-
xmlSAXHandlerPtr handler =
|
277
|
+
xmlSAXHandlerPtr handler = ruby_xcalloc((size_t)1, sizeof(xmlSAXHandler));
|
272
278
|
|
273
279
|
handler->startDocument = start_document;
|
274
280
|
handler->endDocument = end_document;
|
@@ -288,7 +294,7 @@ allocate(VALUE klass)
|
|
288
294
|
}
|
289
295
|
|
290
296
|
void
|
291
|
-
noko_init_xml_sax_parser()
|
297
|
+
noko_init_xml_sax_parser(void)
|
292
298
|
{
|
293
299
|
cNokogiriXmlSaxParser = rb_define_class_under(mNokogiriXmlSax, "Parser", rb_cObject);
|
294
300
|
|
@@ -7,13 +7,8 @@ static ID id_read;
|
|
7
7
|
static void
|
8
8
|
deallocate(xmlParserCtxtPtr ctxt)
|
9
9
|
{
|
10
|
-
NOKOGIRI_DEBUG_START(ctxt);
|
11
|
-
|
12
10
|
ctxt->sax = NULL;
|
13
|
-
|
14
11
|
xmlFreeParserCtxt(ctxt);
|
15
|
-
|
16
|
-
NOKOGIRI_DEBUG_END(ctxt);
|
17
12
|
}
|
18
13
|
|
19
14
|
/*
|
@@ -266,7 +261,7 @@ get_recovery(VALUE self)
|
|
266
261
|
}
|
267
262
|
|
268
263
|
void
|
269
|
-
noko_init_xml_sax_parser_context()
|
264
|
+
noko_init_xml_sax_parser_context(void)
|
270
265
|
{
|
271
266
|
cNokogiriXmlSaxParserContext = rb_define_class_under(mNokogiriXmlSax, "ParserContext", rb_cObject);
|
272
267
|
|
@@ -5,12 +5,10 @@ VALUE cNokogiriXmlSaxPushParser ;
|
|
5
5
|
static void
|
6
6
|
deallocate(xmlParserCtxtPtr ctx)
|
7
7
|
{
|
8
|
-
NOKOGIRI_DEBUG_START(ctx);
|
9
8
|
if (ctx != NULL) {
|
10
9
|
NOKOGIRI_SAX_TUPLE_DESTROY(ctx->userData);
|
11
10
|
xmlFreeParserCtxt(ctx);
|
12
11
|
}
|
13
|
-
NOKOGIRI_DEBUG_END(ctx);
|
14
12
|
}
|
15
13
|
|
16
14
|
static VALUE
|
@@ -152,7 +150,7 @@ set_replace_entities(VALUE self, VALUE value)
|
|
152
150
|
}
|
153
151
|
|
154
152
|
void
|
155
|
-
noko_init_xml_sax_push_parser()
|
153
|
+
noko_init_xml_sax_push_parser(void)
|
156
154
|
{
|
157
155
|
cNokogiriXmlSaxPushParser = rb_define_class_under(mNokogiriXmlSax, "PushParser", rb_cObject);
|
158
156
|
|
data/ext/nokogiri/xml_schema.c
CHANGED
@@ -5,9 +5,7 @@ VALUE cNokogiriXmlSchema;
|
|
5
5
|
static void
|
6
6
|
dealloc(xmlSchemaPtr schema)
|
7
7
|
{
|
8
|
-
NOKOGIRI_DEBUG_START(schema);
|
9
8
|
xmlSchemaFree(schema);
|
10
|
-
NOKOGIRI_DEBUG_END(schema);
|
11
9
|
}
|
12
10
|
|
13
11
|
/*
|
@@ -25,7 +23,7 @@ validate_document(VALUE self, VALUE document)
|
|
25
23
|
VALUE errors;
|
26
24
|
|
27
25
|
Data_Get_Struct(self, xmlSchema, schema);
|
28
|
-
|
26
|
+
Noko_Node_Get_Struct(document, xmlDoc, doc);
|
29
27
|
|
30
28
|
errors = rb_ary_new();
|
31
29
|
|
@@ -179,7 +177,7 @@ has_blank_nodes_p(VALUE cache)
|
|
179
177
|
for (i = 0; i < RARRAY_LEN(cache); i++) {
|
180
178
|
xmlNodePtr node;
|
181
179
|
VALUE element = rb_ary_entry(cache, i);
|
182
|
-
|
180
|
+
Noko_Node_Get_Struct(element, xmlNode, node);
|
183
181
|
if (xmlIsBlankNode(node)) {
|
184
182
|
return 1;
|
185
183
|
}
|
@@ -210,7 +208,7 @@ from_document(int argc, VALUE *argv, VALUE klass)
|
|
210
208
|
|
211
209
|
scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options);
|
212
210
|
|
213
|
-
|
211
|
+
Noko_Node_Get_Struct(document, xmlDoc, doc);
|
214
212
|
doc = doc->doc; /* In case someone passes us a node. ugh. */
|
215
213
|
|
216
214
|
if (scanned_args == 1) {
|
@@ -270,7 +268,7 @@ from_document(int argc, VALUE *argv, VALUE klass)
|
|
270
268
|
}
|
271
269
|
|
272
270
|
void
|
273
|
-
noko_init_xml_schema()
|
271
|
+
noko_init_xml_schema(void)
|
274
272
|
{
|
275
273
|
cNokogiriXmlSchema = rb_define_class_under(mNokogiriXml, "Schema", rb_cObject);
|
276
274
|
|
data/ext/nokogiri/xml_text.c
CHANGED
@@ -20,7 +20,7 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
20
20
|
|
21
21
|
rb_scan_args(argc, argv, "2*", &string, &document, &rest);
|
22
22
|
|
23
|
-
|
23
|
+
Noko_Node_Get_Struct(document, xmlDoc, doc);
|
24
24
|
|
25
25
|
node = xmlNewText((xmlChar *)StringValueCStr(string));
|
26
26
|
node->doc = doc->doc;
|
@@ -36,7 +36,7 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
36
36
|
}
|
37
37
|
|
38
38
|
void
|
39
|
-
noko_init_xml_text()
|
39
|
+
noko_init_xml_text(void)
|
40
40
|
{
|
41
41
|
assert(cNokogiriXmlCharacterData);
|
42
42
|
/*
|