nokogiri 1.11.0.rc2-x86-linux → 1.11.2-x86-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 +4 -4
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +1015 -947
- data/LICENSE.md +1 -1
- data/README.md +171 -94
- data/ext/nokogiri/depend +37 -358
- data/ext/nokogiri/extconf.rb +581 -374
- data/ext/nokogiri/html_document.c +78 -82
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +69 -66
- data/ext/nokogiri/html_sax_push_parser.c +42 -34
- data/ext/nokogiri/include/libexslt/exslt.h +102 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
- data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -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 +173 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +126 -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 +79 -0
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
- data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -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 +163 -0
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +1241 -0
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -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 +89 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
- data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -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 +366 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +945 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +153 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -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 +151 -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 +485 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +566 -0
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -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 +1978 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
- data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
- data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
- data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +192 -93
- data/ext/nokogiri/nokogiri.h +177 -98
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +225 -163
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +338 -286
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +52 -28
- data/ext/nokogiri/xml_sax_parser.c +118 -118
- data/ext/nokogiri/xml_sax_parser_context.c +103 -86
- data/ext/nokogiri/xml_sax_push_parser.c +36 -27
- data/ext/nokogiri/xml_schema.c +95 -47
- data/ext/nokogiri/xml_syntax_error.c +42 -21
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +206 -123
- data/ext/nokogiri/xslt_stylesheet.c +158 -161
- data/lib/nokogiri.rb +4 -8
- data/lib/nokogiri/2.5/nokogiri.so +0 -0
- data/lib/nokogiri/2.6/nokogiri.so +0 -0
- data/lib/nokogiri/2.7/nokogiri.so +0 -0
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/css/parser.rb +62 -62
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/xpath_visitor.rb +70 -42
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document.rb +12 -26
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/version.rb +2 -148
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +205 -0
- data/lib/nokogiri/xml/builder.rb +2 -2
- data/lib/nokogiri/xml/document.rb +48 -18
- data/lib/nokogiri/xml/document_fragment.rb +4 -6
- data/lib/nokogiri/xml/node.rb +88 -69
- data/lib/nokogiri/xml/parse_options.rb +6 -0
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/relax_ng.rb +6 -2
- data/lib/nokogiri/xml/schema.rb +12 -4
- data/lib/nokogiri/xml/searchable.rb +3 -1
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- metadata +151 -158
- data/ext/nokogiri/html_document.h +0 -10
- data/ext/nokogiri/html_element_description.h +0 -10
- data/ext/nokogiri/html_entity_lookup.h +0 -8
- data/ext/nokogiri/html_sax_parser_context.h +0 -11
- data/ext/nokogiri/html_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_attr.h +0 -9
- data/ext/nokogiri/xml_attribute_decl.h +0 -9
- data/ext/nokogiri/xml_cdata.h +0 -9
- data/ext/nokogiri/xml_comment.h +0 -9
- data/ext/nokogiri/xml_document.h +0 -23
- data/ext/nokogiri/xml_document_fragment.h +0 -10
- data/ext/nokogiri/xml_dtd.h +0 -10
- data/ext/nokogiri/xml_element_content.h +0 -10
- data/ext/nokogiri/xml_element_decl.h +0 -9
- data/ext/nokogiri/xml_encoding_handler.h +0 -8
- data/ext/nokogiri/xml_entity_decl.h +0 -10
- data/ext/nokogiri/xml_entity_reference.h +0 -9
- data/ext/nokogiri/xml_io.c +0 -61
- data/ext/nokogiri/xml_io.h +0 -11
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/xml_namespace.h +0 -14
- data/ext/nokogiri/xml_node.h +0 -13
- data/ext/nokogiri/xml_node_set.h +0 -12
- data/ext/nokogiri/xml_processing_instruction.h +0 -9
- data/ext/nokogiri/xml_reader.h +0 -10
- data/ext/nokogiri/xml_relax_ng.h +0 -9
- data/ext/nokogiri/xml_sax_parser.h +0 -39
- data/ext/nokogiri/xml_sax_parser_context.h +0 -10
- data/ext/nokogiri/xml_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_schema.h +0 -9
- data/ext/nokogiri/xml_syntax_error.h +0 -13
- data/ext/nokogiri/xml_text.h +0 -9
- data/ext/nokogiri/xml_xpath_context.h +0 -10
- data/ext/nokogiri/xslt_stylesheet.h +0 -14
- data/lib/nokogiri/2.4/nokogiri.so +0 -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
|
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -1,107 +1,184 @@
|
|
1
1
|
#include <nokogiri.h>
|
2
2
|
|
3
3
|
VALUE mNokogiri ;
|
4
|
-
VALUE mNokogiriXml ;
|
5
4
|
VALUE mNokogiriHtml ;
|
6
|
-
VALUE mNokogiriXslt ;
|
7
|
-
VALUE mNokogiriXmlSax ;
|
8
5
|
VALUE mNokogiriHtmlSax ;
|
6
|
+
VALUE mNokogiriXml ;
|
7
|
+
VALUE mNokogiriXmlSax ;
|
8
|
+
VALUE mNokogiriXmlXpath ;
|
9
|
+
VALUE mNokogiriXslt ;
|
9
10
|
|
10
|
-
|
11
|
+
VALUE cNokogiriSyntaxError;
|
12
|
+
VALUE cNokogiriXmlCharacterData;
|
13
|
+
VALUE cNokogiriXmlElement;
|
14
|
+
VALUE cNokogiriXmlXpathSyntaxError;
|
15
|
+
|
16
|
+
void noko_init_xml_attr();
|
17
|
+
void noko_init_xml_attribute_decl();
|
18
|
+
void noko_init_xml_cdata();
|
19
|
+
void noko_init_xml_comment();
|
20
|
+
void noko_init_xml_document();
|
21
|
+
void noko_init_xml_document_fragment();
|
22
|
+
void noko_init_xml_dtd();
|
23
|
+
void noko_init_xml_element_content();
|
24
|
+
void noko_init_xml_element_decl();
|
25
|
+
void noko_init_xml_encoding_handler();
|
26
|
+
void noko_init_xml_entity_decl();
|
27
|
+
void noko_init_xml_entity_reference();
|
28
|
+
void noko_init_xml_namespace();
|
29
|
+
void noko_init_xml_node();
|
30
|
+
void noko_init_xml_node_set();
|
31
|
+
void noko_init_xml_processing_instruction();
|
32
|
+
void noko_init_xml_reader();
|
33
|
+
void noko_init_xml_relax_ng();
|
34
|
+
void noko_init_xml_sax_parser();
|
35
|
+
void noko_init_xml_sax_parser_context();
|
36
|
+
void noko_init_xml_sax_push_parser();
|
37
|
+
void noko_init_xml_schema();
|
38
|
+
void noko_init_xml_syntax_error();
|
39
|
+
void noko_init_xml_text();
|
40
|
+
void noko_init_xml_xpath_context();
|
41
|
+
void noko_init_xslt_stylesheet();
|
42
|
+
void noko_init_html_document();
|
43
|
+
void noko_init_html_element_description();
|
44
|
+
void noko_init_html_entity_lookup();
|
45
|
+
void noko_init_html_sax_parser_context();
|
46
|
+
void noko_init_html_sax_push_parser();
|
47
|
+
void noko_init_test_global_handlers();
|
48
|
+
|
49
|
+
static ID id_read, id_write;
|
50
|
+
|
51
|
+
|
52
|
+
#ifndef HAVE_VASPRINTF
|
11
53
|
/*
|
12
|
-
* I srsly hate windows. it doesn't have vasprintf.
|
13
54
|
* Thank you Geoffroy Couprie for this implementation of vasprintf!
|
14
55
|
*/
|
15
|
-
int
|
56
|
+
int
|
57
|
+
vasprintf(char **strp, const char *fmt, va_list ap)
|
16
58
|
{
|
17
59
|
/* Mingw32/64 have a broken vsnprintf implementation that fails when
|
18
60
|
* using a zero-byte limit in order to retrieve the required size for malloc.
|
19
61
|
* So we use a one byte buffer instead.
|
20
62
|
*/
|
21
63
|
char tmp[1];
|
22
|
-
int len = vsnprintf
|
64
|
+
int len = vsnprintf(tmp, 1, fmt, ap) + 1;
|
23
65
|
char *res = (char *)malloc((unsigned int)len);
|
24
|
-
if (res == NULL)
|
25
|
-
|
66
|
+
if (res == NULL) {
|
67
|
+
return -1;
|
68
|
+
}
|
26
69
|
*strp = res;
|
27
70
|
return vsnprintf(res, (unsigned int)len, fmt, ap);
|
28
71
|
}
|
29
72
|
#endif
|
30
73
|
|
31
|
-
|
74
|
+
|
75
|
+
static VALUE
|
76
|
+
read_check(VALUE val)
|
32
77
|
{
|
33
|
-
|
78
|
+
VALUE *args = (VALUE *)val;
|
79
|
+
return rb_funcall(args[0], id_read, 1, args[1]);
|
34
80
|
}
|
35
81
|
|
36
|
-
#ifdef HAVE_RUBY_UTIL_H
|
37
|
-
#include "ruby/util.h"
|
38
|
-
#else
|
39
|
-
#include "util.h"
|
40
|
-
#endif
|
41
82
|
|
42
|
-
|
83
|
+
static VALUE
|
84
|
+
read_failed(VALUE arg, VALUE exc)
|
85
|
+
{
|
86
|
+
return Qundef;
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
int
|
91
|
+
noko_io_read(void *ctx, char *buffer, int len)
|
92
|
+
{
|
93
|
+
VALUE string, args[2];
|
94
|
+
size_t str_len, safe_len;
|
95
|
+
|
96
|
+
args[0] = (VALUE)ctx;
|
97
|
+
args[1] = INT2NUM(len);
|
98
|
+
|
99
|
+
string = rb_rescue(read_check, (VALUE)args, read_failed, 0);
|
100
|
+
|
101
|
+
if (NIL_P(string)) { return 0; }
|
102
|
+
if (string == Qundef) { return -1; }
|
103
|
+
if (TYPE(string) != T_STRING) { return -1; }
|
104
|
+
|
105
|
+
str_len = (size_t)RSTRING_LEN(string);
|
106
|
+
safe_len = str_len > (size_t)len ? (size_t)len : str_len;
|
107
|
+
memcpy(buffer, StringValuePtr(string), safe_len);
|
108
|
+
|
109
|
+
return (int)safe_len;
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
write_check(VALUE val)
|
43
115
|
{
|
44
|
-
|
45
|
-
|
116
|
+
VALUE *args = (VALUE *)val;
|
117
|
+
return rb_funcall(args[0], id_write, 1, args[1]);
|
118
|
+
}
|
46
119
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
120
|
+
|
121
|
+
static VALUE
|
122
|
+
write_failed(VALUE arg, VALUE exc)
|
123
|
+
{
|
124
|
+
return Qundef;
|
51
125
|
}
|
52
126
|
|
53
|
-
|
127
|
+
|
128
|
+
int
|
129
|
+
noko_io_write(void *ctx, char *buffer, int len)
|
54
130
|
{
|
55
|
-
|
131
|
+
VALUE args[2], size;
|
132
|
+
|
133
|
+
args[0] = (VALUE)ctx;
|
134
|
+
args[1] = rb_str_new(buffer, (long)len);
|
56
135
|
|
57
|
-
|
58
|
-
|
59
|
-
|
136
|
+
size = rb_rescue(write_check, (VALUE)args, write_failed, 0);
|
137
|
+
|
138
|
+
if (size == Qundef) { return -1; }
|
139
|
+
|
140
|
+
return NUM2INT(size);
|
60
141
|
}
|
61
142
|
|
62
|
-
|
143
|
+
|
144
|
+
int
|
145
|
+
noko_io_close(void *ctx)
|
63
146
|
{
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
(xmlReallocFunc)ruby_xrealloc,
|
68
|
-
ruby_strdup
|
69
|
-
);
|
147
|
+
return 0;
|
148
|
+
}
|
149
|
+
|
70
150
|
|
151
|
+
void
|
152
|
+
Init_nokogiri()
|
153
|
+
{
|
71
154
|
mNokogiri = rb_define_module("Nokogiri");
|
72
155
|
mNokogiriXml = rb_define_module_under(mNokogiri, "XML");
|
73
156
|
mNokogiriHtml = rb_define_module_under(mNokogiri, "HTML");
|
74
157
|
mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT");
|
158
|
+
mNokogiriXmlXpath = rb_define_module_under(mNokogiriXml, "XPath");
|
75
159
|
mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
|
76
160
|
mNokogiriHtmlSax = rb_define_module_under(mNokogiriHtml, "SAX");
|
77
161
|
|
78
|
-
rb_const_set(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
rb_const_set(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
rb_const_set(
|
93
|
-
rb_intern("LIBXSLT_LOADED_VERSION"),
|
94
|
-
NOKOGIRI_STR_NEW2(xsltEngineVersion)
|
95
|
-
);
|
96
|
-
|
97
|
-
#ifdef NOKOGIRI_USE_PACKAGED_LIBRARIES
|
98
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_USE_PACKAGED_LIBRARIES"), Qtrue);
|
99
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
100
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
162
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION));
|
163
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion));
|
164
|
+
|
165
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
166
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
167
|
+
|
168
|
+
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
169
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
170
|
+
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
171
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qtrue);
|
172
|
+
# else
|
173
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
174
|
+
# endif
|
175
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
176
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
101
177
|
#else
|
102
|
-
rb_const_set(mNokogiri, rb_intern("
|
103
|
-
rb_const_set(mNokogiri, rb_intern("
|
104
|
-
rb_const_set(mNokogiri, rb_intern("
|
178
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qfalse);
|
179
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
180
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), Qnil);
|
181
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), Qnil);
|
105
182
|
#endif
|
106
183
|
|
107
184
|
#ifdef LIBXML_ICONV_ENABLED
|
@@ -110,38 +187,60 @@ void Init_nokogiri()
|
|
110
187
|
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
111
188
|
#endif
|
112
189
|
|
190
|
+
#ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
|
191
|
+
rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
|
192
|
+
#endif
|
193
|
+
|
194
|
+
xmlMemSetup((xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, ruby_strdup);
|
195
|
+
|
113
196
|
xmlInitParser();
|
114
197
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
198
|
+
cNokogiriSyntaxError = rb_define_class_under(mNokogiri, "SyntaxError", rb_eStandardError);
|
199
|
+
noko_init_xml_syntax_error();
|
200
|
+
assert(cNokogiriXmlSyntaxError);
|
201
|
+
cNokogiriXmlXpathSyntaxError = rb_define_class_under(mNokogiriXmlXpath, "SyntaxError", cNokogiriXmlSyntaxError);
|
202
|
+
|
203
|
+
noko_init_xml_element_content();
|
204
|
+
noko_init_xml_encoding_handler();
|
205
|
+
noko_init_xml_namespace();
|
206
|
+
noko_init_xml_node_set();
|
207
|
+
noko_init_xml_reader();
|
208
|
+
noko_init_xml_sax_parser();
|
209
|
+
noko_init_xml_xpath_context();
|
210
|
+
noko_init_xslt_stylesheet();
|
211
|
+
noko_init_html_element_description();
|
212
|
+
noko_init_html_entity_lookup();
|
213
|
+
|
214
|
+
noko_init_xml_schema();
|
215
|
+
noko_init_xml_relax_ng();
|
216
|
+
|
217
|
+
noko_init_xml_sax_parser_context();
|
218
|
+
noko_init_html_sax_parser_context();
|
219
|
+
|
220
|
+
noko_init_xml_sax_push_parser();
|
221
|
+
noko_init_html_sax_push_parser();
|
222
|
+
|
223
|
+
noko_init_xml_node();
|
224
|
+
noko_init_xml_attr();
|
225
|
+
noko_init_xml_attribute_decl();
|
226
|
+
noko_init_xml_dtd();
|
227
|
+
noko_init_xml_element_decl();
|
228
|
+
noko_init_xml_entity_decl();
|
229
|
+
noko_init_xml_entity_reference();
|
230
|
+
noko_init_xml_processing_instruction();
|
231
|
+
assert(cNokogiriXmlNode);
|
232
|
+
cNokogiriXmlElement = rb_define_class_under(mNokogiriXml, "Element", cNokogiriXmlNode);
|
233
|
+
cNokogiriXmlCharacterData = rb_define_class_under(mNokogiriXml, "CharacterData", cNokogiriXmlNode);
|
234
|
+
noko_init_xml_comment();
|
235
|
+
noko_init_xml_text();
|
236
|
+
noko_init_xml_cdata();
|
237
|
+
|
238
|
+
noko_init_xml_document_fragment();
|
239
|
+
noko_init_xml_document();
|
240
|
+
noko_init_html_document();
|
241
|
+
|
242
|
+
noko_init_test_global_handlers();
|
243
|
+
|
244
|
+
id_read = rb_intern("read");
|
245
|
+
id_write = rb_intern("write");
|
147
246
|
}
|