nokogiri 1.11.0 → 1.11.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE-DEPENDENCIES.md +12 -12
  3. data/LICENSE.md +1 -1
  4. data/README.md +21 -16
  5. data/dependencies.yml +12 -12
  6. data/ext/nokogiri/depend +34 -474
  7. data/ext/nokogiri/extconf.rb +253 -183
  8. data/ext/nokogiri/html_document.c +10 -15
  9. data/ext/nokogiri/html_element_description.c +84 -71
  10. data/ext/nokogiri/html_entity_lookup.c +21 -16
  11. data/ext/nokogiri/html_sax_parser_context.c +67 -64
  12. data/ext/nokogiri/html_sax_push_parser.c +42 -34
  13. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  14. data/ext/nokogiri/nokogiri.c +190 -60
  15. data/ext/nokogiri/nokogiri.h +158 -75
  16. data/ext/nokogiri/test_global_handlers.c +40 -0
  17. data/ext/nokogiri/xml_attr.c +15 -15
  18. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  19. data/ext/nokogiri/xml_cdata.c +13 -18
  20. data/ext/nokogiri/xml_comment.c +19 -26
  21. data/ext/nokogiri/xml_document.c +246 -188
  22. data/ext/nokogiri/xml_document_fragment.c +13 -15
  23. data/ext/nokogiri/xml_dtd.c +54 -48
  24. data/ext/nokogiri/xml_element_content.c +30 -27
  25. data/ext/nokogiri/xml_element_decl.c +22 -22
  26. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  27. data/ext/nokogiri/xml_entity_decl.c +32 -30
  28. data/ext/nokogiri/xml_entity_reference.c +16 -18
  29. data/ext/nokogiri/xml_namespace.c +56 -49
  30. data/ext/nokogiri/xml_node.c +371 -320
  31. data/ext/nokogiri/xml_node_set.c +168 -156
  32. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  33. data/ext/nokogiri/xml_reader.c +191 -157
  34. data/ext/nokogiri/xml_relax_ng.c +29 -23
  35. data/ext/nokogiri/xml_sax_parser.c +117 -112
  36. data/ext/nokogiri/xml_sax_parser_context.c +101 -84
  37. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  38. data/ext/nokogiri/xml_schema.c +48 -42
  39. data/ext/nokogiri/xml_syntax_error.c +42 -21
  40. data/ext/nokogiri/xml_text.c +13 -17
  41. data/ext/nokogiri/xml_xpath_context.c +134 -127
  42. data/ext/nokogiri/xslt_stylesheet.c +157 -157
  43. data/lib/nokogiri.rb +1 -22
  44. data/lib/nokogiri/css/parser.rb +1 -1
  45. data/lib/nokogiri/extension.rb +26 -0
  46. data/lib/nokogiri/html/document_fragment.rb +15 -15
  47. data/lib/nokogiri/version/constant.rb +1 -1
  48. data/lib/nokogiri/version/info.rb +32 -8
  49. data/lib/nokogiri/xml/document.rb +74 -28
  50. data/lib/nokogiri/xml/node.rb +39 -42
  51. data/lib/nokogiri/xml/reader.rb +2 -9
  52. data/lib/nokogiri/xml/xpath.rb +1 -3
  53. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  54. data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
  55. data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
  56. data/patches/libxml2/{0004-libxml2.la-is-in-top_builddir.patch → 0003-libxml2.la-is-in-top_builddir.patch} +1 -1
  57. data/patches/libxml2/{0008-use-glibc-strlen.patch → 0004-use-glibc-strlen.patch} +0 -0
  58. data/patches/libxml2/{0009-avoid-isnan-isinf.patch → 0005-avoid-isnan-isinf.patch} +4 -4
  59. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2511 -0
  60. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
  61. data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +19 -0
  62. data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
  63. metadata +20 -53
  64. data/ext/nokogiri/html_document.h +0 -10
  65. data/ext/nokogiri/html_element_description.h +0 -10
  66. data/ext/nokogiri/html_entity_lookup.h +0 -8
  67. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  68. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  69. data/ext/nokogiri/xml_attr.h +0 -9
  70. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  71. data/ext/nokogiri/xml_cdata.h +0 -9
  72. data/ext/nokogiri/xml_comment.h +0 -9
  73. data/ext/nokogiri/xml_document.h +0 -23
  74. data/ext/nokogiri/xml_document_fragment.h +0 -10
  75. data/ext/nokogiri/xml_dtd.h +0 -10
  76. data/ext/nokogiri/xml_element_content.h +0 -10
  77. data/ext/nokogiri/xml_element_decl.h +0 -9
  78. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  79. data/ext/nokogiri/xml_entity_decl.h +0 -10
  80. data/ext/nokogiri/xml_entity_reference.h +0 -9
  81. data/ext/nokogiri/xml_io.c +0 -63
  82. data/ext/nokogiri/xml_io.h +0 -11
  83. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  84. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  85. data/ext/nokogiri/xml_namespace.h +0 -14
  86. data/ext/nokogiri/xml_node.h +0 -13
  87. data/ext/nokogiri/xml_node_set.h +0 -12
  88. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  89. data/ext/nokogiri/xml_reader.h +0 -10
  90. data/ext/nokogiri/xml_relax_ng.h +0 -9
  91. data/ext/nokogiri/xml_sax_parser.h +0 -39
  92. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  93. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  94. data/ext/nokogiri/xml_schema.h +0 -9
  95. data/ext/nokogiri/xml_syntax_error.h +0 -13
  96. data/ext/nokogiri/xml_text.h +0 -9
  97. data/ext/nokogiri/xml_xpath_context.h +0 -10
  98. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  99. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  100. data/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch +0 -32
  101. data/patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch +0 -73
  102. data/patches/libxml2/0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch +0 -103
  103. data/ports/archives/libxml2-2.9.10.tar.gz +0 -0
