libxml-ruby 4.1.1-x64-mingw-ucrt → 5.0.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +22 -0
  3. data/ext/libxml/extconf.rb +67 -61
  4. data/ext/libxml/ruby_libxml.h +43 -44
  5. data/ext/libxml/ruby_xml.c +0 -343
  6. data/ext/libxml/ruby_xml.h +9 -10
  7. data/ext/libxml/ruby_xml_attr_decl.c +154 -153
  8. data/ext/libxml/ruby_xml_attributes.c +276 -275
  9. data/ext/libxml/ruby_xml_attributes.h +2 -0
  10. data/ext/libxml/ruby_xml_document.c +6 -6
  11. data/ext/libxml/ruby_xml_document.h +11 -11
  12. data/ext/libxml/ruby_xml_dtd.c +3 -3
  13. data/ext/libxml/ruby_xml_encoding.h +20 -18
  14. data/ext/libxml/ruby_xml_error.c +9 -6
  15. data/ext/libxml/ruby_xml_error.h +2 -2
  16. data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
  17. data/ext/libxml/ruby_xml_namespace.c +0 -3
  18. data/ext/libxml/ruby_xml_node.c +1394 -1398
  19. data/ext/libxml/ruby_xml_parser.h +1 -1
  20. data/ext/libxml/ruby_xml_parser_context.c +47 -39
  21. data/ext/libxml/ruby_xml_parser_options.c +9 -1
  22. data/ext/libxml/ruby_xml_parser_options.h +1 -1
  23. data/ext/libxml/ruby_xml_reader.c +1244 -1242
  24. data/ext/libxml/ruby_xml_relaxng.c +113 -112
  25. data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
  26. data/ext/libxml/ruby_xml_sax_parser.c +1 -9
  27. data/ext/libxml/ruby_xml_schema.c +422 -420
  28. data/ext/libxml/ruby_xml_schema_attribute.c +108 -107
  29. data/ext/libxml/ruby_xml_schema_element.c +70 -69
  30. data/ext/libxml/ruby_xml_schema_type.c +252 -251
  31. data/ext/libxml/ruby_xml_version.h +5 -5
  32. data/ext/libxml/ruby_xml_writer.c +1138 -1137
  33. data/ext/libxml/ruby_xml_xpath.c +1 -1
  34. data/ext/libxml/ruby_xml_xpath_context.c +2 -2
  35. data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
  36. data/ext/libxml/ruby_xml_xpath_object.c +340 -339
  37. data/lib/3.2/libxml_ruby.so +0 -0
  38. data/lib/3.3/libxml_ruby.so +0 -0
  39. data/lib/libxml/document.rb +13 -13
  40. data/lib/libxml/html_parser.rb +23 -23
  41. data/lib/libxml/parser.rb +26 -24
  42. data/lib/libxml/schema/element.rb +27 -19
  43. data/test/test.rb +5 -0
  44. data/test/test_document_write.rb +1 -4
  45. data/test/test_dtd.rb +1 -4
  46. data/test/test_encoding.rb +1 -4
  47. data/test/test_helper.rb +9 -2
  48. data/test/test_html_parser.rb +162 -162
  49. data/test/test_namespace.rb +1 -3
  50. data/test/test_node.rb +1 -3
  51. data/test/test_node_write.rb +1 -4
  52. data/test/test_parser.rb +26 -17
  53. data/test/test_reader.rb +4 -4
  54. data/test/test_sax_parser.rb +1 -1
  55. data/test/test_schema.rb +237 -231
  56. data/test/test_xml.rb +0 -99
  57. metadata +5 -4
  58. data/lib/3.1/libxml_ruby.so +0 -0
@@ -5,6 +5,6 @@
5
5
 
6
6
  extern VALUE cXMLParser;
7
7
 
8
- void rxml_init_parser();
8
+ void rxml_init_parser(void);
9
9
 
10
10
  #endif
@@ -39,31 +39,33 @@ static VALUE rxml_parser_context_alloc(VALUE klass)
39
39
  *
40
40
  * Parameters:
