nokogiri 1.10.9-x86-mingw32 → 1.11.0.rc4-x86-mingw32
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/LICENSE-DEPENDENCIES.md +1015 -947
- data/README.md +24 -22
- data/ext/nokogiri/depend +476 -357
- data/ext/nokogiri/extconf.rb +485 -352
- data/ext/nokogiri/html_document.c +79 -78
- data/ext/nokogiri/html_sax_parser_context.c +2 -2
- 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/nokogiri.c +34 -40
- data/ext/nokogiri/nokogiri.h +26 -17
- data/ext/nokogiri/xml_document.c +18 -4
- data/ext/nokogiri/xml_io.c +8 -6
- data/ext/nokogiri/xml_node.c +21 -1
- data/ext/nokogiri/xml_node_set.c +1 -1
- data/ext/nokogiri/xml_reader.c +6 -17
- data/ext/nokogiri/xml_relax_ng.c +29 -11
- data/ext/nokogiri/xml_sax_parser.c +2 -7
- data/ext/nokogiri/xml_sax_parser_context.c +2 -2
- data/ext/nokogiri/xml_schema.c +55 -13
- data/ext/nokogiri/xml_xpath_context.c +80 -4
- data/ext/nokogiri/xslt_stylesheet.c +1 -8
- data/lib/nokogiri.rb +4 -21
- 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.rb +1 -0
- data/lib/nokogiri/css/node.rb +1 -0
- data/lib/nokogiri/css/parser.rb +63 -62
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/parser_extras.rb +39 -36
- data/lib/nokogiri/css/syntax_error.rb +1 -0
- data/lib/nokogiri/css/tokenizer.rb +1 -0
- data/lib/nokogiri/css/xpath_visitor.rb +73 -43
- data/lib/nokogiri/decorators/slop.rb +1 -0
- data/lib/nokogiri/html.rb +1 -0
- data/lib/nokogiri/html/builder.rb +1 -0
- data/lib/nokogiri/html/document.rb +13 -26
- data/lib/nokogiri/html/document_fragment.rb +1 -0
- data/lib/nokogiri/html/element_description.rb +1 -0
- data/lib/nokogiri/html/element_description_defaults.rb +1 -0
- data/lib/nokogiri/html/entity_lookup.rb +1 -0
- data/lib/nokogiri/html/sax/parser.rb +1 -0
- data/lib/nokogiri/html/sax/parser_context.rb +1 -0
- data/lib/nokogiri/html/sax/push_parser.rb +1 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +1 -0
- data/lib/nokogiri/version.rb +3 -109
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/xml.rb +1 -0
- data/lib/nokogiri/xml/attr.rb +1 -0
- data/lib/nokogiri/xml/attribute_decl.rb +1 -0
- data/lib/nokogiri/xml/builder.rb +3 -2
- data/lib/nokogiri/xml/cdata.rb +1 -0
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +20 -15
- data/lib/nokogiri/xml/document_fragment.rb +5 -6
- data/lib/nokogiri/xml/dtd.rb +1 -0
- data/lib/nokogiri/xml/element_content.rb +1 -0
- data/lib/nokogiri/xml/element_decl.rb +1 -0
- data/lib/nokogiri/xml/entity_decl.rb +1 -0
- data/lib/nokogiri/xml/entity_reference.rb +1 -0
- data/lib/nokogiri/xml/namespace.rb +1 -0
- data/lib/nokogiri/xml/node.rb +587 -249
- data/lib/nokogiri/xml/node/save_options.rb +1 -0
- data/lib/nokogiri/xml/node_set.rb +1 -0
- data/lib/nokogiri/xml/notation.rb +1 -0
- data/lib/nokogiri/xml/parse_options.rb +10 -3
- data/lib/nokogiri/xml/pp.rb +1 -0
- data/lib/nokogiri/xml/pp/character_data.rb +1 -0
- data/lib/nokogiri/xml/pp/node.rb +1 -0
- data/lib/nokogiri/xml/processing_instruction.rb +1 -0
- data/lib/nokogiri/xml/reader.rb +7 -3
- data/lib/nokogiri/xml/relax_ng.rb +7 -2
- data/lib/nokogiri/xml/sax.rb +1 -0
- data/lib/nokogiri/xml/sax/document.rb +1 -0
- data/lib/nokogiri/xml/sax/parser.rb +1 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
- data/lib/nokogiri/xml/schema.rb +13 -4
- data/lib/nokogiri/xml/searchable.rb +25 -16
- data/lib/nokogiri/xml/syntax_error.rb +1 -0
- data/lib/nokogiri/xml/text.rb +1 -0
- data/lib/nokogiri/xml/xpath.rb +1 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -0
- data/lib/nokogiri/xml/xpath_context.rb +1 -0
- data/lib/nokogiri/xslt.rb +1 -0
- data/lib/nokogiri/xslt/stylesheet.rb +1 -0
- data/lib/xsd/xmlparser/nokogiri.rb +1 -0
- metadata +140 -57
- data/lib/nokogiri/2.3/nokogiri.so +0 -0
- data/lib/nokogiri/2.4/nokogiri.so +0 -0
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -7,12 +7,11 @@ VALUE mNokogiriXslt ;
|
|
7
7
|
VALUE mNokogiriXmlSax ;
|
8
8
|
VALUE mNokogiriHtmlSax ;
|
9
9
|
|
10
|
-
#
|
10
|
+
#ifndef HAVE_VASPRINTF
|
11
11
|
/*
|
12
|
-
* I srsly hate windows. it doesn't have vasprintf.
|
13
12
|
* Thank you Geoffroy Couprie for this implementation of vasprintf!
|
14
13
|
*/
|
15
|
-
int vasprintf
|
14
|
+
int vasprintf(char **strp, const char *fmt, va_list ap)
|
16
15
|
{
|
17
16
|
/* Mingw32/64 have a broken vsnprintf implementation that fails when
|
18
17
|
* using a zero-byte limit in order to retrieve the required size for malloc.
|
@@ -21,23 +20,15 @@ int vasprintf (char **strp, const char *fmt, va_list ap)
|
|
21
20
|
char tmp[1];
|
22
21
|
int len = vsnprintf (tmp, 1, fmt, ap) + 1;
|
23
22
|
char *res = (char *)malloc((unsigned int)len);
|
24
|
-
if (res == NULL)
|
25
|
-
|
23
|
+
if (res == NULL) {
|
24
|
+
return -1;
|
25
|
+
}
|
26
26
|
*strp = res;
|
27
27
|
return vsnprintf(res, (unsigned int)len, fmt, ap);
|
28
28
|
}
|
29
29
|
#endif
|
30
30
|
|
31
|
-
void vasprintf_free (void *p)
|
32
|
-
{
|
33
|
-
free(p);
|
34
|
-
}
|
35
|
-
|
36
|
-
#ifdef HAVE_RUBY_UTIL_H
|
37
31
|
#include "ruby/util.h"
|
38
|
-
#else
|
39
|
-
#include "util.h"
|
40
|
-
#endif
|
41
32
|
|
42
33
|
void nokogiri_root_node(xmlNodePtr node)
|
43
34
|
{
|
@@ -45,7 +36,7 @@ void nokogiri_root_node(xmlNodePtr node)
|
|
45
36
|
nokogiriTuplePtr tuple;
|
46
37
|
|
47
38
|
doc = node->doc;
|
48
|
-
if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
|
39
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
|
49
40
|
tuple = (nokogiriTuplePtr)doc->_private;
|
50
41
|
st_insert(tuple->unlinkedNodes, (st_data_t)node, (st_data_t)node);
|
51
42
|
}
|
@@ -54,7 +45,7 @@ void nokogiri_root_nsdef(xmlNsPtr ns, xmlDocPtr doc)
|
|
54
45
|
{
|
55
46
|
nokogiriTuplePtr tuple;
|
56
47
|
|
57
|
-
if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
|
48
|
+
if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
|
58
49
|
tuple = (nokogiriTuplePtr)doc->_private;
|
59
50
|
st_insert(tuple->unlinkedNodes, (st_data_t)ns, (st_data_t)ns);
|
60
51
|
}
|
@@ -62,10 +53,10 @@ void nokogiri_root_nsdef(xmlNsPtr ns, xmlDocPtr doc)
|
|
62
53
|
void Init_nokogiri()
|
63
54
|
{
|
64
55
|
xmlMemSetup(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
56
|
+
(xmlFreeFunc)ruby_xfree,
|
57
|
+
(xmlMallocFunc)ruby_xmalloc,
|
58
|
+
(xmlReallocFunc)ruby_xrealloc,
|
59
|
+
ruby_strdup
|
69
60
|
);
|
70
61
|
|
71
62
|
mNokogiri = rb_define_module("Nokogiri");
|
@@ -75,27 +66,26 @@ void Init_nokogiri()
|
|
75
66
|
mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX");
|
76
67
|
mNokogiriHtmlSax = rb_define_module_under(mNokogiriHtml, "SAX");
|
77
68
|
|
78
|
-
rb_const_set(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
rb_const_set(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
rb_const_set(mNokogiri, rb_intern("
|
90
|
-
|
91
|
-
rb_const_set(mNokogiri, rb_intern("
|
92
|
-
rb_const_set(mNokogiri, rb_intern("
|
69
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION));
|
70
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion));
|
71
|
+
|
72
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
73
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
74
|
+
|
75
|
+
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
76
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
77
|
+
#ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
78
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qtrue);
|
79
|
+
#else
|
80
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
81
|
+
#endif
|
82
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " "));
|
83
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " "));
|
93
84
|
#else
|
94
|
-
rb_const_set(mNokogiri, rb_intern("
|
95
|
-
rb_const_set(mNokogiri, rb_intern("
|
96
|
-
rb_const_set(mNokogiri, rb_intern("
|
97
|
-
rb_const_set(mNokogiri, rb_intern("
|
98
|
-
rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATCHES"), Qnil);
|
85
|
+
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qfalse);
|
86
|
+
rb_const_set(mNokogiri, rb_intern("PRECOMPILED_LIBRARIES"), Qfalse);
|
87
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML2_PATCHES"), Qnil);
|
88
|
+
rb_const_set(mNokogiri, rb_intern("LIBXSLT_PATCHES"), Qnil);
|
99
89
|
#endif
|
100
90
|
|
101
91
|
#ifdef LIBXML_ICONV_ENABLED
|
@@ -104,6 +94,10 @@ void Init_nokogiri()
|
|
104
94
|
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
105
95
|
#endif
|
106
96
|
|
97
|
+
#ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
|
98
|
+
rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
|
99
|
+
#endif
|
100
|
+
|
107
101
|
xmlInitParser();
|
108
102
|
|
109
103
|
init_xml_document();
|
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
#ifndef NOKOGIRI_NATIVE
|
2
2
|
#define NOKOGIRI_NATIVE
|
3
3
|
|
4
|
+
#if _MSC_VER
|
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
|
+
|
4
18
|
#include <stdlib.h>
|
5
19
|
#include <string.h>
|
6
20
|
#include <assert.h>
|
7
21
|
#include <stdarg.h>
|
8
|
-
|
9
|
-
#ifdef USE_INCLUDED_VASPRINTF
|
10
|
-
int vasprintf (char **strp, const char *fmt, va_list ap);
|
11
|
-
#else
|
12
|
-
|
13
|
-
#define _GNU_SOURCE
|
14
|
-
# include <stdio.h>
|
15
|
-
#undef _GNU_SOURCE
|
16
|
-
|
17
|
-
#endif
|
22
|
+
#include <stdio.h>
|
18
23
|
|
19
24
|
#include <libxml/parser.h>
|
20
25
|
#include <libxml/entities.h>
|
@@ -29,7 +34,9 @@ int vasprintf (char **strp, const char *fmt, va_list ap);
|
|
29
34
|
#include <libxml/relaxng.h>
|
30
35
|
#include <libxml/xinclude.h>
|
31
36
|
#include <libxslt/extensions.h>
|
37
|
+
#include <libxslt/xsltconfig.h>
|
32
38
|
#include <libxml/c14n.h>
|
39
|
+
|
33
40
|
#include <ruby.h>
|
34
41
|
#include <ruby/st.h>
|
35
42
|
#include <ruby/encoding.h>
|
@@ -93,25 +100,27 @@ extern VALUE mNokogiriHtml ;
|
|
93
100
|
extern VALUE mNokogiriHtmlSax ;
|
94
101
|
extern VALUE mNokogiriXslt ;
|
95
102
|
|
103
|
+
int vasprintf(char **strp, const char *fmt, va_list ap);
|
104
|
+
|
96
105
|
void nokogiri_root_node(xmlNodePtr);
|
97
106
|
void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr);
|
98
107
|
|
99
108
|
#ifdef DEBUG
|
100
109
|
|
101
|
-
#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);
|
102
|
-
#define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p);
|
110
|
+
# 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);
|
111
|
+
# define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p);
|
103
112
|
|
104
113
|
#else
|
105
114
|
|
106
|
-
#define NOKOGIRI_DEBUG_START(p)
|
107
|
-
#define NOKOGIRI_DEBUG_END(p)
|
115
|
+
# define NOKOGIRI_DEBUG_START(p)
|
116
|
+
# define NOKOGIRI_DEBUG_END(p)
|
108
117
|
|
109
118
|
#endif
|
110
119
|
|
111
120
|
#ifndef __builtin_expect
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
121
|
+
# if defined(__GNUC__)
|
122
|
+
# define __builtin_expect(expr, c) __builtin_expect((long)(expr), (long)(c))
|
123
|
+
# endif
|
115
124
|
#endif
|
116
125
|
|
117
126
|
#define XMLNS_PREFIX "xmlns"
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include <xml_document.h>
|
2
2
|
|
3
|
-
static int
|
3
|
+
static int dealloc_node_i2(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
|
4
4
|
{
|
5
5
|
switch(node->type) {
|
6
6
|
case XML_ATTRIBUTE_NODE:
|
@@ -20,6 +20,11 @@ static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
|
|
20
20
|
return ST_CONTINUE;
|
21
21
|
}
|
22
22
|
|
23
|
+
static int dealloc_node_i(st_data_t key, st_data_t node, st_data_t doc)
|
24
|
+
{
|
25
|
+
return dealloc_node_i2((xmlNodePtr)key, (xmlNodePtr)node, (xmlDocPtr)doc);
|
26
|
+
}
|
27
|
+
|
23
28
|
static void remove_private(xmlNodePtr node)
|
24
29
|
{
|
25
30
|
xmlNodePtr child;
|
@@ -38,6 +43,15 @@ static void remove_private(xmlNodePtr node)
|
|
38
43
|
node->_private = NULL;
|
39
44
|
}
|
40
45
|
|
46
|
+
static void mark(xmlDocPtr doc)
|
47
|
+
{
|
48
|
+
nokogiriTuplePtr tuple = (nokogiriTuplePtr)doc->_private;
|
49
|
+
if(tuple) {
|
50
|
+
rb_gc_mark(tuple->doc);
|
51
|
+
rb_gc_mark(tuple->node_cache);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
41
55
|
static void dealloc(xmlDocPtr doc)
|
42
56
|
{
|
43
57
|
st_table *node_hash;
|
@@ -492,7 +506,7 @@ static int block_caller(void * ctx, xmlNodePtr _node, xmlNodePtr _parent)
|
|
492
506
|
* The block must return a non-nil, non-false value if the +obj+ passed in
|
493
507
|
* should be included in the canonicalized document.
|
494
508
|
*/
|
495
|
-
static VALUE
|
509
|
+
static VALUE nokogiri_xml_document_canonicalize(int argc, VALUE* argv, VALUE self)
|
496
510
|
{
|
497
511
|
VALUE mode;
|
498
512
|
VALUE incl_ns;
|
@@ -573,7 +587,7 @@ void init_xml_document()
|
|
573
587
|
rb_define_method(klass, "encoding", encoding, 0);
|
574
588
|
rb_define_method(klass, "encoding=", set_encoding, 1);
|
575
589
|
rb_define_method(klass, "version", version, 0);
|
576
|
-
rb_define_method(klass, "canonicalize",
|
590
|
+
rb_define_method(klass, "canonicalize", nokogiri_xml_document_canonicalize, -1);
|
577
591
|
rb_define_method(klass, "dup", duplicate_document, -1);
|
578
592
|
rb_define_method(klass, "url", url, 0);
|
579
593
|
rb_define_method(klass, "create_entity", create_entity, -1);
|
@@ -588,7 +602,7 @@ VALUE Nokogiri_wrap_xml_document(VALUE klass, xmlDocPtr doc)
|
|
588
602
|
|
589
603
|
VALUE rb_doc = Data_Wrap_Struct(
|
590
604
|
klass ? klass : cNokogiriXmlDocument,
|
591
|
-
|
605
|
+
mark,
|
592
606
|
dealloc,
|
593
607
|
doc
|
594
608
|
);
|
data/ext/nokogiri/xml_io.c
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
static ID id_read, id_write;
|
4
4
|
|
5
|
-
VALUE read_check(VALUE
|
5
|
+
VALUE read_check(VALUE val) {
|
6
|
+
VALUE *args = (VALUE *)val;
|
6
7
|
return rb_funcall(args[0], id_read, 1, args[1]);
|
7
8
|
}
|
8
9
|
|
9
|
-
VALUE read_failed(
|
10
|
-
|
10
|
+
VALUE read_failed(VALUE arg, VALUE exc) {
|
11
|
+
return Qundef;
|
11
12
|
}
|
12
13
|
|
13
14
|
int io_read_callback(void * ctx, char * buffer, int len) {
|
@@ -30,12 +31,13 @@ int io_read_callback(void * ctx, char * buffer, int len) {
|
|
30
31
|
return (int)safe_len;
|
31
32
|
}
|
32
33
|
|
33
|
-
VALUE write_check(VALUE
|
34
|
+
VALUE write_check(VALUE val) {
|
35
|
+
VALUE *args = (VALUE *)val;
|
34
36
|
return rb_funcall(args[0], id_write, 1, args[1]);
|
35
37
|
}
|
36
38
|
|
37
|
-
VALUE write_failed(
|
38
|
-
|
39
|
+
VALUE write_failed(VALUE arg, VALUE exc) {
|
40
|
+
return Qundef;
|
39
41
|
}
|
40
42
|
|
41
43
|
int io_write_callback(void * ctx, char * buffer, int len) {
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -301,7 +301,7 @@ ok:
|
|
301
301
|
* issue #391, where new node's prefix may become the string "default"
|
302
302
|
* see libxml2 tree.c xmlNewReconciliedNs which implements this behavior.
|
303
303
|
*/
|
304
|
-
xmlFree(reparentee->ns->prefix);
|
304
|
+
xmlFree((xmlChar*)reparentee->ns->prefix);
|
305
305
|
reparentee->ns->prefix = NULL;
|
306
306
|
}
|
307
307
|
}
|
@@ -1332,6 +1332,25 @@ static VALUE line(VALUE self)
|
|
1332
1332
|
return INT2NUM(xmlGetLineNo(node));
|
1333
1333
|
}
|
1334
1334
|
|
1335
|
+
/*
|
1336
|
+
* call-seq:
|
1337
|
+
* line=(num)
|
1338
|
+
*
|
1339
|
+
* Sets the line for this Node. num must be less than 65535.
|
1340
|
+
*/
|
1341
|
+
static VALUE set_line(VALUE self, VALUE num)
|
1342
|
+
{
|
1343
|
+
xmlNodePtr node;
|
1344
|
+
Data_Get_Struct(self, xmlNode, node);
|
1345
|
+
|
1346
|
+
int value = NUM2INT(num);
|
1347
|
+
if (value < 65535) {
|
1348
|
+
node->line = value;
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
return num;
|
1352
|
+
}
|
1353
|
+
|
1335
1354
|
/*
|
1336
1355
|
* call-seq:
|
1337
1356
|
* add_namespace_definition(prefix, href)
|
@@ -1728,6 +1747,7 @@ void init_xml_node()
|
|
1728
1747
|
rb_define_method(klass, "create_external_subset", create_external_subset, 3);
|
1729
1748
|
rb_define_method(klass, "pointer_id", pointer_id, 0);
|
1730
1749
|
rb_define_method(klass, "line", line, 0);
|
1750
|
+
rb_define_method(klass, "line=", set_line, 1);
|
1731
1751
|
rb_define_method(klass, "content", get_native_content, 0);
|
1732
1752
|
rb_define_method(klass, "native_content=", set_native_content, 1);
|
1733
1753
|
rb_define_method(klass, "lang", get_lang, 0);
|
data/ext/nokogiri/xml_node_set.c
CHANGED
data/ext/nokogiri/xml_reader.c
CHANGED
@@ -28,35 +28,24 @@ static int has_attributes(xmlTextReaderPtr reader)
|
|
28
28
|
static void Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash)
|
29
29
|
{
|
30
30
|
xmlNsPtr ns;
|
31
|
-
|
32
|
-
char *key ;
|
33
|
-
size_t keylen ;
|
31
|
+
VALUE key;
|
34
32
|
|
35
33
|
if (node->type != XML_ELEMENT_NODE) return ;
|
36
34
|
|
37
35
|
ns = node->nsDef;
|
38
36
|
while (ns != NULL) {
|
39
37
|
|
40
|
-
|
41
|
-
if (keylen > XMLNS_BUFFER_LEN) {
|
42
|
-
key = (char*)malloc(keylen) ;
|
43
|
-
} else {
|
44
|
-
key = buffer ;
|
45
|
-
}
|
46
|
-
|
38
|
+
key = rb_enc_str_new_cstr(XMLNS_PREFIX, rb_utf8_encoding());
|
47
39
|
if (ns->prefix) {
|
48
|
-
|
49
|
-
|
50
|
-
sprintf(key, "%s", XMLNS_PREFIX);
|
40
|
+
rb_str_cat_cstr(key, ":");
|
41
|
+
rb_str_cat_cstr(key, (const char*)ns->prefix);
|
51
42
|
}
|
52
43
|
|
44
|
+
key = rb_str_conv_enc(key, rb_utf8_encoding(), rb_default_internal_encoding());
|
53
45
|
rb_hash_aset(attr_hash,
|
54
|
-
|
46
|
+
key,
|
55
47
|
(ns->href ? NOKOGIRI_STR_NEW2(ns->href) : Qnil)
|
56
48
|
);
|
57
|
-
if (key != buffer) {
|
58
|
-
free(key);
|
59
|
-
}
|
60
49
|
ns = ns->next ;
|
61
50
|
}
|
62
51
|
}
|
data/ext/nokogiri/xml_relax_ng.c
CHANGED
@@ -53,16 +53,24 @@ static VALUE validate_document(VALUE self, VALUE document)
|
|
53
53
|
*
|
54
54
|
* Create a new RelaxNG from the contents of +string+
|
55
55
|
*/
|
56
|
-
static VALUE read_memory(VALUE
|
56
|
+
static VALUE read_memory(int argc, VALUE *argv, VALUE klass)
|
57
57
|
{
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
);
|
58
|
+
VALUE content;
|
59
|
+
VALUE parse_options;
|
60
|
+
xmlRelaxNGParserCtxtPtr ctx;
|
62
61
|
xmlRelaxNGPtr schema;
|
63
|
-
VALUE errors
|
62
|
+
VALUE errors;
|
64
63
|
VALUE rb_schema;
|
64
|
+
int scanned_args = 0;
|
65
|
+
|
66
|
+
scanned_args = rb_scan_args(argc, argv, "11", &content, &parse_options);
|
67
|
+
if (scanned_args == 1) {
|
68
|
+
parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA"));
|
69
|
+
}
|
65
70
|
|
71
|
+
ctx = xmlRelaxNGNewMemParserCtxt((const char *)StringValuePtr(content), (int)RSTRING_LEN(content));
|
72
|
+
|
73
|
+
errors = rb_ary_new();
|
66
74
|
xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher);
|
67
75
|
|
68
76
|
#ifdef HAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS
|
@@ -90,6 +98,7 @@ static VALUE read_memory(VALUE klass, VALUE content)
|
|
90
98
|
|
91
99
|
rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
|
92
100
|
rb_iv_set(rb_schema, "@errors", errors);
|
101
|
+
rb_iv_set(rb_schema, "@parse_options", parse_options);
|
93
102
|
|
94
103
|
return rb_schema;
|
95
104
|
}
|
@@ -100,18 +109,25 @@ static VALUE read_memory(VALUE klass, VALUE content)
|
|
100
109
|
*
|
101
110
|
* Create a new RelaxNG schema from the Nokogiri::XML::Document +doc+
|
102
111
|
*/
|
103
|
-
static VALUE from_document(VALUE
|
112
|
+
static VALUE from_document(int argc, VALUE *argv, VALUE klass)
|
104
113
|
{
|
114
|
+
VALUE document;
|
115
|
+
VALUE parse_options;
|
105
116
|
xmlDocPtr doc;
|
106
117
|
xmlRelaxNGParserCtxtPtr ctx;
|
107
118
|
xmlRelaxNGPtr schema;
|
108
119
|
VALUE errors;
|
109
120
|
VALUE rb_schema;
|
121
|
+
int scanned_args = 0;
|
122
|
+
|
123
|
+
scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options);
|
110
124
|
|
111
125
|
Data_Get_Struct(document, xmlDoc, doc);
|
126
|
+
doc = doc->doc; /* In case someone passes us a node. ugh. */
|
112
127
|
|
113
|
-
|
114
|
-
|
128
|
+
if (scanned_args == 1) {
|
129
|
+
parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA"));
|
130
|
+
}
|
115
131
|
|
116
132
|
ctx = xmlRelaxNGNewDocParserCtxt(doc);
|
117
133
|
|
@@ -129,6 +145,7 @@ static VALUE from_document(VALUE klass, VALUE document)
|
|
129
145
|
schema = xmlRelaxNGParse(ctx);
|
130
146
|
|
131
147
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
148
|
+
xmlRelaxNGFreeParserCtxt(ctx);
|
132
149
|
|
133
150
|
if(NULL == schema) {
|
134
151
|
xmlErrorPtr error = xmlGetLastError();
|
@@ -142,6 +159,7 @@ static VALUE from_document(VALUE klass, VALUE document)
|
|
142
159
|
|
143
160
|
rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
|
144
161
|
rb_iv_set(rb_schema, "@errors", errors);
|
162
|
+
rb_iv_set(rb_schema, "@parse_options", parse_options);
|
145
163
|
|
146
164
|
return rb_schema;
|
147
165
|
}
|
@@ -155,7 +173,7 @@ void init_xml_relax_ng()
|
|
155
173
|
|
156
174
|
cNokogiriXmlRelaxNG = klass;
|
157
175
|
|
158
|
-
rb_define_singleton_method(klass, "read_memory", read_memory, 1);
|
159
|
-
rb_define_singleton_method(klass, "from_document", from_document, 1);
|
176
|
+
rb_define_singleton_method(klass, "read_memory", read_memory, -1);
|
177
|
+
rb_define_singleton_method(klass, "from_document", from_document, -1);
|
160
178
|
rb_define_private_method(klass, "validate_document", validate_document, 1);
|
161
179
|
}
|