libxml-ruby 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGES +22 -0
  2. data/README +3 -1
  3. data/ext/libxml/cbg.c +86 -76
  4. data/ext/libxml/extconf.rb +2 -1
  5. data/ext/libxml/libxml.c +899 -885
  6. data/ext/libxml/ruby_libxml.h +65 -70
  7. data/ext/libxml/ruby_xml_attr.c +485 -500
  8. data/ext/libxml/ruby_xml_attributes.c +107 -106
  9. data/ext/libxml/ruby_xml_document.c +355 -356
  10. data/ext/libxml/ruby_xml_dtd.c +119 -117
  11. data/ext/libxml/ruby_xml_error.c +1112 -581
  12. data/ext/libxml/ruby_xml_html_parser.c +35 -34
  13. data/ext/libxml/ruby_xml_input.c +182 -187
  14. data/ext/libxml/ruby_xml_input_cbg.c +197 -179
  15. data/ext/libxml/ruby_xml_node.c +1529 -1566
  16. data/ext/libxml/ruby_xml_node.h +2 -2
  17. data/ext/libxml/ruby_xml_ns.c +150 -156
  18. data/ext/libxml/ruby_xml_parser.c +37 -36
  19. data/ext/libxml/ruby_xml_parser_context.c +657 -659
  20. data/ext/libxml/ruby_xml_reader.c +203 -209
  21. data/ext/libxml/ruby_xml_relaxng.c +29 -25
  22. data/ext/libxml/ruby_xml_sax_parser.c +33 -32
  23. data/ext/libxml/ruby_xml_schema.c +165 -161
  24. data/ext/libxml/ruby_xml_state.c +19 -21
  25. data/ext/libxml/ruby_xml_xinclude.c +24 -25
  26. data/ext/libxml/ruby_xml_xpath.c +108 -108
  27. data/ext/libxml/ruby_xml_xpath_context.c +305 -293
  28. data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
  29. data/ext/libxml/ruby_xml_xpath_object.c +89 -96
  30. data/ext/libxml/ruby_xml_xpointer.c +107 -109
  31. data/ext/libxml/ruby_xml_xpointer.h +13 -13
  32. data/ext/libxml/version.h +2 -2
  33. data/ext/mingw/Rakefile +1 -1
  34. data/ext/vc/libxml_ruby.vcproj +1 -1
  35. data/lib/libxml/error.rb +4 -4
  36. data/test/tc_node_edit.rb +14 -2
  37. data/test/tc_node_text.rb +9 -9
  38. metadata +2 -2
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_html_parser.c 630 2008-11-24 06:53:01Z cfis $ */
1
+ /* $Id: ruby_xml_html_parser.c 650 2008-11-30 03:40:22Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -8,77 +8,78 @@ VALUE cXMLHTMLParser;
8
8
  static ID INPUT_ATTR;
9
9
 
10
10
  /*
11
- * Document-class: LibXML::XML::HTMLParser
12
- *
13
- * The HTML parser implements an HTML 4.0 non-verifying parser with an API
14
- * compatible with the XML::Parser. In contrast with the XML::Parser,
15
- * it can parse "real world" HTML, even if it severely broken from a
16
- * specification point of view. */
17
-
11
+ * Document-class: LibXML::XML::HTMLParser
12
+ *
13
+ * The HTML parser implements an HTML 4.0 non-verifying parser with an API
14
+ * compatible with the XML::Parser. In contrast with the XML::Parser,
15
+ * it can parse "real world" HTML, even if it severely broken from a
16
+ * specification point of view. */
18
17
 
19
18
  /*
20
19
  * call-seq:
21
20
  * XML::HTMLParser.initialize -> parser
22
- *
21
+ *
23
22
  * Initializes a new parser instance with no pre-determined source.
24
23
  */
