nokogiri-maglev- 1.5.0.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGELOG.ja.rdoc +56 -12
  2. data/CHANGELOG.rdoc +49 -0
  3. data/C_CODING_STYLE.rdoc +27 -0
  4. data/Manifest.txt +4 -0
  5. data/README.rdoc +11 -7
  6. data/Rakefile +42 -27
  7. data/bin/nokogiri +10 -2
  8. data/ext/nokogiri/extconf.rb +11 -3
  9. data/ext/nokogiri/html_document.c +16 -0
  10. data/ext/nokogiri/html_sax_parser_context.c +59 -37
  11. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  12. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  13. data/ext/nokogiri/nokogiri.c +7 -9
  14. data/ext/nokogiri/nokogiri.h +3 -0
  15. data/ext/nokogiri/xml_document.c +101 -3
  16. data/ext/nokogiri/xml_document.h +3 -3
  17. data/ext/nokogiri/xml_node.c +151 -58
  18. data/ext/nokogiri/xml_node_set.c +169 -120
  19. data/ext/nokogiri/xml_node_set.h +5 -0
  20. data/ext/nokogiri/xml_sax_parser_context.c +64 -41
  21. data/ext/nokogiri/xml_text.c +2 -0
  22. data/ext/nokogiri/xml_xpath_context.c +31 -25
  23. data/ext/nokogiri/xslt_stylesheet.c +62 -16
  24. data/ext/nokogiri/xslt_stylesheet.h +5 -0
  25. data/lib/nokogiri/css/parser.rb +165 -159
  26. data/lib/nokogiri/css/parser.y +6 -3
  27. data/lib/nokogiri/css/tokenizer.rb +1 -1
  28. data/lib/nokogiri/css/tokenizer.rex +1 -1
  29. data/lib/nokogiri/html.rb +1 -0
  30. data/lib/nokogiri/html/document.rb +82 -42
  31. data/lib/nokogiri/html/sax/push_parser.rb +16 -0
  32. data/lib/nokogiri/version.rb +1 -1
  33. data/lib/nokogiri/xml.rb +6 -0
  34. data/lib/nokogiri/xml/builder.rb +7 -1
  35. data/lib/nokogiri/xml/document.rb +32 -17
  36. data/lib/nokogiri/xml/document_fragment.rb +6 -1
  37. data/lib/nokogiri/xml/node.rb +40 -9
  38. data/lib/nokogiri/xslt.rb +5 -1
  39. data/tasks/cross_compile.rb +1 -0
  40. data/tasks/nokogiri.org.rb +6 -0
  41. data/tasks/test.rb +1 -0
  42. data/test/css/test_xpath_visitor.rb +6 -0
  43. data/test/helper.rb +1 -0
  44. data/test/html/test_document.rb +26 -0
  45. data/test/html/test_document_fragment.rb +1 -2
  46. data/test/test_memory_leak.rb +81 -1
  47. data/test/test_xslt_transforms.rb +152 -123
  48. data/test/xml/test_builder.rb +24 -2
  49. data/test/xml/test_c14n.rb +151 -0
  50. data/test/xml/test_document.rb +48 -0
  51. data/test/xml/test_namespace.rb +5 -0
  52. data/test/xml/test_node.rb +82 -1
  53. data/test/xml/test_node_attributes.rb +19 -0
  54. data/test/xml/test_node_inheritance.rb +32 -0
  55. data/test/xml/test_node_reparenting.rb +32 -0
  56. data/test/xml/test_node_set.rb +16 -8
  57. data/test/xml/test_reader_encoding.rb +16 -0
  58. data/test/xml/test_unparented_node.rb +32 -0
  59. data/test/xml/test_xinclude.rb +83 -0
  60. data/test/xml/test_xpath.rb +22 -0
  61. metadata +208 -241