41
41
  *
42
- * document - An XML::Document instance.
42
+ * document - An XML::Document instance
43
+ * options - A or'ed together list of LibXML::XML::Parser::Options values
43
44
  */
44
- static VALUE rxml_parser_context_document(VALUE klass, VALUE document)
45
+ static VALUE rxml_parser_context_document(int argc, VALUE* argv, VALUE klass)
45
46
  {
46
- xmlParserCtxtPtr ctxt;
47
- xmlDocPtr xdoc;
48
- xmlChar *buffer;
49
- int length;
47
+ VALUE document, options;
48
+ rb_scan_args(argc, argv, "11", &document, &options);
50
49
 
51
50
  if (rb_obj_is_kind_of(document, cXMLDocument) == Qfalse)
52
51
  rb_raise(rb_eTypeError, "Must pass an LibXML::XML::Document object");
53
52
 
53
+ xmlDocPtr xdoc;
54
+ xmlChar *buffer;
55
+ int length;
54
56
  Data_Get_Struct(document, xmlDoc, xdoc);
55
57
  xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, (const char*)xdoc->encoding, 0);
56
58
 
57
- ctxt = xmlCreateDocParserCtxt(buffer);
59
+ xmlParserCtxtPtr ctxt = xmlCreateDocParserCtxt(buffer);
58
60
 
59
61
  if (!ctxt)
60
- rxml_raise(&xmlLastError);
62
+ rxml_raise(xmlGetLastError());
61
63
 
62
64
  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and
63
65
  xmlCtxtUseOptionsInternal (called below) initialize slightly different
64
66
  context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
65
67
  sets to 0 and xmlCtxtUseOptionsInternal sets to 1. So we have to call both. */
66
- xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());
68
+ xmlCtxtUseOptions(ctxt, options == Qnil ? 0 : NUM2INT(options));
67
69
 
68
70
  return rxml_parser_context_wrap(ctxt);
69
71
  }
@@ -75,20 +77,24 @@ static VALUE rxml_parser_context_document(VALUE klass, VALUE document)
75
77
  *
76
78
  * Parameters:
77
79
  *
78
- * file - A filename or uri.
80
+ * file - A filename or uri
81
+ * options - A or'ed together list of LibXML::XML::Parser::Options values
79
82
  */
80
- static VALUE rxml_parser_context_file(VALUE klass, VALUE file)
83
+ static VALUE rxml_parser_context_file(int argc, VALUE* argv, VALUE klass)
81
84
  {
85
+ VALUE file, options;
86
+ rb_scan_args(argc, argv, "11", &file, &options);
87
+
82
88
  xmlParserCtxtPtr ctxt = xmlCreateURLParserCtxt(StringValuePtr(file), 0);
83
89
 
84
90
  if (!ctxt)
85
- rxml_raise(&xmlLastError);
91
+ rxml_raise(xmlGetLastError());
86
92
 
87
93
  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and
88
94
  xmlCtxtUseOptionsInternal (called below) initialize slightly different
89
95
  context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
90
96
  sets to 0 and xmlCtxtUseOptionsInternal sets to 1. So we have to call both. */
91
- xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());
97
+ xmlCtxtUseOptions(ctxt, options == Qnil ? 0 : NUM2INT(options));
92
98
 
93
99
  return rxml_parser_context_wrap(ctxt);
94
100
  }
@@ -100,26 +106,29 @@ static VALUE rxml_parser_context_file(VALUE klass, VALUE file)
100
106
  *
101
107
  * Parameters:
102
108
  *
103
- * string - A string that contains the data to parse.
109
+ * string - A string that contains the data to parse
110
+ * options - A or'ed together list of LibXML::XML::Parser::Options values
104
111
  */
