nokogiri 1.11.1 → 1.11.2

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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE-DEPENDENCIES.md +12 -12
  3. data/LICENSE.md +1 -1
  4. data/README.md +20 -15
  5. data/ext/nokogiri/depend +34 -474
  6. data/ext/nokogiri/extconf.rb +253 -183
  7. data/ext/nokogiri/html_document.c +10 -15
  8. data/ext/nokogiri/html_element_description.c +84 -71
  9. data/ext/nokogiri/html_entity_lookup.c +21 -16
  10. data/ext/nokogiri/html_sax_parser_context.c +66 -65
  11. data/ext/nokogiri/html_sax_push_parser.c +29 -27
  12. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  13. data/ext/nokogiri/nokogiri.c +171 -63
  14. data/ext/nokogiri/nokogiri.h +158 -75
  15. data/ext/nokogiri/test_global_handlers.c +3 -4
  16. data/ext/nokogiri/xml_attr.c +15 -15
  17. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  18. data/ext/nokogiri/xml_cdata.c +13 -18
  19. data/ext/nokogiri/xml_comment.c +19 -26
  20. data/ext/nokogiri/xml_document.c +221 -164
  21. data/ext/nokogiri/xml_document_fragment.c +13 -15
  22. data/ext/nokogiri/xml_dtd.c +54 -48
  23. data/ext/nokogiri/xml_element_content.c +30 -27
  24. data/ext/nokogiri/xml_element_decl.c +22 -22
  25. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  26. data/ext/nokogiri/xml_entity_decl.c +32 -30
  27. data/ext/nokogiri/xml_entity_reference.c +16 -18
  28. data/ext/nokogiri/xml_namespace.c +56 -49
  29. data/ext/nokogiri/xml_node.c +338 -286
  30. data/ext/nokogiri/xml_node_set.c +168 -156
  31. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  32. data/ext/nokogiri/xml_reader.c +191 -157
  33. data/ext/nokogiri/xml_relax_ng.c +29 -23
  34. data/ext/nokogiri/xml_sax_parser.c +117 -112
  35. data/ext/nokogiri/xml_sax_parser_context.c +100 -85
  36. data/ext/nokogiri/xml_sax_push_parser.c +34 -27
  37. data/ext/nokogiri/xml_schema.c +48 -42
  38. data/ext/nokogiri/xml_syntax_error.c +21 -23
  39. data/ext/nokogiri/xml_text.c +13 -17
  40. data/ext/nokogiri/xml_xpath_context.c +134 -127
  41. data/ext/nokogiri/xslt_stylesheet.c +157 -157
  42. data/lib/nokogiri.rb +1 -22
  43. data/lib/nokogiri/css/parser.rb +1 -1
  44. data/lib/nokogiri/extension.rb +26 -0
  45. data/lib/nokogiri/html/document_fragment.rb +15 -15
  46. data/lib/nokogiri/version/constant.rb +1 -1
  47. data/lib/nokogiri/version/info.rb +31 -8
  48. data/lib/nokogiri/xml/document.rb +31 -11
  49. data/lib/nokogiri/xml/node.rb +38 -42
  50. data/lib/nokogiri/xml/reader.rb +2 -9
  51. data/lib/nokogiri/xml/xpath.rb +1 -3
  52. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  53. data/patches/libxml2/0010-parser.c-shrink-the-input-buffer-when-appropriate.patch +70 -0
  54. metadata +8 -41
  55. data/ext/nokogiri/html_document.h +0 -10
  56. data/ext/nokogiri/html_element_description.h +0 -10
  57. data/ext/nokogiri/html_entity_lookup.h +0 -8
  58. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  59. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  60. data/ext/nokogiri/xml_attr.h +0 -9
  61. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  62. data/ext/nokogiri/xml_cdata.h +0 -9
  63. data/ext/nokogiri/xml_comment.h +0 -9
  64. data/ext/nokogiri/xml_document.h +0 -23
  65. data/ext/nokogiri/xml_document_fragment.h +0 -10
  66. data/ext/nokogiri/xml_dtd.h +0 -10
  67. data/ext/nokogiri/xml_element_content.h +0 -10
  68. data/ext/nokogiri/xml_element_decl.h +0 -9
  69. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  70. data/ext/nokogiri/xml_entity_decl.h +0 -10
  71. data/ext/nokogiri/xml_entity_reference.h +0 -9
  72. data/ext/nokogiri/xml_io.c +0 -63
  73. data/ext/nokogiri/xml_io.h +0 -11
  74. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  75. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  76. data/ext/nokogiri/xml_namespace.h +0 -14
  77. data/ext/nokogiri/xml_node.h +0 -13
  78. data/ext/nokogiri/xml_node_set.h +0 -12
  79. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  80. data/ext/nokogiri/xml_reader.h +0 -10
  81. data/ext/nokogiri/xml_relax_ng.h +0 -9
  82. data/ext/nokogiri/xml_sax_parser.h +0 -39
  83. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  84. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  85. data/ext/nokogiri/xml_schema.h +0 -9
  86. data/ext/nokogiri/xml_syntax_error.h +0 -25
  87. data/ext/nokogiri/xml_text.h +0 -9
  88. data/ext/nokogiri/xml_xpath_context.h +0 -10
  89. data/ext/nokogiri/xslt_stylesheet.h +0 -14