data/CHANGELOG.ja.rdoc CHANGED
@@ -1,22 +1,66 @@
1
+ == 1.5.1 / 2012年3月9日
2
+
3
+ * 新機能
4
+
5
+ * XML::Builder#comment はコメントノードを作れるようになった.
6
+ * CSS searches now support namespaced attributes. #593
7
+ * Java integration 機能が追加された. このバージョンから,
8
+ XML::Document.wrap と XML::Document#to_java メソッドが利用可能。
9
+ * RelaxNG validator support in the `nokogiri` cli utility. #591 (thanks, Dan Radez!)
10
+
11
+ * バグの修正
12
+
13
+ * エンコーディング自動認識において発生しうるメモリリークを修正.
14
+ Tim Elliottに感謝!
15
+ * homebrew はインストールしたら、extconf は homebrew のパスを読む。
16
+ * Inconsistent behavior of Nokogiri 1.5.0 Java #620
17
+ * Inheriting from Nokogiri::XML::Node on JRuby (1.6.4/5) fails #560
18
+ * XML::Attr nodes are not allowed to be added as node children, so an
19
+ exception is raised. #558
20
+ * No longer defensively "pickle" adjacent text nodes on
21
+ Node#add_next_sibling and Node#add_previous_sibling calls. #595.
22
+ * Java version inconsistency: it returns nil for empty attributes #589
23
+ * to_xhtml incorrectly generates <p /></p> when tag is empty #557
24
+ * Document#add_child now accepts a Node, NodeSet, DocumentFragment,
25
+ or String. #546.
26
+ * Document#create_element now recognizes namespaces containing
27
+ non-word characters (like "SOAP-ENV"). This is mostly relevant to
28
+ users of Builder, which calls Document#create_element for nearly
29
+ everything. #531.
30
+ * File encoding broken in 1.5.0 / jruby / windows #529
31
+ * Java version does not return namespace defs as attrs for ::HTML #542
32
+ * Bad file descriptor with Nokogiri 1.5.0 #495
33
+ * remove_namespace! doesn't work in pure java version #492
34
+ * The Nokogiri Java native build throws a null pointer exception when
35
+ ActiveSupport's .blank? method is called directly on a parsed object.
36
+ #489
37
+ * 1.5.0 Not using correct character encoding #488
38
+ * Raw XML string in XML Builder broken on JRuby #486
39
+ * Nokogiri 1.5.0 XML generation broken on JRuby #484
40
+ * Do not allow multiple root nodes. #550
41
+ * Fixes for custom XPath functions. #605, #606 (thanks, Juan Wajnerman!)
42
+ * Node#to_xml does not override :save_with if it is provided. #505
43
+ * Node#set is a private method [JRuby]. #564 (thanks, Nick Sieger!)
44
+ * C14n cleanup and Node#canonicalize (thanks, Ivan Pirlik!) #563
45
+
1
46
  == 1.5.0 / 2011年7月1日
2
47
 
3
- * Notes
48
+ *
4
49
 
5
- * See changelog from 1.4.7
50
+ * 1.4.7からの変更点を参照
6
51
 
7
- * Features
52
+ * 新機能
8
53
 
9
- * extracted sets of Node::SaveOptions into Node::SaveOptions::DEFAULT_{X,H,XH}TML (refactor)
54
+ * 各文書形式用のデフォルトのNode::SaveOptionsの組合せを定数化.
55
+ (Node::SaveOptions::DEFAULT_{X,H,XH}TML)
10
56
 
11
- * Bugfixes
57
+ * バグの修正
12
58
 
13
- * default output of XML on JRuby is no longer formatted due to
14
- inconsistent whitespace handling. #415
15
- * (JRuby) making empty NodeSets with null `nodes` member safe to operate on. #443
16
- * Fix a bug in advanced encoding detection that leads to partially
17
- duplicated document when parsing an HTML file with unknown
18
- encoding.
19
- * Add support for <meta charset="...">.
59
+ * JRuby版ではホワイトスペースの扱いに難があるため、XML出力(to_xml)において
60
+ 自動整形をデフォルトでは行わないように変更. #415
61
+ * JRuby版でNodeのないNodeSetでNullPointerExceptionが発生するのを修正. #443
62
+ * エンコーディング宣言のないHTMLファイルで部分的に重複したドキュメントが生成される問題を修正した. #478
63
+ * <meta charset="..."> を認識するようになった.
20
64
 
21
65
 