25
- static VALUE
26
- rxml_html_parser_initialize(VALUE self) {
24
+ static VALUE rxml_html_parser_initialize(VALUE self)
25
+ {
27
26
  VALUE input = rb_class_new_instance(0, NULL, cXMLInput);
28
27
  rb_iv_set(self, "@input", input);
29
28
  return self;
30
29
  }
31
30
 
32
- static htmlDocPtr
33
- rxml_html_parser_read_file(VALUE input) {
31
+ static htmlDocPtr rxml_html_parser_read_file(VALUE input)
32
+ {
34
33
  VALUE file = rb_ivar_get(input, FILE_ATTR);
35
34
  VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
36
35
  VALUE encoding_str = rxml_input_encoding_to_s(Qnil, encoding);
37
- char *xencoding_str = (encoding_str == Qnil ? NULL : StringValuePtr(encoding_str));
36
+ char *xencoding_str = (encoding_str == Qnil ? NULL : StringValuePtr(
37
+ encoding_str));
38
38
  int options = 0;
39
39
 
40
40
  return htmlReadFile(StringValuePtr(file), xencoding_str, options);
41
41
  }
42
42
 
43
- static htmlDocPtr
44
- rxml_html_parser_read_string(VALUE input) {
43
+ static htmlDocPtr rxml_html_parser_read_string(VALUE input)
44
+ {
45
45
  VALUE string = rb_ivar_get(input, STRING_ATTR);
46
46
  VALUE base_url = rb_ivar_get(input, BASE_URL_ATTR);
47
47
  char *xbase_url = (base_url == Qnil ? NULL : StringValuePtr(base_url));
48
48
  VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
49
49
  VALUE encoding_str = rxml_input_encoding_to_s(Qnil, encoding);
50
- char *xencoding_str = (encoding_str == Qnil ? NULL : StringValuePtr(encoding_str));
50
+ char *xencoding_str = (encoding_str == Qnil ? NULL : StringValuePtr(
51
+ encoding_str));
51
52
  int options = 0;
52
53
 
53
54
  return htmlReadMemory(StringValuePtr(string), RSTRING_LEN(string),
54
- xbase_url, xencoding_str, options);
55
+ xbase_url, xencoding_str, options);
55
56
  }
56
57
 
57
- static htmlDocPtr
58
- rxml_html_parser_read_io(VALUE input) {
58
+ static htmlDocPtr rxml_html_parser_read_io(VALUE input)
59
+ {
59
60
  VALUE io = rb_ivar_get(input, IO_ATTR);
60
61
  VALUE base_url = rb_ivar_get(input, BASE_URL_ATTR);
61
62
  char *xbase_url = (base_url == Qnil ? NULL : StringValuePtr(base_url));
62
63
  VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
63
64
  VALUE encoding_str = rxml_input_encoding_to_s(Qnil, encoding);
64
- char *xencoding_str = (encoding_str == Qnil ? NULL : StringValuePtr(encoding_str));
65
+ char *xencoding_str = (encoding_str == Qnil ? NULL : StringValuePtr(
66
+ encoding_str));
65
67
  int options = 0;
66
-
68
+
67
69
  return htmlReadIO((xmlInputReadCallback) rxml_read_callback, NULL,
68
- (void *)io,
69
- xbase_url, xencoding_str, options);
70
+ (void *) io, xbase_url, xencoding_str, options);
70
71
  }
71
72
 
72
73
  /*
73
74
  * call-seq:
74
75
  * parser.parse -> document
75
- *
76
+ *
76
77
  * Parse the input XML and create an XML::Document with
77
78
  * it's content. If an error occurs, XML::Parser::ParseError
78
79
  * is thrown.
79
80
  */
80
- static VALUE
81
- rxml_html_parser_parse(VALUE self) {
81
+ static VALUE rxml_html_parser_parse(VALUE self)
82
+ {
82
83
  VALUE input = rb_ivar_get(self, INPUT_ATTR);
83
84
  htmlDocPtr xdoc;
84
85
 
@@ -90,25 +91,25 @@ rxml_html_parser_parse(VALUE self) {
90
91
  xdoc = rxml_html_parser_read_io(input);
91
92
  else
92
93
  rb_raise(rb_eArgError, "You must specify a parser data source");
93
-
94
+
94
95
  if (!xdoc)
95
96
  rxml_raise(&xmlLastError);
96
97
 
97
98
  return rxml_document_wrap(xdoc);
98
99
  }
99
100
 
100
- // Rdoc needs to know
101
+ // Rdoc needs to know
101
102
  #ifdef RDOC_NEVER_DEFINED
102
- mLibXML = rb_define_module("LibXML");
103
- mXML = rb_define_module_under(mLibXML, "XML");
103
+ mLibXML = rb_define_module("LibXML");
104
+ mXML = rb_define_module_under(mLibXML, "XML");
104
105
  #endif
105
106
 
106
- void
107
- ruby_init_html_parser(void) {
107
+ void ruby_init_html_parser(void)
108
+ {
108
109
  INPUT_ATTR = rb_intern("@input");
109
110
 
110
111
  cXMLHTMLParser = rb_define_class_under(mXML, "HTMLParser", rb_cObject);
111
-
112
+
112
113
  /* Atributes */
113
114
  rb_define_attr(cXMLHTMLParser, "input", 1, 0);
114
115
 
@@ -8,54 +8,54 @@
8
8
  VALUE cXMLInput;
9
9
 
10
10
  /*
11
- * Document-class: LibXML::XML::Input
12
- *
13
- * Input is a helper class that defines a libxml data source.
14
- * Libxml can parse files, strings, io streams and documents
15
- * accessible via networking protocols such as http.
16
- * Be default, the ruby-libxml bindings expose parsing
17
- * files, io streams and strings.
18
- *
19
- * Generally you will not directly work with the input object,
20
- * but instead will use the various Document and Parser apis.
21
- * For example:
22
- *
23
- * parser = XML::Parser.file('my_file')
24
- * parser = XML::Parser.string('<myxml/>')
25
- * parser = XML::Parser.io(File.open('my_file'))
26
- *
27
- * XML::HTMLParser, XML::Reader, XML::SaxParser and
28
- * XML::Document work in the same way.
29
- *
30
- * LibXML converts all data sources to UTF8 internally before
31
- * processing them. By default, LibXML will determine a data
32
- * source's encoding using the algorithm described on its
33
- * website[* http://xmlsoft.org/encoding.html].
34
- *
35
- * However, its some cases it is possible to tell LibXML
36
- * the data source's encoding via the constants defined in
37
- * the Encoding module.
38
- *
39
- * Example 1:
40
- *
41
- * parser = XML::Parser.new
42
- * parser.input.encoding = XML::Input::ISO_8859_1
43
- * parser.io = File.open('some_file', 'rb')
44
- * doc = parser.parse
45
- *
46
- * Example 2:
47
- *
48
- * parser = XML::HTMLParser.new
49
- * parser.encoding = XML::Input::ISO_8859_1
50
- * parser.file = "some_file"
51
- * doc = parser.parse
52
- *
53
- * Example 3:
54
- *
55
- * document = XML::Document.new
56
- * encoding_string = XML::Input.encoding_to_s(XML::Encoding::ISO_8859_1)
57
- * document.encoding = document
58
- * doc << XML::Node.new */
11
+ * Document-class: LibXML::XML::Input
12
+ *
13
+ * Input is a helper class that defines a libxml data source.
14
+ * Libxml can parse files, strings, io streams and documents
15
+ * accessible via networking protocols such as http.
16
+ * Be default, the ruby-libxml bindings expose parsing
17
+ * files, io streams and strings.
18
+ *
19
+ * Generally you will not directly work with the input object,
20
+ * but instead will use the various Document and Parser apis.
21
+ * For example:
22
+ *
23
+ * parser = XML::Parser.file('my_file')
24
+ * parser = XML::Parser.string('<myxml/>')
25
+ * parser = XML::Parser.io(File.open('my_file'))
26
+ *
27
+ * XML::HTMLParser, XML::Reader, XML::SaxParser and
28
+ * XML::Document work in the same way.
29
+ *
30
+ * LibXML converts all data sources to UTF8 internally before
31
+ * processing them. By default, LibXML will determine a data
32
+ * source's encoding using the algorithm described on its
33
+ * website[* http://xmlsoft.org/encoding.html].
34
+ *
35
+ * However, its some cases it is possible to tell LibXML
36
+ * the data source's encoding via the constants defined in
37
+ * the Encoding module.
38
+ *
39
+ * Example 1:
40
+ *
41
+ * parser = XML::Parser.new
42
+ * parser.input.encoding = XML::Input::ISO_8859_1
43
+ * parser.io = File.open('some_file', 'rb')
44
+ * doc = parser.parse
45
+ *
46
+ * Example 2:
47
+ *
48
+ * parser = XML::HTMLParser.new
49
+ * parser.encoding = XML::Input::ISO_8859_1
50
+ * parser.file = "some_file"
51
+ * doc = parser.parse
52
+ *
53
+ * Example 3:
54
+ *
55
+ * document = XML::Document.new
56
+ * encoding_string = XML::Input.encoding_to_s(XML::Encoding::ISO_8859_1)
57
+ * document.encoding = document
58
+ * doc << XML::Node.new */
59
59
 
60
60
  ID BASE_URL_ATTR;
61
61
  ID ENCODING_ATTR;
@@ -65,18 +65,18 @@ ID IO_ATTR;
65
65
 
66
66
  static ID READ_METHOD;
67
67
 
68
-
69
68
  /* This method is called by libxml when it wants to read
70
- more data from a stream. We go with the duck typing
71
- solution to support StringIO objects. */
72
- int rxml_read_callback(void *context, char *buffer, int len) {
73
- VALUE io = (VALUE)context;
69
+ more data from a stream. We go with the duck typing
70
+ solution to support StringIO objects. */
71
+ int rxml_read_callback(void *context, char *buffer, int len)
72
+ {
73
+ VALUE io = (VALUE) context;
74
74
  VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
75
75
  int size;
76
-
77
- if(string == Qnil)
76
+
77
+ if (string == Qnil)
78
78
  return 0;
79
-
79
+
80
80
  size = RSTRING_LEN(string);
81
81
  memcpy(buffer, StringValuePtr(string), size);
82
82
 
@@ -86,89 +86,88 @@ int rxml_read_callback(void *context, char *buffer, int len) {
86
86
  /*
87
87
  * call-seq:
88
88
  * Input.encoding_to_s(Input::ENCODING) -> "encoding"
89
- *
89
+ *
90
90
  * Converts an encoding contstant defined on the XML::Input
91
91
  * class to its text representation.
92
92
  */
93
- VALUE
94
- rxml_input_encoding_to_s(VALUE self, VALUE encoding)
93
+ VALUE rxml_input_encoding_to_s(VALUE self, VALUE encoding)
95
94
  {
96
95
  char* encodingStr = NULL;
97
96
 
98
97
  switch (NUM2INT(encoding))
99
98
  {
100
- case XML_CHAR_ENCODING_ERROR:
101
- encodingStr = "Error";
102
- break;
103
- case XML_CHAR_ENCODING_NONE:
104
- encodingStr = "None";
105
- break;
106
- case XML_CHAR_ENCODING_UTF8:
107
- encodingStr = "UTF-8";
108
- break;
109
- case XML_CHAR_ENCODING_UTF16LE:
110
- encodingStr = "UTF-16LE";
111
- break;
112
- case XML_CHAR_ENCODING_UTF16BE:
113
- encodingStr = "UTF-16BE";
114
- break;
115
- case XML_CHAR_ENCODING_UCS4LE:
116
- encodingStr = "UCS-4LE";
117
- break;
118
- case XML_CHAR_ENCODING_UCS4BE:
119
- encodingStr = "UCS-4BE";
120
- break;
121
- case XML_CHAR_ENCODING_EBCDIC:
122
- encodingStr = "EBCDIC";
123
- break;
124
- case XML_CHAR_ENCODING_UCS4_2143:
125
- encodingStr = "UCS-4";
126
- break;
127
- case XML_CHAR_ENCODING_UCS4_3412:
128
- encodingStr = "UCS-4";
129
- break;
130
- case XML_CHAR_ENCODING_UCS2:
131
- encodingStr = "UCS-2";
132
- break;
133
- case XML_CHAR_ENCODING_8859_1:
134
- encodingStr = "ISO-8859-1";
135
- break;
136
- case XML_CHAR_ENCODING_8859_2:
137
- encodingStr = "ISO-8859-2";
138
- break;
139
- case XML_CHAR_ENCODING_8859_3:
140
- encodingStr = "ISO-8859-3";
141
- break;
142
- case XML_CHAR_ENCODING_8859_4:
143
- encodingStr = "ISO-8859-4";
144
- break;
145
- case XML_CHAR_ENCODING_8859_5:
146
- encodingStr = "ISO-8859-5";
147
- break;
148
- case XML_CHAR_ENCODING_8859_6:
149
- encodingStr = "ISO-8859-6";
150
- break;
151
- case XML_CHAR_ENCODING_8859_7:
152
- encodingStr = "ISO-8859-7";
153
- break;
154
- case XML_CHAR_ENCODING_8859_8:
155
- encodingStr = "ISO-8859-8";
156
- break;
157
- case XML_CHAR_ENCODING_8859_9:
158
- encodingStr = "ISO-8859-9";
159
- break;
160
- case XML_CHAR_ENCODING_2022_JP:
161
- encodingStr = "ISO-2022-JP";
162
- break;
163
- case XML_CHAR_ENCODING_SHIFT_JIS:
164
- encodingStr = "Shift_JIS";
165
- break;
166
- case XML_CHAR_ENCODING_EUC_JP:
167
- encodingStr = "EUC-JP";
168
- break;
169
- case XML_CHAR_ENCODING_ASCII:
170
- encodingStr = "ASCII";
171
- break;
99
+ case XML_CHAR_ENCODING_ERROR:
100
+ encodingStr = "Error";
101
+ break;
102
+ case XML_CHAR_ENCODING_NONE:
103
+ encodingStr = "None";
104
+ break;
105
+ case XML_CHAR_ENCODING_UTF8:
106
+ encodingStr = "UTF-8";
107
+ break;
108
+ case XML_CHAR_ENCODING_UTF16LE:
109
+ encodingStr = "UTF-16LE";
110
+ break;
111
+ case XML_CHAR_ENCODING_UTF16BE:
112
+ encodingStr = "UTF-16BE";
113
+ break;
114
+ case XML_CHAR_ENCODING_UCS4LE:
115
+ encodingStr = "UCS-4LE";
116
+ break;
117
+ case XML_CHAR_ENCODING_UCS4BE:
118
+ encodingStr = "UCS-4BE";
119
+ break;
120
+ case XML_CHAR_ENCODING_EBCDIC:
121
+ encodingStr = "EBCDIC";
122
+ break;
123
+ case XML_CHAR_ENCODING_UCS4_2143:
124
+ encodingStr = "UCS-4";
125
+ break;
126
+ case XML_CHAR_ENCODING_UCS4_3412:
127
+ encodingStr = "UCS-4";
128
+ break;
129
+ case XML_CHAR_ENCODING_UCS2:
130
+ encodingStr = "UCS-2";
131
+ break;
132
+ case XML_CHAR_ENCODING_8859_1:
133
+ encodingStr = "ISO-8859-1";
134
+ break;
135
+ case XML_CHAR_ENCODING_8859_2:
136
+ encodingStr = "ISO-8859-2";
137
+ break;
138
+ case XML_CHAR_ENCODING_8859_3:
139
+ encodingStr = "ISO-8859-3";
140
+ break;
141
+ case XML_CHAR_ENCODING_8859_4:
142
+ encodingStr = "ISO-8859-4";
143
+ break;
144
+ case XML_CHAR_ENCODING_8859_5:
145
+ encodingStr = "ISO-8859-5";
146
+ break;
147
+ case XML_CHAR_ENCODING_8859_6:
148
+ encodingStr = "ISO-8859-6";
149
+ break;
150
+ case XML_CHAR_ENCODING_8859_7:
151
+ encodingStr = "ISO-8859-7";
152
+ break;
153
+ case XML_CHAR_ENCODING_8859_8:
154
+ encodingStr = "ISO-8859-8";
155
+ break;
156
+ case XML_CHAR_ENCODING_8859_9:
157
+ encodingStr = "ISO-8859-9";
158
+ break;
159
+ case XML_CHAR_ENCODING_2022_JP:
160
+ encodingStr = "ISO-2022-JP";
161
+ break;
162
+ case XML_CHAR_ENCODING_SHIFT_JIS:
163
+ encodingStr = "Shift_JIS";
164
+ break;
165
+ case XML_CHAR_ENCODING_EUC_JP:
166
+ encodingStr = "EUC-JP";
167
+ break;
168
+ case XML_CHAR_ENCODING_ASCII:
169
+ encodingStr = "ASCII";
170
+ break;
172
171
  }
173
172
 
174
173
  return rb_str_new2(encodingStr);
@@ -177,35 +176,34 @@ rxml_input_encoding_to_s(VALUE self, VALUE encoding)
177
176
  /*
178
177
  * call-seq:
179
178
  * initialize -> LibXML::XML::Input instance
180
- *
179
+ *
181
180
  * Initialize a new intput object.
182
181
  */
183
- static VALUE
184
- rxml_input_initialize(VALUE self) {
182
+ static VALUE rxml_input_initialize(VALUE self)
183
+ {
185
184
  rb_ivar_set(self, ENCODING_ATTR, INT2NUM(XML_CHAR_ENCODING_UTF8));
186
185
  return self;
187
186
  }
188
187
 
189
-
190
188
  /*
191
189
  * call-seq:
192
190
  * input.FILE -> "FILE"
193
- *
191
+ *
194
192
  * Obtain the FILE this parser will read from.
195
193
  */
196
- static VALUE
197
- rxml_input_file_get(VALUE self) {
194
+ static VALUE rxml_input_file_get(VALUE self)
195
+ {
198
196
  return rb_ivar_get(self, FILE_ATTR);
199
197
  }
200
198
 
201
199
  /*
202
200
  * call-seq:
203
201
  * input.FILE = "FILE"
204
- *
202
+ *
205
203
  * Set the FILE this parser will read from.
206
204
  */
207
- static VALUE
208
- rxml_input_file_set(VALUE self, VALUE FILE) {
205
+ static VALUE rxml_input_file_set(VALUE self, VALUE FILE)
206
+ {
209
207
  Check_Type(FILE, T_STRING);
210
208
  rb_ivar_set(self, FILE_ATTR, FILE);
211
209
  rb_ivar_set(self, IO_ATTR, Qnil);
@@ -213,27 +211,25 @@ rxml_input_file_set(VALUE self, VALUE FILE) {
213
211
  return self;
214
212
  }
215
213
 
216
-
217
214
  /*
218
215
  * call-seq:
219
216
  * input.string -> "string"
220
- *
217
+ *
221
218
  * Obtain the string this parser will read from.
222
219
  */
223
- static VALUE
224
- rxml_input_string_get(VALUE self) {
220
+ static VALUE rxml_input_string_get(VALUE self)
221
+ {
225
222
  return rb_ivar_get(self, STRING_ATTR);
226
223
  }
227
224
 
228
-
229
225
  /*
230
226
  * call-seq:
231
227
  * input.string = "string"
232
- *
228
+ *
233
229
  * Set the string this parser will read from.
234
230
  */
235
- static VALUE
236
- rxml_input_string_set(VALUE self, VALUE string) {
231
+ static VALUE rxml_input_string_set(VALUE self, VALUE string)
232
+ {
237
233
  Check_Type(string, T_STRING);
238
234
  rb_ivar_set(self, FILE_ATTR, Qnil);
239
235
  rb_ivar_set(self, IO_ATTR, Qnil);
@@ -244,44 +240,42 @@ rxml_input_string_set(VALUE self, VALUE string) {
244
240
  /*
245
241
  * call-seq:
246
242
  * input.io -> IO
247
- *
243
+ *
248
244
  * Obtain the IO instance this parser works with.
249
245
  */
250
- static VALUE
251
- rxml_input_io_get(VALUE self) {
246
+ static VALUE rxml_input_io_get(VALUE self)
247
+ {
252
248
  return rb_ivar_get(self, IO_ATTR);
253
249
  }
254
250
 
255
251
  /*
256
252
  * call-seq:
257
253
  * input.io = IO
258
- *
254
+ *
259
255
  * Set the IO instance this parser works with.
260
256
  */
261
- static VALUE
262
- rxml_input_io_set(VALUE self, VALUE io) {
257
+ static VALUE rxml_input_io_set(VALUE self, VALUE io)
258
+ {
263
259
  rb_ivar_set(self, FILE_ATTR, Qnil);
264
260
  rb_ivar_set(self, IO_ATTR, io);
265
261
  rb_ivar_set(self, STRING_ATTR, Qnil);
266
262
  return self;
267
263
  }
268
264
 
269
- // Rdoc needs to know
265
+ // Rdoc needs to know
270
266
  #ifdef RDOC_NEVER_DEFINED
271
- mLibXML = rb_define_module("LibXML");
272
- mXML = rb_define_module_under(mLibXML, "XML");
267
+ mLibXML = rb_define_module("LibXML");
268
+ mXML = rb_define_module_under(mLibXML, "XML");
273
269
  #endif
274
270
 
275
-
276
-
277
- // Rdoc needs to know
271
+ // Rdoc needs to know
278
272
  #ifdef RDOC_NEVER_DEFINED
279
- mLibXML = rb_define_module("LibXML");
280
- mXML = rb_define_module_under(mLibXML, "XML");
273
+ mLibXML = rb_define_module("LibXML");
274
+ mXML = rb_define_module_under(mLibXML, "XML");
281
275
  #endif
282
276
 
283
- void
284
- ruby_init_xml_input(void) {
277
+ void ruby_init_xml_input(void)
278
+ {
285
279
  BASE_URL_ATTR = rb_intern("@base_url");
286
280
  ENCODING_ATTR = rb_intern("@encoding");
287
281
  FILE_ATTR = rb_intern("@file");
@@ -291,33 +285,34 @@ ruby_init_xml_input(void) {
291
285
  READ_METHOD = rb_intern("read");
292
286
 
293
287
  cXMLInput = rb_define_class_under(mXML, "Input", rb_cObject);
294
- rb_define_singleton_method(cXMLInput, "encoding_to_s", rxml_input_encoding_to_s, 1);
288
+ rb_define_singleton_method(cXMLInput, "encoding_to_s",
289
+ rxml_input_encoding_to_s, 1);
295
290
 
296
291
  rb_define_const(cXMLInput, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
297
- rb_define_const(cXMLInput, "ERROR", INT2NUM(XML_CHAR_ENCODING_ERROR)); /* No char encoding detected */
298
- rb_define_const(cXMLInput, "NONE", INT2NUM(XML_CHAR_ENCODING_NONE)); /* No char encoding detected */
299
- rb_define_const(cXMLInput, "UTF8", INT2NUM(XML_CHAR_ENCODING_UTF8)); /* UTF-8 */
300
- rb_define_const(cXMLInput, "UTF16LE", INT2NUM(XML_CHAR_ENCODING_UTF16LE)); /* UTF-16 little endian */
301
- rb_define_const(cXMLInput, "UTF16BE", INT2NUM(XML_CHAR_ENCODING_UTF16BE)); /* UTF-16 big endian */
302
- rb_define_const(cXMLInput, "UCS4LE", INT2NUM(XML_CHAR_ENCODING_UCS4LE)); /* UCS-4 little endian */
303
- rb_define_const(cXMLInput, "UCS4BE", INT2NUM(XML_CHAR_ENCODING_UCS4BE)); /* UCS-4 big endian */
304
- rb_define_const(cXMLInput, "EBCDIC", INT2NUM(XML_CHAR_ENCODING_EBCDIC)); /* EBCDIC uh! */
292
+ rb_define_const(cXMLInput, "ERROR", INT2NUM(XML_CHAR_ENCODING_ERROR)); /* No char encoding detected */
293
+ rb_define_const(cXMLInput, "NONE", INT2NUM(XML_CHAR_ENCODING_NONE)); /* No char encoding detected */
294
+ rb_define_const(cXMLInput, "UTF8", INT2NUM(XML_CHAR_ENCODING_UTF8)); /* UTF-8 */
295
+ rb_define_const(cXMLInput, "UTF16LE", INT2NUM(XML_CHAR_ENCODING_UTF16LE)); /* UTF-16 little endian */
296
+ rb_define_const(cXMLInput, "UTF16BE", INT2NUM(XML_CHAR_ENCODING_UTF16BE)); /* UTF-16 big endian */
297
+ rb_define_const(cXMLInput, "UCS4LE", INT2NUM(XML_CHAR_ENCODING_UCS4LE)); /* UCS-4 little endian */
298
+ rb_define_const(cXMLInput, "UCS4BE", INT2NUM(XML_CHAR_ENCODING_UCS4BE)); /* UCS-4 big endian */
299
+ rb_define_const(cXMLInput, "EBCDIC", INT2NUM(XML_CHAR_ENCODING_EBCDIC)); /* EBCDIC uh! */
305
300
  rb_define_const(cXMLInput, "UCS4_2143", INT2NUM(XML_CHAR_ENCODING_UCS4_2143)); /* UCS-4 unusual ordering */
306
301
  rb_define_const(cXMLInput, "UCS4_3412", INT2NUM(XML_CHAR_ENCODING_UCS4_3412)); /* UCS-4 unusual ordering */
307
- rb_define_const(cXMLInput, "UCS2", INT2NUM(XML_CHAR_ENCODING_UCS2)); /* UCS-2 */
308
- rb_define_const(cXMLInput, "ISO_8859_1", INT2NUM(XML_CHAR_ENCODING_8859_1)); /* ISO-8859-1 ISO Latin 1 */
309
- rb_define_const(cXMLInput, "ISO_8859_2", INT2NUM(XML_CHAR_ENCODING_8859_2)); /* ISO-8859-2 ISO Latin 2 */
310
- rb_define_const(cXMLInput, "ISO_8859_3", INT2NUM(XML_CHAR_ENCODING_8859_3)); /* ISO-8859-3 */
311
- rb_define_const(cXMLInput, "ISO_8859_4", INT2NUM(XML_CHAR_ENCODING_8859_4)); /* ISO-8859-4 */
312
- rb_define_const(cXMLInput, "ISO_8859_5", INT2NUM(XML_CHAR_ENCODING_8859_5)); /* ISO-8859-5 */
313
- rb_define_const(cXMLInput, "ISO_8859_6", INT2NUM(XML_CHAR_ENCODING_8859_6)); /* ISO-8859-6 */
314
- rb_define_const(cXMLInput, "ISO_8859_7", INT2NUM(XML_CHAR_ENCODING_8859_7)); /* ISO-8859-7 */
315
- rb_define_const(cXMLInput, "ISO_8859_8", INT2NUM(XML_CHAR_ENCODING_8859_8)); /* ISO-8859-8 */
316
- rb_define_const(cXMLInput, "ISO_8859_9", INT2NUM(XML_CHAR_ENCODING_8859_9)); /* ISO-8859-9 */
317
- rb_define_const(cXMLInput, "ISO_2022_JP", INT2NUM(XML_CHAR_ENCODING_2022_JP)); /* ISO-2022-JP */
302
+ rb_define_const(cXMLInput, "UCS2", INT2NUM(XML_CHAR_ENCODING_UCS2)); /* UCS-2 */
303
+ rb_define_const(cXMLInput, "ISO_8859_1", INT2NUM(XML_CHAR_ENCODING_8859_1)); /* ISO-8859-1 ISO Latin 1 */
304
+ rb_define_const(cXMLInput, "ISO_8859_2", INT2NUM(XML_CHAR_ENCODING_8859_2)); /* ISO-8859-2 ISO Latin 2 */
305
+ rb_define_const(cXMLInput, "ISO_8859_3", INT2NUM(XML_CHAR_ENCODING_8859_3)); /* ISO-8859-3 */
306
+ rb_define_const(cXMLInput, "ISO_8859_4", INT2NUM(XML_CHAR_ENCODING_8859_4)); /* ISO-8859-4 */
307
+ rb_define_const(cXMLInput, "ISO_8859_5", INT2NUM(XML_CHAR_ENCODING_8859_5)); /* ISO-8859-5 */
308
+ rb_define_const(cXMLInput, "ISO_8859_6", INT2NUM(XML_CHAR_ENCODING_8859_6)); /* ISO-8859-6 */
309
+ rb_define_const(cXMLInput, "ISO_8859_7", INT2NUM(XML_CHAR_ENCODING_8859_7)); /* ISO-8859-7 */
310
+ rb_define_const(cXMLInput, "ISO_8859_8", INT2NUM(XML_CHAR_ENCODING_8859_8)); /* ISO-8859-8 */
311
+ rb_define_const(cXMLInput, "ISO_8859_9", INT2NUM(XML_CHAR_ENCODING_8859_9)); /* ISO-8859-9 */
312
+ rb_define_const(cXMLInput, "ISO_2022_JP", INT2NUM(XML_CHAR_ENCODING_2022_JP)); /* ISO-2022-JP */
318
313
  rb_define_const(cXMLInput, "SHIFT_JIS", INT2NUM(XML_CHAR_ENCODING_SHIFT_JIS)); /* Shift_JIS */
319
- rb_define_const(cXMLInput, "EUC_JP", INT2NUM(XML_CHAR_ENCODING_EUC_JP)); /* EUC-JP */
320
- rb_define_const(cXMLInput, "ASCII", INT2NUM(XML_CHAR_ENCODING_ASCII)); /* pure ASCII */
314
+ rb_define_const(cXMLInput, "EUC_JP", INT2NUM(XML_CHAR_ENCODING_EUC_JP)); /* EUC-JP */
315
+ rb_define_const(cXMLInput, "ASCII", INT2NUM(XML_CHAR_ENCODING_ASCII)); /* pure ASCII */
321
316
 
322
317
  rb_define_attr(cXMLInput, "base_url", 1, 1);
323
318
  rb_define_attr(cXMLInput, "encoding", 1, 1);