@@ -15,17 +15,26 @@
15
15
  # include <windows.h>
16
16
  #endif
17
17
 
18
+ #if _WIN32
19
+ # define NOKOPUBFUN __declspec(dllexport)
20
+ # define NOKOPUBVAR __declspec(dllexport) extern
21
+ #else
22
+ # define NOKOPUBFUN
23
+ # define NOKOPUBVAR extern
24
+ #endif
25
+
26
+
18
27
  #include <stdlib.h>
19
28
  #include <string.h>
20
29
  #include <assert.h>
21
30
  #include <stdarg.h>
22
31
  #include <stdio.h>
23
32
 
33
+
24
34
  #include <libxml/parser.h>
35
+ #include <libxml/tree.h>
25
36
  #include <libxml/entities.h>
26
- #include <libxml/parserInternals.h>
27
37
  #include <libxml/xpath.h>
28
- #include <libxml/xpathInternals.h>
29
38
  #include <libxml/xmlreader.h>
30
39
  #include <libxml/xmlsave.h>
31
40
  #include <libxml/xmlschemas.h>
@@ -33,98 +42,172 @@
33
42
  #include <libxml/HTMLtree.h>
34
43
  #include <libxml/relaxng.h>
35
44
  #include <libxml/xinclude.h>
45
+ #include <libxml/c14n.h>
46
+ #include <libxml/parserInternals.h>
47
+ #include <libxml/xpathInternals.h>
48
+
36
49
  #include <libxslt/extensions.h>
37
50
  #include <libxslt/xsltconfig.h>
38
- #include <libxml/c14n.h>
51
+ #include <libxslt/xsltutils.h>
52
+ #include <libxslt/transform.h>
53
+ #include <libxslt/xsltInternals.h>
39
54
 
40
- #include <ruby.h>
41
- #include <ruby/st.h>
42
- #include <ruby/encoding.h>
55
+ #include <libexslt/exslt.h>
43
56
 
44
- #ifndef NORETURN
45
- # if defined(__GNUC__)
46
- # define NORETURN(name) __attribute__((noreturn)) name
47
- # else
48
- # define NORETURN(name) name
49
- # endif
57
+ /* libxml2_backwards_compat.c */
58
+ #ifndef HAVE_XMLFIRSTELEMENTCHILD
59
+ xmlNodePtr xmlFirstElementChild(xmlNodePtr parent);
60
+ xmlNodePtr xmlNextElementSibling(xmlNodePtr node);
61
+ xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
50
62
  #endif
51
63
 
