Nokogiri_precompiled_aarch64_dedshit 1.14.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +44 -0
  3. data/LICENSE-DEPENDENCIES.md +2224 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +287 -0
  6. data/bin/nokogiri +131 -0
  7. data/dependencies.yml +41 -0
  8. data/ext/java/nokogiri/Html4Document.java +157 -0
  9. data/ext/java/nokogiri/Html4ElementDescription.java +133 -0
  10. data/ext/java/nokogiri/Html4EntityLookup.java +63 -0
  11. data/ext/java/nokogiri/Html4SaxParserContext.java +289 -0
  12. data/ext/java/nokogiri/Html4SaxPushParser.java +213 -0
  13. data/ext/java/nokogiri/NokogiriService.java +613 -0
  14. data/ext/java/nokogiri/XmlAttr.java +154 -0
  15. data/ext/java/nokogiri/XmlAttributeDecl.java +119 -0
  16. data/ext/java/nokogiri/XmlCdata.java +60 -0
  17. data/ext/java/nokogiri/XmlComment.java +77 -0
  18. data/ext/java/nokogiri/XmlDocument.java +705 -0
  19. data/ext/java/nokogiri/XmlDocumentFragment.java +163 -0
  20. data/ext/java/nokogiri/XmlDtd.java +516 -0
  21. data/ext/java/nokogiri/XmlElement.java +44 -0
  22. data/ext/java/nokogiri/XmlElementContent.java +412 -0
  23. data/ext/java/nokogiri/XmlElementDecl.java +148 -0
  24. data/ext/java/nokogiri/XmlEntityDecl.java +151 -0
  25. data/ext/java/nokogiri/XmlEntityReference.java +79 -0
  26. data/ext/java/nokogiri/XmlNamespace.java +193 -0
  27. data/ext/java/nokogiri/XmlNode.java +1938 -0
  28. data/ext/java/nokogiri/XmlNodeSet.java +463 -0
  29. data/ext/java/nokogiri/XmlProcessingInstruction.java +79 -0
  30. data/ext/java/nokogiri/XmlReader.java +615 -0
  31. data/ext/java/nokogiri/XmlRelaxng.java +133 -0
  32. data/ext/java/nokogiri/XmlSaxParserContext.java +329 -0
  33. data/ext/java/nokogiri/XmlSaxPushParser.java +288 -0
  34. data/ext/java/nokogiri/XmlSchema.java +423 -0
  35. data/ext/java/nokogiri/XmlSyntaxError.java +137 -0
  36. data/ext/java/nokogiri/XmlText.java +90 -0
  37. data/ext/java/nokogiri/XmlXpathContext.java +305 -0
  38. data/ext/java/nokogiri/XsltStylesheet.java +368 -0
  39. data/ext/java/nokogiri/internals/ClosedStreamException.java +13 -0
  40. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +252 -0
  41. data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +27 -0
  42. data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +178 -0
  43. data/ext/java/nokogiri/internals/NokogiriDomParser.java +99 -0
  44. data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +140 -0
  45. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +65 -0
  46. data/ext/java/nokogiri/internals/NokogiriHandler.java +339 -0
  47. data/ext/java/nokogiri/internals/NokogiriHelpers.java +817 -0
  48. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +228 -0
  49. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +110 -0
  50. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +86 -0
  51. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +107 -0
  52. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +62 -0
  53. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +165 -0
  54. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +50 -0
  55. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +37 -0
  56. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +70 -0
  57. data/ext/java/nokogiri/internals/ParserContext.java +262 -0
  58. data/ext/java/nokogiri/internals/ReaderNode.java +564 -0
  59. data/ext/java/nokogiri/internals/SaveContextVisitor.java +865 -0
  60. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +50 -0
  61. data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +174 -0
  62. data/ext/java/nokogiri/internals/XmlDeclHandler.java +11 -0
  63. data/ext/java/nokogiri/internals/XmlDomParserContext.java +265 -0
  64. data/ext/java/nokogiri/internals/XmlSaxParser.java +40 -0
  65. data/ext/java/nokogiri/internals/c14n/AttrCompare.java +122 -0
  66. data/ext/java/nokogiri/internals/c14n/C14nHelper.java +178 -0
  67. data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +43 -0
  68. data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +106 -0
  69. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +278 -0
  70. data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +664 -0
  71. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +45 -0
  72. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +45 -0
  73. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +388 -0
  74. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +308 -0
  75. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +47 -0
  76. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +51 -0
  77. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +51 -0
  78. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +50 -0
  79. data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +660 -0
  80. data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +194 -0
  81. data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +77 -0
  82. data/ext/java/nokogiri/internals/c14n/Constants.java +45 -0
  83. data/ext/java/nokogiri/internals/c14n/ElementProxy.java +325 -0
  84. data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +106 -0
  85. data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +86 -0
  86. data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +181 -0
  87. data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +87 -0
  88. data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +452 -0
  89. data/ext/java/nokogiri/internals/c14n/NodeFilter.java +52 -0
  90. data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +190 -0
  91. data/ext/java/nokogiri/internals/c14n/XMLUtils.java +540 -0
  92. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1712 -0
  93. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +737 -0
  94. data/ext/nokogiri/depend +38 -0
  95. data/ext/nokogiri/extconf.rb +1086 -0
  96. data/ext/nokogiri/gumbo.c +594 -0
  97. data/ext/nokogiri/html4_document.c +167 -0
  98. data/ext/nokogiri/html4_element_description.c +294 -0
  99. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  100. data/ext/nokogiri/html4_sax_parser_context.c +116 -0
  101. data/ext/nokogiri/html4_sax_push_parser.c +95 -0
  102. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  103. data/ext/nokogiri/nokogiri.c +265 -0
  104. data/ext/nokogiri/nokogiri.h +235 -0
  105. data/ext/nokogiri/test_global_handlers.c +42 -0
  106. data/ext/nokogiri/xml_attr.c +103 -0
  107. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  108. data/ext/nokogiri/xml_cdata.c +57 -0
  109. data/ext/nokogiri/xml_comment.c +62 -0
  110. data/ext/nokogiri/xml_document.c +689 -0
  111. data/ext/nokogiri/xml_document_fragment.c +44 -0
  112. data/ext/nokogiri/xml_dtd.c +210 -0
  113. data/ext/nokogiri/xml_element_content.c +128 -0
  114. data/ext/nokogiri/xml_element_decl.c +69 -0
  115. data/ext/nokogiri/xml_encoding_handler.c +104 -0
  116. data/ext/nokogiri/xml_entity_decl.c +112 -0
  117. data/ext/nokogiri/xml_entity_reference.c +50 -0
  118. data/ext/nokogiri/xml_namespace.c +186 -0
  119. data/ext/nokogiri/xml_node.c +2426 -0
  120. data/ext/nokogiri/xml_node_set.c +496 -0
  121. data/ext/nokogiri/xml_processing_instruction.c +54 -0
  122. data/ext/nokogiri/xml_reader.c +794 -0
  123. data/ext/nokogiri/xml_relax_ng.c +164 -0
  124. data/ext/nokogiri/xml_sax_parser.c +316 -0
  125. data/ext/nokogiri/xml_sax_parser_context.c +283 -0
  126. data/ext/nokogiri/xml_sax_push_parser.c +166 -0
  127. data/ext/nokogiri/xml_schema.c +260 -0
  128. data/ext/nokogiri/xml_syntax_error.c +85 -0
  129. data/ext/nokogiri/xml_text.c +48 -0
  130. data/ext/nokogiri/xml_xpath_context.c +415 -0
  131. data/ext/nokogiri/xslt_stylesheet.c +363 -0
  132. data/gumbo-parser/CHANGES.md +63 -0
  133. data/gumbo-parser/Makefile +111 -0
  134. data/gumbo-parser/THANKS +27 -0
  135. data/gumbo-parser/src/Makefile +34 -0
  136. data/gumbo-parser/src/README.md +41 -0
  137. data/gumbo-parser/src/ascii.c +75 -0
  138. data/gumbo-parser/src/ascii.h +115 -0
  139. data/gumbo-parser/src/attribute.c +42 -0
  140. data/gumbo-parser/src/attribute.h +17 -0
  141. data/gumbo-parser/src/char_ref.c +22225 -0
  142. data/gumbo-parser/src/char_ref.h +29 -0
  143. data/gumbo-parser/src/char_ref.rl +2154 -0
  144. data/gumbo-parser/src/error.c +626 -0
  145. data/gumbo-parser/src/error.h +148 -0
  146. data/gumbo-parser/src/foreign_attrs.c +104 -0
  147. data/gumbo-parser/src/foreign_attrs.gperf +27 -0
  148. data/gumbo-parser/src/insertion_mode.h +33 -0
  149. data/gumbo-parser/src/macros.h +91 -0
  150. data/gumbo-parser/src/nokogiri_gumbo.h +944 -0
  151. data/gumbo-parser/src/parser.c +4878 -0
  152. data/gumbo-parser/src/parser.h +41 -0
  153. data/gumbo-parser/src/replacement.h +33 -0
  154. data/gumbo-parser/src/string_buffer.c +103 -0
  155. data/gumbo-parser/src/string_buffer.h +68 -0
  156. data/gumbo-parser/src/string_piece.c +48 -0
  157. data/gumbo-parser/src/svg_attrs.c +174 -0
  158. data/gumbo-parser/src/svg_attrs.gperf +77 -0
  159. data/gumbo-parser/src/svg_tags.c +137 -0
  160. data/gumbo-parser/src/svg_tags.gperf +55 -0
  161. data/gumbo-parser/src/tag.c +223 -0
  162. data/gumbo-parser/src/tag_lookup.c +382 -0
  163. data/gumbo-parser/src/tag_lookup.gperf +170 -0
  164. data/gumbo-parser/src/tag_lookup.h +13 -0
  165. data/gumbo-parser/src/token_buffer.c +79 -0
  166. data/gumbo-parser/src/token_buffer.h +71 -0
  167. data/gumbo-parser/src/token_type.h +17 -0
  168. data/gumbo-parser/src/tokenizer.c +3463 -0
  169. data/gumbo-parser/src/tokenizer.h +112 -0
  170. data/gumbo-parser/src/tokenizer_states.h +339 -0
  171. data/gumbo-parser/src/utf8.c +245 -0
  172. data/gumbo-parser/src/utf8.h +164 -0
  173. data/gumbo-parser/src/util.c +66 -0
  174. data/gumbo-parser/src/util.h +34 -0
  175. data/gumbo-parser/src/vector.c +111 -0
  176. data/gumbo-parser/src/vector.h +45 -0
  177. data/lib/nokogiri/class_resolver.rb +67 -0
  178. data/lib/nokogiri/css/node.rb +54 -0
  179. data/lib/nokogiri/css/parser.rb +770 -0
  180. data/lib/nokogiri/css/parser.y +277 -0
  181. data/lib/nokogiri/css/parser_extras.rb +96 -0
  182. data/lib/nokogiri/css/syntax_error.rb +9 -0
  183. data/lib/nokogiri/css/tokenizer.rb +155 -0
  184. data/lib/nokogiri/css/tokenizer.rex +56 -0
  185. data/lib/nokogiri/css/xpath_visitor.rb +359 -0
  186. data/lib/nokogiri/css.rb +66 -0
  187. data/lib/nokogiri/decorators/slop.rb +44 -0
  188. data/lib/nokogiri/encoding_handler.rb +57 -0
  189. data/lib/nokogiri/extension.rb +32 -0
  190. data/lib/nokogiri/gumbo.rb +15 -0
  191. data/lib/nokogiri/html.rb +48 -0
  192. data/lib/nokogiri/html4/builder.rb +37 -0
  193. data/lib/nokogiri/html4/document.rb +214 -0
  194. data/lib/nokogiri/html4/document_fragment.rb +54 -0
  195. data/lib/nokogiri/html4/element_description.rb +25 -0
  196. data/lib/nokogiri/html4/element_description_defaults.rb +572 -0
  197. data/lib/nokogiri/html4/encoding_reader.rb +121 -0
  198. data/lib/nokogiri/html4/entity_lookup.rb +15 -0
  199. data/lib/nokogiri/html4/sax/parser.rb +63 -0
  200. data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
  201. data/lib/nokogiri/html4/sax/push_parser.rb +37 -0
  202. data/lib/nokogiri/html4.rb +47 -0
  203. data/lib/nokogiri/html5/document.rb +168 -0
  204. data/lib/nokogiri/html5/document_fragment.rb +90 -0
  205. data/lib/nokogiri/html5/node.rb +98 -0
  206. data/lib/nokogiri/html5.rb +389 -0
  207. data/lib/nokogiri/jruby/dependencies.rb +3 -0
  208. data/lib/nokogiri/jruby/isorelax/isorelax/20030108/isorelax-20030108.jar +0 -0
  209. data/lib/nokogiri/jruby/net/sf/saxon/Saxon-HE/9.6.0-4/Saxon-HE-9.6.0-4.jar +0 -0
  210. data/lib/nokogiri/jruby/net/sourceforge/htmlunit/neko-htmlunit/2.63.0/neko-htmlunit-2.63.0.jar +0 -0
  211. data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
  212. data/lib/nokogiri/jruby/nu/validator/jing/20200702VNU/jing-20200702VNU.jar +0 -0
  213. data/lib/nokogiri/jruby/org/nokogiri/nekodtd/0.1.11.noko2/nekodtd-0.1.11.noko2.jar +0 -0
  214. data/lib/nokogiri/jruby/xalan/serializer/2.7.3/serializer-2.7.3.jar +0 -0
  215. data/lib/nokogiri/jruby/xalan/xalan/2.7.3/xalan-2.7.3.jar +0 -0
  216. data/lib/nokogiri/jruby/xerces/xercesImpl/2.12.2/xercesImpl-2.12.2.jar +0 -0
  217. data/lib/nokogiri/jruby/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar +0 -0
  218. data/lib/nokogiri/syntax_error.rb +6 -0
  219. data/lib/nokogiri/version/constant.rb +6 -0
  220. data/lib/nokogiri/version/info.rb +223 -0
  221. data/lib/nokogiri/version.rb +4 -0
  222. data/lib/nokogiri/xml/attr.rb +66 -0
  223. data/lib/nokogiri/xml/attribute_decl.rb +20 -0
  224. data/lib/nokogiri/xml/builder.rb +487 -0
  225. data/lib/nokogiri/xml/cdata.rb +13 -0
  226. data/lib/nokogiri/xml/character_data.rb +9 -0
  227. data/lib/nokogiri/xml/document.rb +471 -0
  228. data/lib/nokogiri/xml/document_fragment.rb +205 -0
  229. data/lib/nokogiri/xml/dtd.rb +34 -0
  230. data/lib/nokogiri/xml/element_content.rb +38 -0
  231. data/lib/nokogiri/xml/element_decl.rb +15 -0
  232. data/lib/nokogiri/xml/entity_decl.rb +21 -0
  233. data/lib/nokogiri/xml/entity_reference.rb +20 -0
  234. data/lib/nokogiri/xml/namespace.rb +58 -0
  235. data/lib/nokogiri/xml/node/save_options.rb +68 -0
  236. data/lib/nokogiri/xml/node.rb +1563 -0
  237. data/lib/nokogiri/xml/node_set.rb +447 -0
  238. data/lib/nokogiri/xml/notation.rb +19 -0
  239. data/lib/nokogiri/xml/parse_options.rb +213 -0
  240. data/lib/nokogiri/xml/pp/character_data.rb +21 -0
  241. data/lib/nokogiri/xml/pp/node.rb +57 -0
  242. data/lib/nokogiri/xml/pp.rb +4 -0
  243. data/lib/nokogiri/xml/processing_instruction.rb +11 -0
  244. data/lib/nokogiri/xml/reader.rb +105 -0
  245. data/lib/nokogiri/xml/relax_ng.rb +38 -0
  246. data/lib/nokogiri/xml/sax/document.rb +167 -0
  247. data/lib/nokogiri/xml/sax/parser.rb +125 -0
  248. data/lib/nokogiri/xml/sax/parser_context.rb +21 -0
  249. data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
  250. data/lib/nokogiri/xml/sax.rb +6 -0
  251. data/lib/nokogiri/xml/schema.rb +73 -0
  252. data/lib/nokogiri/xml/searchable.rb +270 -0
  253. data/lib/nokogiri/xml/syntax_error.rb +72 -0
  254. data/lib/nokogiri/xml/text.rb +11 -0
  255. data/lib/nokogiri/xml/xpath/syntax_error.rb +13 -0
  256. data/lib/nokogiri/xml/xpath.rb +21 -0
  257. data/lib/nokogiri/xml/xpath_context.rb +16 -0
  258. data/lib/nokogiri/xml.rb +76 -0
  259. data/lib/nokogiri/xslt/stylesheet.rb +27 -0
  260. data/lib/nokogiri/xslt.rb +65 -0
  261. data/lib/nokogiri.rb +120 -0
  262. data/lib/xsd/xmlparser/nokogiri.rb +106 -0
  263. metadata +391 -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,265 @@
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
+ VALUE rb_enc = Qnil;
116
+ rb_encoding *io_encoding;
117
+
118
+ if (rb_respond_to(rb_io, id_external_encoding)) {
119
+ rb_enc = rb_funcall(rb_io, id_external_encoding, 0);
120
+ }
121
+ io_encoding = RB_NIL_P(rb_enc) ? rb_ascii8bit_encoding() : rb_to_encoding(rb_enc);
122
+
123
+ rb_args[0] = rb_io;
124
+ rb_args[1] = rb_enc_str_new(c_buffer, (long)c_buffer_len, io_encoding);
125
+
126
+ rb_n_bytes_written = rb_rescue(noko_io_write_check, (VALUE)rb_args, noko_io_write_failed, 0);
127
+ if (rb_n_bytes_written == Qundef) { return -1; }
128
+
129
+ return NUM2INT(rb_n_bytes_written);
130
+ }
131
+
132
+
133
+ int
134
+ noko_io_close(void *io)
135
+ {
136
+ return 0;
137
+ }
138
+
139
+
140
+ void
141
+ Init_nokogiri(void)
142
+ {
143
+ mNokogiri = rb_define_module("Nokogiri");
144
+ mNokogiriGumbo = rb_define_module_under(mNokogiri, "Gumbo");
145
+ mNokogiriHtml4 = rb_define_module_under(mNokogiri, "HTML4");
146
+ mNokogiriHtml4Sax = rb_define_module_under(mNokogiriHtml4, "SAX");
147
+ mNokogiriHtml5 = rb_define_module_under(mNokogiri, "HTML5");
148
+ mNokogiriXml = rb_define_module_under(mNokogiri, "XML");
149
+ mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
150
+ mNokogiriXmlXpath = rb_define_module_under(mNokogiriXml, "XPath");
151
+ mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT");
152
+
153
+ rb_const_set(mNokogiri, rb_intern("LIBXML_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION));
154
+ rb_const_set(mNokogiri, rb_intern("LIBXML_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion));
155
+
156
+ rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
157
+ rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
158
+
159
+ #ifdef NOKOGIRI_PACKAGED_LIBRARIES
160
+ rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
161
+ # ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
162
+ rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qtrue);
163
+ # else
164
+ rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
165
+ # endif
166
+ rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
167
+ rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
168
+ #else
169
+ rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qfalse);
170
+ rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
171
+ rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), Qnil);
172
+ rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), Qnil);
173
+ #endif
174
+
175
+ #ifdef LIBXML_ICONV_ENABLED
176
+ rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue);
177
+ #else
178
+ rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
179
+ #endif
180
+
181
+ #ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
182
+ rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
183
+ #endif
184
+
185
+ #if defined(_WIN32) && !defined(NOKOGIRI_PACKAGED_LIBRARIES)
186
+ /*
187
+ * We choose *not* to do use Ruby's memory management functions with windows DLLs because of this
188
+ * issue in libxml 2.9.12:
189
+ *
190
+ * https://github.com/sparklemotion/nokogiri/issues/2241
191
+ *
192
+ * If the atexit() issue gets fixed in a future version of libxml2, then we may be able to skip
193
+ * this config only for the specific libxml2 versions 2.9.12.
194
+ *
195
+ * Alternatively, now that Ruby has a generational GC, it might be OK to let libxml2 use its
196
+ * default memory management functions (recall that this config was introduced to reduce memory
197
+ * bloat and allow Ruby to GC more often); but we should *really* test with production workloads
198
+ * before making that kind of a potentially-invasive change.
199
+ */
200
+ rb_const_set(mNokogiri, rb_intern("LIBXML_MEMORY_MANAGEMENT"), NOKOGIRI_STR_NEW2("default"));
201
+ #else
202
+ rb_const_set(mNokogiri, rb_intern("LIBXML_MEMORY_MANAGEMENT"), NOKOGIRI_STR_NEW2("ruby"));
203
+ xmlMemSetup((xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, ruby_strdup);
204
+ #endif
205
+
206
+ xmlInitParser();
207
+ exsltRegisterAll();
208
+
209
+ if (xsltExtModuleFunctionLookup((const xmlChar *)"date-time", EXSLT_DATE_NAMESPACE)) {
210
+ rb_const_set(mNokogiri, rb_intern("LIBXSLT_DATETIME_ENABLED"), Qtrue);
211
+ } else {
212
+ rb_const_set(mNokogiri, rb_intern("LIBXSLT_DATETIME_ENABLED"), Qfalse);
213
+ }
214
+
215
+ cNokogiriSyntaxError = rb_define_class_under(mNokogiri, "SyntaxError", rb_eStandardError);
216
+ noko_init_xml_syntax_error();
217
+ assert(cNokogiriXmlSyntaxError);
218
+ cNokogiriXmlXpathSyntaxError = rb_define_class_under(mNokogiriXmlXpath, "SyntaxError", cNokogiriXmlSyntaxError);
219
+
220
+ noko_init_xml_element_content();
221
+ noko_init_xml_encoding_handler();
222
+ noko_init_xml_namespace();
223
+ noko_init_xml_node_set();
224
+ noko_init_xml_reader();
225
+ noko_init_xml_sax_parser();
226
+ noko_init_xml_xpath_context();
227
+ noko_init_xslt_stylesheet();
228
+ noko_init_html_element_description();
229
+ noko_init_html_entity_lookup();
230
+
231
+ noko_init_xml_schema();
232
+ noko_init_xml_relax_ng();
233
+
234
+ noko_init_xml_sax_parser_context();
235
+ noko_init_html_sax_parser_context();
236
+
237
+ noko_init_xml_sax_push_parser();
238
+ noko_init_html_sax_push_parser();
239
+
240
+ noko_init_xml_node();
241
+ noko_init_xml_attr();
242
+ noko_init_xml_attribute_decl();
243
+ noko_init_xml_dtd();
244
+ noko_init_xml_element_decl();
245
+ noko_init_xml_entity_decl();
246
+ noko_init_xml_entity_reference();
247
+ noko_init_xml_processing_instruction();
248
+ assert(cNokogiriXmlNode);
249
+ cNokogiriXmlElement = rb_define_class_under(mNokogiriXml, "Element", cNokogiriXmlNode);
250
+ cNokogiriXmlCharacterData = rb_define_class_under(mNokogiriXml, "CharacterData", cNokogiriXmlNode);
251
+ noko_init_xml_comment();
252
+ noko_init_xml_text();
253
+ noko_init_xml_cdata();
254
+
255
+ noko_init_xml_document_fragment();
256
+ noko_init_xml_document();
257
+ noko_init_html_document();
258
+ noko_init_gumbo();
259
+
260
+ noko_init_test_global_handlers();
261
+
262
+ id_read = rb_intern("read");
263
+ id_write = rb_intern("write");
264
+ id_external_encoding = rb_intern("external_encoding");
265
+ }
@@ -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,42 @@
1
+ #include <nokogiri.h>
2
+
3
+ static VALUE foreign_error_handler_block = Qnil;
4
+ void xmlSetStructuredErrorFunc(void *aaa, void*bbb);
5
+
6
+
7
+ static void
8
+ foreign_error_handler(void *user_data, xmlErrorPtr c_error)
9
+ {
10
+ rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
11
+ }
12
+
13
+ /*
14
+ * call-seq:
15
+ * __foreign_error_handler { ... } -> nil
16
+ *
17
+ * Override libxml2's global error handlers to call the block. This method thus has very little
18
+ * value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See
19
+ * test/helper.rb for how this is being used.
20
+ */
21
+ static VALUE
22
+ rb_foreign_error_handler(VALUE klass)
23
+ {
24
+ rb_need_block();
25
+ foreign_error_handler_block = rb_block_proc();
26
+ xmlSetStructuredErrorFunc(NULL, foreign_error_handler);
27
+ return Qnil;
28
+ }
29
+
30
+ /*
31
+ * Document-module: Nokogiri::Test
32
+ *
33
+ * The Nokogiri::Test module should only be used for testing Nokogiri.
34
+ * Do NOT use this outside of the Nokogiri test suite.
35
+ */
36
+ void
37
+ noko_init_test_global_handlers(void)
38
+ {
39
+ VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
40
+
41
+ rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
42
+ }