105
- static VALUE rxml_parser_context_string(VALUE klass, VALUE string)
112
+ static VALUE rxml_parser_context_string(int argc, VALUE* argv, VALUE klass)
106
113
  {
107
- xmlParserCtxtPtr ctxt;
114
+ VALUE string, options;
115
+ rb_scan_args(argc, argv, "11", &string, &options);
116
+
108
117
  Check_Type(string, T_STRING);
109
118
 
110
119
  if (RSTRING_LEN(string) == 0)
111
120
  rb_raise(rb_eArgError, "Must specify a string with one or more characters");
112
121
 
113
- ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(string), (int)RSTRING_LEN(string));
122
+ xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(string), (int)RSTRING_LEN(string));
114
123
 
115
124
  if (!ctxt)
116
- rxml_raise(&xmlLastError);
125
+ rxml_raise(xmlGetLastError());
117
126
 
118
127
  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and
119
128
  xmlCtxtUseOptionsInternal (called below) initialize slightly different
120
129
  context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
121
130
  sets to 0 and xmlCtxtUseOptionsInternal sets to 1. So we have to call both. */
122
- xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());
131
+ xmlCtxtUseOptions(ctxt, options == Qnil ? 0 : NUM2INT(options));
123
132
 
124
133
  return rxml_parser_context_wrap(ctxt);
125
134
  }
@@ -131,45 +140,44 @@ static VALUE rxml_parser_context_string(VALUE klass, VALUE string)
131
140
  *
132
141
  * Parameters:
133
142
  *
134
- * io - A ruby IO object.
143
+ * io - A ruby IO object
144
+ * options - A or'ed together list of LibXML::XML::Parser::Options values
135
145
  */
136
- static VALUE rxml_parser_context_io(VALUE klass, VALUE io)
146
+ static VALUE rxml_parser_context_io(int argc, VALUE* argv, VALUE klass)
137
147
  {
138
- VALUE result;
139
- xmlParserCtxtPtr ctxt;
140
- xmlParserInputBufferPtr input;
141
- xmlParserInputPtr stream;
148
+ VALUE io, options;
149
+ rb_scan_args(argc, argv, "11", &io, &options);
142
150
 
143
151
  if (NIL_P(io))
144
152
  rb_raise(rb_eTypeError, "Must pass in an IO object");
145
153
 
146
- input = xmlParserInputBufferCreateIO((xmlInputReadCallback) rxml_read_callback, NULL,
154
+ xmlParserInputBufferPtr input = xmlParserInputBufferCreateIO((xmlInputReadCallback) rxml_read_callback, NULL,
147
155
  (void*)io, XML_CHAR_ENCODING_NONE);
148
-
149
- ctxt = xmlNewParserCtxt();
156
+
157
+ xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
150
158
 
151
159
  if (!ctxt)
152
160
  {
153
161
  xmlFreeParserInputBuffer(input);
154
- rxml_raise(&xmlLastError);
162
+ rxml_raise(xmlGetLastError());
155
163
  }
156
164
 
157
165
  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and
158
166
  xmlCtxtUseOptionsInternal (called below) initialize slightly different
159
167
  context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
160
168
  sets to 0 and xmlCtxtUseOptionsInternal sets to 1. So we have to call both. */
161
- xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());
169
+ xmlCtxtUseOptions(ctxt, options == Qnil ? 0 : NUM2INT(options));
162
170
 
163
- stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
171
+ xmlParserInputPtr stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
164
172
 
165
173
  if (!stream)
166
174
  {
167
175
  xmlFreeParserInputBuffer(input);
168
176
  xmlFreeParserCtxt(ctxt);
169
- rxml_raise(&xmlLastError);
177
+ rxml_raise(xmlGetLastError());
170
178
  }
171
179
  inputPush(ctxt, stream);
172
- result = rxml_parser_context_wrap(ctxt);
180
+ VALUE result = rxml_parser_context_wrap(ctxt);
173
181
 
174
182
  /* Attach io object to parser so it won't get freed.*/
175
183
  rb_ivar_set(result, IO_ATTR, io);
@@ -303,7 +311,7 @@ static VALUE rxml_parser_context_disable_cdata_set(VALUE self, VALUE value)
303
311
  if (value)
304
312
  ctxt->sax->cdataBlock = NULL;
305
313
  else
306
- ctxt->sax->cdataBlock = xmlDefaultSAXHandler.cdataBlock;
314
+ ctxt->sax->cdataBlock = xmlSAX2CDataBlock;
307
315
 
308
316
  return value;
309
317
  }
