libxml-ruby 2.7.0 → 2.9.0

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.
Files changed (85) hide show
  1. checksums.yaml +6 -14
  2. data/HISTORY +33 -11
  3. data/README.rdoc +7 -7
  4. data/Rakefile +80 -77
  5. data/ext/libxml/extconf.h +4 -5
  6. data/ext/libxml/extconf.rb +57 -118
  7. data/ext/libxml/libxml.c +4 -0
  8. data/ext/libxml/ruby_xml.c +977 -893
  9. data/ext/libxml/ruby_xml.h +20 -10
  10. data/ext/libxml/ruby_xml_attr.c +333 -333
  11. data/ext/libxml/ruby_xml_attr_decl.c +2 -2
  12. data/ext/libxml/ruby_xml_cbg.c +85 -85
  13. data/ext/libxml/ruby_xml_document.c +1133 -1147
  14. data/ext/libxml/ruby_xml_dtd.c +261 -268
  15. data/ext/libxml/ruby_xml_encoding.c +262 -260
  16. data/ext/libxml/ruby_xml_encoding.h +19 -19
  17. data/ext/libxml/ruby_xml_html_parser_context.c +337 -338
  18. data/ext/libxml/ruby_xml_input_cbg.c +191 -191
  19. data/ext/libxml/ruby_xml_io.c +52 -50
  20. data/ext/libxml/ruby_xml_namespace.c +2 -2
  21. data/ext/libxml/ruby_xml_node.c +1446 -1452
  22. data/ext/libxml/ruby_xml_parser_context.c +999 -1001
  23. data/ext/libxml/ruby_xml_reader.c +1226 -1228
  24. data/ext/libxml/ruby_xml_relaxng.c +110 -111
  25. data/ext/libxml/ruby_xml_sax2_handler.c +326 -328
  26. data/ext/libxml/ruby_xml_schema.c +300 -301
  27. data/ext/libxml/ruby_xml_version.h +3 -3
  28. data/ext/libxml/ruby_xml_writer.c +34 -16
  29. data/ext/libxml/ruby_xml_xpath.c +188 -187
  30. data/ext/libxml/ruby_xml_xpath_context.c +360 -361
  31. data/ext/libxml/ruby_xml_xpath_object.c +335 -335
  32. data/libxml-ruby.gemspec +47 -44
  33. data/test/tc_attr.rb +5 -7
  34. data/test/tc_attr_decl.rb +5 -6
  35. data/test/tc_attributes.rb +1 -2
  36. data/test/tc_canonicalize.rb +1 -2
  37. data/test/tc_deprecated_require.rb +1 -2
  38. data/test/tc_document.rb +4 -5
  39. data/test/tc_document_write.rb +2 -3
  40. data/test/tc_dtd.rb +4 -5
  41. data/test/tc_encoding.rb +126 -126
  42. data/test/tc_encoding_sax.rb +4 -3
  43. data/test/tc_error.rb +14 -15
  44. data/test/tc_html_parser.rb +15 -7
  45. data/test/tc_html_parser_context.rb +1 -2
  46. data/test/tc_namespace.rb +2 -3
  47. data/test/tc_namespaces.rb +5 -6
  48. data/test/tc_node.rb +2 -3
  49. data/test/tc_node_cdata.rb +2 -3
  50. data/test/tc_node_comment.rb +1 -2
  51. data/test/tc_node_copy.rb +1 -2
  52. data/test/tc_node_edit.rb +5 -7
  53. data/test/tc_node_pi.rb +1 -2
  54. data/test/tc_node_text.rb +2 -3
  55. data/test/tc_node_write.rb +2 -3
  56. data/test/tc_node_xlink.rb +1 -2
  57. data/test/tc_parser.rb +18 -24
  58. data/test/tc_parser_context.rb +6 -7
  59. data/test/tc_properties.rb +1 -2
  60. data/test/tc_reader.rb +9 -10
  61. data/test/tc_relaxng.rb +4 -5
  62. data/test/tc_sax_parser.rb +9 -10
  63. data/test/tc_schema.rb +4 -5
  64. data/test/tc_traversal.rb +1 -2
  65. data/test/tc_writer.rb +1 -2
  66. data/test/tc_xinclude.rb +1 -2
  67. data/test/tc_xml.rb +1 -2
  68. data/test/tc_xpath.rb +8 -9
  69. data/test/tc_xpath_context.rb +3 -4
  70. data/test/tc_xpath_expression.rb +3 -4
  71. data/test/tc_xpointer.rb +1 -3
  72. data/test/test_helper.rb +3 -1
  73. data/test/test_suite.rb +0 -1
  74. metadata +90 -72
  75. data/test/etc_doc_to_s.rb +0 -21
  76. data/test/ets_doc_file.rb +0 -17
  77. data/test/ets_doc_to_s.rb +0 -23
  78. data/test/ets_gpx.rb +0 -28
  79. data/test/ets_node_gc.rb +0 -23
  80. data/test/ets_test.xml +0 -2
  81. data/test/ets_tsr.rb +0 -11
  82. data/test/model/kml_sample.xml +0 -915
  83. data/test/remove_test.rb +0 -9
  84. data/test/tc_gc.rb +0 -86
  85. data/test/tc_parser.rb.orig +0 -384
