libxml-ruby 4.1.2 → 6.0.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 (172) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY → CHANGELOG.md} +875 -887
  3. data/LICENSE +20 -20
  4. data/README.md +67 -0
  5. data/Rakefile +77 -98
  6. data/ext/libxml/extconf.rb +39 -20
  7. data/ext/libxml/libxml.c +67 -79
  8. data/ext/libxml/ruby_libxml.h +43 -44
  9. data/ext/libxml/ruby_xml.c +556 -899
  10. data/ext/libxml/ruby_xml.h +9 -10
  11. data/ext/libxml/ruby_xml_attr.c +338 -333
  12. data/ext/libxml/ruby_xml_attr.h +13 -12
  13. data/ext/libxml/ruby_xml_attr_decl.c +19 -12
  14. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  15. data/ext/libxml/ruby_xml_attributes.c +18 -9
  16. data/ext/libxml/ruby_xml_attributes.h +17 -15
  17. data/ext/libxml/ruby_xml_document.c +1142 -1129
  18. data/ext/libxml/ruby_xml_document.h +12 -11
  19. data/ext/libxml/ruby_xml_dtd.c +287 -248
  20. data/ext/libxml/ruby_xml_dtd.h +10 -9
  21. data/ext/libxml/ruby_xml_encoding.c +250 -250
  22. data/ext/libxml/ruby_xml_encoding.h +20 -18
  23. data/ext/libxml/ruby_xml_error.c +1003 -996
  24. data/ext/libxml/ruby_xml_error.h +14 -14
  25. data/ext/libxml/ruby_xml_html_parser.c +91 -91
  26. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  27. data/ext/libxml/ruby_xml_html_parser_context.c +364 -337
  28. data/ext/libxml/ruby_xml_html_parser_context.h +11 -10
  29. data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
  30. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  31. data/ext/libxml/ruby_xml_input_cbg.c +216 -188
  32. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  33. data/ext/libxml/ruby_xml_io.c +49 -47
  34. data/ext/libxml/ruby_xml_io.h +10 -10
  35. data/ext/libxml/ruby_xml_namespace.c +159 -154
  36. data/ext/libxml/ruby_xml_namespace.h +11 -10
  37. data/ext/libxml/ruby_xml_namespaces.c +313 -293
  38. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  39. data/ext/libxml/ruby_xml_node.c +1433 -1398
  40. data/ext/libxml/ruby_xml_node.h +15 -13
  41. data/ext/libxml/ruby_xml_parser.c +91 -91
  42. data/ext/libxml/ruby_xml_parser.h +10 -10
  43. data/ext/libxml/ruby_xml_parser_context.c +1016 -1001
  44. data/ext/libxml/ruby_xml_parser_context.h +11 -10
  45. data/ext/libxml/ruby_xml_parser_options.c +74 -66
  46. data/ext/libxml/ruby_xml_parser_options.h +10 -10
  47. data/ext/libxml/ruby_xml_reader.c +40 -31
  48. data/ext/libxml/ruby_xml_reader.h +14 -14
  49. data/ext/libxml/ruby_xml_registry.c +31 -0
  50. data/ext/libxml/ruby_xml_registry.h +22 -0
  51. data/ext/libxml/ruby_xml_relaxng.c +21 -5
  52. data/ext/libxml/ruby_xml_relaxng.h +9 -8
  53. data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
  54. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  55. data/ext/libxml/ruby_xml_sax_parser.c +108 -116
  56. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  57. data/ext/libxml/ruby_xml_schema.c +22 -15
  58. data/ext/libxml/ruby_xml_schema.h +26 -25
  59. data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
  60. data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
  61. data/ext/libxml/ruby_xml_schema_element.c +8 -8
  62. data/ext/libxml/ruby_xml_schema_element.h +11 -11
  63. data/ext/libxml/ruby_xml_schema_facet.c +50 -50
  64. data/ext/libxml/ruby_xml_schema_facet.h +9 -9
  65. data/ext/libxml/ruby_xml_schema_type.c +12 -19
  66. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  67. data/ext/libxml/ruby_xml_version.h +9 -9
  68. data/ext/libxml/ruby_xml_writer.c +183 -185
  69. data/ext/libxml/ruby_xml_writer.h +6 -6
  70. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  71. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  72. data/ext/libxml/ruby_xml_xpath.c +195 -195
  73. data/ext/libxml/ruby_xml_xpath.h +15 -15
  74. data/ext/libxml/ruby_xml_xpath_context.c +408 -362
  75. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  76. data/ext/libxml/ruby_xml_xpath_expression.c +12 -6
  77. data/ext/libxml/ruby_xml_xpath_expression.h +11 -10
  78. data/ext/libxml/ruby_xml_xpath_object.c +69 -54
  79. data/ext/libxml/ruby_xml_xpath_object.h +19 -17
  80. data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
  81. data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
  82. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  83. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  84. data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
  85. data/lib/libxml/attr.rb +122 -122
  86. data/lib/libxml/attr_decl.rb +80 -80
  87. data/lib/libxml/attributes.rb +13 -13
  88. data/lib/libxml/document.rb +165 -194
  89. data/lib/libxml/error.rb +122 -95
  90. data/lib/libxml/html_parser.rb +80 -96
  91. data/lib/libxml/namespace.rb +61 -61
  92. data/lib/libxml/namespaces.rb +37 -37
  93. data/lib/libxml/node.rb +321 -323
  94. data/lib/libxml/parser.rb +94 -100
  95. data/lib/libxml/sax_callbacks.rb +179 -179
  96. data/lib/libxml/sax_parser.rb +40 -40
  97. data/lib/libxml/schema/attribute.rb +27 -19
  98. data/lib/libxml/schema/element.rb +20 -0
  99. data/lib/libxml/schema/type.rb +44 -21
  100. data/lib/libxml/schema.rb +47 -47
  101. data/lib/libxml/tree.rb +28 -28
  102. data/lib/libxml-ruby.rb +30 -30
  103. data/libxml-ruby.gemspec +46 -48
  104. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  105. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  106. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  107. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  108. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  109. data/test/c14n/result/with-comments/example-1 +5 -5
  110. data/test/c14n/result/with-comments/example-2 +10 -10
  111. data/test/c14n/result/with-comments/example-3 +13 -13
  112. data/test/c14n/result/with-comments/example-4 +8 -8
  113. data/test/c14n/result/with-comments/example-5 +3 -3
  114. data/test/c14n/result/without-comments/example-1 +3 -3
  115. data/test/c14n/result/without-comments/example-2 +10 -10
  116. data/test/c14n/result/without-comments/example-3 +13 -13
  117. data/test/c14n/result/without-comments/example-4 +8 -8
  118. data/test/c14n/result/without-comments/example-5 +2 -2
  119. data/test/test_attr.rb +179 -180
  120. data/test/test_attr_decl.rb +131 -131
  121. data/test/test_attributes.rb +135 -135
  122. data/test/test_canonicalize.rb +122 -120
  123. data/test/test_document.rb +138 -132
  124. data/test/test_document_write.rb +142 -145
  125. data/test/test_dtd.rb +134 -129
  126. data/test/test_encoding.rb +126 -129
  127. data/test/test_encoding_sax.rb +114 -114
  128. data/test/test_error.rb +197 -194
  129. data/test/test_helper.rb +21 -13
  130. data/test/test_html_parser.rb +166 -162
  131. data/test/test_html_parser_context.rb +22 -22
  132. data/test/test_input_callbacks.rb +36 -0
  133. data/test/test_namespace.rb +58 -60
  134. data/test/test_namespaces.rb +200 -200
  135. data/test/test_node.rb +251 -237
  136. data/test/test_node_cdata.rb +50 -50
  137. data/test/test_node_comment.rb +32 -32
  138. data/test/test_node_copy.rb +40 -40
  139. data/test/test_node_edit.rb +176 -158
  140. data/test/test_node_pi.rb +37 -37
  141. data/test/test_node_text.rb +69 -69
  142. data/test/test_node_write.rb +93 -96
  143. data/test/test_node_xlink.rb +28 -28
  144. data/test/test_parser.rb +297 -324
  145. data/test/test_parser_context.rb +198 -198
  146. data/test/test_properties.rb +38 -38
  147. data/test/test_reader.rb +413 -364
  148. data/test/test_relaxng.rb +59 -53
  149. data/test/test_sax_parser.rb +345 -326
  150. data/test/test_schema.rb +28 -0
  151. data/test/test_traversal.rb +152 -152
  152. data/test/test_writer.rb +469 -468
  153. data/test/test_xinclude.rb +20 -20
  154. data/test/test_xml.rb +164 -267
  155. data/test/test_xpath.rb +244 -244
  156. data/test/test_xpath_context.rb +87 -87
  157. data/test/test_xpath_expression.rb +37 -37
  158. metadata +49 -31
  159. data/README.rdoc +0 -217
  160. data/ext/libxml/extconf.h +0 -3
  161. data/ext/libxml/ruby_xml_cbg.c +0 -85
  162. data/lib/libxml/hpricot.rb +0 -78
  163. data/lib/libxml.rb +0 -5
  164. data/lib/xml/libxml.rb +0 -10
  165. data/lib/xml.rb +0 -14
  166. data/script/benchmark/depixelate +0 -634
  167. data/script/benchmark/hamlet.xml +0 -9055
  168. data/script/benchmark/parsecount +0 -170
  169. data/script/benchmark/sock_entries.xml +0 -507
  170. data/script/benchmark/throughput +0 -41
  171. data/script/test +0 -6
  172. data/test/test_deprecated_require.rb +0 -12
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- Copyright (c) 2008-2013 Charlie Savage and contributors
2
- Copyright (c) 2002-2007 Sean Chittenden and contributors
3
- Copyright (c) 2001 Wai-Sun "Squidster" Chia
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
- of the Software, and to permit persons to whom the Software is furnished to do
10
- so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ Copyright (c) 2008-2013 Charlie Savage and contributors
2
+ Copyright (c) 2002-2007 Sean Chittenden and contributors
3
+ Copyright (c) 2001 Wai-Sun "Squidster" Chia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # LibXML Ruby
2
+
3
+ ## Overview
4
+ The libxml gem provides Ruby language bindings for GNOME's Libxml2
5
+ XML toolkit. It is free software, released under the MIT License.
6
+
7
+ libxml-ruby let's you:
8
+
9
+ * Read xml files
10
+ * Write xml files
11
+ * Search xml files using XPath
12
+ * Validate XML files
13
+
14
+ Full documentation is available at [xml4r.github.io/libxml-ruby](https://xml4r.github.io/libxml-ruby/) including a getting started guide.
15
+
16
+ ## Requirements
17
+
18
+ libxml-ruby requires Ruby 3.2 or higher.
19
+
20
+ ## Installation
21
+ The easiest way to install libxml-ruby is via RubyGems. To install:
22
+
23
+ ```
24
+ gem install libxml-ruby
25
+ ```
26
+
27
+ If the extension compile process cannot find libxml2, you may need to indicate
28
+ the location of the libxml2 configuration utility as it is used to find the
29
+ required header and include files. (If you need to indicate a location for the
30
+ libxml2 library or header files different than reported by `xml2-config`,
31
+ see the additional configuration options.)
32
+
33
+ This may be done with RubyGems:
34
+
35
+ ```
36
+ gem install libxml-ruby -- --with-xml2-config=/path/to/xml2-config
37
+ ```
38
+
39
+ Or bundler:
40
+
41
+ ```
42
+ bundle config build.libxml-ruby --with-xml2-config=/path/to/xml2-config
43
+ bundle install
44
+ ```
45
+
46
+ Full documentation is available at [xml4r.github.io/libxml-ruby](https://xml4r.github.io/libxml-ruby/) including a [getting started](https://xml4r.github.io/libxml-ruby/getting_started/) guide.
47
+
48
+ ## Tests
49
+
50
+ To run tests you first need to build the shared library:
51
+
52
+ ```
53
+ rake compile
54
+ ```
55
+
56
+ Once you have built the shared library, you can then run tests using rake:
57
+
58
+ ```
59
+ rake test
60
+ ```
61
+
62
+ ## Support
63
+ If you have any questions about using libxml-ruby, please report an issue
64
+ on [GitHub](https://github.com/xml4r/libxml-ruby/issues).
65
+
66
+ ## License
67
+ See [LICENSE](LICENSE) for license information.
data/Rakefile CHANGED
@@ -1,99 +1,78 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "rubygems"
4
- require "rake/extensiontask"
5
- require "rake/testtask"
6
- require "rubygems/package_task"
7
- require "rdoc/task"
8
- require "yaml"
9
-
10
- GEM_NAME = "libxml-ruby"
11
- SO_NAME = "libxml_ruby"
12
-
13
- # Read the spec file
14
- spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
15
-
16
- task :default => [:test]
17
-
18
- # Setup compile tasks
19
- Rake::ExtensionTask.new do |ext|
20
- ext.gem_spec = spec
21
- ext.name = SO_NAME
22
- ext.ext_dir = "ext/libxml"
23
- ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
24
- if RUBY_PLATFORM.match(/mswin|mingw/)
25
- ext.config_options <<
26
- if (dir = ENV['WINDOWS_XML2_INCLUDE'])
27
- "--with-xml2-include=#{dir}"
28
- else
29
- case RUBY_PLATFORM
30
- when 'i386-mingw32'
31
- '--with-xml2-include=C:/msys64/mingw32/include/libxml2'
32
- when 'x64-mingw32'
33
- '--with-xml2-include=C:/msys64/mingw64/include/libxml2'
34
- when 'x64-mingw-ucrt'
35
- '--with-xml2-include=C:/msys64/ucrt64/include/libxml2'
36
- else
37
- raise "Unknown Windows Ruby, please set ENV['WINDOWS_XML2_INCLUDE']"
38
- end
39
- end
40
- else
41
- ext.config_options << '--with-xml2-include=/usr/include/libxml2'
42
- end
43
- end
44
-
45
- # Setup generic gem
46
- Gem::PackageTask.new(spec) do |pkg|
47
- pkg.package_dir = 'pkg'
48
- pkg.need_tar = false
49
- end
50
-
51
- # Setup Windows Gem
52
- if RUBY_PLATFORM.match(/mswin|mingw/)
53
- binaries = (FileList['lib/**/*.so',
54
- 'lib/**/*dll'])
55
-
56
- # Windows specification
57
- win_spec = spec.clone
58
- win_spec.platform = Gem::Platform::CURRENT
59
- win_spec.files += binaries.to_a
60
- win_spec.instance_variable_set(:@cache_file, nil)
61
-
62
- # Unset extensions
63
- win_spec.extensions = nil
64
-
65
- # Rake task to build the windows package
66
- Gem::PackageTask.new(win_spec) do |pkg|
67
- pkg.package_dir = 'pkg'
68
- pkg.need_tar = false
69
- end
70
- end
71
-
72
- # RDoc Task
73
- desc 'Generate rdoc documentation'
74
- RDoc::Task.new("rdoc") do |rdoc|
75
- rdoc.rdoc_dir = 'rdoc'
76
- rdoc.title = 'LibXML'
77
- rdoc.generator = 'hanna'
78
-
79
- # Show source inline with line numbers
80
- rdoc.options << '--line-numbers'
81
- rdoc.options << '--charset=utf-8'
82
- # Make the readme file the start page for the generated html
83
- rdoc.main = 'README.rdoc'
84
- rdoc.rdoc_files.include('doc/*.rdoc',
85
- 'ext/**/libxml.c',
86
- 'ext/**/ruby_xml.c',
87
- 'ext/**/*.c',
88
- 'lib/**/*.rb',
89
- 'README.rdoc',
90
- 'HISTORY',
91
- 'LICENSE')
92
- end
93
-
94
- # Test Task
95
- Rake::TestTask.new do |t|
96
- t.libs << "test"
97
- t.test_files = FileList['test/test*.rb'] - ['test/test_suite.rb']
98
- t.verbose = true
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "rake/extensiontask"
5
+ require "rake/testtask"
6
+ require "rubygems/package_task"
7
+ require "rdoc/task"
8
+ require "yaml"
9
+
10
+ GEM_NAME = "libxml-ruby"
11
+ SO_NAME = "libxml_ruby"
12
+
13
+ # Read the spec file
14
+ spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
15
+
16
+ task :default => [:test]
17
+
18
+ # Setup compile tasks
19
+ Rake::ExtensionTask.new do |ext|
20
+ ext.gem_spec = spec
21
+ ext.name = SO_NAME
22
+ ext.ext_dir = "ext/libxml"
23
+ ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d+$/, '')}"
24
+ end
25
+
26
+ # Setup generic gem
27
+ Gem::PackageTask.new(spec) do |pkg|
28
+ pkg.package_dir = 'pkg'
29
+ pkg.need_tar = false
30
+ end
31
+
32
+ # Setup Windows Gem
33
+ if RUBY_PLATFORM.match(/mingw/)
34
+ binaries = (FileList['lib/**/*.so'])
35
+
36
+ # Windows specification
37
+ mingw_spec = spec.clone
38
+ mingw_spec.platform = Gem::Platform::CURRENT
39
+ mingw_spec.files += binaries.to_a
40
+ mingw_spec.instance_variable_set(:@cache_file, nil)
41
+
42
+ # Unset extensions
43
+ mingw_spec.extensions = nil
44
+
45
+ # Rake task to build the windows package
46
+ Gem::PackageTask.new(mingw_spec) do |pkg|
47
+ pkg.package_dir = 'pkg'
48
+ pkg.need_tar = false
49
+ end
50
+ end
51
+
52
+ # RDoc Task
53
+ desc 'Generate rdoc documentation'
54
+ RDoc::Task.new("rdoc") do |rdoc|
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = 'LibXML'
57
+ rdoc.generator = 'aliki'
58
+
59
+ # Show source inline with line numbers
60
+ rdoc.options << '--line-numbers'
61
+ rdoc.options << '--charset=utf-8'
62
+ # Make the readme file the start page for the generated html
63
+ rdoc.main = 'README.md'
64
+ rdoc.rdoc_files.include('ext/**/libxml.c',
65
+ 'ext/**/ruby_xml.c',
66
+ 'ext/**/*.c',
67
+ 'lib/**/*.rb',
68
+ 'README.md',
69
+ 'CHANGELOG.md',
70
+ 'LICENSE')
71
+ end
72
+
73
+ # Test Task
74
+ Rake::TestTask.new do |t|
75
+ t.libs << "test"
76
+ t.test_files = FileList['test/test*.rb'] - ['test/test_suite.rb']
77
+ t.verbose = true
99
78
  end
@@ -23,32 +23,46 @@ if xc
23
23
  end
24
24
  else
25
25
  dir_config('xml2')
26
+ pkg_config('libxml-2.0')
26
27
  end
27
28
 
28
- found_header = find_header('libxml/xmlversion.h',
29
- '/opt/include/libxml2',
30
- '/opt/local/include/libxml2',
31
- '/opt/homebrew/opt/libxml2/include/libxml2',
32
- '/usr/local/include/libxml2',
33
- '/usr/include/libxml2',
34
- '/usr/local/include',
35
- '/usr/local/opt/libxml2/include/libxml2')
29
+ include_dirs = []
30
+ lib_dirs = []
31
+
32
+ if (msystem_prefix = ENV['MSYSTEM_PREFIX']) && !msystem_prefix.empty?
33
+ include_dirs.concat([
34
+ "#{msystem_prefix}/include/libxml2",
35
+ "#{msystem_prefix}/include"
36
+ ])
37
+ lib_dirs << "#{msystem_prefix}/lib"
38
+ end
39
+
40
+ include_dirs.concat([
41
+ '/opt/include/libxml2',
42
+ '/opt/local/include/libxml2',
43
+ '/opt/homebrew/opt/libxml2/include/libxml2',
44
+ '/usr/local/include/libxml2',
45
+ '/usr/include/libxml2',
46
+ '/usr/local/include',
47
+ '/usr/local/opt/libxml2/include/libxml2'
48
+ ])
49
+
50
+ lib_dirs.concat([
51
+ '/opt/lib',
52
+ '/opt/local/lib',
53
+ '/opt/homebrew/opt/libxml2/lib',
54
+ '/usr/lib',
55
+ '/usr/local/lib',
56
+ '/usr/local/opt/libxml2/lib'
57
+ ])
58
+
59
+ found_header = find_header('libxml/xmlversion.h', *include_dirs)
36
60
 
37
61
  found_lib = find_library('xml2', 'xmlParseDoc',
38
- '/opt/lib',
39
- '/opt/local/lib',
40
- '/opt/homebrew/opt/libxml2/lib',
41
- '/usr/lib',
42
- '/usr/local/lib',
43
- '/usr/local/opt/libxml2/lib')
62
+ *lib_dirs)
44
63
 
