nokogiri 1.11.1 → 1.12.0.rc1

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.

Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE-DEPENDENCIES.md +232 -11
  3. data/LICENSE.md +1 -1
  4. data/README.md +27 -21
  5. data/dependencies.yml +12 -12
  6. data/ext/nokogiri/depend +35 -474
  7. data/ext/nokogiri/extconf.rb +391 -243
  8. data/ext/nokogiri/gumbo.c +611 -0
  9. data/ext/nokogiri/{html_document.c → html4_document.c} +18 -23
  10. data/ext/nokogiri/html4_element_description.c +294 -0
  11. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  12. data/ext/nokogiri/html4_sax_parser_context.c +119 -0
  13. data/ext/nokogiri/{html_sax_push_parser.c → html4_sax_push_parser.c} +29 -27
  14. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  15. data/ext/nokogiri/nokogiri.c +206 -66
  16. data/ext/nokogiri/nokogiri.h +166 -76
  17. data/ext/nokogiri/test_global_handlers.c +3 -4
  18. data/ext/nokogiri/xml_attr.c +15 -15
  19. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  20. data/ext/nokogiri/xml_cdata.c +13 -18
  21. data/ext/nokogiri/xml_comment.c +19 -26
  22. data/ext/nokogiri/xml_document.c +258 -200
  23. data/ext/nokogiri/xml_document_fragment.c +13 -15
  24. data/ext/nokogiri/xml_dtd.c +54 -48
  25. data/ext/nokogiri/xml_element_content.c +31 -26
  26. data/ext/nokogiri/xml_element_decl.c +22 -22
  27. data/ext/nokogiri/xml_encoding_handler.c +28 -17
  28. data/ext/nokogiri/xml_entity_decl.c +32 -30
  29. data/ext/nokogiri/xml_entity_reference.c +16 -18
  30. data/ext/nokogiri/xml_namespace.c +58 -49
  31. data/ext/nokogiri/xml_node.c +473 -414
  32. data/ext/nokogiri/xml_node_set.c +174 -162
  33. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  34. data/ext/nokogiri/xml_reader.c +193 -157
  35. data/ext/nokogiri/xml_relax_ng.c +29 -23
  36. data/ext/nokogiri/xml_sax_parser.c +111 -106
  37. data/ext/nokogiri/xml_sax_parser_context.c +102 -85
  38. data/ext/nokogiri/xml_sax_push_parser.c +34 -27
  39. data/ext/nokogiri/xml_schema.c +49 -41
  40. data/ext/nokogiri/xml_syntax_error.c +21 -23
  41. data/ext/nokogiri/xml_text.c +13 -17
  42. data/ext/nokogiri/xml_xpath_context.c +86 -77
  43. data/ext/nokogiri/xslt_stylesheet.c +157 -156
  44. data/gumbo-parser/CHANGES.md +63 -0
  45. data/gumbo-parser/Makefile +101 -0
  46. data/gumbo-parser/THANKS +27 -0
  47. data/gumbo-parser/src/Makefile +17 -0
  48. data/gumbo-parser/src/README.md +41 -0
  49. data/gumbo-parser/src/ascii.c +75 -0
  50. data/gumbo-parser/src/ascii.h +115 -0
  51. data/gumbo-parser/src/attribute.c +42 -0
  52. data/gumbo-parser/src/attribute.h +17 -0
  53. data/gumbo-parser/src/char_ref.c +22225 -0
  54. data/gumbo-parser/src/char_ref.h +29 -0
  55. data/gumbo-parser/src/char_ref.rl +2154 -0
  56. data/gumbo-parser/src/error.c +626 -0
  57. data/gumbo-parser/src/error.h +148 -0
  58. data/gumbo-parser/src/foreign_attrs.c +104 -0
  59. data/gumbo-parser/src/foreign_attrs.gperf +27 -0
  60. data/gumbo-parser/src/gumbo.h +943 -0
  61. data/gumbo-parser/src/insertion_mode.h +33 -0
  62. data/gumbo-parser/src/macros.h +91 -0
  63. data/gumbo-parser/src/parser.c +4886 -0
  64. data/gumbo-parser/src/parser.h +41 -0
  65. data/gumbo-parser/src/replacement.h +33 -0
  66. data/gumbo-parser/src/string_buffer.c +103 -0
  67. data/gumbo-parser/src/string_buffer.h +68 -0
  68. data/gumbo-parser/src/string_piece.c +48 -0
  69. data/gumbo-parser/src/svg_attrs.c +174 -0
  70. data/gumbo-parser/src/svg_attrs.gperf +77 -0
  71. data/gumbo-parser/src/svg_tags.c +137 -0
  72. data/gumbo-parser/src/svg_tags.gperf +55 -0
  73. data/gumbo-parser/src/tag.c +222 -0
  74. data/gumbo-parser/src/tag_lookup.c +382 -0
  75. data/gumbo-parser/src/tag_lookup.gperf +169 -0
  76. data/gumbo-parser/src/tag_lookup.h +13 -0
  77. data/gumbo-parser/src/token_buffer.c +79 -0
  78. data/gumbo-parser/src/token_buffer.h +71 -0
  79. data/gumbo-parser/src/token_type.h +17 -0
  80. data/gumbo-parser/src/tokenizer.c +3463 -0
  81. data/gumbo-parser/src/tokenizer.h +112 -0
  82. data/gumbo-parser/src/tokenizer_states.h +339 -0
  83. data/gumbo-parser/src/utf8.c +245 -0
  84. data/gumbo-parser/src/utf8.h +164 -0
  85. data/gumbo-parser/src/util.c +68 -0
  86. data/gumbo-parser/src/util.h +30 -0
  87. data/gumbo-parser/src/vector.c +111 -0
  88. data/gumbo-parser/src/vector.h +45 -0
  89. data/lib/nokogiri.rb +31 -50
  90. data/lib/nokogiri/css.rb +14 -14
  91. data/lib/nokogiri/css/parser.rb +2 -2
  92. data/lib/nokogiri/css/parser.y +1 -1
  93. data/lib/nokogiri/css/syntax_error.rb +1 -1
  94. data/lib/nokogiri/extension.rb +26 -0
  95. data/lib/nokogiri/gumbo.rb +14 -0
  96. data/lib/nokogiri/html.rb +31 -27
  97. data/lib/nokogiri/html4.rb +40 -0
  98. data/lib/nokogiri/{html → html4}/builder.rb +2 -2
  99. data/lib/nokogiri/{html → html4}/document.rb +4 -4
  100. data/lib/nokogiri/{html → html4}/document_fragment.rb +17 -17
  101. data/lib/nokogiri/{html → html4}/element_description.rb +1 -1
  102. data/lib/nokogiri/{html → html4}/element_description_defaults.rb +1 -1
  103. data/lib/nokogiri/{html → html4}/entity_lookup.rb +1 -1
  104. data/lib/nokogiri/{html → html4}/sax/parser.rb +11 -14
  105. data/lib/nokogiri/html4/sax/parser_context.rb +19 -0
  106. data/lib/nokogiri/{html → html4}/sax/push_parser.rb +5 -5
  107. data/lib/nokogiri/html5.rb +473 -0
  108. data/lib/nokogiri/html5/document.rb +74 -0
  109. data/lib/nokogiri/html5/document_fragment.rb +80 -0
  110. data/lib/nokogiri/html5/node.rb +93 -0
  111. data/lib/nokogiri/version/constant.rb +1 -1
  112. data/lib/nokogiri/version/info.rb +42 -9
  113. data/lib/nokogiri/xml.rb +35 -36
  114. data/lib/nokogiri/xml/document.rb +74 -28
  115. data/lib/nokogiri/xml/node.rb +45 -47
  116. data/lib/nokogiri/xml/parse_options.rb +2 -0
  117. data/lib/nokogiri/xml/pp.rb +2 -2
  118. data/lib/nokogiri/xml/reader.rb +2 -9
  119. data/lib/nokogiri/xml/sax.rb +4 -4
  120. data/lib/nokogiri/xml/sax/document.rb +24 -30
  121. data/lib/nokogiri/xml/xpath.rb +3 -5
  122. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  123. data/lib/nokogiri/xslt.rb +16 -16
  124. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  125. data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
  126. data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
  127. data/patches/libxml2/{0004-libxml2.la-is-in-top_builddir.patch → 0003-libxml2.la-is-in-top_builddir.patch} +1 -1
  128. data/patches/libxml2/{0008-use-glibc-strlen.patch → 0004-use-glibc-strlen.patch} +0 -0
  129. data/patches/libxml2/{0009-avoid-isnan-isinf.patch → 0005-avoid-isnan-isinf.patch} +4 -4
  130. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2511 -0
  131. data/patches/libxml2/0007-Fix-XPath-recursion-limit.patch +31 -0
  132. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
  133. data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +19 -0
  134. data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
  135. metadata +117 -109
  136. data/ext/nokogiri/html_document.h +0 -10
  137. data/ext/nokogiri/html_element_description.c +0 -279
  138. data/ext/nokogiri/html_element_description.h +0 -10
  139. data/ext/nokogiri/html_entity_lookup.c +0 -32
  140. data/ext/nokogiri/html_entity_lookup.h +0 -8
  141. data/ext/nokogiri/html_sax_parser_context.c +0 -118
  142. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  143. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  144. data/ext/nokogiri/xml_attr.h +0 -9
  145. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  146. data/ext/nokogiri/xml_cdata.h +0 -9
  147. data/ext/nokogiri/xml_comment.h +0 -9
  148. data/ext/nokogiri/xml_document.h +0 -23
  149. data/ext/nokogiri/xml_document_fragment.h +0 -10
  150. data/ext/nokogiri/xml_dtd.h +0 -10
  151. data/ext/nokogiri/xml_element_content.h +0 -10
  152. data/ext/nokogiri/xml_element_decl.h +0 -9
  153. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  154. data/ext/nokogiri/xml_entity_decl.h +0 -10
  155. data/ext/nokogiri/xml_entity_reference.h +0 -9
  156. data/ext/nokogiri/xml_io.c +0 -63
  157. data/ext/nokogiri/xml_io.h +0 -11
  158. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  159. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  160. data/ext/nokogiri/xml_namespace.h +0 -14
  161. data/ext/nokogiri/xml_node.h +0 -13
  162. data/ext/nokogiri/xml_node_set.h +0 -12
  163. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  164. data/ext/nokogiri/xml_reader.h +0 -10
  165. data/ext/nokogiri/xml_relax_ng.h +0 -9
  166. data/ext/nokogiri/xml_sax_parser.h +0 -39
  167. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  168. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  169. data/ext/nokogiri/xml_schema.h +0 -9
  170. data/ext/nokogiri/xml_syntax_error.h +0 -25
  171. data/ext/nokogiri/xml_text.h +0 -9
  172. data/ext/nokogiri/xml_xpath_context.h +0 -10
  173. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  174. data/lib/nokogiri/html/sax/parser_context.rb +0 -17
  175. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  176. data/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch +0 -32
  177. data/patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch +0 -73
  178. data/patches/libxml2/0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch +0 -103
  179. data/ports/archives/libxml2-2.9.10.tar.gz +0 -0