@@ -1,191 +1,191 @@
1
- /* Author: Martin Povolny (xpovolny@fi.muni.cz) */
2
-
3
- #include "ruby_libxml.h"
4
- #include "ruby_xml_input_cbg.h"
5
-
6
- /* Document-class: LibXML::XML::InputCallbacks
7
- *
8
- * Support for adding custom scheme handlers. */
9
-
10
- static ic_scheme *first_scheme = 0;
11
-
12
- int ic_match(char const *filename)
13
- {
14
- ic_scheme *scheme;
15
-
16
- //fprintf( stderr, "ic_match: %s\n", filename );
17
-
18
- scheme = first_scheme;
19
- while (0 != scheme)
20
- {
21
- if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
22
- {
23
- return 1;
24
- }
25
- scheme = scheme->next_scheme;
26
- }
27
- return 0;
28
- }
29
-
30
- void* ic_open(char const *filename)
31
- {
32
- ic_doc_context *ic_doc;
33
- ic_scheme *scheme;
34
- VALUE res;
35
-
36
- scheme = first_scheme;
37
- while (0 != scheme)
38
- {
39
- if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
40
- {
41
- ic_doc = (ic_doc_context*) malloc(sizeof(ic_doc_context));
42
-
43
- res = rb_funcall(scheme->class, rb_intern("document_query"), 1,
44
- rb_str_new2(filename));
45
-
46
- ic_doc->buffer = strdup(StringValuePtr(res));
47
-
48
- ic_doc->bpos = ic_doc->buffer;
49
- ic_doc->remaining = strlen(ic_doc->buffer);
50
- return ic_doc;
51
- }
52
- scheme = scheme->next_scheme;
53
- }
54
- return 0;
55
- }
56
-
57
- int ic_read(void *context, char *buffer, int len)
58
- {
59
- ic_doc_context *ic_doc;
60
- int ret_len;
61
- ic_doc = (ic_doc_context*) context;
62
-
63
- if (len >= ic_doc->remaining)
64
- {
65
- ret_len = ic_doc->remaining;
66
- }
67
- else
68
- {
69
- ret_len = len;
70
- }
71
- ic_doc->remaining -= ret_len;
72
- strncpy(buffer, ic_doc->bpos, ret_len);
73
- ic_doc->bpos += ret_len;
74
-
75
- return ret_len;
76
- }
77
-
78
- int ic_close(void *context)
79
- {
80
- ruby_xfree(((ic_doc_context*) context)->buffer);
81
- ruby_xfree(context);
82
- return 1;
83
- }
84
-
85
- /*
86
- * call-seq:
87
- * register
88
- *
89
- * Register a new set of I/O callback for handling parser input.
90
- */
91
- static VALUE input_callbacks_register_input_callbacks()
92
- {
93
- xmlRegisterInputCallbacks(ic_match, ic_open, ic_read, ic_close);
94
- return (Qtrue);
95
- }
96
-
97
- /*
98
- * call-seq:
99
- * add_scheme
100
- *
101
- * No documentation available.
102
- */
103
- static VALUE input_callbacks_add_scheme(VALUE self, VALUE scheme_name,
104
- VALUE class)
105
- {
106
- ic_scheme *scheme;
107
-
108
- Check_Type(scheme_name, T_STRING);
109
-
110
- scheme = (ic_scheme*) malloc(sizeof(ic_scheme));
111
- scheme->next_scheme = 0;
112
- scheme->scheme_name = strdup(StringValuePtr(scheme_name)); /* TODO alloc, dealloc */
113
- scheme->name_len = strlen(scheme->scheme_name);
114
- scheme->class = class; /* TODO alloc, dealloc */
115
-
116
- //fprintf( stderr, "registered: %s, %d, %s\n", scheme->scheme_name, scheme->name_len, scheme->class );
117
-
118
- if (0 == first_scheme)
119
- first_scheme = scheme;
120
- else
121
- {
122
- ic_scheme *pos;
123
- pos = first_scheme;
124
- while (0 != pos->next_scheme)
125
- pos = pos->next_scheme;
126
- pos->next_scheme = scheme;
127
- }
128
-
129
- return (Qtrue);
130
- }
131
-
132
- /*
133
- * call-seq:
134
- * remove_scheme
135
- *
136
- * No documentation available.
137
- */
138
- static VALUE input_callbacks_remove_scheme(VALUE self, VALUE scheme_name)
139
- {
140
- char *name;
141
- ic_scheme *save_scheme, *scheme;
142
-
143
- Check_Type(scheme_name, T_STRING);
144
- name = StringValuePtr(scheme_name);
145
-
146
- if (0 == first_scheme)
147
- return Qfalse;
148
-
149
- if (!strncmp(name, first_scheme->scheme_name, first_scheme->name_len))
150
- {
151
- save_scheme = first_scheme->next_scheme;
152
-
153
- ruby_xfree(first_scheme->scheme_name);
154
- ruby_xfree(first_scheme);
155
-
156
- first_scheme = save_scheme;
157
- return Qtrue;
158
- }
159
-
160
- scheme = first_scheme;
161
- while (0 != scheme->next_scheme)
162
- {
163
- if (!strncmp(name, scheme->next_scheme->scheme_name,
164
- scheme->next_scheme->name_len))
165
- {
166
- save_scheme = scheme->next_scheme->next_scheme;
167
-
168
- ruby_xfree(scheme->next_scheme->scheme_name);
169
- ruby_xfree(scheme->next_scheme);
170
-
171
- scheme->next_scheme = save_scheme;
172
- return Qtrue;
173
- }
174
- scheme = scheme->next_scheme;
175
- }
176
- return Qfalse;
177
- }
178
-
179
- void rxml_init_input_callbacks(void)
180
- {
181
- VALUE cInputCallbacks;
182
- cInputCallbacks = rb_define_class_under(mXML, "InputCallbacks", rb_cObject);
183
-
184
- /* Class Methods */
185
- rb_define_singleton_method(cInputCallbacks, "register",
186
- input_callbacks_register_input_callbacks, 0);
187
- rb_define_singleton_method(cInputCallbacks, "add_scheme",
188
- input_callbacks_add_scheme, 2);
189
- rb_define_singleton_method(cInputCallbacks, "remove_scheme",
190
- input_callbacks_remove_scheme, 1);
191
- }
1
+ /* Author: Martin Povolny (xpovolny@fi.muni.cz) */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include "ruby_xml_input_cbg.h"
5
+
6
+ /* Document-class: LibXML::XML::InputCallbacks
7
+ *
8
+ * Support for adding custom scheme handlers. */
9
+
10
+ static ic_scheme *first_scheme = 0;
11
+
12
+ int ic_match(char const *filename)
13
+ {
14
+ ic_scheme *scheme;
15
+
16
+ //fprintf( stderr, "ic_match: %s\n", filename );
17
+
18
+ scheme = first_scheme;
19
+ while (0 != scheme)
20
+ {
21
+ if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
22
+ {
23
+ return 1;
24
+ }
25
+ scheme = scheme->next_scheme;
26
+ }
27
+ return 0;
28
+ }
29
+
30
+ void* ic_open(char const *filename)
31
+ {
32
+ ic_doc_context *ic_doc;
33
+ ic_scheme *scheme;
34
+ VALUE res;
35
+
36
+ scheme = first_scheme;
37
+ while (0 != scheme)
38
+ {
39
+ if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
40
+ {
41
+ ic_doc = (ic_doc_context*) malloc(sizeof(ic_doc_context));
42
+
43
+ res = rb_funcall(scheme->class, rb_intern("document_query"), 1,
44
+ rb_str_new2(filename));
45
+
46
+ ic_doc->buffer = strdup(StringValuePtr(res));
47
+
48
+ ic_doc->bpos = ic_doc->buffer;
49
+ ic_doc->remaining = (int)strlen(ic_doc->buffer);
50
+ return ic_doc;
51
+ }
52
+ scheme = scheme->next_scheme;
53
+ }
54
+ return 0;
55
+ }
56
+
57
+ int ic_read(void *context, char *buffer, int len)
58
+ {
59
+ ic_doc_context *ic_doc;
60
+ int ret_len;
61
+ ic_doc = (ic_doc_context*) context;
62
+
63
+ if (len >= ic_doc->remaining)
64
+ {
65
+ ret_len = ic_doc->remaining;
66
+ }
67
+ else
68
+ {
69
+ ret_len = len;
70
+ }
71
+ ic_doc->remaining -= ret_len;
72
+ strncpy(buffer, ic_doc->bpos, ret_len);
73
+ ic_doc->bpos += ret_len;
74
+
75
+ return ret_len;
76
+ }
77
+
78
+ int ic_close(void *context)
79
+ {
80
+ ruby_xfree(((ic_doc_context*) context)->buffer);
81
+ ruby_xfree(context);
82
+ return 1;
83
+ }
84
+
85
+ /*
86
+ * call-seq:
87
+ * register
88
+ *
89
+ * Register a new set of I/O callback for handling parser input.
90
+ */
91
+ static VALUE input_callbacks_register_input_callbacks()
92
+ {
93
+ xmlRegisterInputCallbacks(ic_match, ic_open, ic_read, ic_close);
94
+ return (Qtrue);
95
+ }
96
+
97
+ /*
98
+ * call-seq:
99
+ * add_scheme
100
+ *
101
+ * No documentation available.
102
+ */
103
+ static VALUE input_callbacks_add_scheme(VALUE self, VALUE scheme_name,
104
+ VALUE class)
105
+ {
106
+ ic_scheme *scheme;
107
+
108
+ Check_Type(scheme_name, T_STRING);
109
+
110
+ scheme = (ic_scheme*) malloc(sizeof(ic_scheme));
111
+ scheme->next_scheme = 0;
112
+ scheme->scheme_name = strdup(StringValuePtr(scheme_name)); /* TODO alloc, dealloc */
113
+ scheme->name_len = (int)strlen(scheme->scheme_name);
114
+ scheme->class = class; /* TODO alloc, dealloc */
115
+
116
+ //fprintf( stderr, "registered: %s, %d, %s\n", scheme->scheme_name, scheme->name_len, scheme->class );
117
+
118
+ if (0 == first_scheme)
119
+ first_scheme = scheme;
120
+ else
121
+ {
122
+ ic_scheme *pos;
123
+ pos = first_scheme;
124
+ while (0 != pos->next_scheme)
125
+ pos = pos->next_scheme;
126
+ pos->next_scheme = scheme;
127
+ }
128
+
129
+ return (Qtrue);
130
+ }
131
+
132
+ /*
133
+ * call-seq:
134
+ * remove_scheme
135
+ *
136
+ * No documentation available.
137
+ */
138
+ static VALUE input_callbacks_remove_scheme(VALUE self, VALUE scheme_name)
139
+ {
140
+ char *name;
141
+ ic_scheme *save_scheme, *scheme;
142
+
143
+ Check_Type(scheme_name, T_STRING);
144
+ name = StringValuePtr(scheme_name);
145
+
146
+ if (0 == first_scheme)
147
+ return Qfalse;
148
+
149
+ if (!strncmp(name, first_scheme->scheme_name, first_scheme->name_len))
150
+ {
151
+ save_scheme = first_scheme->next_scheme;
152
+
153
+ ruby_xfree(first_scheme->scheme_name);
154
+ ruby_xfree(first_scheme);
155
+
156
+ first_scheme = save_scheme;
157
+ return Qtrue;
158
+ }
159
+
160
+ scheme = first_scheme;
161
+ while (0 != scheme->next_scheme)
162
+ {
163
+ if (!strncmp(name, scheme->next_scheme->scheme_name,
164
+ scheme->next_scheme->name_len))
165
+ {
166
+ save_scheme = scheme->next_scheme->next_scheme;
167
+
168
+ ruby_xfree(scheme->next_scheme->scheme_name);
169
+ ruby_xfree(scheme->next_scheme);
170
+
171
+ scheme->next_scheme = save_scheme;
172
+ return Qtrue;
173
+ }
174
+ scheme = scheme->next_scheme;
175
+ }
176
+ return Qfalse;
177
+ }
178
+
179
+ void rxml_init_input_callbacks(void)
180
+ {
181
+ VALUE cInputCallbacks;
182
+ cInputCallbacks = rb_define_class_under(mXML, "InputCallbacks", rb_cObject);
183
+
184
+ /* Class Methods */
185
+ rb_define_singleton_method(cInputCallbacks, "register",
186
+ input_callbacks_register_input_callbacks, 0);
187
+ rb_define_singleton_method(cInputCallbacks, "add_scheme",
188
+ input_callbacks_add_scheme, 2);
189
+ rb_define_singleton_method(cInputCallbacks, "remove_scheme",
190
+ input_callbacks_remove_scheme, 1);
191
+ }
@@ -1,50 +1,52 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include "extconf.h"
4
- #include "ruby_libxml.h"
5
-
6
- static ID READ_METHOD;
7
- #ifndef HAVE_RB_IO_BUFWRITE
8
- static ID WRITE_METHOD;
9
- #endif /* !HAVE_RB_IO_BUFWRITE */
10
-
11
- /* This method is called by libxml when it wants to read
12
- more data from a stream. We go with the duck typing
13
- solution to support StringIO objects. */
14
- int rxml_read_callback(void *context, char *buffer, int len)
15
- {
16
- VALUE io = (VALUE) context;
17
- VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
18
- int size;
19
-
20
- if (string == Qnil)
21
- return 0;
22
-
23
- size = RSTRING_LEN(string);
24
- memcpy(buffer, StringValuePtr(string), size);
25
-
26
- return size;
27
- }
28
-
29
- int rxml_write_callback(void *context, const char *buffer, int len)
30
- {
31
- #ifndef HAVE_RB_IO_BUFWRITE
32
- VALUE io, written, string;
33
-
34
- io = (VALUE) context;
35
- string = rb_str_new(buffer, len);
36
- written = rb_funcall(io, WRITE_METHOD, 1, string);
37
-
38
- return NUM2INT(written);
39
- #else
40
- return rb_io_bufwrite((VALUE) context, buffer, (size_t) len);
41
- #endif /* !HAVE_RB_IO_BUFWRITE */
42
- }
43
-
44
- void rxml_init_io(void)
45
- {
46
- READ_METHOD = rb_intern("read");
47
- #ifndef HAVE_RB_IO_BUFWRITE
48
- WRITE_METHOD = rb_intern("write");
49
- #endif /* !HAVE_RB_IO_BUFWRITE */
50
- }
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #include "extconf.h"
4
+ #include "ruby_libxml.h"
5
+
6
+ static ID READ_METHOD;
7
+ #ifdef HAVE_RB_IO_BUFWRITE
8
+ #include <ruby/io.h>
9
+ #else
10
+ static ID WRITE_METHOD;
11
+ #endif /* !HAVE_RB_IO_BUFWRITE */
12
+
13
+ /* This method is called by libxml when it wants to read
14
+ more data from a stream. We go with the duck typing
15
+ solution to support StringIO objects. */
16
+ int rxml_read_callback(void *context, char *buffer, int len)
17
+ {
18
+ VALUE io = (VALUE) context;
19
+ VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
20
+ size_t size;
21
+
22
+ if (string == Qnil)
23
+ return 0;
24
+
25
+ size = RSTRING_LEN(string);
26
+ memcpy(buffer, StringValuePtr(string), size);
27
+
28
+ return (int)size;
29
+ }
30
+
31
+ int rxml_write_callback(void *context, const char *buffer, int len)
32
+ {
33
+ #ifndef HAVE_RB_IO_BUFWRITE
34
+ VALUE io, written, string;
35
+
36
+ io = (VALUE) context;
37
+ string = rb_str_new(buffer, len);
38
+ written = rb_funcall(io, WRITE_METHOD, 1, string);
39
+
40
+ return NUM2INT(written);
41
+ #else
42
+ return (int)rb_io_bufwrite((VALUE) context, buffer, (size_t)len);
43
+ #endif /* !HAVE_RB_IO_BUFWRITE */
44
+ }
45
+
46
+ void rxml_init_io(void)
47
+ {
48
+ READ_METHOD = rb_intern("read");
49
+ #ifndef HAVE_RB_IO_BUFWRITE
50
+ WRITE_METHOD = rb_intern("write");
51
+ #endif /* !HAVE_RB_IO_BUFWRITE */
52
+ }
@@ -81,7 +81,7 @@ static VALUE rxml_namespace_href_get(VALUE self)
81
81
  if (xns->href == NULL)
82
82
  return Qnil;
83
83
  else
84
- return rxml_new_cstr((const char*) xns->href, NULL);
84
+ return rxml_new_cstr( xns->href, NULL);
85
85
  }
86
86
 
87
87
  /*
@@ -116,7 +116,7 @@ static VALUE rxml_namespace_prefix_get(VALUE self)
116
116
  if (xns->prefix == NULL)
117
117
  return Qnil;
118
118
  else
119
- return rxml_new_cstr((const char*) xns->prefix, NULL);
119
+ return rxml_new_cstr( xns->prefix, NULL);
120
120
  }
121
121
 
122
122
  /*