nokogiri 1.16.8-aarch64-linux → 1.17.0-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -21
- data/README.md +4 -0
- data/dependencies.yml +6 -6
- data/ext/nokogiri/extconf.rb +191 -137
- data/ext/nokogiri/gumbo.c +69 -53
- data/ext/nokogiri/html4_document.c +10 -4
- data/ext/nokogiri/html4_element_description.c +18 -18
- data/ext/nokogiri/html4_sax_parser.c +40 -0
- data/ext/nokogiri/html4_sax_parser_context.c +48 -58
- data/ext/nokogiri/html4_sax_push_parser.c +25 -24
- data/ext/nokogiri/include/libexslt/exsltconfig.h +3 -3
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +12 -19
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +1 -12
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +1 -1
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +9 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +12 -1
- data/ext/nokogiri/include/libxml2/libxml/hash.h +19 -0
- data/ext/nokogiri/include/libxml2/libxml/list.h +2 -2
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +17 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +60 -54
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +9 -1
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +6 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +32 -12
- data/ext/nokogiri/include/libxml2/libxml/uri.h +11 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +29 -2
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +7 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +21 -4
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +14 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +111 -15
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +8 -45
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +2 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +5 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +165 -1
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +7 -171
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +1 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +4 -0
- data/ext/nokogiri/include/libxslt/xsltInternals.h +3 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +4 -37
- data/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/ext/nokogiri/nokogiri.c +9 -2
- data/ext/nokogiri/nokogiri.h +18 -33
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +2 -10
- data/ext/nokogiri/xml_comment.c +3 -8
- data/ext/nokogiri/xml_document.c +163 -156
- data/ext/nokogiri/xml_document_fragment.c +10 -25
- data/ext/nokogiri/xml_dtd.c +1 -1
- data/ext/nokogiri/xml_element_content.c +9 -9
- data/ext/nokogiri/xml_encoding_handler.c +4 -4
- data/ext/nokogiri/xml_namespace.c +6 -6
- data/ext/nokogiri/xml_node.c +130 -104
- data/ext/nokogiri/xml_node_set.c +46 -44
- data/ext/nokogiri/xml_reader.c +54 -58
- data/ext/nokogiri/xml_relax_ng.c +35 -56
- data/ext/nokogiri/xml_sax_parser.c +156 -88
- data/ext/nokogiri/xml_sax_parser_context.c +213 -131
- data/ext/nokogiri/xml_sax_push_parser.c +68 -49
- data/ext/nokogiri/xml_schema.c +50 -85
- data/ext/nokogiri/xml_syntax_error.c +19 -11
- data/ext/nokogiri/xml_text.c +2 -4
- data/ext/nokogiri/xml_xpath_context.c +2 -2
- data/ext/nokogiri/xslt_stylesheet.c +8 -8
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/3.1/nokogiri.so +0 -0
- data/lib/nokogiri/3.2/nokogiri.so +0 -0
- data/lib/nokogiri/3.3/nokogiri.so +0 -0
- data/lib/nokogiri/class_resolver.rb +1 -1
- data/lib/nokogiri/css/node.rb +6 -2
- data/lib/nokogiri/css/parser.rb +6 -4
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/parser_extras.rb +6 -66
- data/lib/nokogiri/css/selector_cache.rb +38 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -4
- data/lib/nokogiri/css/tokenizer.rex +9 -8
- data/lib/nokogiri/css/xpath_visitor.rb +42 -6
- data/lib/nokogiri/css.rb +86 -20
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/encoding_handler.rb +2 -2
- data/lib/nokogiri/html4/document.rb +44 -23
- data/lib/nokogiri/html4/document_fragment.rb +124 -12
- data/lib/nokogiri/html4/encoding_reader.rb +1 -1
- data/lib/nokogiri/html4/sax/parser.rb +23 -38
- data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
- data/lib/nokogiri/html4.rb +9 -14
- data/lib/nokogiri/html5/builder.rb +40 -0
- data/lib/nokogiri/html5/document.rb +61 -30
- data/lib/nokogiri/html5/document_fragment.rb +130 -20
- data/lib/nokogiri/html5/node.rb +4 -4
- data/lib/nokogiri/html5.rb +114 -72
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +8 -1
- data/lib/nokogiri/xml/document.rb +70 -26
- data/lib/nokogiri/xml/document_fragment.rb +84 -13
- data/lib/nokogiri/xml/node.rb +82 -11
- data/lib/nokogiri/xml/node_set.rb +9 -7
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/lib/nokogiri/xml/pp/node.rb +6 -1
- data/lib/nokogiri/xml/reader.rb +46 -13
- data/lib/nokogiri/xml/relax_ng.rb +57 -20
- data/lib/nokogiri/xml/sax/document.rb +174 -83
- data/lib/nokogiri/xml/sax/parser.rb +115 -41
- data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
- data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
- data/lib/nokogiri/xml/sax.rb +48 -0
- data/lib/nokogiri/xml/schema.rb +112 -45
- data/lib/nokogiri/xml/searchable.rb +6 -8
- data/lib/nokogiri/xml/syntax_error.rb +22 -0
- data/lib/nokogiri/xml.rb +13 -24
- data/lib/nokogiri/xslt.rb +3 -9
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- metadata +8 -4
- data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
data/ext/nokogiri/xml_document.c
CHANGED
@@ -17,6 +17,8 @@ dealloc_node_i2(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
|
|
17
17
|
break;
|
18
18
|
default:
|
19
19
|
if (node->parent == NULL) {
|
20
|
+
node->next = NULL;
|
21
|
+
node->prev = NULL;
|
20
22
|
xmlAddChild((xmlNodePtr)doc, node);
|
21
23
|
}
|
22
24
|
}
|
@@ -107,7 +109,7 @@ memsize_node(const xmlNodePtr node)
|
|
107
109
|
xmlAttrPtr property;
|
108
110
|
size_t memsize = 0;
|
109
111
|
|
110
|
-
memsize += xmlStrlen(node->name);
|
112
|
+
memsize += (size_t)xmlStrlen(node->name);
|
111
113
|
|
112
114
|
if (node->type == XML_ELEMENT_NODE) {
|
113
115
|
for (property = node->properties; property; property = property->next) {
|
@@ -115,7 +117,7 @@ memsize_node(const xmlNodePtr node)
|
|
115
117
|
}
|
116
118
|
}
|
117
119
|
if (node->type == XML_TEXT_NODE) {
|
118
|
-
memsize += xmlStrlen(node->content);
|
120
|
+
memsize += (size_t)xmlStrlen(node->content);
|
119
121
|
}
|
120
122
|
for (child = node->children; child; child = child->next) {
|
121
123
|
memsize += sizeof(xmlNode) + memsize_node(child);
|
@@ -133,8 +135,8 @@ memsize(const void *data)
|
|
133
135
|
return memsize;
|
134
136
|
}
|
135
137
|
|
136
|
-
static const rb_data_type_t
|
137
|
-
.wrap_struct_name = "
|
138
|
+
static const rb_data_type_t xml_doc_type = {
|
139
|
+
.wrap_struct_name = "xmlDoc",
|
138
140
|
.function = {
|
139
141
|
.dmark = mark,
|
140
142
|
.dfree = dealloc,
|
@@ -143,6 +145,53 @@ static const rb_data_type_t noko_xml_document_data_type = {
|
|
143
145
|
// .flags = RUBY_TYPED_FREE_IMMEDIATELY, // TODO see https://github.com/sparklemotion/nokogiri/issues/2822
|
144
146
|
};
|
145
147
|
|
148
|
+
static VALUE
|
149
|
+
_xml_document_alloc(VALUE klass)
|
150
|
+
{
|
151
|
+
return TypedData_Wrap_Struct(klass, &xml_doc_type, NULL);
|
152
|
+
}
|
153
|
+
|
154
|
+
static void
|
155
|
+
_xml_document_data_ptr_set(VALUE rb_document, xmlDocPtr c_document)
|
156
|
+
{
|
157
|
+
nokogiriTuplePtr tuple;
|
158
|
+
|
159
|
+
assert(DATA_PTR(rb_document) == NULL);
|
160
|
+
assert(c_document->_private == NULL);
|
161
|
+
|
162
|
+
DATA_PTR(rb_document) = c_document;
|
163
|
+
|
164
|
+
tuple = (nokogiriTuplePtr)ruby_xmalloc(sizeof(nokogiriTuple));
|
165
|
+
tuple->doc = rb_document;
|
166
|
+
tuple->unlinkedNodes = st_init_numtable_with_size(128);
|
167
|
+
tuple->node_cache = rb_ary_new();
|
168
|
+
|
169
|
+
c_document->_private = tuple ;
|
170
|
+
|
171
|
+
rb_iv_set(rb_document, "@node_cache", tuple->node_cache);
|
172
|
+
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
|
176
|
+
/* :nodoc: */
|
177
|
+
static VALUE
|
178
|
+
rb_xml_document_initialize_copy_with_args(VALUE rb_self, VALUE rb_other, VALUE rb_level)
|
179
|
+
{
|
180
|
+
xmlDocPtr c_other, c_self;
|
181
|
+
int c_level;
|
182
|
+
|
183
|
+
c_other = noko_xml_document_unwrap(rb_other);
|
184
|
+
c_level = (int)NUM2INT(rb_level);
|
185
|
+
|
186
|
+
c_self = xmlCopyDoc(c_other, c_level);
|
187
|
+
if (c_self == NULL) { return Qnil; }
|
188
|
+
|
189
|
+
c_self->type = c_other->type;
|
190
|
+
_xml_document_data_ptr_set(rb_self, c_self);
|
191
|
+
|
192
|
+
return rb_self ;
|
193
|
+
}
|
194
|
+
|
146
195
|
static void
|
147
196
|
recursively_remove_namespaces_from_node(xmlNodePtr node)
|
148
197
|
{
|
@@ -315,49 +364,46 @@ version(VALUE self)
|
|
315
364
|
* Create a new document from an IO object
|
316
365
|
*/
|
317
366
|
static VALUE
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
{
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
VALUE
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
|
367
|
+
noko_xml_document_s_read_io(VALUE rb_class,
|
368
|
+
VALUE rb_io,
|
369
|
+
VALUE rb_url,
|
370
|
+
VALUE rb_encoding,
|
371
|
+
VALUE rb_options)
|
372
|
+
{
|
373
|
+
/* TODO: deprecate this method, parse should be the preferred entry point. then we can make this
|
374
|
+
private. */
|
375
|
+
libxmlStructuredErrorHandlerState handler_state;
|
376
|
+
VALUE rb_errors = rb_ary_new();
|
377
|
+
|
378
|
+
noko__structured_error_func_save_and_set(&handler_state, (void *)rb_errors, noko__error_array_pusher);
|
379
|
+
|
380
|
+
const char *c_url = NIL_P(rb_url) ? NULL : StringValueCStr(rb_url);
|
381
|
+
const char *c_enc = NIL_P(rb_encoding) ? NULL : StringValueCStr(rb_encoding);
|
382
|
+
xmlDocPtr c_document = xmlReadIO(
|
383
|
+
(xmlInputReadCallback)noko_io_read,
|
384
|
+
(xmlInputCloseCallback)noko_io_close,
|
385
|
+
(void *)rb_io,
|
386
|
+
c_url,
|
387
|
+
c_enc,
|
388
|
+
(int)NUM2INT(rb_options)
|
389
|
+
);
|
390
|
+
|
391
|
+
noko__structured_error_func_restore(&handler_state);
|
392
|
+
|
393
|
+
if (c_document == NULL) {
|
394
|
+
xmlFreeDoc(c_document);
|
395
|
+
|
396
|
+
VALUE exception = rb_funcall(cNokogiriXmlSyntaxError, rb_intern("aggregate"), 1, rb_errors);
|
397
|
+
if (RB_TEST(exception)) {
|
398
|
+
rb_exc_raise(exception);
|
351
399
|
} else {
|
352
400
|
rb_raise(rb_eRuntimeError, "Could not parse document");
|
353
401
|
}
|
354
|
-
|
355
|
-
return Qnil;
|
356
402
|
}
|
357
403
|
|
358
|
-
|
359
|
-
rb_iv_set(
|
360
|
-
return
|
404
|
+
VALUE rb_document = noko_xml_document_wrap(rb_class, c_document);
|
405
|
+
rb_iv_set(rb_document, "@errors", rb_errors);
|
406
|
+
return rb_document;
|
361
407
|
}
|
362
408
|
|
363
409
|
/*
|
@@ -367,80 +413,44 @@ read_io(VALUE klass,
|
|
367
413
|
* Create a new document from a String
|
368
414
|
*/
|
369
415
|
static VALUE
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
{
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
VALUE error_list = rb_ary_new();
|
381
|
-
VALUE document;
|
382
|
-
xmlDocPtr doc;
|
383
|
-
|
384
|
-
xmlResetLastError();
|
385
|
-
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
386
|
-
doc = xmlReadMemory(c_buffer, len, c_url, c_enc, (int)NUM2INT(options));
|
387
|
-
xmlSetStructuredErrorFunc(NULL, NULL);
|
416
|
+
noko_xml_document_s_read_memory(VALUE rb_class,
|
417
|
+
VALUE rb_input,
|
418
|
+
VALUE rb_url,
|
419
|
+
VALUE rb_encoding,
|
420
|
+
VALUE rb_options)
|
421
|
+
{
|
422
|
+
/* TODO: deprecate this method, parse should be the preferred entry point. then we can make this
|
423
|
+
private. */
|
424
|
+
VALUE rb_errors = rb_ary_new();
|
425
|
+
xmlSetStructuredErrorFunc((void *)rb_errors, noko__error_array_pusher);
|
388
426
|
|
389
|
-
|
390
|
-
|
427
|
+
const char *c_buffer = StringValuePtr(rb_input);
|
428
|
+
const char *c_url = NIL_P(rb_url) ? NULL : StringValueCStr(rb_url);
|
429
|
+
const char *c_enc = NIL_P(rb_encoding) ? NULL : StringValueCStr(rb_encoding);
|
430
|
+
int c_buffer_len = (int)RSTRING_LEN(rb_input);
|
431
|
+
xmlDocPtr c_document = xmlReadMemory(c_buffer, c_buffer_len, c_url, c_enc, (int)NUM2INT(rb_options));
|
391
432
|
|
392
|
-
|
433
|
+
xmlSetStructuredErrorFunc(NULL, NULL);
|
393
434
|
|
394
|
-
|
395
|
-
|
396
|
-
|
435
|
+
if (c_document == NULL) {
|
436
|
+
VALUE exception = rb_funcall(cNokogiriXmlSyntaxError, rb_intern("aggregate"), 1, rb_errors);
|
437
|
+
if (RB_TEST(exception)) {
|
438
|
+
rb_exc_raise(exception);
|
397
439
|
} else {
|
398
440
|
rb_raise(rb_eRuntimeError, "Could not parse document");
|
399
441
|
}
|
400
|
-
|
401
|
-
return Qnil;
|
402
442
|
}
|
403
443
|
|
404
|
-
document = noko_xml_document_wrap(
|
405
|
-
rb_iv_set(document, "@errors",
|
444
|
+
VALUE document = noko_xml_document_wrap(rb_class, c_document);
|
445
|
+
rb_iv_set(document, "@errors", rb_errors);
|
406
446
|
return document;
|
407
447
|
}
|
408
448
|
|
409
449
|
/*
|
410
450
|
* call-seq:
|
411
|
-
*
|
451
|
+
* new(version = "1.0")
|
412
452
|
*
|
413
|
-
*
|
414
|
-
* to a deep copy. 0 is a shallow copy, 1 is a deep copy.
|
415
|
-
*/
|
416
|
-
static VALUE
|
417
|
-
duplicate_document(int argc, VALUE *argv, VALUE self)
|
418
|
-
{
|
419
|
-
xmlDocPtr doc, dup;
|
420
|
-
VALUE copy;
|
421
|
-
VALUE level;
|
422
|
-
|
423
|
-
if (rb_scan_args(argc, argv, "01", &level) == 0) {
|
424
|
-
level = INT2NUM((long)1);
|
425
|
-
}
|
426
|
-
|
427
|
-
doc = noko_xml_document_unwrap(self);
|
428
|
-
|
429
|
-
dup = xmlCopyDoc(doc, (int)NUM2INT(level));
|
430
|
-
|
431
|
-
if (dup == NULL) { return Qnil; }
|
432
|
-
|
433
|
-
dup->type = doc->type;
|
434
|
-
copy = noko_xml_document_wrap(rb_obj_class(self), dup);
|
435
|
-
rb_iv_set(copy, "@errors", rb_iv_get(self, "@errors"));
|
436
|
-
return copy ;
|
437
|
-
}
|
438
|
-
|
439
|
-
/*
|
440
|
-
* call-seq:
|
441
|
-
* new(version = default)
|
442
|
-
*
|
443
|
-
* Create a new document with +version+ (defaults to "1.0")
|
453
|
+
* Create a new empty document declaring XML version +version+.
|
444
454
|
*/
|
445
455
|
static VALUE
|
446
456
|
new (int argc, VALUE *argv, VALUE klass)
|
@@ -503,55 +513,58 @@ remove_namespaces_bang(VALUE self)
|
|
503
513
|
return self;
|
504
514
|
}
|
505
515
|
|
506
|
-
/* call-seq:
|
516
|
+
/* call-seq:
|
517
|
+
* doc.create_entity(name, type, external_id, system_id, content)
|
507
518
|
*
|
508
519
|
* Create a new entity named +name+.
|
509
520
|
*
|
510
|
-
* +type+ is an integer representing the type of entity to be created, and it
|
511
|
-
*
|
512
|
-
*
|
521
|
+
* +type+ is an integer representing the type of entity to be created, and it defaults to
|
522
|
+
* +Nokogiri::XML::EntityDecl::INTERNAL_GENERAL+. See the constants on Nokogiri::XML::EntityDecl for
|
523
|
+
* more information.
|
513
524
|
*
|
514
525
|
* +external_id+, +system_id+, and +content+ set the External ID, System ID,
|
515
526
|
* and content respectively. All of these parameters are optional.
|
516
527
|
*/
|
517
528
|
static VALUE
|
518
|
-
|
519
|
-
{
|
520
|
-
VALUE
|
521
|
-
VALUE
|
522
|
-
VALUE
|
523
|
-
VALUE
|
524
|
-
VALUE
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
529
|
+
noko_xml_document__create_entity(int argc, VALUE *argv, VALUE rb_document)
|
530
|
+
{
|
531
|
+
VALUE rb_name;
|
532
|
+
VALUE rb_type;
|
533
|
+
VALUE rb_ext_id;
|
534
|
+
VALUE rb_sys_id;
|
535
|
+
VALUE rb_content;
|
536
|
+
|
537
|
+
rb_scan_args(argc, argv, "14",
|
538
|
+
&rb_name,
|
539
|
+
&rb_type, &rb_ext_id, &rb_sys_id, &rb_content);
|
540
|
+
|
541
|
+
xmlDocPtr c_document = noko_xml_document_unwrap(rb_document);
|
542
|
+
|
543
|
+
libxmlStructuredErrorHandlerState handler_state;
|
544
|
+
VALUE rb_errors = rb_ary_new();
|
545
|
+
noko__structured_error_func_save_and_set(&handler_state, (void *)rb_errors, noko__error_array_pusher);
|
546
|
+
|
547
|
+
xmlEntityPtr c_entity = xmlAddDocEntity(
|
548
|
+
c_document,
|
549
|
+
(xmlChar *)(NIL_P(rb_name) ? NULL : StringValueCStr(rb_name)),
|
550
|
+
(int)(NIL_P(rb_type) ? XML_INTERNAL_GENERAL_ENTITY : NUM2INT(rb_type)),
|
551
|
+
(xmlChar *)(NIL_P(rb_ext_id) ? NULL : StringValueCStr(rb_ext_id)),
|
552
|
+
(xmlChar *)(NIL_P(rb_sys_id) ? NULL : StringValueCStr(rb_sys_id)),
|
553
|
+
(xmlChar *)(NIL_P(rb_content) ? NULL : StringValueCStr(rb_content))
|
554
|
+
);
|
555
|
+
|
556
|
+
noko__structured_error_func_restore(&handler_state);
|
557
|
+
|
558
|
+
if (NULL == c_entity) {
|
559
|
+
VALUE exception = rb_funcall(cNokogiriXmlSyntaxError, rb_intern("aggregate"), 1, rb_errors);
|
560
|
+
if (RB_TEST(exception)) {
|
561
|
+
rb_exc_raise(exception);
|
547
562
|
} else {
|
548
563
|
rb_raise(rb_eRuntimeError, "Could not create entity");
|
549
564
|
}
|
550
|
-
|
551
|
-
return Qnil;
|
552
565
|
}
|
553
566
|
|
554
|
-
return noko_xml_node_wrap(cNokogiriXmlEntityDecl, (xmlNodePtr)
|
567
|
+
return noko_xml_node_wrap(cNokogiriXmlEntityDecl, (xmlNodePtr)c_entity);
|
555
568
|
}
|
556
569
|
|
557
570
|
static int
|
@@ -655,24 +668,16 @@ VALUE
|
|
655
668
|
noko_xml_document_wrap_with_init_args(VALUE klass, xmlDocPtr c_document, int argc, VALUE *argv)
|
656
669
|
{
|
657
670
|
VALUE rb_document;
|
658
|
-
nokogiriTuplePtr tuple;
|
659
671
|
|
660
672
|
if (!klass) {
|
661
673
|
klass = cNokogiriXmlDocument;
|
662
674
|
}
|
663
675
|
|
664
|
-
rb_document =
|
665
|
-
|
666
|
-
tuple = (nokogiriTuplePtr)ruby_xmalloc(sizeof(nokogiriTuple));
|
667
|
-
tuple->doc = rb_document;
|
668
|
-
tuple->unlinkedNodes = st_init_numtable_with_size(128);
|
669
|
-
tuple->node_cache = rb_ary_new();
|
670
|
-
|
671
|
-
c_document->_private = tuple ;
|
676
|
+
rb_document = _xml_document_alloc(klass);
|
677
|
+
_xml_document_data_ptr_set(rb_document, c_document);
|
672
678
|
|
673
679
|
rb_iv_set(rb_document, "@decorators", Qnil);
|
674
680
|
rb_iv_set(rb_document, "@errors", Qnil);
|
675
|
-
rb_iv_set(rb_document, "@node_cache", tuple->node_cache);
|
676
681
|
|
677
682
|
rb_obj_call_init(rb_document, argc, argv);
|
678
683
|
|
@@ -698,7 +703,7 @@ xmlDocPtr
|
|
698
703
|
noko_xml_document_unwrap(VALUE rb_document)
|
699
704
|
{
|
700
705
|
xmlDocPtr c_document;
|
701
|
-
TypedData_Get_Struct(rb_document, xmlDoc, &
|
706
|
+
TypedData_Get_Struct(rb_document, xmlDoc, &xml_doc_type, c_document);
|
702
707
|
return c_document;
|
703
708
|
}
|
704
709
|
|
@@ -755,13 +760,13 @@ void
|
|
755
760
|
noko_init_xml_document(void)
|
756
761
|
{
|
757
762
|
assert(cNokogiriXmlNode);
|
758
|
-
|
759
|
-
* Nokogiri::XML::Document wraps an xml document.
|
760
|
-
*/
|
763
|
+
|
761
764
|
cNokogiriXmlDocument = rb_define_class_under(mNokogiriXml, "Document", cNokogiriXmlNode);
|
762
765
|
|
763
|
-
|
764
|
-
|
766
|
+
rb_define_alloc_func(cNokogiriXmlDocument, _xml_document_alloc);
|
767
|
+
|
768
|
+
rb_define_singleton_method(cNokogiriXmlDocument, "read_memory", noko_xml_document_s_read_memory, 4);
|
769
|
+
rb_define_singleton_method(cNokogiriXmlDocument, "read_io", noko_xml_document_s_read_io, 4);
|
765
770
|
rb_define_singleton_method(cNokogiriXmlDocument, "new", new, -1);
|
766
771
|
|
767
772
|
rb_define_method(cNokogiriXmlDocument, "root", rb_xml_document_root, 0);
|
@@ -770,8 +775,10 @@ noko_init_xml_document(void)
|
|
770
775
|
rb_define_method(cNokogiriXmlDocument, "encoding=", set_encoding, 1);
|
771
776
|
rb_define_method(cNokogiriXmlDocument, "version", version, 0);
|
772
777
|
rb_define_method(cNokogiriXmlDocument, "canonicalize", rb_xml_document_canonicalize, -1);
|
773
|
-
rb_define_method(cNokogiriXmlDocument, "dup", duplicate_document, -1);
|
774
778
|
rb_define_method(cNokogiriXmlDocument, "url", url, 0);
|
775
|
-
rb_define_method(cNokogiriXmlDocument, "create_entity",
|
779
|
+
rb_define_method(cNokogiriXmlDocument, "create_entity", noko_xml_document__create_entity, -1);
|
776
780
|
rb_define_method(cNokogiriXmlDocument, "remove_namespaces!", remove_namespaces_bang, 0);
|
781
|
+
|
782
|
+
rb_define_protected_method(cNokogiriXmlDocument, "initialize_copy_with_args", rb_xml_document_initialize_copy_with_args,
|
783
|
+
2);
|
777
784
|
}
|
@@ -2,31 +2,18 @@
|
|
2
2
|
|
3
3
|
VALUE cNokogiriXmlDocumentFragment;
|
4
4
|
|
5
|
-
/*
|
6
|
-
* call-seq:
|
7
|
-
* new(document)
|
8
|
-
*
|
9
|
-
* Create a new DocumentFragment element on the +document+
|
10
|
-
*/
|
5
|
+
/* :nodoc: */
|
11
6
|
static VALUE
|
12
|
-
|
7
|
+
noko_xml_document_fragment_s_native_new(VALUE klass, VALUE rb_doc)
|
13
8
|
{
|
14
|
-
xmlDocPtr
|
15
|
-
xmlNodePtr
|
16
|
-
VALUE document;
|
17
|
-
VALUE rest;
|
9
|
+
xmlDocPtr c_doc;
|
10
|
+
xmlNodePtr c_node;
|
18
11
|
VALUE rb_node;
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
node = xmlNewDocFragment(xml_doc->doc);
|
25
|
-
|
26
|
-
noko_xml_document_pin_node(node);
|
27
|
-
|
28
|
-
rb_node = noko_xml_node_wrap(klass, node);
|
29
|
-
rb_obj_call_init(rb_node, argc, argv);
|
13
|
+
c_doc = noko_xml_document_unwrap(rb_doc);
|
14
|
+
c_node = xmlNewDocFragment(c_doc->doc);
|
15
|
+
noko_xml_document_pin_node(c_node);
|
16
|
+
rb_node = noko_xml_node_wrap(klass, c_node);
|
30
17
|
|
31
18
|
return rb_node;
|
32
19
|
}
|
@@ -35,10 +22,8 @@ void
|
|
35
22
|
noko_init_xml_document_fragment(void)
|
36
23
|
{
|
37
24
|
assert(cNokogiriXmlNode);
|
38
|
-
|
39
|
-
* DocumentFragment represents a DocumentFragment node in an xml document.
|
40
|
-
*/
|
25
|
+
|
41
26
|
cNokogiriXmlDocumentFragment = rb_define_class_under(mNokogiriXml, "DocumentFragment", cNokogiriXmlNode);
|
42
27
|
|
43
|
-
rb_define_singleton_method(cNokogiriXmlDocumentFragment, "
|
28
|
+
rb_define_singleton_method(cNokogiriXmlDocumentFragment, "native_new", noko_xml_document_fragment_s_native_new, 1);
|
44
29
|
}
|
data/ext/nokogiri/xml_dtd.c
CHANGED
@@ -144,7 +144,7 @@ validate(VALUE self, VALUE document)
|
|
144
144
|
|
145
145
|
ctxt = xmlNewValidCtxt();
|
146
146
|
|
147
|
-
xmlSetStructuredErrorFunc((void *)error_list,
|
147
|
+
xmlSetStructuredErrorFunc((void *)error_list, noko__error_array_pusher);
|
148
148
|
|
149
149
|
xmlValidateDtd(ctxt, doc, dtd);
|
150
150
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
VALUE cNokogiriXmlElementContent;
|
4
4
|
|
5
|
-
static const rb_data_type_t
|
6
|
-
.wrap_struct_name = "
|
5
|
+
static const rb_data_type_t xml_element_content_type = {
|
6
|
+
.wrap_struct_name = "xmlElementContent",
|
7
7
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
8
8
|
};
|
9
9
|
|
@@ -17,7 +17,7 @@ static VALUE
|
|
17
17
|
get_name(VALUE self)
|
18
18
|
{
|
19
19
|
xmlElementContentPtr elem;
|
20
|
-
TypedData_Get_Struct(self, xmlElementContent, &
|
20
|
+
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
|
21
21
|
|
22
22
|
if (!elem->name) { return Qnil; }
|
23
23
|
return NOKOGIRI_STR_NEW2(elem->name);
|
@@ -33,7 +33,7 @@ static VALUE
|
|
33
33
|
get_type(VALUE self)
|
34
34
|
{
|
35
35
|
xmlElementContentPtr elem;
|
36
|
-
TypedData_Get_Struct(self, xmlElementContent, &
|
36
|
+
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
|
37
37
|
|
38
38
|
return INT2NUM(elem->type);
|
39
39
|
}
|
@@ -45,7 +45,7 @@ static VALUE
|
|
45
45
|
get_c1(VALUE self)
|
46
46
|
{
|
47
47
|
xmlElementContentPtr elem;
|
48
|
-
TypedData_Get_Struct(self, xmlElementContent, &
|
48
|
+
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
|
49
49
|
|
50
50
|
if (!elem->c1) { return Qnil; }
|
51
51
|
return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c1);
|
@@ -58,7 +58,7 @@ static VALUE
|
|
58
58
|
get_c2(VALUE self)
|
59
59
|
{
|
60
60
|
xmlElementContentPtr elem;
|
61
|
-
TypedData_Get_Struct(self, xmlElementContent, &
|
61
|
+
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
|
62
62
|
|
63
63
|
if (!elem->c2) { return Qnil; }
|
64
64
|
return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c2);
|
@@ -74,7 +74,7 @@ static VALUE
|
|
74
74
|
get_occur(VALUE self)
|
75
75
|
{
|
76
76
|
xmlElementContentPtr elem;
|
77
|
-
TypedData_Get_Struct(self, xmlElementContent, &
|
77
|
+
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
|
78
78
|
|
79
79
|
return INT2NUM(elem->ocur);
|
80
80
|
}
|
@@ -89,7 +89,7 @@ static VALUE
|
|
89
89
|
get_prefix(VALUE self)
|
90
90
|
{
|
91
91
|
xmlElementContentPtr elem;
|
92
|
-
TypedData_Get_Struct(self, xmlElementContent, &
|
92
|
+
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);
|
93
93
|
|
94
94
|
if (!elem->prefix) { return Qnil; }
|
95
95
|
|
@@ -104,7 +104,7 @@ noko_xml_element_content_wrap(VALUE rb_document, xmlElementContentPtr c_element_
|
|
104
104
|
{
|
105
105
|
VALUE elem = TypedData_Wrap_Struct(
|
106
106
|
cNokogiriXmlElementContent,
|
107
|
-
&
|
107
|
+
&xml_element_content_type,
|
108
108
|
c_element_content
|
109
109
|
);
|
110
110
|
|
@@ -10,8 +10,8 @@ xml_encoding_handler_dealloc(void *data)
|
|
10
10
|
xmlCharEncCloseFunc(c_handler);
|
11
11
|
}
|
12
12
|
|
13
|
-
static const rb_data_type_t
|
14
|
-
.wrap_struct_name = "
|
13
|
+
static const rb_data_type_t xml_char_encoding_handler_type = {
|
14
|
+
.wrap_struct_name = "xmlCharEncodingHandler",
|
15
15
|
.function = {
|
16
16
|
.dfree = xml_encoding_handler_dealloc,
|
17
17
|
},
|
@@ -31,7 +31,7 @@ rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
|
|
31
31
|
|
32
32
|
handler = xmlFindCharEncodingHandler(StringValueCStr(key));
|
33
33
|
if (handler) {
|
34
|
-
return TypedData_Wrap_Struct(klass, &
|
34
|
+
return TypedData_Wrap_Struct(klass, &xml_char_encoding_handler_type, handler);
|
35
35
|
}
|
36
36
|
|
37
37
|
return Qnil;
|
@@ -90,7 +90,7 @@ rb_xml_encoding_handler_name(VALUE self)
|
|
90
90
|
{
|
91
91
|
xmlCharEncodingHandlerPtr handler;
|
92
92
|
|
93
|
-
TypedData_Get_Struct(self, xmlCharEncodingHandler, &
|
93
|
+
TypedData_Get_Struct(self, xmlCharEncodingHandler, &xml_char_encoding_handler_type, handler);
|
94
94
|
|
95
95
|
return NOKOGIRI_STR_NEW2(handler->name);
|
96
96
|
}
|
@@ -51,8 +51,8 @@ _xml_namespace_update_references(void *ptr)
|
|
51
51
|
}
|
52
52
|
}
|
53
53
|
|
54
|
-
static const rb_data_type_t
|
55
|
-
.wrap_struct_name = "
|
54
|
+
static const rb_data_type_t xml_ns_type_with_free = {
|
55
|
+
.wrap_struct_name = "xmlNs (with free)",
|
56
56
|
.function = {
|
57
57
|
.dfree = _xml_namespace_dealloc,
|
58
58
|
.dcompact = _xml_namespace_update_references,
|
@@ -60,8 +60,8 @@ static const rb_data_type_t nokogiri_xml_namespace_type_with_dealloc = {
|
|
60
60
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
61
61
|
};
|
62
62
|
|
63
|
-
static const rb_data_type_t
|
64
|
-
.wrap_struct_name = "
|
63
|
+
static const rb_data_type_t xml_ns_type_without_free = {
|
64
|
+
.wrap_struct_name = "xmlNs (without free)",
|
65
65
|
.function = {
|
66
66
|
.dcompact = _xml_namespace_update_references,
|
67
67
|
},
|
@@ -145,7 +145,7 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)
|
|
145
145
|
|
146
146
|
if (c_document) {
|
147
147
|
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
|
148
|
-
&
|
148
|
+
&xml_ns_type_without_free,
|
149
149
|
c_namespace);
|
150
150
|
|
151
151
|
if (DOC_RUBY_OBJECT_TEST(c_document)) {
|
@@ -154,7 +154,7 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)
|
|
154
154
|
}
|
155
155
|
} else {
|
156
156
|
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
|
157
|
-
&
|
157
|
+
&xml_ns_type_with_free,
|
158
158
|
c_namespace);
|
159
159
|
}
|
160
160
|
|