22
66
  == 1.5.0 beta3 2010年12月2日
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,52 @@
1
+ == 1.5.2 / 2012-03-09
2
+
3
+ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631, #632.
4
+
5
+ == 1.5.1 / 2012-03-09
6
+
7
+ * Features
8
+
9
+ * XML::Builder#comment allows creation of comment nodes.
10
+ * CSS searches now support namespaced attributes. #593
11
+ * Java integration feature is added. Now, XML::Document.wrap
12
+ and XML::Document#to_java methods are available.
13
+ * RelaxNG validator support in the `nokogiri` cli utility. #591 (thanks, Dan Radez!)
14
+
15
+ * Bugfixes
16
+
17
+ * Fix many memory leaks and segfault opportunities. Thanks, Tim Elliott!
18
+ * extconf searches homebrew paths if homebrew is installed.
19
+ * Inconsistent behavior of Nokogiri 1.5.0 Java #620
20
+ * Inheriting from Nokogiri::XML::Node on JRuby (1.6.4/5) fails #560
21
+ * XML::Attr nodes are not allowed to be added as node children, so an
22
+ exception is raised. #558
23
+ * No longer defensively "pickle" adjacent text nodes on
24
+ Node#add_next_sibling and Node#add_previous_sibling calls. #595.
25
+ * Java version inconsistency: it returns nil for empty attributes #589
26
+ * to_xhtml incorrectly generates <p /></p> when tag is empty #557
27
+ * Document#add_child now accepts a Node, NodeSet, DocumentFragment,
28
+ or String. #546.
29
+ * Document#create_element now recognizes namespaces containing
30
+ non-word characters (like "SOAP-ENV"). This is mostly relevant to
31
+ users of Builder, which calls Document#create_element for nearly
32
+ everything. #531.
33
+ * File encoding broken in 1.5.0 / jruby / windows #529
34
+ * Java version does not return namespace defs as attrs for ::HTML #542
35
+ * Bad file descriptor with Nokogiri 1.5.0 #495
36
+ * remove_namespace! doesn't work in pure java version #492
37
+ * The Nokogiri Java native build throws a null pointer exception
38
+ when ActiveSupport's .blank? method is called directly on a parsed
39
+ object. #489
40
+ * 1.5.0 Not using correct character encoding #488
41
+ * Raw XML string in XML Builder broken on JRuby #486
42
+ * Nokogiri 1.5.0 XML generation broken on JRuby #484
43
+ * Do not allow multiple root nodes. #550
44
+ * Fixes for custom XPath functions. #605, #606 (thanks, Juan Wajnerman!)
45
+ * Node#to_xml does not override :save_with if it is provided. #505
46
+ * Node#set is a private method [JRuby]. #564 (thanks, Nick Sieger!)
47
+ * C14n cleanup and Node#canonicalize (thanks, Ivan Pirlik!) #563
48
+
49
+
1
50
  == 1.5.0 / 2011-07-01
2
51
 
3
52
  * Notes
@@ -0,0 +1,27 @@
1
+ = C/C++ mode style for Nokogiri
2
+
3
+ Please don't propose commits that only change whitespace. However, if your
4
+ commit touches a function or section that is not using MRI Ruby conventions,
5
+ feel free to update whitespace in the surrounding code.
6
+
7
+ = WHITESPACE:
8
+
9
+ indent level: 2
10
+ indent type: Always spaces
11
+ Line Breaks: LF
12
+
13
+ = FUNCTION DECLARATION:
14
+
15
+ ANSI C style:
16
+
17
+ type name(args)
18
+ {
19
+ declarations
20
+
21
+ code
22
+ }
23
+
24
+ = SOURCES:
25
+
26
+ * <3<3<3
27
+
data/Manifest.txt CHANGED
@@ -72,6 +72,8 @@ ext/nokogiri/html_entity_lookup.c
72
72
  ext/nokogiri/html_entity_lookup.h
73
73
  ext/nokogiri/html_sax_parser_context.c
74
74
  ext/nokogiri/html_sax_parser_context.h
75
+ ext/nokogiri/html_sax_push_parser.c
76
+ ext/nokogiri/html_sax_push_parser.h
75
77
  ext/nokogiri/nokogiri.c
76
78
  ext/nokogiri/nokogiri.h
77
79
  ext/nokogiri/xml_attr.c
@@ -154,6 +156,7 @@ lib/nokogiri/html/element_description_defaults.rb
154
156
  lib/nokogiri/html/entity_lookup.rb
155
157
  lib/nokogiri/html/sax/parser.rb
156
158
  lib/nokogiri/html/sax/parser_context.rb
159
+ lib/nokogiri/html/sax/push_parser.rb
157
160
  lib/nokogiri/syntax_error.rb
158
161
  lib/nokogiri/version.rb
159
162
  lib/nokogiri/xml.rb
@@ -270,6 +273,7 @@ test/xml/test_node_attributes.rb
270
273
  test/xml/test_node_encoding.rb
271
274
  test/xml/test_node_reparenting.rb
272
275
  test/xml/test_node_set.rb