@@ -1,10 +0,0 @@
1
- #ifndef NOKOGIRI_HTML_ELEMENT_DESCRIPTION
2
- #define NOKOGIRI_HTML_ELEMENT_DESCRIPTION
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_html_element_description();
7
-
8
- extern VALUE cNokogiriHtmlElementDescription ;
9
-
10
- #endif
@@ -1,32 +0,0 @@
1
- #include <html_entity_lookup.h>
2
-
3
- /*
4
- * call-seq:
5
- * get(key)
6
- *
7
- * Get the HTML::EntityDescription for +key+
8
- */
9
- static VALUE get(VALUE self, VALUE key)
10
- {
11
- const htmlEntityDesc * desc =
12
- htmlEntityLookup((const xmlChar *)StringValueCStr(key));
13
- VALUE klass, args[3];
14
-
15
- if(NULL == desc) return Qnil;
16
- klass = rb_const_get(mNokogiriHtml, rb_intern("EntityDescription"));
17
-
18
- args[0] = INT2NUM((long)desc->value);
19
- args[1] = NOKOGIRI_STR_NEW2(desc->name);
20
- args[2] = NOKOGIRI_STR_NEW2(desc->desc);
21
-
22
- return rb_class_new_instance(3, args, klass);
23
- }
24
-
25
- void init_html_entity_lookup()
26
- {
27
- VALUE nokogiri = rb_define_module("Nokogiri");
28
- VALUE html = rb_define_module_under(nokogiri, "HTML");
29
- VALUE klass = rb_define_class_under(html, "EntityLookup", rb_cObject);
30
-
31
- rb_define_method(klass, "get", get, 1);
32
- }
@@ -1,8 +0,0 @@
1
- #ifndef NOKOGIRI_HTML_ENTITY_LOOKUP
2
- #define NOKOGIRI_HTML_ENTITY_LOOKUP
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_html_entity_lookup();
7
-
8
- #endif
@@ -1,118 +0,0 @@
1
- #include <html_sax_parser_context.h>
2
-
3
- VALUE cNokogiriHtmlSaxParserContext ;
4
-
5
- static void deallocate(xmlParserCtxtPtr ctxt)
6
- {
7
- NOKOGIRI_DEBUG_START(ctxt);
8
-
9
- ctxt->sax = NULL;
10
-
11
- htmlFreeParserCtxt(ctxt);
12
-
13
- NOKOGIRI_DEBUG_END(ctxt);
14
- }
15
-
16
- static VALUE
17
- parse_memory(VALUE klass, VALUE data, VALUE encoding)
18
- {
19
- htmlParserCtxtPtr ctxt;
20
-
21
- if (NIL_P(data))
22
- rb_raise(rb_eArgError, "data cannot be nil");
23
- if (!(int)RSTRING_LEN(data))
24
- rb_raise(rb_eRuntimeError, "data cannot be empty");
25
-
26
- ctxt = htmlCreateMemoryParserCtxt(StringValuePtr(data),
27
- (int)RSTRING_LEN(data));
28
- if (ctxt->sax) {
29
- xmlFree(ctxt->sax);
30
- ctxt->sax = NULL;
31
- }
32
-
33
- if (RTEST(encoding)) {
34
- xmlCharEncodingHandlerPtr enc = xmlFindCharEncodingHandler(StringValueCStr(encoding));
35
- if (enc != NULL) {
36
- xmlSwitchToEncoding(ctxt, enc);
37
- if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
38
- rb_raise(rb_eRuntimeError, "Unsupported encoding %s",
39
- StringValueCStr(encoding));
40
- }
41
- }
42
- }
43
-
44
- return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
45
- }
46
-
47
- static VALUE parse_file(VALUE klass, VALUE filename, VALUE encoding)
48
- {
49
- htmlParserCtxtPtr ctxt = htmlCreateFileParserCtxt(
50
- StringValueCStr(filename),
51
- StringValueCStr(encoding)
52
- );
53
- return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
54
- }
55
-
56
- static VALUE
57
- parse_doc(VALUE ctxt_val)
58
- {
59
- htmlParserCtxtPtr ctxt = (htmlParserCtxtPtr)ctxt_val;
60
- htmlParseDocument(ctxt);
61
- return Qnil;
62
- }
63
-
64
- static VALUE
65
- parse_doc_finalize(VALUE ctxt_val)
66
- {
67
- htmlParserCtxtPtr ctxt = (htmlParserCtxtPtr)ctxt_val;
68
-
69
- if (ctxt->myDoc)
70
- xmlFreeDoc(ctxt->myDoc);
71
-
72
- NOKOGIRI_SAX_TUPLE_DESTROY(ctxt->userData);
73
- return Qnil;
74
- }
75
-
76
- static VALUE
77
- parse_with(VALUE self, VALUE sax_handler)
78
- {
79
- htmlParserCtxtPtr ctxt;
80
- htmlSAXHandlerPtr sax;
81
-
82
- if (!rb_obj_is_kind_of(sax_handler, cNokogiriXmlSaxParser))
83
- rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::SAX::Parser");
84
-
85
- Data_Get_Struct(self, htmlParserCtxt, ctxt);
86
- Data_Get_Struct(sax_handler, htmlSAXHandler, sax);
87
-
88
- /* Free the sax handler since we'll assign our own */
89
- if (ctxt->sax && ctxt->sax != (xmlSAXHandlerPtr)&xmlDefaultSAXHandler)
90
- xmlFree(ctxt->sax);
91
-
92
- ctxt->sax = sax;
93
- ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
94
-
95
- xmlSetStructuredErrorFunc(NULL, NULL);
96
-
97
- rb_ensure(parse_doc, (VALUE)ctxt, parse_doc_finalize, (VALUE)ctxt);
98
-
99
- return self;
100
- }
101
-
102
- void init_html_sax_parser_context()
103
- {
104
- VALUE nokogiri = rb_define_module("Nokogiri");
105
- VALUE xml = rb_define_module_under(nokogiri, "XML");
106
- VALUE html = rb_define_module_under(nokogiri, "HTML");
107
- VALUE sax = rb_define_module_under(xml, "SAX");
108
- VALUE hsax = rb_define_module_under(html, "SAX");
109
- VALUE pc = rb_define_class_under(sax, "ParserContext", rb_cObject);
110
- VALUE klass = rb_define_class_under(hsax, "ParserContext", pc);
111
-
112
- cNokogiriHtmlSaxParserContext = klass;
113
-
114
- rb_define_singleton_method(klass, "memory", parse_memory, 2);
115
- rb_define_singleton_method(klass, "file", parse_file, 2);
116
-
117
- rb_define_method(klass, "parse_with", parse_with, 1);
118
- }
@@ -1,11 +0,0 @@
1
- #ifndef NOKOGIRI_HTML_SAX_PARSER_CONTEXT
2
- #define NOKOGIRI_HTML_SAX_PARSER_CONTEXT
3
-
4
- #include <nokogiri.h>
5
-
6
- extern VALUE cNokogiriHtmlSaxParserContext;
7
-
8
- void init_html_sax_parser_context();
9
-
10
- #endif
11
-
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_HTML_SAX_PUSH_PARSER
2
- #define NOKOGIRI_HTML_SAX_PUSH_PARSER
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_html_sax_push_parser();
7
-
8
- extern VALUE cNokogiriHtmlSaxPushParser ;
9
- #endif
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ATTR
2
- #define NOKOGIRI_XML_ATTR
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_attr();
7
-
8
- extern VALUE cNokogiriXmlAttr;
9
- #endif
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ATTRIBUTE_DECL
2
- #define NOKOGIRI_XML_ATTRIBUTE_DECL
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_attribute_decl();
7
-
8
- extern VALUE cNokogiriXmlAttributeDecl;
9
- #endif
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_XML_CDATA
2
- #define NOKOGIRI_XML_CDATA
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_cdata();
7
-
8
- extern VALUE cNokogiriXmlCData;
9
- #endif
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_XML_COMMENT
2
- #define NOKOGIRI_XML_COMMENT
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_comment();
7
-
8
- extern VALUE cNokogiriXmlComment;
9
- #endif
@@ -1,23 +0,0 @@
1
- #ifndef NOKOGIRI_XML_DOCUMENT
2
- #define NOKOGIRI_XML_DOCUMENT
3
-
4
- #include <nokogiri.h>
5
-
6
- struct _nokogiriTuple {
7
- VALUE doc;
8
- st_table *unlinkedNodes;
9
- VALUE node_cache;
10
- };
11
- typedef struct _nokogiriTuple nokogiriTuple;
12
- typedef nokogiriTuple * nokogiriTuplePtr;
13
-
14
- void init_xml_document();
15
- VALUE Nokogiri_wrap_xml_document(VALUE klass, xmlDocPtr doc);
16
-
17
- #define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
18
- #define DOC_RUBY_OBJECT(x) (((nokogiriTuplePtr)(x->_private))->doc)
19
- #define DOC_UNLINKED_NODE_HASH(x) (((nokogiriTuplePtr)(x->_private))->unlinkedNodes)
20
- #define DOC_NODE_CACHE(x) (((nokogiriTuplePtr)(x->_private))->node_cache)
21
-
22
- extern VALUE cNokogiriXmlDocument ;
23
- #endif
@@ -1,10 +0,0 @@
1
- #ifndef NOKOGIRI_XML_DOCUMENT_FRAGMENT
2
- #define NOKOGIRI_XML_DOCUMENT_FRAGMENT
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_document_fragment();
7
-
8
- extern VALUE cNokogiriXmlDocumentFragment;
9
- #endif
10
-
@@ -1,10 +0,0 @@
1
- #ifndef NOKOGIRI_XML_DTD
2
- #define NOKOGIRI_XML_DTD
3
-
4
- #include <nokogiri.h>
5
-
6
- extern VALUE cNokogiriXmlDtd;
7
-
8
- void init_xml_dtd();
9
-
10
- #endif
@@ -1,10 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ELEMENT_CONTENT
2
- #define NOKOGIRI_XML_ELEMENT_CONTENT
3
-
4
- #include <nokogiri.h>
5
-
6
-
7
- VALUE Nokogiri_wrap_element_content(VALUE doc, xmlElementContentPtr element);
8
- void init_xml_element_content();
9
-
10
- #endif
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ELEMENT_DECL
2
- #define NOKOGIRI_XML_ELEMENT_DECL
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_element_decl();
7
-
8
- extern VALUE cNokogiriXmlElementDecl;
9
- #endif
@@ -1,8 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ENCODING_HANDLER
2
- #define NOKOGIRI_XML_ENCODING_HANDLER
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_encoding_handler();
7
-
8
- #endif
@@ -1,10 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ENTITY_DECL
2
- #define NOKOGIRI_XML_ENTITY_DECL
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_entity_decl();
7
-
8
- extern VALUE cNokogiriXmlEntityDecl;
9
- #endif
10
-
@@ -1,9 +0,0 @@
1
- #ifndef NOKOGIRI_XML_ENTITY_REFERENCE
2
- #define NOKOGIRI_XML_ENTITY_REFERENCE
3
-
4
- #include <nokogiri.h>
5
-
6
- void init_xml_entity_reference();
7
-
8
- extern VALUE cNokogiriXmlEntityReference;
9
- #endif
@@ -1,63 +0,0 @@
1
- #include <xml_io.h>
2
-
3
- static ID id_read, id_write;
4
-
5
- VALUE read_check(VALUE val) {
6
- VALUE *args = (VALUE *)val;
7
- return rb_funcall(args[0], id_read, 1, args[1]);
8
- }
9
-
10
- VALUE read_failed(VALUE arg, VALUE exc) {
11
- return Qundef;
12
- }
13
-
14
- int io_read_callback(void * ctx, char * buffer, int len) {
15
- VALUE string, args[2];
16
- size_t str_len, safe_len;
17
-
18
- args[0] = (VALUE)ctx;
19
- args[1] = INT2NUM(len);
20
-
21
- string = rb_rescue(read_check, (VALUE)args, read_failed, 0);
22
-
23
- if (NIL_P(string)) return 0;
24
- if (string == Qundef) return -1;
25
- if (TYPE(string) != T_STRING) return -1;
26
-
27
- str_len = (size_t)RSTRING_LEN(string);
28
- safe_len = str_len > (size_t)len ? (size_t)len : str_len;
29
- memcpy(buffer, StringValuePtr(string), safe_len);
30
-
31
- return (int)safe_len;
32
- }
33
-
34
- VALUE write_check(VALUE val) {
35
- VALUE *args = (VALUE *)val;
36
- return rb_funcall(args[0], id_write, 1, args[1]);
37
- }
38
-
39
- VALUE write_failed(VALUE arg, VALUE exc) {
40
- return Qundef;
41
- }
42
-
43
- int io_write_callback(void * ctx, char * buffer, int len) {
44
- VALUE args[2], size;
45
-
46
- args[0] = (VALUE)ctx;
47
- args[1] = rb_str_new(buffer, (long)len);
48
-
49
- size = rb_rescue(write_check, (VALUE)args, write_failed, 0);
50
-
51
- if (size == Qundef) return -1;
52
-
53
- return NUM2INT(size);
54
- }
55
-
56
- int io_close_callback(void * ctx) {
57
- return 0;
58
- }
59
-
60
- void init_nokogiri_io() {
61
- id_read = rb_intern("read");
62
- id_write = rb_intern("write");
63
- }
@@ -1,11 +0,0 @@
1
- #ifndef NOKOGIRI_XML_IO
2
- #define NOKOGIRI_XML_IO
3
-
4
- #include <nokogiri.h>
5
-
6
- int io_read_callback(void * ctx, char * buffer, int len);
7
- int io_write_callback(void * ctx, char * buffer, int len);
8
- int io_close_callback(void * ctx);
9
- void init_nokogiri_io();
10
-
11
- #endif
@@ -1,112 +0,0 @@
1
- #ifndef HAVE_XMLFIRSTELEMENTCHILD
2
- #include <libxml/tree.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
- xmlNodePtr cur = NULL;
17
-
18
- if (parent == NULL)
19
- return(NULL);
20
- switch (parent->type) {
21
- case XML_ELEMENT_NODE:
22
- case XML_ENTITY_NODE:
23
- case XML_DOCUMENT_NODE:
24
- case XML_HTML_DOCUMENT_NODE:
25
- cur = parent->children;
26
- break;
27
- default:
28
- return(NULL);
29
- }
30
- while (cur != NULL) {
31
- if (cur->type == XML_ELEMENT_NODE)
32
- return(cur);
33
- cur = cur->next;
34
- }
35
- return(NULL);
36
- }
37
-
38
- /**
39
- * xmlNextElementSibling:
40
- * @node: the current node
41
- *
42
- * Finds the first closest next sibling of the node which is an
43
- * element node.
44
- * Note the handling of entities references is different than in
45
- * the W3C DOM element traversal spec since we don't have back reference
46
- * from entities content to entities references.
47
- *
48
- * Returns the next element sibling or NULL if not available
49
- */
50
- xmlNodePtr
51
- xmlNextElementSibling(xmlNodePtr node) {
52
- if (node == NULL)
53
- return(NULL);
54
- switch (node->type) {
55
- case XML_ELEMENT_NODE:
56
- case XML_TEXT_NODE:
57
- case XML_CDATA_SECTION_NODE:
58
- case XML_ENTITY_REF_NODE:
59
- case XML_ENTITY_NODE:
60
- case XML_PI_NODE:
61
- case XML_COMMENT_NODE:
62
- case XML_DTD_NODE:
63
- case XML_XINCLUDE_START:
64
- case XML_XINCLUDE_END:
65
- node = node->next;
66
- break;
67
- default:
68
- return(NULL);
69
- }
70
- while (node != NULL) {
71
- if (node->type == XML_ELEMENT_NODE)
72
- return(node);
73
- node = node->next;
74
- }
75
- return(NULL);
76
- }
77
-
78
- /**
79
- * xmlLastElementChild:
80
- * @parent: the parent node
81
- *
82
- * Finds the last child node of that element which is a Element node
83
- * Note the handling of entities references is different than in
84
- * the W3C DOM element traversal spec since we don't have back reference
85
- * from entities content to entities references.
86
- *
87
- * Returns the last element child or NULL if not available
88
- */
89
- xmlNodePtr
90
- xmlLastElementChild(xmlNodePtr parent) {
91
- xmlNodePtr cur = NULL;
92
-
93
- if (parent == NULL)
94
- return(NULL);
95
- switch (parent->type) {
96
- case XML_ELEMENT_NODE:
97
- case XML_ENTITY_NODE:
98
- case XML_DOCUMENT_NODE:
99
- case XML_HTML_DOCUMENT_NODE:
100
- cur = parent->last;
101
- break;
102
- default:
103
- return(NULL);
104
- }
105
- while (cur != NULL) {
106
- if (cur->type == XML_ELEMENT_NODE)
107
- return(cur);
108
- cur = cur->prev;
109
- }
110
- return(NULL);
111
- }
112
- #endif