@@ -377,7 +385,7 @@ static VALUE rxml_parser_context_encoding_set(VALUE self, VALUE encoding)
377
385
  result = xmlSwitchToEncoding(ctxt, hdlr);
378
386
 
379
387
  if (result != 0)
380
- rxml_raise(&xmlLastError);
388
+ rxml_raise(xmlGetLastError());
381
389
 
382
390
  if (ctxt->encoding != NULL)
383
391
  xmlFree((xmlChar *) ctxt->encoding);
@@ -950,10 +958,10 @@ void rxml_init_parser_context(void)
950
958
  cXMLParserContext = rb_define_class_under(cXMLParser, "Context", rb_cObject);
951
959
  rb_define_alloc_func(cXMLParserContext, rxml_parser_context_alloc);
952
960
 
953
- rb_define_singleton_method(cXMLParserContext, "document", rxml_parser_context_document, 1);
954
- rb_define_singleton_method(cXMLParserContext, "file", rxml_parser_context_file, 1);
955
- rb_define_singleton_method(cXMLParserContext, "io", rxml_parser_context_io, 1);
956
- rb_define_singleton_method(cXMLParserContext, "string", rxml_parser_context_string, 1);
961
+ rb_define_singleton_method(cXMLParserContext, "document", rxml_parser_context_document, -1);
962
+ rb_define_singleton_method(cXMLParserContext, "file", rxml_parser_context_file, -1);
963
+ rb_define_singleton_method(cXMLParserContext, "io", rxml_parser_context_io, -1);
964
+ rb_define_singleton_method(cXMLParserContext, "string", rxml_parser_context_string, -1);
957
965
 
958
966
  rb_define_method(cXMLParserContext, "base_uri", rxml_parser_context_base_uri_get, 0);
959
967
  rb_define_method(cXMLParserContext, "base_uri=", rxml_parser_context_base_uri_set, 1);
@@ -55,7 +55,7 @@ void rxml_init_parser_options(void)
55
55
  /* compact small text nodes */
56
56
  rb_define_const(mXMLParserOptions, "COMPACT", INT2NUM(XML_PARSE_COMPACT));
57
57
  /* parse using XML-1.0 before update 5 */
58
- rb_define_const(mXMLParserOptions, "PARSE_OLD10", INT2NUM(XML_PARSE_OLD10));
58
+ rb_define_const(mXMLParserOptions, "OLD10", INT2NUM(XML_PARSE_OLD10));
59
59
  /* do not fixup XINCLUDE xml:base uris */
60
60
  rb_define_const(mXMLParserOptions, "NOBASEFIX", INT2NUM(XML_PARSE_NOBASEFIX));
61
61
  #endif
@@ -63,4 +63,12 @@ void rxml_init_parser_options(void)
63
63
  /* relax any hardcoded limit from the parser */
64
64
  rb_define_const(mXMLParserOptions, "HUGE", INT2NUM(XML_PARSE_HUGE));
65
65
  #endif
66
+ #if LIBXML_VERSION >= 21106
67
+ /* parse using SAX2 interface before 2.7.0 */
68
+ rb_define_const(mXMLParserOptions, "OLDSAX", INT2NUM(XML_PARSE_OLDSAX));
69
+ /* ignore internal document encoding hint */
70
+ rb_define_const(mXMLParserOptions, "IGNORE_ENC", INT2NUM(XML_PARSE_IGNORE_ENC));
71
+ /* Store big lines numbers in text PSVI field */
72
+ rb_define_const(mXMLParserOptions, "BIG_LINES", INT2NUM(XML_PARSE_BIG_LINES));
73
+ #endif
66
74
  }
@@ -5,6 +5,6 @@
5
5
 
6
6
  extern VALUE mXMLParserOptions;
7
7
 
8
- void rxml_init_parser_options();
8
+ void rxml_init_parser_options(void);
9
9
 
10
10
  #endif