nokogiri 1.14.0.rc1-arm-linux
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 +7 -0
- data/Gemfile +38 -0
- data/LICENSE-DEPENDENCIES.md +2224 -0
- data/LICENSE.md +9 -0
- data/README.md +287 -0
- data/bin/nokogiri +131 -0
- data/dependencies.yml +41 -0
- data/ext/nokogiri/depend +38 -0
- data/ext/nokogiri/extconf.rb +1082 -0
- data/ext/nokogiri/gumbo.c +594 -0
- data/ext/nokogiri/html4_document.c +166 -0
- data/ext/nokogiri/html4_element_description.c +294 -0
- data/ext/nokogiri/html4_entity_lookup.c +37 -0
- data/ext/nokogiri/html4_sax_parser_context.c +114 -0
- data/ext/nokogiri/html4_sax_push_parser.c +95 -0
- data/ext/nokogiri/include/libexslt/exslt.h +108 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
- data/ext/nokogiri/include/libexslt/exsltexports.h +63 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX.h +204 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +172 -0
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +128 -0
- data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
- data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
- data/ext/nokogiri/include/libxml2/libxml/dict.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +232 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +153 -0
- data/ext/nokogiri/include/libxml2/libxml/globals.h +499 -0
- data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
- data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
- data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +186 -0
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +1244 -0
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +656 -0
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +218 -0
- data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
- data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
- data/ext/nokogiri/include/libxml2/libxml/threads.h +91 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +1312 -0
- data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +463 -0
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
- data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +368 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +947 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +77 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +226 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +152 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +503 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +575 -0
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +137 -0
- data/ext/nokogiri/include/libxslt/attributes.h +38 -0
- data/ext/nokogiri/include/libxslt/documents.h +93 -0
- data/ext/nokogiri/include/libxslt/extensions.h +262 -0
- data/ext/nokogiri/include/libxslt/extra.h +72 -0
- data/ext/nokogiri/include/libxslt/functions.h +78 -0
- data/ext/nokogiri/include/libxslt/imports.h +75 -0
- data/ext/nokogiri/include/libxslt/keys.h +53 -0
- data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
- data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
- data/ext/nokogiri/include/libxslt/pattern.h +84 -0
- data/ext/nokogiri/include/libxslt/preproc.h +43 -0
- data/ext/nokogiri/include/libxslt/security.h +104 -0
- data/ext/nokogiri/include/libxslt/templates.h +77 -0
- data/ext/nokogiri/include/libxslt/transform.h +207 -0
- data/ext/nokogiri/include/libxslt/variables.h +118 -0
- data/ext/nokogiri/include/libxslt/xslt.h +110 -0
- data/ext/nokogiri/include/libxslt/xsltInternals.h +1982 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +179 -0
- data/ext/nokogiri/include/libxslt/xsltexports.h +64 -0
- data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
- data/ext/nokogiri/include/libxslt/xsltutils.h +310 -0
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +259 -0
- data/ext/nokogiri/nokogiri.h +235 -0
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_cdata.c +57 -0
- data/ext/nokogiri/xml_comment.c +62 -0
- data/ext/nokogiri/xml_document.c +689 -0
- data/ext/nokogiri/xml_document_fragment.c +44 -0
- data/ext/nokogiri/xml_dtd.c +208 -0
- data/ext/nokogiri/xml_element_content.c +128 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_encoding_handler.c +104 -0
- data/ext/nokogiri/xml_entity_decl.c +112 -0
- data/ext/nokogiri/xml_entity_reference.c +50 -0
- data/ext/nokogiri/xml_namespace.c +186 -0
- data/ext/nokogiri/xml_node.c +2425 -0
- data/ext/nokogiri/xml_node_set.c +496 -0
- data/ext/nokogiri/xml_processing_instruction.c +54 -0
- data/ext/nokogiri/xml_reader.c +794 -0
- data/ext/nokogiri/xml_relax_ng.c +183 -0
- data/ext/nokogiri/xml_sax_parser.c +316 -0
- data/ext/nokogiri/xml_sax_parser_context.c +283 -0
- data/ext/nokogiri/xml_sax_push_parser.c +166 -0
- data/ext/nokogiri/xml_schema.c +282 -0
- data/ext/nokogiri/xml_syntax_error.c +85 -0
- data/ext/nokogiri/xml_text.c +48 -0
- data/ext/nokogiri/xml_xpath_context.c +413 -0
- data/ext/nokogiri/xslt_stylesheet.c +363 -0
- data/gumbo-parser/CHANGES.md +63 -0
- data/gumbo-parser/Makefile +111 -0
- data/gumbo-parser/THANKS +27 -0
- data/lib/nokogiri/2.7/nokogiri.so +0 -0
- 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/class_resolver.rb +67 -0
- data/lib/nokogiri/css/node.rb +54 -0
- data/lib/nokogiri/css/parser.rb +770 -0
- data/lib/nokogiri/css/parser.y +277 -0
- data/lib/nokogiri/css/parser_extras.rb +96 -0
- data/lib/nokogiri/css/syntax_error.rb +9 -0
- data/lib/nokogiri/css/tokenizer.rb +155 -0
- data/lib/nokogiri/css/tokenizer.rex +56 -0
- data/lib/nokogiri/css/xpath_visitor.rb +359 -0
- data/lib/nokogiri/css.rb +66 -0
- data/lib/nokogiri/decorators/slop.rb +44 -0
- data/lib/nokogiri/encoding_handler.rb +57 -0
- data/lib/nokogiri/extension.rb +32 -0
- data/lib/nokogiri/gumbo.rb +15 -0
- data/lib/nokogiri/html.rb +48 -0
- data/lib/nokogiri/html4/builder.rb +37 -0
- data/lib/nokogiri/html4/document.rb +214 -0
- data/lib/nokogiri/html4/document_fragment.rb +54 -0
- data/lib/nokogiri/html4/element_description.rb +25 -0
- data/lib/nokogiri/html4/element_description_defaults.rb +572 -0
- data/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/lib/nokogiri/html4/entity_lookup.rb +15 -0
- data/lib/nokogiri/html4/sax/parser.rb +63 -0
- data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
- data/lib/nokogiri/html4/sax/push_parser.rb +37 -0
- data/lib/nokogiri/html4.rb +47 -0
- data/lib/nokogiri/html5/document.rb +168 -0
- data/lib/nokogiri/html5/document_fragment.rb +90 -0
- data/lib/nokogiri/html5/node.rb +98 -0
- data/lib/nokogiri/html5.rb +389 -0
- data/lib/nokogiri/jruby/dependencies.rb +3 -0
- data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
- data/lib/nokogiri/syntax_error.rb +6 -0
- data/lib/nokogiri/version/constant.rb +6 -0
- data/lib/nokogiri/version/info.rb +223 -0
- data/lib/nokogiri/version.rb +4 -0
- data/lib/nokogiri/xml/attr.rb +66 -0
- data/lib/nokogiri/xml/attribute_decl.rb +20 -0
- data/lib/nokogiri/xml/builder.rb +487 -0
- data/lib/nokogiri/xml/cdata.rb +13 -0
- data/lib/nokogiri/xml/character_data.rb +9 -0
- data/lib/nokogiri/xml/document.rb +471 -0
- data/lib/nokogiri/xml/document_fragment.rb +205 -0
- data/lib/nokogiri/xml/dtd.rb +34 -0
- data/lib/nokogiri/xml/element_content.rb +38 -0
- data/lib/nokogiri/xml/element_decl.rb +15 -0
- data/lib/nokogiri/xml/entity_decl.rb +21 -0
- data/lib/nokogiri/xml/entity_reference.rb +20 -0
- data/lib/nokogiri/xml/namespace.rb +58 -0
- data/lib/nokogiri/xml/node/save_options.rb +68 -0
- data/lib/nokogiri/xml/node.rb +1563 -0
- data/lib/nokogiri/xml/node_set.rb +446 -0
- data/lib/nokogiri/xml/notation.rb +19 -0
- data/lib/nokogiri/xml/parse_options.rb +213 -0
- data/lib/nokogiri/xml/pp/character_data.rb +21 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/pp.rb +4 -0
- data/lib/nokogiri/xml/processing_instruction.rb +11 -0
- data/lib/nokogiri/xml/reader.rb +105 -0
- data/lib/nokogiri/xml/relax_ng.rb +38 -0
- data/lib/nokogiri/xml/sax/document.rb +167 -0
- data/lib/nokogiri/xml/sax/parser.rb +125 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +21 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/sax.rb +6 -0
- data/lib/nokogiri/xml/schema.rb +73 -0
- data/lib/nokogiri/xml/searchable.rb +270 -0
- data/lib/nokogiri/xml/syntax_error.rb +72 -0
- data/lib/nokogiri/xml/text.rb +11 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +13 -0
- data/lib/nokogiri/xml/xpath.rb +21 -0
- data/lib/nokogiri/xml/xpath_context.rb +16 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xslt/stylesheet.rb +27 -0
- data/lib/nokogiri/xslt.rb +65 -0
- data/lib/nokogiri.rb +120 -0
- data/lib/xsd/xmlparser/nokogiri.rb +104 -0
- metadata +317 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
#ifndef HAVE_XMLFIRSTELEMENTCHILD
|
2
|
+
#include <nokogiri.h>
|
3
|
+
/**
|
4
|
+
* xmlFirstElementChild:
|
5
|
+
* @parent: the parent node
|
6
|
+
*
|
7
|
+
* Finds the first child node of that element which is a Element node
|
8
|
+
* Note the handling of entities references is different than in
|
9
|
+
* the W3C DOM element traversal spec since we don't have back reference
|
10
|
+
* from entities content to entities references.
|
11
|
+
*
|
12
|
+
* Returns the first element child or NULL if not available
|
13
|
+
*/
|
14
|
+
xmlNodePtr
|
15
|
+
xmlFirstElementChild(xmlNodePtr parent)
|
16
|
+
{
|
17
|
+
xmlNodePtr cur = NULL;
|
18
|
+
|
19
|
+
if (parent == NULL) {
|
20
|
+
return (NULL);
|
21
|
+
}
|
22
|
+
switch (parent->type) {
|
23
|
+
case XML_ELEMENT_NODE:
|
24
|
+
case XML_ENTITY_NODE:
|
25
|
+
case XML_DOCUMENT_NODE:
|
26
|
+
case XML_HTML_DOCUMENT_NODE:
|
27
|
+
cur = parent->children;
|
28
|
+
break;
|
29
|
+
default:
|
30
|
+
return (NULL);
|
31
|
+
}
|
32
|
+
while (cur != NULL) {
|
33
|
+
if (cur->type == XML_ELEMENT_NODE) {
|
34
|
+
return (cur);
|
35
|
+
}
|
36
|
+
cur = cur->next;
|
37
|
+
}
|
38
|
+
return (NULL);
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* xmlNextElementSibling:
|
43
|
+
* @node: the current node
|
44
|
+
*
|
45
|
+
* Finds the first closest next sibling of the node which is an
|
46
|
+
* element node.
|
47
|
+
* Note the handling of entities references is different than in
|
48
|
+
* the W3C DOM element traversal spec since we don't have back reference
|
49
|
+
* from entities content to entities references.
|
50
|
+
*
|
51
|
+
* Returns the next element sibling or NULL if not available
|
52
|
+
*/
|
53
|
+
xmlNodePtr
|
54
|
+
xmlNextElementSibling(xmlNodePtr node)
|
55
|
+
{
|
56
|
+
if (node == NULL) {
|
57
|
+
return (NULL);
|
58
|
+
}
|
59
|
+
switch (node->type) {
|
60
|
+
case XML_ELEMENT_NODE:
|
61
|
+
case XML_TEXT_NODE:
|
62
|
+
case XML_CDATA_SECTION_NODE:
|
63
|
+
case XML_ENTITY_REF_NODE:
|
64
|
+
case XML_ENTITY_NODE:
|
65
|
+
case XML_PI_NODE:
|
66
|
+
case XML_COMMENT_NODE:
|
67
|
+
case XML_DTD_NODE:
|
68
|
+
case XML_XINCLUDE_START:
|
69
|
+
case XML_XINCLUDE_END:
|
70
|
+
node = node->next;
|
71
|
+
break;
|
72
|
+
default:
|
73
|
+
return (NULL);
|
74
|
+
}
|
75
|
+
while (node != NULL) {
|
76
|
+
if (node->type == XML_ELEMENT_NODE) {
|
77
|
+
return (node);
|
78
|
+
}
|
79
|
+
node = node->next;
|
80
|
+
}
|
81
|
+
return (NULL);
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* xmlLastElementChild:
|
86
|
+
* @parent: the parent node
|
87
|
+
*
|
88
|
+
* Finds the last child node of that element which is a Element node
|
89
|
+
* Note the handling of entities references is different than in
|
90
|
+
* the W3C DOM element traversal spec since we don't have back reference
|
91
|
+
* from entities content to entities references.
|
92
|
+
*
|
93
|
+
* Returns the last element child or NULL if not available
|
94
|
+
*/
|
95
|
+
xmlNodePtr
|
96
|
+
xmlLastElementChild(xmlNodePtr parent)
|
97
|
+
{
|
98
|
+
xmlNodePtr cur = NULL;
|
99
|
+
|
100
|
+
if (parent == NULL) {
|
101
|
+
return (NULL);
|
102
|
+
}
|
103
|
+
switch (parent->type) {
|
104
|
+
case XML_ELEMENT_NODE:
|
105
|
+
case XML_ENTITY_NODE:
|
106
|
+
case XML_DOCUMENT_NODE:
|
107
|
+
case XML_HTML_DOCUMENT_NODE:
|
108
|
+
cur = parent->last;
|
109
|
+
break;
|
110
|
+
default:
|
111
|
+
return (NULL);
|
112
|
+
}
|
113
|
+
while (cur != NULL) {
|
114
|
+
if (cur->type == XML_ELEMENT_NODE) {
|
115
|
+
return (cur);
|
116
|
+
}
|
117
|
+
cur = cur->prev;
|
118
|
+
}
|
119
|
+
return (NULL);
|
120
|
+
}
|
121
|
+
#endif
|
@@ -0,0 +1,259 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE mNokogiri ;
|
4
|
+
VALUE mNokogiriGumbo ;
|
5
|
+
VALUE mNokogiriHtml4 ;
|
6
|
+
VALUE mNokogiriHtml4Sax ;
|
7
|
+
VALUE mNokogiriHtml5 ;
|
8
|
+
VALUE mNokogiriXml ;
|
9
|
+
VALUE mNokogiriXmlSax ;
|
10
|
+
VALUE mNokogiriXmlXpath ;
|
11
|
+
VALUE mNokogiriXslt ;
|
12
|
+
|
13
|
+
VALUE cNokogiriSyntaxError;
|
14
|
+
VALUE cNokogiriXmlCharacterData;
|
15
|
+
VALUE cNokogiriXmlElement;
|
16
|
+
VALUE cNokogiriXmlXpathSyntaxError;
|
17
|
+
|
18
|
+
void noko_init_xml_attr(void);
|
19
|
+
void noko_init_xml_attribute_decl(void);
|
20
|
+
void noko_init_xml_cdata(void);
|
21
|
+
void noko_init_xml_comment(void);
|
22
|
+
void noko_init_xml_document(void);
|
23
|
+
void noko_init_xml_document_fragment(void);
|
24
|
+
void noko_init_xml_dtd(void);
|
25
|
+
void noko_init_xml_element_content(void);
|
26
|
+
void noko_init_xml_element_decl(void);
|
27
|
+
void noko_init_xml_encoding_handler(void);
|
28
|
+
void noko_init_xml_entity_decl(void);
|
29
|
+
void noko_init_xml_entity_reference(void);
|
30
|
+
void noko_init_xml_namespace(void);
|
31
|
+
void noko_init_xml_node(void);
|
32
|
+
void noko_init_xml_node_set(void);
|
33
|
+
void noko_init_xml_processing_instruction(void);
|
34
|
+
void noko_init_xml_reader(void);
|
35
|
+
void noko_init_xml_relax_ng(void);
|
36
|
+
void noko_init_xml_sax_parser(void);
|
37
|
+
void noko_init_xml_sax_parser_context(void);
|
38
|
+
void noko_init_xml_sax_push_parser(void);
|
39
|
+
void noko_init_xml_schema(void);
|
40
|
+
void noko_init_xml_syntax_error(void);
|
41
|
+
void noko_init_xml_text(void);
|
42
|
+
void noko_init_xml_xpath_context(void);
|
43
|
+
void noko_init_xslt_stylesheet(void);
|
44
|
+
void noko_init_html_document(void);
|
45
|
+
void noko_init_html_element_description(void);
|
46
|
+
void noko_init_html_entity_lookup(void);
|
47
|
+
void noko_init_html_sax_parser_context(void);
|
48
|
+
void noko_init_html_sax_push_parser(void);
|
49
|
+
void noko_init_gumbo(void);
|
50
|
+
void noko_init_test_global_handlers(void);
|
51
|
+
|
52
|
+
static ID id_read, id_write, id_external_encoding;
|
53
|
+
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
noko_io_read_check(VALUE val)
|
57
|
+
{
|
58
|
+
VALUE *args = (VALUE *)val;
|
59
|
+
return rb_funcall(args[0], id_read, 1, args[1]);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
static VALUE
|
64
|
+
noko_io_read_failed(VALUE arg, VALUE exc)
|
65
|
+
{
|
66
|
+
return Qundef;
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
int
|
71
|
+
noko_io_read(void *io, char *c_buffer, int c_buffer_len)
|
72
|
+
{
|
73
|
+
VALUE rb_io = (VALUE)io;
|
74
|
+
VALUE rb_read_string, rb_args[2];
|
75
|
+
size_t n_bytes_read, safe_len;
|
76
|
+
|
77
|
+
rb_args[0] = rb_io;
|
78
|
+
rb_args[1] = INT2NUM(c_buffer_len);
|
79
|
+
|
80
|
+
rb_read_string = rb_rescue(noko_io_read_check, (VALUE)rb_args, noko_io_read_failed, 0);
|
81
|
+
|
82
|
+
if (NIL_P(rb_read_string)) { return 0; }
|
83
|
+
if (rb_read_string == Qundef) { return -1; }
|
84
|
+
if (TYPE(rb_read_string) != T_STRING) { return -1; }
|
85
|
+
|
86
|
+
n_bytes_read = (size_t)RSTRING_LEN(rb_read_string);
|
87
|
+
safe_len = (n_bytes_read > (size_t)c_buffer_len) ? (size_t)c_buffer_len : n_bytes_read;
|
88
|
+
memcpy(c_buffer, StringValuePtr(rb_read_string), safe_len);
|
89
|
+
|
90
|
+
return (int)safe_len;
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
static VALUE
|
95
|
+
noko_io_write_check(VALUE rb_args)
|
96
|
+
{
|
97
|
+
VALUE rb_io = ((VALUE *)rb_args)[0];
|
98
|
+
VALUE rb_output = ((VALUE *)rb_args)[1];
|
99
|
+
return rb_funcall(rb_io, id_write, 1, rb_output);
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
static VALUE
|
104
|
+
noko_io_write_failed(VALUE arg, VALUE exc)
|
105
|
+
{
|
106
|
+
return Qundef;
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
int
|
111
|
+
noko_io_write(void *io, char *c_buffer, int c_buffer_len)
|
112
|
+
{
|
113
|
+
VALUE rb_args[2], rb_n_bytes_written;
|
114
|
+
VALUE rb_io = (VALUE)io;
|
115
|
+
rb_encoding *io_encoding = rb_to_encoding(rb_funcall(rb_io, id_external_encoding, 0));
|
116
|
+
|
117
|
+
rb_args[0] = rb_io;
|
118
|
+
rb_args[1] = rb_enc_str_new(c_buffer, (long)c_buffer_len, io_encoding);
|
119
|
+
|
120
|
+
rb_n_bytes_written = rb_rescue(noko_io_write_check, (VALUE)rb_args, noko_io_write_failed, 0);
|
121
|
+
if (rb_n_bytes_written == Qundef) { return -1; }
|
122
|
+
|
123
|
+
return NUM2INT(rb_n_bytes_written);
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
int
|
128
|
+
noko_io_close(void *io)
|
129
|
+
{
|
130
|
+
return 0;
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
void
|
135
|
+
Init_nokogiri()
|
136
|
+
{
|
137
|
+
mNokogiri = rb_define_module("Nokogiri");
|
138
|
+
mNokogiriGumbo = rb_define_module_under(mNokogiri, "Gumbo");
|
139
|
+
mNokogiriHtml4 = rb_define_module_under(mNokogiri, "HTML4");
|
140
|
+
mNokogiriHtml4Sax = rb_define_module_under(mNokogiriHtml4, "SAX");
|
141
|
+
mNokogiriHtml5 = rb_define_module_under(mNokogiri, "HTML5");
|
142
|
+
mNokogiriXml = rb_define_module_under(mNokogiri, "XML");
|
143
|
+
mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
|
144
|
+
mNokogiriXmlXpath = rb_define_module_under(mNokogiriXml, "XPath");
|
145
|
+
mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT");
|
146
|
+
|
147
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION));
|
148
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion));
|
149
|
+
|
150
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
151
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
152
|
+
|
153
|
+
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
154
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
155
|
+
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
156
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qtrue);
|
157
|
+
# else
|
158
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
159
|
+
# endif
|
160
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
161
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
162
|
+
#else
|
163
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qfalse);
|
164
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
165
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), Qnil);
|
166
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), Qnil);
|
167
|
+
#endif
|
168
|
+
|
169
|
+
#ifdef LIBXML_ICONV_ENABLED
|
170
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue);
|
171
|
+
#else
|
172
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
173
|
+
#endif
|
174
|
+
|
175
|
+
#ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
|
176
|
+
rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
|
177
|
+
#endif
|
178
|
+
|
179
|
+
#if defined(_WIN32) && !defined(NOKOGIRI_PACKAGED_LIBRARIES)
|
180
|
+
/*
|
181
|
+
* We choose *not* to do use Ruby's memory management functions with windows DLLs because of this
|
182
|
+
* issue in libxml 2.9.12:
|
183
|
+
*
|
184
|
+
* https://github.com/sparklemotion/nokogiri/issues/2241
|
185
|
+
*
|
186
|
+
* If the atexit() issue gets fixed in a future version of libxml2, then we may be able to skip
|
187
|
+
* this config only for the specific libxml2 versions 2.9.12.
|
188
|
+
*
|
189
|
+
* Alternatively, now that Ruby has a generational GC, it might be OK to let libxml2 use its
|
190
|
+
* default memory management functions (recall that this config was introduced to reduce memory
|
191
|
+
* bloat and allow Ruby to GC more often); but we should *really* test with production workloads
|
192
|
+
* before making that kind of a potentially-invasive change.
|
193
|
+
*/
|
194
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_MEMORY_MANAGEMENT"), NOKOGIRI_STR_NEW2("default"));
|
195
|
+
#else
|
196
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_MEMORY_MANAGEMENT"), NOKOGIRI_STR_NEW2("ruby"));
|
197
|
+
xmlMemSetup((xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, ruby_strdup);
|
198
|
+
#endif
|
199
|
+
|
200
|
+
xmlInitParser();
|
201
|
+
exsltRegisterAll();
|
202
|
+
|
203
|
+
if (xsltExtModuleFunctionLookup((const xmlChar *)"date-time", EXSLT_DATE_NAMESPACE)) {
|
204
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_DATETIME_ENABLED"), Qtrue);
|
205
|
+
} else {
|
206
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_DATETIME_ENABLED"), Qfalse);
|
207
|
+
}
|
208
|
+
|
209
|
+
cNokogiriSyntaxError = rb_define_class_under(mNokogiri, "SyntaxError", rb_eStandardError);
|
210
|
+
noko_init_xml_syntax_error();
|
211
|
+
assert(cNokogiriXmlSyntaxError);
|
212
|
+
cNokogiriXmlXpathSyntaxError = rb_define_class_under(mNokogiriXmlXpath, "SyntaxError", cNokogiriXmlSyntaxError);
|
213
|
+
|
214
|
+
noko_init_xml_element_content();
|
215
|
+
noko_init_xml_encoding_handler();
|
216
|
+
noko_init_xml_namespace();
|
217
|
+
noko_init_xml_node_set();
|
218
|
+
noko_init_xml_reader();
|
219
|
+
noko_init_xml_sax_parser();
|
220
|
+
noko_init_xml_xpath_context();
|
221
|
+
noko_init_xslt_stylesheet();
|
222
|
+
noko_init_html_element_description();
|
223
|
+
noko_init_html_entity_lookup();
|
224
|
+
|
225
|
+
noko_init_xml_schema();
|
226
|
+
noko_init_xml_relax_ng();
|
227
|
+
|
228
|
+
noko_init_xml_sax_parser_context();
|
229
|
+
noko_init_html_sax_parser_context();
|
230
|
+
|
231
|
+
noko_init_xml_sax_push_parser();
|
232
|
+
noko_init_html_sax_push_parser();
|
233
|
+
|
234
|
+
noko_init_xml_node();
|
235
|
+
noko_init_xml_attr();
|
236
|
+
noko_init_xml_attribute_decl();
|
237
|
+
noko_init_xml_dtd();
|
238
|
+
noko_init_xml_element_decl();
|
239
|
+
noko_init_xml_entity_decl();
|
240
|
+
noko_init_xml_entity_reference();
|
241
|
+
noko_init_xml_processing_instruction();
|
242
|
+
assert(cNokogiriXmlNode);
|
243
|
+
cNokogiriXmlElement = rb_define_class_under(mNokogiriXml, "Element", cNokogiriXmlNode);
|
244
|
+
cNokogiriXmlCharacterData = rb_define_class_under(mNokogiriXml, "CharacterData", cNokogiriXmlNode);
|
245
|
+
noko_init_xml_comment();
|
246
|
+
noko_init_xml_text();
|
247
|
+
noko_init_xml_cdata();
|
248
|
+
|
249
|
+
noko_init_xml_document_fragment();
|
250
|
+
noko_init_xml_document();
|
251
|
+
noko_init_html_document();
|
252
|
+
noko_init_gumbo();
|
253
|
+
|
254
|
+
noko_init_test_global_handlers();
|
255
|
+
|
256
|
+
id_read = rb_intern("read");
|
257
|
+
id_write = rb_intern("write");
|
258
|
+
id_external_encoding = rb_intern("external_encoding");
|
259
|
+
}
|
@@ -0,0 +1,235 @@
|
|
1
|
+
#ifndef NOKOGIRI_NATIVE
|
2
|
+
#define NOKOGIRI_NATIVE
|
3
|
+
|
4
|
+
#include <ruby/defines.h> // https://github.com/sparklemotion/nokogiri/issues/2696
|
5
|
+
|
6
|
+
#ifdef _MSC_VER
|
7
|
+
# ifndef WIN32_LEAN_AND_MEAN
|
8
|
+
# define WIN32_LEAN_AND_MEAN
|
9
|
+
# endif /* WIN32_LEAN_AND_MEAN */
|
10
|
+
|
11
|
+
# ifndef WIN32
|
12
|
+
# define WIN32
|
13
|
+
# endif /* WIN32 */
|
14
|
+
|
15
|
+
# include <winsock2.h>
|
16
|
+
# include <ws2tcpip.h>
|
17
|
+
# include <windows.h>
|
18
|
+
#endif
|
19
|
+
|
20
|
+
#ifdef _WIN32
|
21
|
+
# define NOKOPUBFUN __declspec(dllexport)
|
22
|
+
# define NOKOPUBVAR __declspec(dllexport) extern
|
23
|
+
#else
|
24
|
+
# define NOKOPUBFUN
|
25
|
+
# define NOKOPUBVAR extern
|
26
|
+
#endif
|
27
|
+
|
28
|
+
#include <stdlib.h>
|
29
|
+
#include <string.h>
|
30
|
+
#include <assert.h>
|
31
|
+
#include <stdarg.h>
|
32
|
+
#include <stdio.h>
|
33
|
+
|
34
|
+
|
35
|
+
#include <libxml/parser.h>
|
36
|
+
#include <libxml/tree.h>
|
37
|
+
#include <libxml/entities.h>
|
38
|
+
#include <libxml/xpath.h>
|
39
|
+
#include <libxml/xmlreader.h>
|
40
|
+
#include <libxml/xmlsave.h>
|
41
|
+
#include <libxml/xmlschemas.h>
|
42
|
+
#include <libxml/HTMLparser.h>
|
43
|
+
#include <libxml/HTMLtree.h>
|
44
|
+
#include <libxml/relaxng.h>
|
45
|
+
#include <libxml/xinclude.h>
|
46
|
+
#include <libxml/c14n.h>
|
47
|
+
#include <libxml/parserInternals.h>
|
48
|
+
#include <libxml/xpathInternals.h>
|
49
|
+
|
50
|
+
#include <libxslt/extensions.h>
|
51
|
+
#include <libxslt/xsltconfig.h>
|
52
|
+
#include <libxslt/xsltutils.h>
|
53
|
+
#include <libxslt/transform.h>
|
54
|
+
#include <libxslt/xsltInternals.h>
|
55
|
+
|
56
|
+
#include <libexslt/exslt.h>
|
57
|
+
|
58
|
+
/* libxml2_backwards_compat.c */
|
59
|
+
#ifndef HAVE_XMLFIRSTELEMENTCHILD
|
60
|
+
xmlNodePtr xmlFirstElementChild(xmlNodePtr parent);
|
61
|
+
xmlNodePtr xmlNextElementSibling(xmlNodePtr node);
|
62
|
+
xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
|
63
|
+
#endif
|
64
|
+
|
65
|
+
#define XMLNS_PREFIX "xmlns"
|
66
|
+
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
|
67
|
+
|
68
|
+
|
69
|
+
#include <ruby.h>
|
70
|
+
#include <ruby/st.h>
|
71
|
+
#include <ruby/encoding.h>
|
72
|
+
#include <ruby/util.h>
|
73
|
+
#include <ruby/version.h>
|
74
|
+
|
75
|
+
#define NOKOGIRI_STR_NEW2(str) NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
|
76
|
+
#define NOKOGIRI_STR_NEW(str, len) rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
|
77
|
+
#define RBSTR_OR_QNIL(_str) (_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
78
|
+
|
79
|
+
#ifndef NORETURN_DECL
|
80
|
+
# if defined(__GNUC__)
|
81
|
+
# define NORETURN_DECL __attribute__ ((noreturn))
|
82
|
+
# else
|
83
|
+
# define NORETURN_DECL
|
84
|
+
# endif
|
85
|
+
#endif
|
86
|
+
|
87
|
+
#ifndef PRINTFLIKE_DECL
|
88
|
+
# if defined(__GNUC__)
|
89
|
+
# define PRINTFLIKE_DECL(stringidx, argidx) __attribute__ ((format(printf,stringidx,argidx)))
|
90
|
+
# else
|
91
|
+
# define PRINTFLIKE_DECL(stringidx, argidx)
|
92
|
+
# endif
|
93
|
+
#endif
|
94
|
+
|
95
|
+
#if defined(TRUFFLERUBY) && !defined(NOKOGIRI_PACKAGED_LIBRARIES)
|
96
|
+
# define TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
97
|
+
#endif
|
98
|
+
|
99
|
+
NOKOPUBVAR VALUE mNokogiri ;
|
100
|
+
NOKOPUBVAR VALUE mNokogiriGumbo ;
|
101
|
+
NOKOPUBVAR VALUE mNokogiriHtml4 ;
|
102
|
+
NOKOPUBVAR VALUE mNokogiriHtml4Sax ;
|
103
|
+
NOKOPUBVAR VALUE mNokogiriHtml5 ;
|
104
|
+
NOKOPUBVAR VALUE mNokogiriXml ;
|
105
|
+
NOKOPUBVAR VALUE mNokogiriXmlSax ;
|
106
|
+
NOKOPUBVAR VALUE mNokogiriXmlXpath ;
|
107
|
+
NOKOPUBVAR VALUE mNokogiriXslt ;
|
108
|
+
|
109
|
+
NOKOPUBVAR VALUE cNokogiriEncodingHandler;
|
110
|
+
NOKOPUBVAR VALUE cNokogiriSyntaxError;
|
111
|
+
NOKOPUBVAR VALUE cNokogiriXmlAttr;
|
112
|
+
NOKOPUBVAR VALUE cNokogiriXmlAttributeDecl;
|
113
|
+
NOKOPUBVAR VALUE cNokogiriXmlCData;
|
114
|
+
NOKOPUBVAR VALUE cNokogiriXmlCharacterData;
|
115
|
+
NOKOPUBVAR VALUE cNokogiriXmlComment;
|
116
|
+
NOKOPUBVAR VALUE cNokogiriXmlDocument ;
|
117
|
+
NOKOPUBVAR VALUE cNokogiriXmlDocumentFragment;
|
118
|
+
NOKOPUBVAR VALUE cNokogiriXmlDtd;
|
119
|
+
NOKOPUBVAR VALUE cNokogiriXmlElement ;
|
120
|
+
NOKOPUBVAR VALUE cNokogiriXmlElementContent;
|
121
|
+
NOKOPUBVAR VALUE cNokogiriXmlElementDecl;
|
122
|
+
NOKOPUBVAR VALUE cNokogiriXmlEntityDecl;
|
123
|
+
NOKOPUBVAR VALUE cNokogiriXmlEntityReference;
|
124
|
+
NOKOPUBVAR VALUE cNokogiriXmlNamespace ;
|
125
|
+
NOKOPUBVAR VALUE cNokogiriXmlNode ;
|
126
|
+
NOKOPUBVAR VALUE cNokogiriXmlNodeSet ;
|
127
|
+
NOKOPUBVAR VALUE cNokogiriXmlProcessingInstruction;
|
128
|
+
NOKOPUBVAR VALUE cNokogiriXmlReader;
|
129
|
+
NOKOPUBVAR VALUE cNokogiriXmlRelaxNG;
|
130
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxParser ;
|
131
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxParserContext;
|
132
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxPushParser ;
|
133
|
+
NOKOPUBVAR VALUE cNokogiriXmlSchema;
|
134
|
+
NOKOPUBVAR VALUE cNokogiriXmlSyntaxError;
|
135
|
+
NOKOPUBVAR VALUE cNokogiriXmlText ;
|
136
|
+
NOKOPUBVAR VALUE cNokogiriXmlXpathContext;
|
137
|
+
NOKOPUBVAR VALUE cNokogiriXmlXpathSyntaxError;
|
138
|
+
NOKOPUBVAR VALUE cNokogiriXsltStylesheet ;
|
139
|
+
|
140
|
+
NOKOPUBVAR VALUE cNokogiriHtml4Document ;
|
141
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxPushParser ;
|
142
|
+
NOKOPUBVAR VALUE cNokogiriHtml4ElementDescription ;
|
143
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxParserContext;
|
144
|
+
NOKOPUBVAR VALUE cNokogiriHtml5Document ;
|
145
|
+
|
146
|
+
typedef struct _nokogiriTuple {
|
147
|
+
VALUE doc;
|
148
|
+
st_table *unlinkedNodes;
|
149
|
+
VALUE node_cache;
|
150
|
+
} nokogiriTuple;
|
151
|
+
typedef nokogiriTuple *nokogiriTuplePtr;
|
152
|
+
|
153
|
+
typedef struct _nokogiriSAXTuple {
|
154
|
+
xmlParserCtxtPtr ctxt;
|
155
|
+
VALUE self;
|
156
|
+
} nokogiriSAXTuple;
|
157
|
+
typedef nokogiriSAXTuple *nokogiriSAXTuplePtr;
|
158
|
+
|
159
|
+
typedef struct _libxmlStructuredErrorHandlerState {
|
160
|
+
void *user_data;
|
161
|
+
xmlStructuredErrorFunc handler;
|
162
|
+
} libxmlStructuredErrorHandlerState ;
|
163
|
+
|
164
|
+
typedef struct _nokogiriXsltStylesheetTuple {
|
165
|
+
xsltStylesheetPtr ss;
|
166
|
+
VALUE func_instances;
|
167
|
+
} nokogiriXsltStylesheetTuple;
|
168
|
+
|
169
|
+
void noko_xml_document_pin_node(xmlNodePtr);
|
170
|
+
void noko_xml_document_pin_namespace(xmlNsPtr, xmlDocPtr);
|
171
|
+
|
172
|
+
int noko_io_read(void *ctx, char *buffer, int len);
|
173
|
+
int noko_io_write(void *ctx, char *buffer, int len);
|
174
|
+
int noko_io_close(void *ctx);
|
175
|
+
|
176
|
+
#define Noko_Node_Get_Struct(obj,type,sval) ((sval) = (type*)DATA_PTR(obj))
|
177
|
+
#define Noko_Namespace_Get_Struct(obj,type,sval) ((sval) = (type*)DATA_PTR(obj))
|
178
|
+
|
179
|
+
VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ;
|
180
|
+
VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ;
|
181
|
+
VALUE noko_xml_node_attrs(xmlNodePtr node) ;
|
182
|
+
|
183
|
+
VALUE noko_xml_namespace_wrap(xmlNsPtr node, xmlDocPtr doc);
|
184
|
+
VALUE noko_xml_namespace_wrap_xpath_copy(xmlNsPtr node);
|
185
|
+
|
186
|
+
VALUE noko_xml_element_content_wrap(VALUE doc, xmlElementContentPtr element);
|
187
|
+
|
188
|
+
VALUE noko_xml_node_set_wrap(xmlNodeSetPtr node_set, VALUE document) ;
|
189
|
+
|
190
|
+
VALUE noko_xml_document_wrap_with_init_args(VALUE klass, xmlDocPtr doc, int argc, VALUE *argv);
|
191
|
+
VALUE noko_xml_document_wrap(VALUE klass, xmlDocPtr doc);
|
192
|
+
NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
|
193
|
+
xmlDocPtr doc); /* deprecated. use noko_xml_document_wrap() instead. */
|
194
|
+
|
195
|
+
#define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
|
196
|
+
#define DOC_RUBY_OBJECT(x) (((nokogiriTuplePtr)(x->_private))->doc)
|
197
|
+
#define DOC_UNLINKED_NODE_HASH(x) (((nokogiriTuplePtr)(x->_private))->unlinkedNodes)
|
198
|
+
#define DOC_NODE_CACHE(x) (((nokogiriTuplePtr)(x->_private))->node_cache)
|
199
|
+
#define NOKOGIRI_NAMESPACE_EH(node) ((node)->type == XML_NAMESPACE_DECL)
|
200
|
+
|
201
|
+
#define NOKOGIRI_SAX_SELF(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->self
|
202
|
+
#define NOKOGIRI_SAX_CTXT(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->ctxt
|
203
|
+
#define NOKOGIRI_SAX_TUPLE_NEW(_ctxt, _self) nokogiri_sax_tuple_new(_ctxt, _self)
|
204
|
+
#define NOKOGIRI_SAX_TUPLE_DESTROY(_tuple) ruby_xfree(_tuple)
|
205
|
+
|
206
|
+
#define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
|
207
|
+
#define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
|
208
|
+
|
209
|
+
#if HAVE_RB_CATEGORY_WARNING
|
210
|
+
# define NOKO_WARN_DEPRECATION(message) rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, message)
|
211
|
+
#else
|
212
|
+
# define NOKO_WARN_DEPRECATION(message) rb_warning(message)
|
213
|
+
#endif
|
214
|
+
|
215
|
+
void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
|
216
|
+
void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
|
217
|
+
xmlStructuredErrorFunc handler);
|
218
|
+
void Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
|
219
|
+
VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error);
|
220
|
+
void Nokogiri_error_array_pusher(void *ctx, xmlErrorPtr error);
|
221
|
+
NORETURN_DECL void Nokogiri_error_raise(void *ctx, xmlErrorPtr error);
|
222
|
+
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
|
223
|
+
const char *function_name) ;
|
224
|
+
|
225
|
+
static inline
|
226
|
+
nokogiriSAXTuplePtr
|
227
|
+
nokogiri_sax_tuple_new(xmlParserCtxtPtr ctxt, VALUE self)
|
228
|
+
{
|
229
|
+
nokogiriSAXTuplePtr tuple = ruby_xmalloc(sizeof(nokogiriSAXTuple));
|
230
|
+
tuple->self = self;
|
231
|
+
tuple->ctxt = ctxt;
|
232
|
+
return tuple;
|
233
|
+
}
|
234
|
+
|
235
|
+
#endif /* NOKOGIRI_NATIVE */
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
static VALUE foreign_error_handler_block = Qnil;
|
4
|
+
|
5
|
+
static void
|
6
|
+
foreign_error_handler(void *user_data, xmlErrorPtr c_error)
|
7
|
+
{
|
8
|
+
rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
|
9
|
+
}
|
10
|
+
|
11
|
+
/*
|
12
|
+
* call-seq:
|
13
|
+
* __foreign_error_handler { ... } -> nil
|
14
|
+
*
|
15
|
+
* Override libxml2's global error handlers to call the block. This method thus has very little
|
16
|
+
* value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See
|
17
|
+
* test/helper.rb for how this is being used.
|
18
|
+
*/
|
19
|
+
static VALUE
|
20
|
+
rb_foreign_error_handler(VALUE klass)
|
21
|
+
{
|
22
|
+
rb_need_block();
|
23
|
+
foreign_error_handler_block = rb_block_proc();
|
24
|
+
xmlSetStructuredErrorFunc(NULL, foreign_error_handler);
|
25
|
+
return Qnil;
|
26
|
+
}
|
27
|
+
|
28
|
+
/*
|
29
|
+
* Document-module: Nokogiri::Test
|
30
|
+
*
|
31
|
+
* The Nokogiri::Test module should only be used for testing Nokogiri.
|
32
|
+
* Do NOT use this outside of the Nokogiri test suite.
|
33
|
+
*/
|
34
|
+
void
|
35
|
+
noko_init_test_global_handlers()
|
36
|
+
{
|
37
|
+
VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
|
38
|
+
|
39
|
+
rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
|
40
|
+
}
|