45
64
  found_lib ||= find_library('libxml2', 'xmlParseDoc',
46
- '/opt/lib',
47
- '/opt/local/lib',
48
- '/opt/homebrew/opt/libxml2/lib',
49
- '/usr/lib',
50
- '/usr/local/lib',
51
- '/usr/local/opt/libxml2/lib')
65
+ *lib_dirs)
52
66
 
53
67
  if !found_header || !found_lib
54
68
  crash(<<~EOL)
@@ -63,5 +77,10 @@ if !found_header || !found_lib
63
77
  EOL
64
78
  end
65
79
 
80
+ # Optional zlib support via libxml2; defines HAVE_ZLIB_H if available.
81
+ unless have_header("zlib.h")
82
+ message "zlib not found: building without compression support\n"
83
+ end
84
+
66
85
  create_header()
67
86
  create_makefile('libxml_ruby')
data/ext/libxml/libxml.c CHANGED
@@ -1,79 +1,67 @@
1
- #include "ruby_libxml.h"
2
-
3
- #if RUBY_INTERN_H
4
- #include <ruby/util.h>
5
- #else
6
- #include <util.h>
7
- #endif
8
-
9
-
10
- VALUE mLibXML;
11
-
12
- static void rxml_init_memory(void)
13
- {
14
- /* Disable for now - broke attributes.
15
- xmlGcMemSetup(
16
- (xmlFreeFunc)ruby_xfree,
17
- (xmlMallocFunc)ruby_xmalloc,
18
- (xmlMallocFunc)ruby_xmalloc,
19
- (xmlReallocFunc)ruby_xrealloc,
20
- (xmlStrdupFunc)ruby_strdup
21
- );*/
22
- }
23
-
24
- void Init_libxml_ruby(void)
25
- {
26
- /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
27
- * XML toolkit. To get started you may:
28
- *
29
- * require 'test_helper'
30
- * document = XML::Document.new
31
- *
32
- * However, when creating an application or library you plan to
33
- * redistribute, it is best to not add the LibXML module to the global
34
- * namespace, in which case you can either write your code like this:
35
- *
36
- * require 'libxml'
37
- * document = LibXML::XML::Document.new
38
- *
39
- * Refer to the README file to get started and the LICENSE file for
40
- * copyright and distribution information.
41
- */
42
-
43
- // Seutp for threading. http://xmlsoft.org/threads.html
44
- xmlInitParser();
45
-
46
- mLibXML = rb_define_module("LibXML");
47
-
48
- rxml_init_memory();
49
- rxml_init_xml();
50
- rxml_init_io();
51
- rxml_init_error();
52
- rxml_init_encoding();
53
- rxml_init_parser();
54
- rxml_init_parser_context();
55
- rxml_init_parser_options();
56
- rxml_init_node();
57
- rxml_init_attributes();
58
- rxml_init_attr();
59
- rxml_init_attr_decl();
60
- rxml_init_document();
61
- rxml_init_namespaces();
62
- rxml_init_namespace();
63
- rxml_init_sax_parser();
64
- rxml_init_sax2_handler();
65
- rxml_init_xinclude();
66
- rxml_init_xpath();
67
- rxml_init_xpath_object();
68
- rxml_init_xpath_context();
69
- rxml_init_xpath_expression();
70
- rxml_init_html_parser();
71
- rxml_init_html_parser_options();
72
- rxml_init_html_parser_context();
73
- rxml_init_input_callbacks();
74
- rxml_init_dtd();
75
- rxml_init_schema();
76
- rxml_init_relaxng();
77
- rxml_init_reader();
78
- rxml_init_writer();
79
- }
1
+ #include "ruby_libxml.h"
2
+
3
+ #if RUBY_INTERN_H
4
+ #include <ruby/util.h>
5
+ #else
6
+ #include <util.h>
7
+ #endif
8
+
9
+
10
+ VALUE mLibXML;
11
+
12
+ void Init_libxml_ruby(void)
13
+ {
14
+ /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
15
+ * XML toolkit. To get started you may:
16
+ *
17
+ * require 'test_helper'
18
+ * document = XML::Document.new
19
+ *
20
+ * However, when creating an application or library you plan to
21
+ * redistribute, it is best to not add the LibXML module to the global
22
+ * namespace, in which case you can either write your code like this:
23
+ *
24
+ * require 'libxml'
25
+ * document = LibXML::XML::Document.new
26
+ *
27
+ * Refer to the README file to get started and the LICENSE file for
28
+ * copyright and distribution information.
29
+ */
30
+
31
+ // Setup for threading. http://xmlsoft.org/threads.html
32
+ xmlInitParser();
33
+
34
+ mLibXML = rb_define_module("LibXML");
35
+
36
+ rxml_init_registry();
37
+ rxml_init_xml();
38
+ rxml_init_io();
39
+ rxml_init_error();
40
+ rxml_init_encoding();
41
+ rxml_init_parser();
42
+ rxml_init_parser_context();
43
+ rxml_init_parser_options();
44
+ rxml_init_node();
45
+ rxml_init_attributes();
46
+ rxml_init_attr();
47
+ rxml_init_attr_decl();
48
+ rxml_init_document();
49
+ rxml_init_namespaces();
50
+ rxml_init_namespace();
51
+ rxml_init_sax_parser();
52
+ rxml_init_sax2_handler();
53
+ rxml_init_xinclude();
54
+ rxml_init_xpath();
55
+ rxml_init_xpath_object();
56
+ rxml_init_xpath_context();
57
+ rxml_init_xpath_expression();
58
+ rxml_init_html_parser();
59
+ rxml_init_html_parser_options();
60
+ rxml_init_html_parser_context();
61
+ rxml_init_input_callbacks();
62
+ rxml_init_dtd();
63
+ rxml_init_schema();
64
+ rxml_init_relaxng();
65
+ rxml_init_reader();
66
+ rxml_init_writer();
67
+ }
@@ -1,44 +1,43 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RUBY_LIBXML_H__
4
- #define __RUBY_LIBXML_H__
5
-
6
- #include <ruby.h>
7
- #include <libxml/xmlversion.h>
8
-
9
- #include "ruby_xml_version.h"
10
- #include "ruby_xml.h"
11
- #include "ruby_xml_io.h"
12
- #include "ruby_xml_error.h"
13
- #include "ruby_xml_encoding.h"
14
- #include "ruby_xml_attributes.h"
15
- #include "ruby_xml_attr.h"
16
- #include "ruby_xml_attr_decl.h"
17
- #include "ruby_xml_document.h"
18
- #include "ruby_xml_node.h"
19
- #include "ruby_xml_namespace.h"
20
- #include "ruby_xml_namespaces.h"
21
- #include "ruby_xml_parser.h"
22
- #include "ruby_xml_parser_options.h"
23
- #include "ruby_xml_parser_context.h"
24
- #include "ruby_xml_html_parser.h"
25
- #include "ruby_xml_html_parser_options.h"
26
- #include "ruby_xml_html_parser_context.h"
27
- #include "ruby_xml_reader.h"
28
- #include "ruby_xml_writer.h"
29
- #include "ruby_xml_sax2_handler.h"
30
- #include "ruby_xml_sax_parser.h"
31
- #include "ruby_xml_writer.h"
32
- #include "ruby_xml_xinclude.h"
33
- #include "ruby_xml_xpath.h"
34
- #include "ruby_xml_xpath_expression.h"
35
- #include "ruby_xml_xpath_context.h"
36
- #include "ruby_xml_xpath_object.h"
37
- #include "ruby_xml_input_cbg.h"
38
- #include "ruby_xml_dtd.h"
39
- #include "ruby_xml_schema.h"
40
- #include "ruby_xml_relaxng.h"
41
-
42
- extern VALUE mLibXML;
43
-
44
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RUBY_LIBXML_H__
4
+ #define __RUBY_LIBXML_H__
5
+
6
+ #include <ruby.h>
7
+
8
+ #include "ruby_xml_version.h"
9
+ #include "ruby_xml.h"
10
+ #include "ruby_xml_io.h"
11
+ #include "ruby_xml_error.h"
12
+ #include "ruby_xml_encoding.h"
13
+ #include "ruby_xml_attributes.h"
14
+ #include "ruby_xml_attr.h"
15
+ #include "ruby_xml_attr_decl.h"
16
+ #include "ruby_xml_document.h"
17
+ #include "ruby_xml_node.h"
18
+ #include "ruby_xml_namespace.h"
19
+ #include "ruby_xml_namespaces.h"
20
+ #include "ruby_xml_parser.h"
21
+ #include "ruby_xml_parser_options.h"
22
+ #include "ruby_xml_parser_context.h"
23
+ #include "ruby_xml_html_parser.h"
24
+ #include "ruby_xml_html_parser_options.h"
25
+ #include "ruby_xml_html_parser_context.h"
26
+ #include "ruby_xml_reader.h"
27
+ #include "ruby_xml_sax2_handler.h"
28
+ #include "ruby_xml_sax_parser.h"
29
+ #include "ruby_xml_writer.h"
30
+ #include "ruby_xml_xinclude.h"
31
+ #include "ruby_xml_xpath.h"
32
+ #include "ruby_xml_xpath_expression.h"
33
+ #include "ruby_xml_xpath_context.h"
34
+ #include "ruby_xml_xpath_object.h"
35
+ #include "ruby_xml_input_cbg.h"
36
+ #include "ruby_xml_dtd.h"
37
+ #include "ruby_xml_schema.h"
38
+ #include "ruby_xml_relaxng.h"
39
+ #include "ruby_xml_registry.h"
40
+
41
+ extern VALUE mLibXML;
42
+
43
+ #endif