@@ -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 */
@@ -1,9 +1,9 @@
1
1
  #include <nokogiri.h>
2
- #include "libxml/xmlerror.h"
3
2
 
4
3
  static VALUE foreign_error_handler_block = Qnil;
5
4
 
6
- static void foreign_error_handler(void* user_data, xmlErrorPtr c_error)
5
+ static void
6
+ foreign_error_handler(void *user_data, xmlErrorPtr c_error)
7
7
  {
8
8
  rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
9
9
  }
@@ -32,9 +32,8 @@ rb_foreign_error_handler(VALUE klass)
32
32
  * Do NOT use this outside of the Nokogiri test suite.
33
33
  */
34
34
  void
35
- init_test_global_handlers()
35
+ noko_init_test_global_handlers()
36
36
  {
37
- VALUE mNokogiri = rb_define_module("Nokogiri");
38
37
  VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
39
38
 
40
39
  rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
@@ -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
  }
@@ -1,4 +1,6 @@
1
- #include <xml_cdata.h>
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlCData;
2
4
 
3
5
  /*
4
6
  * call-seq:
@@ -9,7 +11,8 @@
9
11
  * If +content+ cannot be implicitly converted to a string, this method will
10
12
  * raise a TypeError exception.
11
13
  */
12
- static VALUE new(int argc, VALUE *argv, VALUE klass)
14
+ static VALUE
15
+ new (int argc, VALUE *argv, VALUE klass)
13
16
  {
14
17
  xmlDocPtr xml_doc;
15
18
  xmlNodePtr node;
@@ -31,32 +34,24 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
31
34
 
32
35
  node = xmlNewCDataBlock(xml_doc->doc, content_str, content_str_len);
33
36
 
34
- nokogiri_root_node(node);
37
+ noko_xml_document_pin_node(node);
35
38
 
36
- rb_node = Nokogiri_wrap_xml_node(klass, node);
39
+ rb_node = noko_xml_node_wrap(klass, node);
37
40
  rb_obj_call_init(rb_node, argc, argv);
38
41
 
39
- if(rb_block_given_p()) { rb_yield(rb_node); }
42
+ if (rb_block_given_p()) { rb_yield(rb_node); }
40
43
 
41
44
  return rb_node;
42
45
  }
43
46
 
44
- VALUE cNokogiriXmlCData;
45
- void init_xml_cdata()
47
+ void
48
+ noko_init_xml_cdata()
46
49
  {
47
- VALUE nokogiri = rb_define_module("Nokogiri");
48
- VALUE xml = rb_define_module_under(nokogiri, "XML");
49
- VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
50
- VALUE char_data = rb_define_class_under(xml, "CharacterData", node);
51
- VALUE text = rb_define_class_under(xml, "Text", char_data);
52
-
50
+ assert(cNokogiriXmlText);
53
51
  /*
54
52
  * CData represents a CData node in an xml document.
55
53
  */
56
- VALUE klass = rb_define_class_under(xml, "CDATA", text);
57
-
58
-
59
- cNokogiriXmlCData = klass;
54
+ cNokogiriXmlCData = rb_define_class_under(mNokogiriXml, "CDATA", cNokogiriXmlText);
60
55
 
61
- rb_define_singleton_method(klass, "new", new, -1);
56
+ rb_define_singleton_method(cNokogiriXmlCData, "new", new, -1);
62
57
  }