nokogiri 1.16.7-aarch64-linux → 1.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +11 -21
- data/LICENSE-DEPENDENCIES.md +6 -6
- data/README.md +8 -5
- data/dependencies.yml +6 -6
- data/ext/nokogiri/extconf.rb +188 -142
- data/ext/nokogiri/gumbo.c +69 -53
- data/ext/nokogiri/html4_document.c +10 -4
- data/ext/nokogiri/html4_element_description.c +18 -18
- data/ext/nokogiri/html4_sax_parser.c +40 -0
- data/ext/nokogiri/html4_sax_parser_context.c +48 -58
- data/ext/nokogiri/html4_sax_push_parser.c +25 -24
- data/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/ext/nokogiri/nokogiri.c +9 -2
- data/ext/nokogiri/nokogiri.h +18 -33
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_cdata.c +2 -10
- data/ext/nokogiri/xml_comment.c +3 -8
- data/ext/nokogiri/xml_document.c +163 -156
- data/ext/nokogiri/xml_document_fragment.c +10 -25
- data/ext/nokogiri/xml_dtd.c +1 -1
- data/ext/nokogiri/xml_element_content.c +9 -9
- data/ext/nokogiri/xml_encoding_handler.c +4 -4
- data/ext/nokogiri/xml_namespace.c +6 -6
- data/ext/nokogiri/xml_node.c +141 -104
- data/ext/nokogiri/xml_node_set.c +46 -44
- data/ext/nokogiri/xml_reader.c +54 -58
- data/ext/nokogiri/xml_relax_ng.c +35 -56
- data/ext/nokogiri/xml_sax_parser.c +156 -88
- data/ext/nokogiri/xml_sax_parser_context.c +219 -131
- data/ext/nokogiri/xml_sax_push_parser.c +68 -49
- data/ext/nokogiri/xml_schema.c +50 -85
- data/ext/nokogiri/xml_syntax_error.c +19 -11
- data/ext/nokogiri/xml_text.c +2 -4
- data/ext/nokogiri/xml_xpath_context.c +103 -100
- data/ext/nokogiri/xslt_stylesheet.c +8 -8
- data/gumbo-parser/src/Makefile +34 -0
- data/gumbo-parser/src/README.md +41 -0
- data/gumbo-parser/src/ascii.c +75 -0
- data/gumbo-parser/src/ascii.h +115 -0
- data/gumbo-parser/src/attribute.c +42 -0
- data/gumbo-parser/src/attribute.h +17 -0
- data/gumbo-parser/src/char_ref.c +22225 -0
- data/gumbo-parser/src/char_ref.h +29 -0
- data/gumbo-parser/src/char_ref.rl +2154 -0
- data/gumbo-parser/src/error.c +658 -0
- data/gumbo-parser/src/error.h +152 -0
- data/gumbo-parser/src/foreign_attrs.c +103 -0
- data/gumbo-parser/src/foreign_attrs.gperf +27 -0
- data/gumbo-parser/src/insertion_mode.h +33 -0
- data/gumbo-parser/src/macros.h +91 -0
- data/gumbo-parser/src/nokogiri_gumbo.h +953 -0
- data/gumbo-parser/src/parser.c +4932 -0
- data/gumbo-parser/src/parser.h +41 -0
- data/gumbo-parser/src/replacement.h +33 -0
- data/gumbo-parser/src/string_buffer.c +103 -0
- data/gumbo-parser/src/string_buffer.h +68 -0
- data/gumbo-parser/src/string_piece.c +48 -0
- data/gumbo-parser/src/svg_attrs.c +174 -0
- data/gumbo-parser/src/svg_attrs.gperf +77 -0
- data/gumbo-parser/src/svg_tags.c +137 -0
- data/gumbo-parser/src/svg_tags.gperf +55 -0
- data/gumbo-parser/src/tag.c +223 -0
- data/gumbo-parser/src/tag_lookup.c +382 -0
- data/gumbo-parser/src/tag_lookup.gperf +170 -0
- data/gumbo-parser/src/tag_lookup.h +13 -0
- data/gumbo-parser/src/token_buffer.c +79 -0
- data/gumbo-parser/src/token_buffer.h +71 -0
- data/gumbo-parser/src/token_type.h +17 -0
- data/gumbo-parser/src/tokenizer.c +3464 -0
- data/gumbo-parser/src/tokenizer.h +112 -0
- data/gumbo-parser/src/tokenizer_states.h +339 -0
- data/gumbo-parser/src/utf8.c +245 -0
- data/gumbo-parser/src/utf8.h +164 -0
- data/gumbo-parser/src/util.c +66 -0
- data/gumbo-parser/src/util.h +34 -0
- data/gumbo-parser/src/vector.c +111 -0
- data/gumbo-parser/src/vector.h +45 -0
- data/lib/nokogiri/class_resolver.rb +1 -1
- data/lib/nokogiri/css/node.rb +6 -2
- data/lib/nokogiri/css/parser.rb +6 -4
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/parser_extras.rb +6 -66
- data/lib/nokogiri/css/selector_cache.rb +38 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -4
- data/lib/nokogiri/css/tokenizer.rex +9 -8
- data/lib/nokogiri/css/xpath_visitor.rb +43 -6
- data/lib/nokogiri/css.rb +86 -20
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/encoding_handler.rb +2 -2
- data/lib/nokogiri/html4/document.rb +44 -23
- data/lib/nokogiri/html4/document_fragment.rb +124 -12
- data/lib/nokogiri/html4/encoding_reader.rb +1 -1
- data/lib/nokogiri/html4/sax/parser.rb +23 -38
- data/lib/nokogiri/html4/sax/parser_context.rb +4 -9
- data/lib/nokogiri/html4.rb +9 -14
- data/lib/nokogiri/html5/builder.rb +40 -0
- data/lib/nokogiri/html5/document.rb +61 -30
- data/lib/nokogiri/html5/document_fragment.rb +130 -20
- data/lib/nokogiri/html5/node.rb +4 -4
- data/lib/nokogiri/html5.rb +114 -72
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +8 -1
- data/lib/nokogiri/xml/document.rb +70 -26
- data/lib/nokogiri/xml/document_fragment.rb +84 -13
- data/lib/nokogiri/xml/node.rb +82 -11
- data/lib/nokogiri/xml/node_set.rb +9 -7
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/lib/nokogiri/xml/pp/node.rb +6 -1
- data/lib/nokogiri/xml/reader.rb +46 -13
- data/lib/nokogiri/xml/relax_ng.rb +57 -20
- data/lib/nokogiri/xml/sax/document.rb +174 -83
- data/lib/nokogiri/xml/sax/parser.rb +115 -41
- data/lib/nokogiri/xml/sax/parser_context.rb +116 -8
- data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
- data/lib/nokogiri/xml/sax.rb +48 -0
- data/lib/nokogiri/xml/schema.rb +112 -45
- data/lib/nokogiri/xml/searchable.rb +38 -42
- data/lib/nokogiri/xml/syntax_error.rb +22 -0
- data/lib/nokogiri/xml/xpath_context.rb +14 -3
- data/lib/nokogiri/xml.rb +13 -24
- data/lib/nokogiri/xslt.rb +3 -9
- data/lib/xsd/xmlparser/nokogiri.rb +3 -4
- data/patches/libxml2/0001-Remove-script-macro-support.patch +40 -0
- data/patches/libxml2/0002-Update-entities-to-remove-handling-of-ssi.patch +44 -0
- data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
- data/patches/libxml2/0010-update-config.guess-and-config.sub-for-libxml2.patch +224 -0
- data/patches/libxml2/0011-rip-out-libxml2-s-libc_single_threaded-support.patch +30 -0
- data/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
- data/patches/libxslt/0001-update-config.guess-and-config.sub-for-libxslt.patch +224 -0
- data/ports/archives/libxml2-2.13.6.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.42.tar.xz +0 -0
- metadata +78 -89
- data/ext/nokogiri/include/libexslt/exslt.h +0 -108
- data/ext/nokogiri/include/libexslt/exsltconfig.h +0 -70
- data/ext/nokogiri/include/libexslt/exsltexports.h +0 -63
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +0 -343
- data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +0 -147
- data/ext/nokogiri/include/libxml2/libxml/SAX.h +0 -202
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +0 -171
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +0 -126
- data/ext/nokogiri/include/libxml2/libxml/catalog.h +0 -182
- data/ext/nokogiri/include/libxml2/libxml/chvalid.h +0 -230
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +0 -217
- data/ext/nokogiri/include/libxml2/libxml/dict.h +0 -82
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +0 -235
- data/ext/nokogiri/include/libxml2/libxml/entities.h +0 -155
- data/ext/nokogiri/include/libxml2/libxml/globals.h +0 -41
- data/ext/nokogiri/include/libxml2/libxml/hash.h +0 -232
- data/ext/nokogiri/include/libxml2/libxml/list.h +0 -137
- data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +0 -186
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +0 -81
- data/ext/nokogiri/include/libxml2/libxml/parser.h +0 -1384
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +0 -663
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +0 -100
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +0 -219
- data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +0 -959
- data/ext/nokogiri/include/libxml2/libxml/schematron.h +0 -143
- data/ext/nokogiri/include/libxml2/libxml/threads.h +0 -87
- data/ext/nokogiri/include/libxml2/libxml/tree.h +0 -1362
- data/ext/nokogiri/include/libxml2/libxml/uri.h +0 -95
- data/ext/nokogiri/include/libxml2/libxml/valid.h +0 -450
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +0 -129
- data/ext/nokogiri/include/libxml2/libxml/xlink.h +0 -189
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +0 -421
- data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +0 -146
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +0 -948
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +0 -50
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +0 -225
- data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +0 -57
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +0 -434
- data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +0 -215
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +0 -97
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +0 -249
- data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +0 -152
- data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +0 -140
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +0 -202
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +0 -511
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +0 -488
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +0 -575
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +0 -633
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +0 -138
- data/ext/nokogiri/include/libxslt/attributes.h +0 -39
- data/ext/nokogiri/include/libxslt/documents.h +0 -93
- data/ext/nokogiri/include/libxslt/extensions.h +0 -262
- data/ext/nokogiri/include/libxslt/extra.h +0 -72
- data/ext/nokogiri/include/libxslt/functions.h +0 -78
- data/ext/nokogiri/include/libxslt/imports.h +0 -75
- data/ext/nokogiri/include/libxslt/keys.h +0 -53
- data/ext/nokogiri/include/libxslt/namespaces.h +0 -68
- data/ext/nokogiri/include/libxslt/numbersInternals.h +0 -73
- data/ext/nokogiri/include/libxslt/pattern.h +0 -84
- data/ext/nokogiri/include/libxslt/preproc.h +0 -43
- data/ext/nokogiri/include/libxslt/security.h +0 -104
- data/ext/nokogiri/include/libxslt/templates.h +0 -77
- data/ext/nokogiri/include/libxslt/transform.h +0 -207
- data/ext/nokogiri/include/libxslt/variables.h +0 -118
- data/ext/nokogiri/include/libxslt/xslt.h +0 -110
- data/ext/nokogiri/include/libxslt/xsltInternals.h +0 -1992
- data/ext/nokogiri/include/libxslt/xsltconfig.h +0 -179
- data/ext/nokogiri/include/libxslt/xsltexports.h +0 -64
- data/ext/nokogiri/include/libxslt/xsltlocale.h +0 -44
- data/ext/nokogiri/include/libxslt/xsltutils.h +0 -343
- data/ext/nokogiri/libxml2_backwards_compat.c +0 -121
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/3.1/nokogiri.so +0 -0
- data/lib/nokogiri/3.2/nokogiri.so +0 -0
- data/lib/nokogiri/3.3/nokogiri.so +0 -0
|
@@ -12,23 +12,23 @@ static const xmlChar *NOKOGIRI_BUILTIN_PREFIX = (const xmlChar *)"nokogiri-built
|
|
|
12
12
|
static const xmlChar *NOKOGIRI_BUILTIN_URI = (const xmlChar *)"https://www.nokogiri.org/default_ns/ruby/builtins";
|
|
13
13
|
|
|
14
14
|
static void
|
|
15
|
-
|
|
15
|
+
_noko_xml_xpath_context_dfree(void *data)
|
|
16
16
|
{
|
|
17
17
|
xmlXPathContextPtr c_context = data;
|
|
18
18
|
xmlXPathFreeContext(c_context);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static const rb_data_type_t
|
|
22
|
-
.wrap_struct_name = "
|
|
21
|
+
static const rb_data_type_t _noko_xml_xpath_context_type = {
|
|
22
|
+
.wrap_struct_name = "xmlXPathContext",
|
|
23
23
|
.function = {
|
|
24
|
-
.dfree =
|
|
24
|
+
.dfree = _noko_xml_xpath_context_dfree,
|
|
25
25
|
},
|
|
26
26
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/* find a CSS class in an HTML element's `class` attribute */
|
|
30
30
|
static const xmlChar *
|
|
31
|
-
|
|
31
|
+
_noko_xml_xpath_context__css_class(const xmlChar *str, const xmlChar *val)
|
|
32
32
|
{
|
|
33
33
|
int val_len;
|
|
34
34
|
|
|
@@ -62,9 +62,9 @@ builtin_css_class(const xmlChar *str, const xmlChar *val)
|
|
|
62
62
|
return (NULL);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/* xmlXPathFunction to wrap
|
|
65
|
+
/* xmlXPathFunction to wrap _noko_xml_xpath_context__css_class() */
|
|
66
66
|
static void
|
|
67
|
-
|
|
67
|
+
noko_xml_xpath_context_xpath_func_css_class(xmlXPathParserContextPtr ctxt, int nargs)
|
|
68
68
|
{
|
|
69
69
|
xmlXPathObjectPtr hay, needle;
|
|
70
70
|
|
|
@@ -85,7 +85,7 @@ xpath_builtin_css_class(xmlXPathParserContextPtr ctxt, int nargs)
|
|
|
85
85
|
XP_ERROR(XPATH_INVALID_TYPE);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
if (
|
|
88
|
+
if (_noko_xml_xpath_context__css_class(hay->stringval, needle->stringval)) {
|
|
89
89
|
valuePush(ctxt, xmlXPathNewBoolean(1));
|
|
90
90
|
} else {
|
|
91
91
|
valuePush(ctxt, xmlXPathNewBoolean(0));
|
|
@@ -99,7 +99,7 @@ xpath_builtin_css_class(xmlXPathParserContextPtr ctxt, int nargs)
|
|
|
99
99
|
/* xmlXPathFunction to select nodes whose local name matches, for HTML5 CSS queries that should
|
|
100
100
|
* ignore namespaces */
|
|
101
101
|
static void
|
|
102
|
-
|
|
102
|
+
noko_xml_xpath_context_xpath_func_local_name_is(xmlXPathParserContextPtr ctxt, int nargs)
|
|
103
103
|
{
|
|
104
104
|
xmlXPathObjectPtr element_name;
|
|
105
105
|
|
|
@@ -124,25 +124,26 @@ xpath_builtin_local_name_is(xmlXPathParserContextPtr ctxt, int nargs)
|
|
|
124
124
|
* register_ns(prefix, uri) → Nokogiri::XML::XPathContext
|
|
125
125
|
*
|
|
126
126
|
* Register the namespace with +prefix+ and +uri+ for use in future queries.
|
|
127
|
+
* Passing a uri of +nil+ will unregister the namespace.
|
|
127
128
|
*
|
|
128
129
|
* [Returns] +self+
|
|
129
130
|
*/
|
|
130
131
|
static VALUE
|
|
131
|
-
|
|
132
|
+
noko_xml_xpath_context_register_ns(VALUE rb_context, VALUE prefix, VALUE uri)
|
|
132
133
|
{
|
|
133
134
|
xmlXPathContextPtr c_context;
|
|
135
|
+
const xmlChar *ns_uri;
|
|
134
136
|
|
|
135
|
-
TypedData_Get_Struct(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
|
138
|
+
|
|
139
|
+
if (NIL_P(uri)) {
|
|
140
|
+
ns_uri = NULL;
|
|
141
|
+
} else {
|
|
142
|
+
ns_uri = (const xmlChar *)StringValueCStr(uri);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
xmlXPathRegisterNs(c_context, (const xmlChar *)StringValueCStr(prefix), ns_uri);
|
|
141
146
|
|
|
142
|
-
xmlXPathRegisterNs(c_context,
|
|
143
|
-
(const xmlChar *)StringValueCStr(prefix),
|
|
144
|
-
(const xmlChar *)StringValueCStr(uri)
|
|
145
|
-
);
|
|
146
147
|
return rb_context;
|
|
147
148
|
}
|
|
148
149
|
|
|
@@ -151,29 +152,25 @@ rb_xml_xpath_context_register_ns(VALUE rb_context, VALUE prefix, VALUE uri)
|
|
|
151
152
|
* register_variable(name, value) → Nokogiri::XML::XPathContext
|
|
152
153
|
*
|
|
153
154
|
* Register the variable +name+ with +value+ for use in future queries.
|
|
155
|
+
* Passing a value of +nil+ will unregister the variable.
|
|
154
156
|
*
|
|
155
157
|
* [Returns] +self+
|
|
156
158
|
*/
|
|
157
159
|
static VALUE
|
|
158
|
-
|
|
160
|
+
noko_xml_xpath_context_register_variable(VALUE rb_context, VALUE name, VALUE value)
|
|
159
161
|
{
|
|
160
162
|
xmlXPathContextPtr c_context;
|
|
161
163
|
xmlXPathObjectPtr xmlValue;
|
|
162
164
|
|
|
163
|
-
TypedData_Get_Struct(
|
|
164
|
-
rb_context,
|
|
165
|
-
xmlXPathContext,
|
|
166
|
-
&xml_xpath_context_type,
|
|
167
|
-
c_context
|
|
168
|
-
);
|
|
165
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
|
169
166
|
|
|
170
|
-
|
|
167
|
+
if (NIL_P(value)) {
|
|
168
|
+
xmlValue = NULL;
|
|
169
|
+
} else {
|
|
170
|
+
xmlValue = xmlXPathNewCString(StringValueCStr(value));
|
|
171
|
+
}
|
|
171
172
|
|
|
172
|
-
xmlXPathRegisterVariable(
|
|
173
|
-
c_context,
|
|
174
|
-
(const xmlChar *)StringValueCStr(name),
|
|
175
|
-
xmlValue
|
|
176
|
-
);
|
|
173
|
+
xmlXPathRegisterVariable(c_context, (const xmlChar *)StringValueCStr(name), xmlValue);
|
|
177
174
|
|
|
178
175
|
return rb_context;
|
|
179
176
|
}
|
|
@@ -184,7 +181,7 @@ rb_xml_xpath_context_register_variable(VALUE rb_context, VALUE name, VALUE value
|
|
|
184
181
|
* returns Qundef if no conversion was possible.
|
|
185
182
|
*/
|
|
186
183
|
static VALUE
|
|
187
|
-
|
|
184
|
+
_noko_xml_xpath_context__xpath2ruby(xmlXPathObjectPtr c_xpath_object, xmlXPathContextPtr c_context)
|
|
188
185
|
{
|
|
189
186
|
VALUE rb_retval;
|
|
190
187
|
|
|
@@ -238,7 +235,7 @@ Nokogiri_marshal_xpath_funcall_and_return_values(
|
|
|
238
235
|
|
|
239
236
|
for (int j = argc - 1 ; j >= 0 ; --j) {
|
|
240
237
|
c_xpath_object = valuePop(ctxt);
|
|
241
|
-
argv[j] =
|
|
238
|
+
argv[j] = _noko_xml_xpath_context__xpath2ruby(c_xpath_object, ctxt->context);
|
|
242
239
|
if (argv[j] == Qundef) {
|
|
243
240
|
argv[j] = NOKOGIRI_STR_NEW2(xmlXPathCastToString(c_xpath_object));
|
|
244
241
|
}
|
|
@@ -294,7 +291,7 @@ Nokogiri_marshal_xpath_funcall_and_return_values(
|
|
|
294
291
|
}
|
|
295
292
|
|
|
296
293
|
static void
|
|
297
|
-
|
|
294
|
+
_noko_xml_xpath_context__handler_invoker(xmlXPathParserContextPtr ctxt, int argc)
|
|
298
295
|
{
|
|
299
296
|
VALUE rb_xpath_handler = Qnil;
|
|
300
297
|
const char *method_name = NULL ;
|
|
@@ -316,15 +313,15 @@ method_caller(xmlXPathParserContextPtr ctxt, int argc)
|
|
|
316
313
|
}
|
|
317
314
|
|
|
318
315
|
static xmlXPathFunction
|
|
319
|
-
|
|
316
|
+
_noko_xml_xpath_context_handler_lookup(void *data, const xmlChar *c_name, const xmlChar *c_ns_uri)
|
|
320
317
|
{
|
|
321
318
|
VALUE rb_handler = (VALUE)data;
|
|
322
319
|
if (rb_respond_to(rb_handler, rb_intern((const char *)c_name))) {
|
|
323
320
|
if (c_ns_uri == NULL) {
|
|
324
321
|
NOKO_WARN_DEPRECATION("A custom XPath or CSS handler function named '%s' is being invoked without a namespace. Please update your query to reference this function as 'nokogiri:%s'. Invoking custom handler functions without a namespace is deprecated and will become an error in Nokogiri v1.17.0.",
|
|
325
|
-
c_name, c_name); // deprecated in v1.15.0, remove in v1.
|
|
322
|
+
c_name, c_name); // TODO deprecated in v1.15.0, remove in v1.19.0
|
|
326
323
|
}
|
|
327
|
-
return
|
|
324
|
+
return _noko_xml_xpath_context__handler_invoker;
|
|
328
325
|
}
|
|
329
326
|
|
|
330
327
|
return NULL;
|
|
@@ -332,7 +329,7 @@ handler_lookup(void *data, const xmlChar *c_name, const xmlChar *c_ns_uri)
|
|
|
332
329
|
|
|
333
330
|
PRINTFLIKE_DECL(2, 3)
|
|
334
331
|
static void
|
|
335
|
-
|
|
332
|
+
_noko_xml_xpath_context__generic_exception_pusher(void *data, const char *msg, ...)
|
|
336
333
|
{
|
|
337
334
|
VALUE rb_errors = (VALUE)data;
|
|
338
335
|
VALUE rb_message;
|
|
@@ -343,7 +340,7 @@ generic_exception_pusher(void *data, const char *msg, ...)
|
|
|
343
340
|
#ifdef TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
|
344
341
|
/* It is not currently possible to pass var args from native
|
|
345
342
|
functions to sulong, so we work around the issue here. */
|
|
346
|
-
rb_message = rb_sprintf("
|
|
343
|
+
rb_message = rb_sprintf("_noko_xml_xpath_context__generic_exception_pusher: %s", msg);
|
|
347
344
|
#else
|
|
348
345
|
va_list args;
|
|
349
346
|
va_start(args, msg);
|
|
@@ -365,58 +362,55 @@ generic_exception_pusher(void *data, const char *msg, ...)
|
|
|
365
362
|
* a +Float+, or a boolean.
|
|
366
363
|
*/
|
|
367
364
|
static VALUE
|
|
368
|
-
|
|
365
|
+
noko_xml_xpath_context_evaluate(int argc, VALUE *argv, VALUE rb_context)
|
|
369
366
|
{
|
|
370
|
-
VALUE search_path, xpath_handler;
|
|
371
|
-
VALUE retval = Qnil;
|
|
372
367
|
xmlXPathContextPtr c_context;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
xmlXPathContext,
|
|
380
|
-
&xml_xpath_context_type,
|
|
381
|
-
c_context
|
|
382
|
-
);
|
|
368
|
+
VALUE rb_expression = Qnil;
|
|
369
|
+
VALUE rb_function_lookup_handler = Qnil;
|
|
370
|
+
xmlChar *c_expression_str = NULL;
|
|
371
|
+
VALUE rb_errors = rb_ary_new();
|
|
372
|
+
xmlXPathObjectPtr c_xpath_object;
|
|
373
|
+
VALUE rb_xpath_object = Qnil;
|
|
383
374
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
375
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
|
376
|
+
|
|
377
|
+
rb_scan_args(argc, argv, "11", &rb_expression, &rb_function_lookup_handler);
|
|
387
378
|
|
|
388
|
-
|
|
379
|
+
c_expression_str = (xmlChar *)StringValueCStr(rb_expression);
|
|
389
380
|
|
|
390
|
-
if (Qnil !=
|
|
381
|
+
if (Qnil != rb_function_lookup_handler) {
|
|
391
382
|
/* FIXME: not sure if this is the correct place to shove private data. */
|
|
392
|
-
c_context->userData = (void *)
|
|
383
|
+
c_context->userData = (void *)rb_function_lookup_handler;
|
|
393
384
|
xmlXPathRegisterFuncLookup(
|
|
394
385
|
c_context,
|
|
395
|
-
|
|
396
|
-
(void *)
|
|
386
|
+
_noko_xml_xpath_context_handler_lookup,
|
|
387
|
+
(void *)rb_function_lookup_handler
|
|
397
388
|
);
|
|
398
389
|
}
|
|
399
390
|
|
|
400
|
-
|
|
401
|
-
|
|
391
|
+
/* TODO: use xmlXPathSetErrorHandler (as of 2.13.0) */
|
|
392
|
+
xmlSetStructuredErrorFunc((void *)rb_errors, noko__error_array_pusher);
|
|
393
|
+
xmlSetGenericErrorFunc((void *)rb_errors, _noko_xml_xpath_context__generic_exception_pusher);
|
|
402
394
|
|
|
403
|
-
|
|
395
|
+
c_xpath_object = xmlXPathEvalExpression(c_expression_str, c_context);
|
|
404
396
|
|
|
405
397
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
|
406
398
|
xmlSetGenericErrorFunc(NULL, NULL);
|
|
407
399
|
|
|
408
|
-
|
|
409
|
-
|
|
400
|
+
xmlXPathRegisterFuncLookup(c_context, NULL, NULL);
|
|
401
|
+
|
|
402
|
+
if (c_xpath_object == NULL) {
|
|
403
|
+
rb_exc_raise(rb_ary_entry(rb_errors, 0));
|
|
410
404
|
}
|
|
411
405
|
|
|
412
|
-
|
|
413
|
-
if (
|
|
414
|
-
|
|
406
|
+
rb_xpath_object = _noko_xml_xpath_context__xpath2ruby(c_xpath_object, c_context);
|
|
407
|
+
if (rb_xpath_object == Qundef) {
|
|
408
|
+
rb_xpath_object = noko_xml_node_set_wrap(NULL, DOC_RUBY_OBJECT(c_context->doc));
|
|
415
409
|
}
|
|
416
410
|
|
|
417
|
-
xmlXPathFreeNodeSetList(
|
|
411
|
+
xmlXPathFreeNodeSetList(c_xpath_object);
|
|
418
412
|
|
|
419
|
-
return
|
|
413
|
+
return rb_xpath_object;
|
|
420
414
|
}
|
|
421
415
|
|
|
422
416
|
/*
|
|
@@ -426,45 +420,53 @@ rb_xml_xpath_context_evaluate(int argc, VALUE *argv, VALUE rb_context)
|
|
|
426
420
|
* Create a new XPathContext with +node+ as the context node.
|
|
427
421
|
*/
|
|
428
422
|
static VALUE
|
|
429
|
-
|
|
423
|
+
noko_xml_xpath_context_new(VALUE klass, VALUE rb_node)
|
|
430
424
|
{
|
|
431
|
-
xmlNodePtr
|
|
425
|
+
xmlNodePtr c_node;
|
|
432
426
|
xmlXPathContextPtr c_context;
|
|
433
427
|
VALUE rb_context;
|
|
434
428
|
|
|
435
|
-
Noko_Node_Get_Struct(rb_node, xmlNode,
|
|
429
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
|
436
430
|
|
|
437
431
|
#if LIBXML_VERSION < 21000
|
|
438
|
-
/* deprecated in 40483d0 */
|
|
439
|
-
xmlXPathInit();
|
|
432
|
+
xmlXPathInit(); /* deprecated in 40483d0 */
|
|
440
433
|
#endif
|
|
441
434
|
|
|
442
|
-
c_context = xmlXPathNewContext(
|
|
443
|
-
c_context->node =
|
|
435
|
+
c_context = xmlXPathNewContext(c_node->doc);
|
|
436
|
+
c_context->node = c_node;
|
|
444
437
|
|
|
445
438
|
xmlXPathRegisterNs(c_context, NOKOGIRI_PREFIX, NOKOGIRI_URI);
|
|
446
439
|
xmlXPathRegisterNs(c_context, NOKOGIRI_BUILTIN_PREFIX, NOKOGIRI_BUILTIN_URI);
|
|
447
|
-
xmlXPathRegisterFuncNS(
|
|
448
|
-
c_context,
|
|
449
|
-
(const xmlChar *)"css-class",
|
|
450
|
-
NOKOGIRI_BUILTIN_URI,
|
|
451
|
-
xpath_builtin_css_class
|
|
452
|
-
);
|
|
453
|
-
xmlXPathRegisterFuncNS(
|
|
454
|
-
c_context,
|
|
455
|
-
(const xmlChar *)"local-name-is",
|
|
456
|
-
NOKOGIRI_BUILTIN_URI,
|
|
457
|
-
xpath_builtin_local_name_is
|
|
458
|
-
);
|
|
459
440
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
441
|
+
xmlXPathRegisterFuncNS(c_context,
|
|
442
|
+
(const xmlChar *)"css-class", NOKOGIRI_BUILTIN_URI,
|
|
443
|
+
noko_xml_xpath_context_xpath_func_css_class);
|
|
444
|
+
xmlXPathRegisterFuncNS(c_context,
|
|
445
|
+
(const xmlChar *)"local-name-is", NOKOGIRI_BUILTIN_URI,
|
|
446
|
+
noko_xml_xpath_context_xpath_func_local_name_is);
|
|
447
|
+
|
|
448
|
+
rb_context = TypedData_Wrap_Struct(klass, &_noko_xml_xpath_context_type, c_context);
|
|
449
|
+
|
|
465
450
|
return rb_context;
|
|
466
451
|
}
|
|
467
452
|
|
|
453
|
+
|
|
454
|
+
/* :nodoc: */
|
|
455
|
+
static VALUE
|
|
456
|
+
noko_xml_xpath_context_set_node(VALUE rb_context, VALUE rb_node)
|
|
457
|
+
{
|
|
458
|
+
xmlNodePtr c_node;
|
|
459
|
+
xmlXPathContextPtr c_context;
|
|
460
|
+
|
|
461
|
+
TypedData_Get_Struct(rb_context, xmlXPathContext, &_noko_xml_xpath_context_type, c_context);
|
|
462
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
|
463
|
+
|
|
464
|
+
c_context->doc = c_node->doc;
|
|
465
|
+
c_context->node = c_node;
|
|
466
|
+
|
|
467
|
+
return rb_node;
|
|
468
|
+
}
|
|
469
|
+
|
|
468
470
|
void
|
|
469
471
|
noko_init_xml_xpath_context(void)
|
|
470
472
|
{
|
|
@@ -475,9 +477,10 @@ noko_init_xml_xpath_context(void)
|
|
|
475
477
|
|
|
476
478
|
rb_undef_alloc_func(cNokogiriXmlXpathContext);
|
|
477
479
|
|
|
478
|
-
rb_define_singleton_method(cNokogiriXmlXpathContext, "new",
|
|
480
|
+
rb_define_singleton_method(cNokogiriXmlXpathContext, "new", noko_xml_xpath_context_new, 1);
|
|
479
481
|
|
|
480
|
-
rb_define_method(cNokogiriXmlXpathContext, "evaluate",
|
|
481
|
-
rb_define_method(cNokogiriXmlXpathContext, "register_variable",
|
|
482
|
-
rb_define_method(cNokogiriXmlXpathContext, "register_ns",
|
|
482
|
+
rb_define_method(cNokogiriXmlXpathContext, "evaluate", noko_xml_xpath_context_evaluate, -1);
|
|
483
|
+
rb_define_method(cNokogiriXmlXpathContext, "register_variable", noko_xml_xpath_context_register_variable, 2);
|
|
484
|
+
rb_define_method(cNokogiriXmlXpathContext, "register_ns", noko_xml_xpath_context_register_ns, 2);
|
|
485
|
+
rb_define_method(cNokogiriXmlXpathContext, "node=", noko_xml_xpath_context_set_node, 1);
|
|
483
486
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#include <nokogiri.h>
|
|
2
2
|
|
|
3
|
-
VALUE cNokogiriXsltStylesheet
|
|
3
|
+
VALUE cNokogiriXsltStylesheet;
|
|
4
4
|
|
|
5
5
|
static void
|
|
6
6
|
mark(void *data)
|
|
@@ -18,8 +18,8 @@ dealloc(void *data)
|
|
|
18
18
|
ruby_xfree(wrapper);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static const rb_data_type_t
|
|
22
|
-
.wrap_struct_name = "
|
|
21
|
+
static const rb_data_type_t nokogiri_xslt_stylesheet_tuple_type = {
|
|
22
|
+
.wrap_struct_name = "nokogiriXsltStylesheetTuple",
|
|
23
23
|
.function = {
|
|
24
24
|
.dmark = mark,
|
|
25
25
|
.dfree = dealloc,
|
|
@@ -56,7 +56,7 @@ Nokogiri_wrap_xslt_stylesheet(xsltStylesheetPtr ss)
|
|
|
56
56
|
self = TypedData_Make_Struct(
|
|
57
57
|
cNokogiriXsltStylesheet,
|
|
58
58
|
nokogiriXsltStylesheetTuple,
|
|
59
|
-
&
|
|
59
|
+
&nokogiri_xslt_stylesheet_tuple_type,
|
|
60
60
|
wrapper
|
|
61
61
|
);
|
|
62
62
|
|
|
@@ -124,7 +124,7 @@ rb_xslt_stylesheet_serialize(VALUE self, VALUE xmlobj)
|
|
|
124
124
|
TypedData_Get_Struct(
|
|
125
125
|
self,
|
|
126
126
|
nokogiriXsltStylesheetTuple,
|
|
127
|
-
&
|
|
127
|
+
&nokogiri_xslt_stylesheet_tuple_type,
|
|
128
128
|
wrapper
|
|
129
129
|
);
|
|
130
130
|
xsltSaveResultToString(&doc_ptr, &doc_len, xml, wrapper->ss);
|
|
@@ -273,7 +273,7 @@ rb_xslt_stylesheet_transform(int argc, VALUE *argv, VALUE self)
|
|
|
273
273
|
Check_Type(rb_param, T_ARRAY);
|
|
274
274
|
|
|
275
275
|
c_document = noko_xml_document_unwrap(rb_document);
|
|
276
|
-
TypedData_Get_Struct(self, nokogiriXsltStylesheetTuple, &
|
|
276
|
+
TypedData_Get_Struct(self, nokogiriXsltStylesheetTuple, &nokogiri_xslt_stylesheet_tuple_type, wrapper);
|
|
277
277
|
|
|
278
278
|
param_len = RARRAY_LEN(rb_param);
|
|
279
279
|
params = ruby_xcalloc((size_t)param_len + 1, sizeof(char *));
|
|
@@ -362,7 +362,7 @@ initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
|
|
|
362
362
|
TypedData_Get_Struct(
|
|
363
363
|
(VALUE)ctxt->style->_private,
|
|
364
364
|
nokogiriXsltStylesheetTuple,
|
|
365
|
-
&
|
|
365
|
+
&nokogiri_xslt_stylesheet_tuple_type,
|
|
366
366
|
wrapper
|
|
367
367
|
);
|
|
368
368
|
inst = rb_class_new_instance(0, NULL, obj);
|
|
@@ -380,7 +380,7 @@ shutdownFunc(xsltTransformContextPtr ctxt,
|
|
|
380
380
|
TypedData_Get_Struct(
|
|
381
381
|
(VALUE)ctxt->style->_private,
|
|
382
382
|
nokogiriXsltStylesheetTuple,
|
|
383
|
-
&
|
|
383
|
+
&nokogiri_xslt_stylesheet_tuple_type,
|
|
384
384
|
wrapper
|
|
385
385
|
);
|
|
386
386
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# this Makefile is used by ext/nokogiri/extconf.rb
|
|
2
|
+
# to enable a mini_portile2 recipe to build the gumbo parser
|
|
3
|
+
.PHONY: clean
|
|
4
|
+
|
|
5
|
+
CFLAGS += -std=c99 -Wall
|
|
6
|
+
|
|
7
|
+
# allow the ENV var to override this
|
|
8
|
+
RANLIB ?= ranlib
|
|
9
|
+
|
|
10
|
+
gumbo_objs := \
|
|
11
|
+
ascii.o \
|
|
12
|
+
attribute.o \
|
|
13
|
+
char_ref.o \
|
|
14
|
+
error.o \
|
|
15
|
+
foreign_attrs.o \
|
|
16
|
+
parser.o \
|
|
17
|
+
string_buffer.o \
|
|
18
|
+
string_piece.o \
|
|
19
|
+
svg_attrs.o \
|
|
20
|
+
svg_tags.o \
|
|
21
|
+
tag.o \
|
|
22
|
+
tag_lookup.o \
|
|
23
|
+
token_buffer.o \
|
|
24
|
+
tokenizer.o \
|
|
25
|
+
utf8.o \
|
|
26
|
+
util.o \
|
|
27
|
+
vector.o
|
|
28
|
+
|
|
29
|
+
libgumbo.a: $(gumbo_objs)
|
|
30
|
+
$(AR) $(ARFLAGS) $@ $(gumbo_objs)
|
|
31
|
+
- ($(RANLIB) $@ || true) >/dev/null 2>&1
|
|
32
|
+
|
|
33
|
+
clean:
|
|
34
|
+
rm -f $(gumbo_objs) libgumbo.a
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
libgumbo
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
This is an internal fork of the [libgumbo] library, which was copied and
|
|
5
|
+
later modified under the terms of the Apache 2.0 [license]. See `lua-gumbo`
|
|
6
|
+
commit [`0a04728`] for details of the original import.
|
|
7
|
+
|
|
8
|
+
Since importing the code, the following notable fixes and improvements
|
|
9
|
+
have been made:
|
|
10
|
+
|
|
11
|
+
* `91cef89`: Re-implement `adjust_foreign_attributes()` with a gperf hash
|
|
12
|
+
* `b11abe7`: Pass `TagSet` arrays into functions by reference instead of value
|
|
13
|
+
* `b73dc03`: Simplify `maybe_replace_codepoint()` function
|
|
14
|
+
* `d5d0bb3`: Remove special handling of `<menuitem>` tag
|
|
15
|
+
* `7bd5162`: Remove special handling of `<isindex>` tag
|
|
16
|
+
* `a5c1b0e`: Use `realloc(3)` instead of `malloc(3)` in `enlarge_vector_if_full()`
|
|
17
|
+
* `dcbebd7`: Use `realloc(3)` instead of `malloc(3)` in `maybe_resize_string_buffer()`
|
|
18
|
+
* `df15262`: Make `destroy_node()` function non-recursive
|
|
19
|
+
* `2df37f5`: Fix signedness of some format specifiers
|
|
20
|
+
* `176553e`: Add maximum element nesting limit
|
|
21
|
+
* `bed0f4a`: Annotate `gumbo_debug()` with `PRINTF` macro and fix warnings
|
|
22
|
+
* `7ffc218`: Annotate `print_message()` with `PRINTF` macro and fix warnings
|
|
23
|
+
* `1bd8ab5`, `9136507`, `53a1f9a`: Deduplicate some identical `TagSet` arrays
|
|
24
|
+
* `a7a9065`: Add some GCC/Clang function attributes
|
|
25
|
+
* `8d3d4e4`: Remove custom allocator support
|
|
26
|
+
* `8d3b006`: Fix recording of source positions for `</form>` end tags
|
|
27
|
+
* `1a8d763`: Replace linear search in `maybe_replace_codepoint()` with a lookup table
|
|
28
|
+
* `6dca79e`: Replace `strcasecmp()` and `strncasecmp()` with ascii-only equivalents
|
|
29
|
+
* `17ab1d2`: Fix `TAGSET_INCLUDES` macro to work properly with multiple bit flags
|
|
30
|
+
* `7e56d45`: Re-implement `gumbo_normalize_svg_tagname()` with a gperf hash
|
|
31
|
+
* `a518d35`: Replace linear array search in `adjust_svg_attributes()` with a gperf hash
|
|
32
|
+
* `a4a7433`: Fix duplicate `TagSet` initializer being ignored in `is_special_node()`
|
|
33
|
+
* `8137fcd`: Add support for `<dialog>` tag
|
|
34
|
+
* `4b35471`: Add missing `static` qualifiers to hide symbols that shouldn't be extern
|
|
35
|
+
* `df57c59`, `03101f3`, `ea62330`: Replace use of locale-dependant `ctype.h` functions
|
|
36
|
+
with custom, ASCII-only equivalents
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
[libgumbo]: https://github.com/google/gumbo-parser/tree/aa91b27b02c0c80c482e24348a457ed7c3c088e0/src
|
|
40
|
+
[license]: https://github.com/google/gumbo-parser/blob/aa91b27b02c0c80c482e24348a457ed7c3c088e0/COPYING
|
|
41
|
+
[`0a04728`]: https://gitlab.com/craigbarnes/lua-gumbo/commit/0a047282815af86f3367a7d95fefcfe5723ece48
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#include "ascii.h"
|
|
2
|
+
|
|
3
|
+
int gumbo_ascii_strcasecmp(const char *s1, const char *s2) {
|
|
4
|
+
int c1, c2;
|
|
5
|
+
while (*s1 && *s2) {
|
|
6
|
+
c1 = (int)(unsigned char) gumbo_ascii_tolower(*s1);
|
|
7
|
+
c2 = (int)(unsigned char) gumbo_ascii_tolower(*s2);
|
|
8
|
+
if (c1 != c2) {
|
|
9
|
+
return (c1 - c2);
|
|
10
|
+
}
|
|
11
|
+
s1++;
|
|
12
|
+
s2++;
|
|
13
|
+
}
|
|
14
|
+
return (((int)(unsigned char) *s1) - ((int)(unsigned char) *s2));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
int gumbo_ascii_strncasecmp(const char *s1, const char *s2, size_t n) {
|
|
18
|
+
int c1, c2;
|
|
19
|
+
while (n && *s1 && *s2) {
|
|
20
|
+
n -= 1;
|
|
21
|
+
c1 = (int)(unsigned char) gumbo_ascii_tolower(*s1);
|
|
22
|
+
c2 = (int)(unsigned char) gumbo_ascii_tolower(*s2);
|
|
23
|
+
if (c1 != c2) {
|
|
24
|
+
return (c1 - c2);
|
|
25
|
+
}
|
|
26
|
+
s1++;
|
|
27
|
+
s2++;
|
|
28
|
+
}
|
|
29
|
+
if (n) {
|
|
30
|
+
return (((int)(unsigned char) *s1) - ((int)(unsigned char) *s2));
|
|
31
|
+
}
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const unsigned char _gumbo_ascii_table[0x80] = {
|
|
36
|
+
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x01,0x03,0x03,0x01,0x01,
|
|
37
|
+
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
|
38
|
+
0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
39
|
+
0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
40
|
+
0x00,0x28,0x28,0x28,0x28,0x28,0x28,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
|
41
|
+
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,
|
|
42
|
+
0x00,0x50,0x50,0x50,0x50,0x50,0x50,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
|
|
43
|
+
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Table generation code.
|
|
47
|
+
// clang -DGUMBO_GEN_TABLE ascii.c && ./a.out && rm a.out
|
|
48
|
+
#ifdef GUMBO_GEN_TABLE
|
|
49
|
+
#include <stdio.h>
|
|
50
|
+
|
|
51
|
+
int main() {
|
|
52
|
+
printf("const unsigned char _gumbo_ascii_table[0x80] = {");
|
|
53
|
+
for (int c = 0; c < 0x80; ++c) {
|
|
54
|
+
unsigned int x = 0;
|
|
55
|
+
// https://infra.spec.whatwg.org/#ascii-code-point
|
|
56
|
+
if (c <= 0x1f)
|
|
57
|
+
x |= GUMBO_ASCII_CNTRL;
|
|
58
|
+
if (c == 0x09 || c == 0x0a || c == 0x0c || c == 0x0d || c == 0x20)
|
|
59
|
+
x |= GUMBO_ASCII_SPACE;
|
|
60
|
+
if (c >= 0x30 && c <= 0x39)
|
|
61
|
+
x |= GUMBO_ASCII_DIGIT;
|
|
62
|
+
if ((c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x46))
|
|
63
|
+
x |= GUMBO_ASCII_UPPER_XDIGIT;
|
|
64
|
+
if ((c >= 0x30 && c <= 0x39) || (c >= 0x61 && c <= 0x66))
|
|
65
|
+
x |= GUMBO_ASCII_LOWER_XDIGIT;
|
|
66
|
+
if (c >= 0x41 && c <= 0x5a)
|
|
67
|
+
x |= GUMBO_ASCII_UPPER_ALPHA;
|
|
68
|
+
if (c >= 0x61 && c <= 0x7a)
|
|
69
|
+
x |= GUMBO_ASCII_LOWER_ALPHA;
|
|
70
|
+
printf("%s0x%02x,", (c % 16 == 0? "\n " : ""), x);
|
|
71
|
+
}
|
|
72
|
+
printf("\n};\n");
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
#endif
|