276
+ test/xml/test_node_inheritance.rb
273
277
  test/xml/test_parse_options.rb
274
278
  test/xml/test_processing_instruction.rb
275
279
  test/xml/test_reader_encoding.rb
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Nokogiri
1
+ = Nokogiri {<img src="https://secure.travis-ci.org/tenderlove/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/tenderlove/nokogiri]
2
2
 
3
3
  * http://nokogiri.org
4
4
  * http://github.com/tenderlove/nokogiri/wikis
@@ -25,6 +25,10 @@ correctly implemented CSS3 selector support as well as XPath support.
25
25
 
26
26
  == SUPPORT:
27
27
 
28
+ Before filing a bug report, please read our {submission guidelines}[http://nokogiri.org/tutorials/getting_help.html] at:
29
+
30
+ * http://nokogiri.org/tutorials/getting_help.html
31
+
28
32
  The Nokogiri {mailing list}[http://groups.google.com/group/nokogiri-talk]
29
33
  is available here:
30
34
 
@@ -50,19 +54,19 @@ The IRC channel is #nokogiri on freenode.
50
54
 
51
55
  ####
52
56
  # Search for nodes by css
53
- doc.css('h3.r a.l').each do |link|
57
+ doc.css('h3.r a').each do |link|
54
58
  puts link.content
55
59
  end
56
60
 
57
61
  ####
58
62
  # Search for nodes by xpath
59
- doc.xpath('//h3/a[@class="l"]').each do |link|
63
+ doc.xpath('//h3/a').each do |link|
60
64
  puts link.content
61
65
  end
62
66
 
63
67
  ####
64
68
  # Or mix and match.
65
- doc.search('h3.r a.l', '//h3/a[@class="l"]').each do |link|
69
+ doc.search('h3.r a.l', '//h3/a').each do |link|
66
70
  puts link.content
67
71
  end
68
72
 
@@ -128,8 +132,8 @@ Then run rake:
128
132
 
129
133
  === Developing on JRuby
130
134
 
131
- Currently, development with JRuby depends on C Ruby being installed. With
132
- normal C Ruby, install racc and rexical:
135
+ Currently, development with JRuby depends on CRuby being installed. With
136
+ CRuby, install racc and rexical:
133
137
 
134
138
  $ gem install racc rexical
135
139
 
@@ -145,7 +149,7 @@ Then run rake:
145
149
 
146
150
  (The MIT License)
147
151
 
148
- Copyright (c) 2008 - 2010:
152
+ Copyright (c) 2008 - 2012:
149
153
 
150
154
  * {Aaron Patterson}[http://tenderlovemaking.com]
151
155
  * {Mike Dalessio}[http://mike.daless.io]
data/Rakefile CHANGED
@@ -21,9 +21,9 @@ def maglev?
21
21
  !! defined?(Maglev)
22
22
  end
23
23
 
24
- require 'tasks/nokogiri_org'
24
+ require 'tasks/nokogiri.org'
25
25
 
26
- HOE = Hoe.spec 'nokogiri-maglev-' do
26
+ HOE = Hoe.spec 'maglev-nokogiri' do
27
27
  developer 'Aaron Patterson', 'aaronp@rubyforge.org'
28
28
  developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
29
29
  developer 'Yoko Harada', 'yokolet@gmail.com'
@@ -35,24 +35,22 @@ HOE = Hoe.spec 'nokogiri-maglev-' do
35
35
 
36
36
  self.clean_globs += [
37
37
  'nokogiri.gemspec',
38
- 'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
39
- 'lib/nokogiri/nokogiri.{so,dylib,rb,bundle}',
40
- 'lib/nokogiri/nokogiri.rb',
38
+ 'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
41
39
  'lib/nokogiri/1.{8,9}',
42
40
  GENERATED_PARSER,
43
41
  GENERATED_TOKENIZER
44
42
  ]
45
43
 
46
44
  self.extra_dev_deps += [
45
+ ["hoe-bundler", ">= 1.1"],
46
+ ["hoe-debugging", ">= 1.0.3"],
47
+ ["hoe-gemspec", ">= 1.0"],
48
+ ["hoe-git", ">= 1.4"],
49
+ ["mini_portile", ">= 0.2.2"],
50
+ ["minitest", "~> 2.2.2"],
47
51
  ["racc", ">= 1.4.6"],
52
+ ["rake-compiler", "= 0.8.0"],
48
53
  ["rexical", ">= 1.0.5"],
49
- ["rake-compiler", ">= 0.7.9"],
50
- ["minitest", "~> 2.2.2"],
51
- ["mini_portile", ">= 0.2.2"],
52
- ["hoe-debugging", ">= 0"],
53
- ["hoe-git", ">= 0"],
54
- ["hoe-gemspec", ">= 0"],
55
- ["hoe-bundler", ">= 0"]
56
54
  ]
57
55
 
58
56
  if java?
@@ -87,7 +85,12 @@ if java?
87
85
  HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
88
86
  end
89
87
  elsif ! maglev?
90
- # require 'tasks/cross_compile'
88
+ mingw_available = true
89
+ begin
90
+ require 'tasks/cross_compile'
91
+ rescue
92
+ mingw_available = false
93
+ end
91
94
  require "rake/extensiontask"
92
95
 
93
96
  HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
@@ -95,13 +98,15 @@ elsif ! maglev?
95
98
  Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
96
99
  ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
97
100
  ext.config_options << ENV['EXTOPTS']
98
- # ext.cross_compile = true
99
- # ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
100
- # ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
101
- # ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes[:libxml2].path, 'lib')}"
102
- # ext.cross_config_options << "--with-iconv-dir=#{$recipes[:libiconv].path}"
103
- # ext.cross_config_options << "--with-xslt-dir=#{$recipes[:libxslt].path}"
104
- # ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
101
+ if mingw_available
102
+ ext.cross_compile = true
103
+ ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
104
+ ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
105
+ ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes[:libxml2].path, 'lib')}"
106
+ ext.cross_config_options << "--with-iconv-dir=#{$recipes[:libiconv].path}"
107
+ ext.cross_config_options << "--with-xslt-dir=#{$recipes[:libxslt].path}"
108
+ ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
109
+ end
105
110
  end
106
111
  end
107
112
 
@@ -114,6 +119,7 @@ task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
114
119
  file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
115
120
  racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
116
121
  racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
122
+ racc = %x{command -v racc}.strip if racc.empty?
117
123
  sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
118
124
  end
119
125
 
@@ -149,10 +155,19 @@ end
149
155
 
150
156
  desc "build a windows gem without all the ceremony."
151
157
  task "gem:windows" => "gem" do
152
- rake_compiler_config = YAML.load_file("#{ENV['HOME']}/.rake-compiler/config.yml")
158
+ cross_rubies = ["1.8.7-p330", "1.9.2-p136"]
159
+ ruby_cc_version = cross_rubies.collect { |_| _.split("-").first }.join(":") # e.g., "1.8.7:1.9.2"
160
+ rake_compiler_config_path = "#{ENV['HOME']}/.rake-compiler/config.yml"
161
+
162
+ unless File.exists? rake_compiler_config_path
163
+ raise "rake-compiler has not installed any cross rubies. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{cross_rubies.first}'"
164
+ end
165
+ rake_compiler_config = YAML.load_file(rake_compiler_config_path)
153
166
 
154
- # check that rake-compiler config contains the right patchlevels of 1.8.6 and 1.9.1. see #279.
155
- ["1.8.6-p383", "1.9.1-p243"].each do |version|
167
+ # check that rake-compiler config contains the right patchlevels. see #279 for background,
168
+ # and http://blog.mmediasys.com/2011/01/22/rake-compiler-updated-list-of-supported-ruby-versions-for-cross-compilation/
169
+ # for more up-to-date docs.
170
+ cross_rubies.each do |version|
156
171
  majmin, patchlevel = version.split("-")
157
172
  rbconfig = "rbconfig-#{majmin}"
158
173
  unless rake_compiler_config.key?(rbconfig) && rake_compiler_config[rbconfig] =~ /-#{patchlevel}/
@@ -160,12 +175,12 @@ task "gem:windows" => "gem" do
160
175
  end
161
176
  end
162
177
 
163
- # verify that --export-all is in the 1.9.1 rbconfig. see #279,#374,#375.
164
- rbconfig_191 = rake_compiler_config["rbconfig-1.9.1"]
165
- raise "rbconfig #{rbconfig_191} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_191).grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
178
+ # verify that --export-all is in the 1.9 rbconfig. see #279,#374,#375.
179
+ rbconfig_19 = rake_compiler_config["rbconfig-1.9.2"]
180
+ raise "rbconfig #{rbconfig_19} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_19).split("\n").grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
166
181
 
167
182
  pkg_config_path = [:libxslt, :libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
168
- sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=1.8.6:1.9.1 rake cross native gem") || raise("build failed!")
183
+ sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=#{ruby_cc_version} rake cross native gem") || raise("build failed!")
169
184
  end
170
185
 
171
186
  # vim: syntax=Ruby
data/bin/nokogiri CHANGED
@@ -27,6 +27,10 @@ opts = OptionParser.new do |opts|
27
27
  encoding = v
28
28
  end
29
29
 
30
+ opts.on("--rng <uri|path>", "Validate using this rng file.") do |v|
31
+ @rng = open(v) {|f| Nokogiri::XML::RelaxNG(f)}
32
+ end
33
+
30
34
  opts.on_tail("-?", "--help", "Show this message") do
31
35
  puts opts
32
36
  exit
@@ -48,6 +52,10 @@ end
48
52
 
49
53
  @doc = parse_class.parse(open(uri).read, nil, encoding)
50
54
 
51
- puts "Your document is stored in @doc..."
52
- IRB.start
55
+ if @rng
56
+ puts @rng.validate(@doc)
57
+ else
58
+ puts "Your document is stored in @doc..."
59
+ IRB.start
60
+ end
53
61
 
@@ -17,7 +17,7 @@ end
17
17
  $CFLAGS << " #{ENV["CFLAGS"]}"
18
18
  $LIBS << " #{ENV["LIBS"]}"
19
19
 
20
- if RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin32/
20
+ if RbConfig::CONFIG['target_os'] == 'mingw32' || RbConfig::CONFIG['target_os'] =~ /mswin/
21
21
  $CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
22
22
  elsif RbConfig::CONFIG['target_os'] =~ /solaris/
23
23
  $CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
@@ -30,10 +30,11 @@ if RbConfig::MAKEFILE_CONFIG['CC'] =~ /mingw/
30
30
  end
31
31
 
32
32
  if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
33
- $CFLAGS << " -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
33
+ $CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
34
+ $CFLAGS << " -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
34
35
  end
35
36
 
36
- if RbConfig::CONFIG['target_os'] =~ /mswin32/
37
+ if RbConfig::CONFIG['target_os'] =~ /mswin/
37
38
  lib_prefix = 'lib'
38
39
 
39
40
  # There's no default include/lib dir on Windows. Let's just add the Ruby ones
@@ -80,6 +81,13 @@ else
80
81
  '/usr/local/include/libxml2',
81
82
  File.join(INCLUDEDIR, "libxml2")
82
83
  ] + HEADER_DIRS
84
+
85
+ # If the user has homebrew installed, use the libxml2 inside homebrew
86
+ brew_prefix = `brew --prefix libxml2 2> /dev/null`.chomp
87
+ unless brew_prefix.empty?
88
+ LIB_DIRS.unshift File.join(brew_prefix, 'lib')
89
+ XML2_HEADER_DIRS.unshift File.join(brew_prefix, 'include/libxml2')
90
+ end
83
91
  end
84
92
 
85
93
  dir_config('zlib', HEADER_DIRS, LIB_DIRS)
@@ -1,5 +1,7 @@
1
1
  #include <html_document.h>
2
2
 
3
+ static ID id_encoding_found;
4
+
3
5
  /*
4
6
  * call-seq:
5
7
  * new
@@ -56,6 +58,18 @@ static VALUE read_io( VALUE klass,
56
58
  );
57
59
  xmlSetStructuredErrorFunc(NULL, NULL);
58
60
 
61
+ /*
62
+ * If EncodingFound has occurred in EncodingReader, make sure to do
63
+ * a cleanup and propagate the error.
64
+ */
65
+ if (rb_respond_to(io, id_encoding_found)) {
66
+ VALUE encoding_found = rb_funcall(io, id_encoding_found, 0);
67
+ if (!NIL_P(encoding_found)) {
68
+ xmlFreeDoc(doc);
69
+ rb_exc_raise(encoding_found);
70
+ }
71
+ }
72
+
59
73
  if(doc == NULL) {
60
74
  xmlErrorPtr error;
61
75
 
@@ -151,4 +165,6 @@ void init_html_document()
151
165
  rb_define_singleton_method(klass, "new", new, -1);
152
166
 
153
167
  rb_define_method(klass, "type", type, 0);
168
+
169
+ id_encoding_found = rb_intern("encoding_found");
154
170
  }