nokogiri 1.11.0.rc3-x86-linux → 1.11.3-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 +168 -91
- 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 +246 -188
- 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 +371 -320
- 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 +3 -7
- 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 +3 -3
- 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 -149
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +205 -0
- data/lib/nokogiri/xml/document.rb +91 -35
- data/lib/nokogiri/xml/document_fragment.rb +4 -6
- data/lib/nokogiri/xml/node.rb +89 -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 +150 -171
- 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 -63
- 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
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -2,37 +2,39 @@
|
|
2
2
|
#define NOKOGIRI_NATIVE
|
3
3
|
|
4
4
|
#if _MSC_VER
|
5
|
-
#ifndef WIN32_LEAN_AND_MEAN
|
6
|
-
#define WIN32_LEAN_AND_MEAN
|
7
|
-
#endif /* WIN32_LEAN_AND_MEAN */
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
#include <
|
5
|
+
# ifndef WIN32_LEAN_AND_MEAN
|
6
|
+
# define WIN32_LEAN_AND_MEAN
|
7
|
+
# endif /* WIN32_LEAN_AND_MEAN */
|
8
|
+
|
9
|
+
# ifndef WIN32
|
10
|
+
# define WIN32
|
11
|
+
# endif /* WIN32 */
|
12
|
+
|
13
|
+
# include <winsock2.h>
|
14
|
+
# include <ws2tcpip.h>
|
15
|
+
# include <windows.h>
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#if _WIN32
|
19
|
+
# define NOKOPUBFUN __declspec(dllexport)
|
20
|
+
# define NOKOPUBVAR __declspec(dllexport) extern
|
21
|
+
#else
|
22
|
+
# define NOKOPUBFUN
|
23
|
+
# define NOKOPUBVAR extern
|
14
24
|
#endif
|
15
25
|
|
26
|
+
|
16
27
|
#include <stdlib.h>
|
17
28
|
#include <string.h>
|
18
29
|
#include <assert.h>
|
19
30
|
#include <stdarg.h>
|
31
|
+
#include <stdio.h>
|
20
32
|
|
21
|
-
#ifdef USE_INCLUDED_VASPRINTF
|
22
|
-
int vasprintf (char **strp, const char *fmt, va_list ap);
|
23
|
-
#else
|
24
|
-
|
25
|
-
#define _GNU_SOURCE
|
26
|
-
# include <stdio.h>
|
27
|
-
#undef _GNU_SOURCE
|
28
|
-
|
29
|
-
#endif
|
30
33
|
|
31
34
|
#include <libxml/parser.h>
|
35
|
+
#include <libxml/tree.h>
|
32
36
|
#include <libxml/entities.h>
|
33
|
-
#include <libxml/parserInternals.h>
|
34
37
|
#include <libxml/xpath.h>
|
35
|
-
#include <libxml/xpathInternals.h>
|
36
38
|
#include <libxml/xmlreader.h>
|
37
39
|
#include <libxml/xmlsave.h>
|
38
40
|
#include <libxml/xmlschemas.h>
|
@@ -40,95 +42,172 @@ int vasprintf (char **strp, const char *fmt, va_list ap);
|
|
40
42
|
#include <libxml/HTMLtree.h>
|
41
43
|
#include <libxml/relaxng.h>
|
42
44
|
#include <libxml/xinclude.h>
|
45
|
+
#include <libxml/c14n.h>
|
46
|
+
#include <libxml/parserInternals.h>
|
47
|
+
#include <libxml/xpathInternals.h>
|
48
|
+
|
43
49
|
#include <libxslt/extensions.h>
|
44
50
|
#include <libxslt/xsltconfig.h>
|
45
|
-
#include <
|
46
|
-
#include <
|
47
|
-
#include <
|
48
|
-
#include <ruby/encoding.h>
|
51
|
+
#include <libxslt/xsltutils.h>
|
52
|
+
#include <libxslt/transform.h>
|
53
|
+
#include <libxslt/xsltInternals.h>
|
49
54
|
|
50
|
-
#
|
51
|
-
# if defined(__GNUC__)
|
52
|
-
# define NORETURN(name) __attribute__((noreturn)) name
|
53
|
-
# else
|
54
|
-
# define NORETURN(name) name
|
55
|
-
# endif
|
56
|
-
#endif
|
55
|
+
#include <libexslt/exslt.h>
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
#define RBSTR_OR_QNIL(_str) \
|
65
|
-
(_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
66
|
-
|
67
|
-
#include <xml_libxml2_hacks.h>
|
68
|
-
|
69
|
-
#include <xml_io.h>
|
70
|
-
#include <xml_document.h>
|
71
|
-
#include <html_entity_lookup.h>
|
72
|
-
#include <html_document.h>
|
73
|
-
#include <xml_node.h>
|
74
|
-
#include <xml_text.h>
|
75
|
-
#include <xml_cdata.h>
|
76
|
-
#include <xml_attr.h>
|
77
|
-
#include <xml_processing_instruction.h>
|
78
|
-
#include <xml_entity_reference.h>
|
79
|
-
#include <xml_document_fragment.h>
|
80
|
-
#include <xml_comment.h>
|
81
|
-
#include <xml_node_set.h>
|
82
|
-
#include <xml_dtd.h>
|
83
|
-
#include <xml_attribute_decl.h>
|
84
|
-
#include <xml_element_decl.h>
|
85
|
-
#include <xml_entity_decl.h>
|
86
|
-
#include <xml_xpath_context.h>
|
87
|
-
#include <xml_element_content.h>
|
88
|
-
#include <xml_sax_parser_context.h>
|
89
|
-
#include <xml_sax_parser.h>
|
90
|
-
#include <xml_sax_push_parser.h>
|
91
|
-
#include <xml_reader.h>
|
92
|
-
#include <html_sax_parser_context.h>
|
93
|
-
#include <html_sax_push_parser.h>
|
94
|
-
#include <xslt_stylesheet.h>
|
95
|
-
#include <xml_syntax_error.h>
|
96
|
-
#include <xml_schema.h>
|
97
|
-
#include <xml_relax_ng.h>
|
98
|
-
#include <html_element_description.h>
|
99
|
-
#include <xml_namespace.h>
|
100
|
-
#include <xml_encoding_handler.h>
|
101
|
-
|
102
|
-
extern VALUE mNokogiri ;
|
103
|
-
extern VALUE mNokogiriXml ;
|
104
|
-
extern VALUE mNokogiriXmlSax ;
|
105
|
-
extern VALUE mNokogiriHtml ;
|
106
|
-
extern VALUE mNokogiriHtmlSax ;
|
107
|
-
extern VALUE mNokogiriXslt ;
|
108
|
-
|
109
|
-
void nokogiri_root_node(xmlNodePtr);
|
110
|
-
void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr);
|
57
|
+
/* libxml2_backwards_compat.c */
|
58
|
+
#ifndef HAVE_XMLFIRSTELEMENTCHILD
|
59
|
+
xmlNodePtr xmlFirstElementChild(xmlNodePtr parent);
|
60
|
+
xmlNodePtr xmlNextElementSibling(xmlNodePtr node);
|
61
|
+
xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
|
62
|
+
#endif
|
111
63
|
|
112
|
-
#
|
64
|
+
#define XMLNS_PREFIX "xmlns"
|
65
|
+
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
|
113
66
|
|
114
|
-
#define NOKOGIRI_DEBUG_START(p) if (getenv("NOKOGIRI_NO_FREE")) return ; if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p start\n", __FILE__, __LINE__, p);
|
115
|
-
#define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p);
|
116
67
|
|
117
|
-
#
|
68
|
+
#include <ruby.h>
|
69
|
+
#include <ruby/st.h>
|
70
|
+
#include <ruby/encoding.h>
|
71
|
+
#include <ruby/util.h>
|
118
72
|
|
119
|
-
#define
|
120
|
-
#define
|
73
|
+
#define NOKOGIRI_STR_NEW2(str) NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
|
74
|
+
#define NOKOGIRI_STR_NEW(str, len) rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
|
75
|
+
#define RBSTR_OR_QNIL(_str) (_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
121
76
|
|
77
|
+
#ifdef DEBUG
|
78
|
+
# define NOKOGIRI_DEBUG_START(p) if (getenv("NOKOGIRI_NO_FREE")) return ; if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p start\n", __FILE__, __LINE__, p);
|
79
|
+
# define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p);
|
80
|
+
#else
|
81
|
+
# define NOKOGIRI_DEBUG_START(p)
|
82
|
+
# define NOKOGIRI_DEBUG_END(p)
|
122
83
|
#endif
|
123
84
|
|
124
|
-
#ifndef
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
85
|
+
#ifndef NORETURN
|
86
|
+
# if defined(__GNUC__)
|
87
|
+
# define NORETURN(name) __attribute__((noreturn)) name
|
88
|
+
# else
|
89
|
+
# define NORETURN(name) name
|
90
|
+
# endif
|
128
91
|
#endif
|
129
92
|
|
130
|
-
#define XMLNS_PREFIX "xmlns"
|
131
|
-
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
|
132
|
-
#define XMLNS_BUFFER_LEN 128
|
133
93
|
|
134
|
-
|
94
|
+
NOKOPUBVAR VALUE mNokogiri ;
|
95
|
+
NOKOPUBVAR VALUE mNokogiriHtml ;
|
96
|
+
NOKOPUBVAR VALUE mNokogiriHtmlSax ;
|
97
|
+
NOKOPUBVAR VALUE mNokogiriXml ;
|
98
|
+
NOKOPUBVAR VALUE mNokogiriXmlSax ;
|
99
|
+
NOKOPUBVAR VALUE mNokogiriXslt ;
|
100
|
+
|
101
|
+
NOKOPUBVAR VALUE cNokogiriSyntaxError;
|
102
|
+
NOKOPUBVAR VALUE cNokogiriXmlAttr;
|
103
|
+
NOKOPUBVAR VALUE cNokogiriXmlAttributeDecl;
|
104
|
+
NOKOPUBVAR VALUE cNokogiriXmlCData;
|
105
|
+
NOKOPUBVAR VALUE cNokogiriXmlCharacterData;
|
106
|
+
NOKOPUBVAR VALUE cNokogiriXmlComment;
|
107
|
+
NOKOPUBVAR VALUE cNokogiriXmlDocument ;
|
108
|
+
NOKOPUBVAR VALUE cNokogiriXmlDocumentFragment;
|
109
|
+
NOKOPUBVAR VALUE cNokogiriXmlDtd;
|
110
|
+
NOKOPUBVAR VALUE cNokogiriXmlElement ;
|
111
|
+
NOKOPUBVAR VALUE cNokogiriXmlElementContent;
|
112
|
+
NOKOPUBVAR VALUE cNokogiriXmlElementDecl;
|
113
|
+
NOKOPUBVAR VALUE cNokogiriXmlEntityDecl;
|
114
|
+
NOKOPUBVAR VALUE cNokogiriXmlEntityReference;
|
115
|
+
NOKOPUBVAR VALUE cNokogiriXmlNamespace ;
|
116
|
+
NOKOPUBVAR VALUE cNokogiriXmlNode ;
|
117
|
+
NOKOPUBVAR VALUE cNokogiriXmlNodeSet ;
|
118
|
+
NOKOPUBVAR VALUE cNokogiriXmlProcessingInstruction;
|
119
|
+
NOKOPUBVAR VALUE cNokogiriXmlReader;
|
120
|
+
NOKOPUBVAR VALUE cNokogiriXmlRelaxNG;
|
121
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxParser ;
|
122
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxParserContext;
|
123
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxPushParser ;
|
124
|
+
NOKOPUBVAR VALUE cNokogiriXmlSchema;
|
125
|
+
NOKOPUBVAR VALUE cNokogiriXmlSyntaxError;
|
126
|
+
NOKOPUBVAR VALUE cNokogiriXmlText ;
|
127
|
+
NOKOPUBVAR VALUE cNokogiriXmlXpathContext;
|
128
|
+
NOKOPUBVAR VALUE cNokogiriXmlXpathSyntaxError;
|
129
|
+
NOKOPUBVAR VALUE cNokogiriXsltStylesheet ;
|
130
|
+
|
131
|
+
NOKOPUBVAR VALUE cNokogiriHtmlDocument ;
|
132
|
+
NOKOPUBVAR VALUE cNokogiriHtmlSaxPushParser ;
|
133
|
+
NOKOPUBVAR VALUE cNokogiriHtmlElementDescription ;
|
134
|
+
NOKOPUBVAR VALUE cNokogiriHtmlSaxParserContext;
|
135
|
+
|
136
|
+
typedef struct _nokogiriTuple {
|
137
|
+
VALUE doc;
|
138
|
+
st_table *unlinkedNodes;
|
139
|
+
VALUE node_cache;
|
140
|
+
} nokogiriTuple;
|
141
|
+
typedef nokogiriTuple *nokogiriTuplePtr;
|
142
|
+
|
143
|
+
typedef struct _nokogiriSAXTuple {
|
144
|
+
xmlParserCtxtPtr ctxt;
|
145
|
+
VALUE self;
|
146
|
+
} nokogiriSAXTuple;
|
147
|
+
typedef nokogiriSAXTuple *nokogiriSAXTuplePtr;
|
148
|
+
|
149
|
+
typedef struct _libxmlStructuredErrorHandlerState {
|
150
|
+
void *user_data;
|
151
|
+
xmlStructuredErrorFunc handler;
|
152
|
+
} libxmlStructuredErrorHandlerState ;
|
153
|
+
|
154
|
+
typedef struct _nokogiriXsltStylesheetTuple {
|
155
|
+
xsltStylesheetPtr ss;
|
156
|
+
VALUE func_instances;
|
157
|
+
} nokogiriXsltStylesheetTuple;
|
158
|
+
|
159
|
+
int vasprintf(char **strp, const char *fmt, va_list ap);
|
160
|
+
void noko_xml_document_pin_node(xmlNodePtr);
|
161
|
+
void noko_xml_document_pin_namespace(xmlNsPtr, xmlDocPtr);
|
162
|
+
|
163
|
+
int noko_io_read(void *ctx, char *buffer, int len);
|
164
|
+
int noko_io_write(void *ctx, char *buffer, int len);
|
165
|
+
int noko_io_close(void *ctx);
|
166
|
+
|
167
|
+
VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ;
|
168
|
+
VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ;
|
169
|
+
VALUE noko_xml_node_attrs(xmlNodePtr node) ;
|
170
|
+
|
171
|
+
VALUE noko_xml_namespace_wrap(xmlNsPtr node, xmlDocPtr doc);
|
172
|
+
VALUE noko_xml_namespace_wrap_xpath_copy(xmlNsPtr node);
|
173
|
+
|
174
|
+
VALUE noko_xml_element_content_wrap(VALUE doc, xmlElementContentPtr element);
|
175
|
+
|
176
|
+
VALUE noko_xml_node_set_wrap(xmlNodeSetPtr node_set, VALUE document) ;
|
177
|
+
|
178
|
+
VALUE noko_xml_document_wrap_with_init_args(VALUE klass, xmlDocPtr doc, int argc, VALUE *argv);
|
179
|
+
VALUE noko_xml_document_wrap(VALUE klass, xmlDocPtr doc);
|
180
|
+
NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass, xmlDocPtr doc); /* deprecated. use noko_xml_document_wrap() instead. */
|
181
|
+
|
182
|
+
#define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
|
183
|
+
#define DOC_RUBY_OBJECT(x) (((nokogiriTuplePtr)(x->_private))->doc)
|
184
|
+
#define DOC_UNLINKED_NODE_HASH(x) (((nokogiriTuplePtr)(x->_private))->unlinkedNodes)
|
185
|
+
#define DOC_NODE_CACHE(x) (((nokogiriTuplePtr)(x->_private))->node_cache)
|
186
|
+
#define NOKOGIRI_NAMESPACE_EH(node) ((node)->type == XML_NAMESPACE_DECL)
|
187
|
+
|
188
|
+
#define NOKOGIRI_SAX_SELF(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->self
|
189
|
+
#define NOKOGIRI_SAX_CTXT(_ctxt) ((nokogiriSAXTuplePtr)(_ctxt))->ctxt
|
190
|
+
#define NOKOGIRI_SAX_TUPLE_NEW(_ctxt, _self) nokogiri_sax_tuple_new(_ctxt, _self)
|
191
|
+
#define NOKOGIRI_SAX_TUPLE_DESTROY(_tuple) free(_tuple)
|
192
|
+
|
193
|
+
void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
|
194
|
+
void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
|
195
|
+
xmlStructuredErrorFunc handler);
|
196
|
+
void Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
|
197
|
+
VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error);
|
198
|
+
void Nokogiri_error_array_pusher(void *ctx, xmlErrorPtr error);
|
199
|
+
NORETURN(void Nokogiri_error_raise(void *ctx, xmlErrorPtr error));
|
200
|
+
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
|
201
|
+
const char *function_name) ;
|
202
|
+
|
203
|
+
static inline
|
204
|
+
nokogiriSAXTuplePtr
|
205
|
+
nokogiri_sax_tuple_new(xmlParserCtxtPtr ctxt, VALUE self)
|
206
|
+
{
|
207
|
+
nokogiriSAXTuplePtr tuple = malloc(sizeof(nokogiriSAXTuple));
|
208
|
+
tuple->self = self;
|
209
|
+
tuple->ctxt = ctxt;
|
210
|
+
return tuple;
|
211
|
+
}
|
212
|
+
|
213
|
+
#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
|
+
}
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#include <
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlAttr;
|
2
4
|
|
3
5
|
/*
|
4
6
|
* call-seq:
|
@@ -7,7 +9,8 @@
|
|
7
9
|
* Set the value for this Attr to +content+. Use `nil` to remove the value
|
8
10
|
* (e.g., a HTML boolean attribute).
|
9
11
|
*/
|
10
|
-
static VALUE
|
12
|
+
static VALUE
|
13
|
+
set_value(VALUE self, VALUE content)
|
11
14
|
{
|
12
15
|
xmlAttrPtr attr;
|
13
16
|
xmlChar *value;
|
@@ -49,7 +52,8 @@ static VALUE set_value(VALUE self, VALUE content)
|
|
49
52
|
*
|
50
53
|
* Create a new Attr element on the +document+ with +name+
|
51
54
|
*/
|
52
|
-
static VALUE
|
55
|
+
static VALUE
|
56
|
+
new (int argc, VALUE *argv, VALUE klass)
|
53
57
|
{
|
54
58
|
xmlDocPtr xml_doc;
|
55
59
|
VALUE document;
|
@@ -72,9 +76,9 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
72
76
|
NULL
|
73
77
|
);
|
74
78
|
|
75
|
-
|
79
|
+
noko_xml_document_pin_node((xmlNodePtr)node);
|
76
80
|
|
77
|
-
rb_node =
|
81
|
+
rb_node = noko_xml_node_wrap(klass, (xmlNodePtr)node);
|
78
82
|
rb_obj_call_init(rb_node, argc, argv);
|
79
83
|
|
80
84
|
if (rb_block_given_p()) {
|
@@ -84,20 +88,16 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
84
88
|
return rb_node;
|
85
89
|
}
|
86
90
|
|
87
|
-
|
88
|
-
|
91
|
+
void
|
92
|
+
noko_init_xml_attr()
|
89
93
|
{
|
90
|
-
|
91
|
-
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
92
|
-
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
93
|
-
|
94
|
+
assert(cNokogiriXmlNode);
|
94
95
|
/*
|
95
96
|
* Attr represents a Attr node in an xml document.
|
96
97
|
*/
|
97
|
-
|
98
|
+
cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
|
98
99
|
|
99
|
-
cNokogiriXmlAttr
|
100
|
+
rb_define_singleton_method(cNokogiriXmlAttr, "new", new, -1);
|
100
101
|
|
101
|
-
|
102
|
-
rb_define_method(klass, "value=", set_value, 1);
|
102
|
+
rb_define_method(cNokogiriXmlAttr, "value=", set_value, 1);
|
103
103
|
}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
#include <
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlAttributeDecl;
|
2
4
|
|
3
5
|
/*
|
4
6
|
* call-seq:
|
@@ -6,7 +8,8 @@
|
|
6
8
|
*
|
7
9
|
* The attribute_type for this AttributeDecl
|
8
10
|
*/
|
9
|
-
static VALUE
|
11
|
+
static VALUE
|
12
|
+
attribute_type(VALUE self)
|
10
13
|
{
|
11
14
|
xmlAttributePtr node;
|
12
15
|
Data_Get_Struct(self, xmlAttribute, node);
|
@@ -19,12 +22,13 @@ static VALUE attribute_type(VALUE self)
|
|
19
22
|
*
|
20
23
|
* The default value
|
21
24
|
*/
|
22
|
-
static VALUE
|
25
|
+
static VALUE
|
26
|
+
default_value(VALUE self)
|
23
27
|
{
|
24
28
|
xmlAttributePtr node;
|
25
29
|
Data_Get_Struct(self, xmlAttribute, node);
|
26
30
|
|
27
|
-
if(node->defaultValue) return NOKOGIRI_STR_NEW2(node->defaultValue);
|
31
|
+
if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); }
|
28
32
|
return Qnil;
|
29
33
|
}
|
30
34
|
|
@@ -34,7 +38,8 @@ static VALUE default_value(VALUE self)
|
|
34
38
|
*
|
35
39
|
* An enumeration of possible values
|
36
40
|
*/
|
37
|
-
static VALUE
|
41
|
+
static VALUE
|
42
|
+
enumeration(VALUE self)
|
38
43
|
{
|
39
44
|
xmlAttributePtr node;
|
40
45
|
xmlEnumerationPtr enm;
|
@@ -45,7 +50,7 @@ static VALUE enumeration(VALUE self)
|
|
45
50
|
list = rb_ary_new();
|
46
51
|
enm = node->tree;
|
47
52
|
|
48
|
-
while(enm) {
|
53
|
+
while (enm) {
|
49
54
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
|
50
55
|
enm = enm->next;
|
51
56
|
}
|
@@ -53,18 +58,13 @@ static VALUE enumeration(VALUE self)
|
|
53
58
|
return list;
|
54
59
|
}
|
55
60
|
|
56
|
-
|
57
|
-
|
58
|
-
void init_xml_attribute_decl()
|
61
|
+
void
|
62
|
+
noko_init_xml_attribute_decl()
|
59
63
|
{
|
60
|
-
|
61
|
-
|
62
|
-
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
63
|
-
VALUE klass = rb_define_class_under(xml, "AttributeDecl", node);
|
64
|
-
|
65
|
-
cNokogiriXmlAttributeDecl = klass;
|
64
|
+
assert(cNokogiriXmlNode);
|
65
|
+
cNokogiriXmlAttributeDecl = rb_define_class_under(mNokogiriXml, "AttributeDecl", cNokogiriXmlNode);
|
66
66
|
|
67
|
-
rb_define_method(
|
68
|
-
rb_define_method(
|
69
|
-
rb_define_method(
|
67
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "attribute_type", attribute_type, 0);
|
68
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "default", default_value, 0);
|
69
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "enumeration", enumeration, 0);
|
70
70
|
}
|