52
- #define NOKOGIRI_STR_NEW2(str) \
53
- NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
54
-
55
- #define NOKOGIRI_STR_NEW(str, len) \
56
- rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
57
-
58
- #define RBSTR_OR_QNIL(_str) \
59
- (_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
60
-
61
- #include <xml_libxml2_hacks.h>
62
-
63
- #include <xml_io.h>
64
- #include <xml_document.h>
65
- #include <html_entity_lookup.h>
66
- #include <html_document.h>
67
- #include <xml_node.h>
68
- #include <xml_text.h>
69
- #include <xml_cdata.h>
70
- #include <xml_attr.h>
71
- #include <xml_processing_instruction.h>
72
- #include <xml_entity_reference.h>
73
- #include <xml_document_fragment.h>
74
- #include <xml_comment.h>
75
- #include <xml_node_set.h>
76
- #include <xml_dtd.h>
77
- #include <xml_attribute_decl.h>
78
- #include <xml_element_decl.h>
79
- #include <xml_entity_decl.h>
80
- #include <xml_xpath_context.h>
81
- #include <xml_element_content.h>
82
- #include <xml_sax_parser_context.h>
83
- #include <xml_sax_parser.h>
84
- #include <xml_sax_push_parser.h>
85
- #include <xml_reader.h>
86
- #include <html_sax_parser_context.h>
87
- #include <html_sax_push_parser.h>
88
- #include <xslt_stylesheet.h>
89
- #include <xml_syntax_error.h>
90
- #include <xml_schema.h>
91
- #include <xml_relax_ng.h>
92
- #include <html_element_description.h>
93
- #include <xml_namespace.h>
94
- #include <xml_encoding_handler.h>
95
-
96
- extern VALUE mNokogiri ;
97
- extern VALUE mNokogiriXml ;
98
- extern VALUE mNokogiriXmlSax ;
99
- extern VALUE mNokogiriHtml ;
100
- extern VALUE mNokogiriHtmlSax ;
101
- extern VALUE mNokogiriXslt ;
64
+ #define XMLNS_PREFIX "xmlns"
65
+ #define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
102
66
 
103
- int vasprintf(char **strp, const char *fmt, va_list ap);
104
67
 
105
- void nokogiri_root_node(xmlNodePtr);
106
- void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr);
68
+ #include <ruby.h>
69
+ #include <ruby/st.h>
70
+ #include <ruby/encoding.h>
71
+ #include <ruby/util.h>
72
+
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)
107
76
 
108
77
  #ifdef DEBUG
109
-
110
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);
111
79
  # define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p);
112
-
113
80
  #else
114
-
115
81
  # define NOKOGIRI_DEBUG_START(p)
116
82
  # define NOKOGIRI_DEBUG_END(p)
117
-
118
83
  #endif
119
84
 
120
- #ifndef __builtin_expect
85
+ #ifndef NORETURN
121
86
  # if defined(__GNUC__)
122
- # define __builtin_expect(expr, c) __builtin_expect((long)(expr), (long)(c))
87
+ # define NORETURN(name) __attribute__((noreturn)) name
88
+ # else
89
+ # define NORETURN(name) name
123
90
  # endif
124
91
  #endif
125
92
 
126
- #define XMLNS_PREFIX "xmlns"
127
- #define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
128
- #define XMLNS_BUFFER_LEN 128
129
93
 
130
- #endif
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
+ }
@@ -1,4 +1,6 @@
1
- #include <xml_attr.h>
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 set_value(VALUE self, VALUE content)
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 new(int argc, VALUE *argv, VALUE klass)
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
- nokogiri_root_node((xmlNodePtr)node);
79
+ noko_xml_document_pin_node((xmlNodePtr)node);
76
80
 
77
- rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)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
- VALUE cNokogiriXmlAttr;
88
- void init_xml_attr()
91
+ void
92
+ noko_init_xml_attr()
89
93
  {
90
- VALUE nokogiri = rb_define_module("Nokogiri");
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
- VALUE klass = rb_define_class_under(xml, "Attr", node);
98
+ cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
98
99
 
99
- cNokogiriXmlAttr = klass;
100
+ rb_define_singleton_method(cNokogiriXmlAttr, "new", new, -1);
100
101
 
101
- rb_define_singleton_method(klass, "new", new, -1);
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 <xml_attribute_decl.h>
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 attribute_type(VALUE self)
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 default_value(VALUE self)
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 enumeration(VALUE self)
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
- VALUE cNokogiriXmlAttributeDecl;
57
-
58
- void init_xml_attribute_decl()
61
+ void
62
+ noko_init_xml_attribute_decl()
59
63
  {
60
- VALUE nokogiri = rb_define_module("Nokogiri");
61
- VALUE xml = rb_define_module_under(nokogiri, "XML");
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(klass, "attribute_type", attribute_type, 0);
68
- rb_define_method(klass, "default", default_value, 0);
69
- rb_define_method(klass, "enumeration", enumeration, 0);
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
  }