nokogiri 1.3.2-x86-mswin32 → 1.3.3-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data/CHANGELOG.ja.rdoc +25 -4
- data/CHANGELOG.rdoc +20 -0
- data/Manifest.txt +2 -0
- data/Rakefile +67 -24
- data/ext/nokogiri/extconf.rb +16 -9
- data/ext/nokogiri/html_document.c +0 -2
- data/ext/nokogiri/nokogiri.c +2 -0
- data/ext/nokogiri/nokogiri.h +3 -4
- data/ext/nokogiri/xml_document.c +30 -23
- data/ext/nokogiri/xml_document.h +3 -2
- data/ext/nokogiri/xml_dtd.c +4 -0
- data/ext/nokogiri/xml_dtd.h +2 -0
- data/ext/nokogiri/xml_node.c +28 -9
- data/ext/nokogiri/xml_reader.c +0 -7
- data/ext/nokogiri/xml_relax_ng.c +7 -1
- data/ext/nokogiri/xml_sax_parser.c +2 -0
- data/lib/action-nokogiri.rb +2 -0
- data/lib/nokogiri.rb +9 -3
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +80 -82
- data/lib/nokogiri/css/tokenizer.rb +1 -5
- data/lib/nokogiri/decorators/hpricot/node_set.rb +1 -1
- data/lib/nokogiri/ffi/structs/common_node.rb +1 -1
- data/lib/nokogiri/ffi/structs/xml_document.rb +1 -1
- data/lib/nokogiri/ffi/xml/document.rb +15 -4
- data/lib/nokogiri/ffi/xml/node.rb +85 -63
- data/lib/nokogiri/ffi/xml/reader.rb +4 -15
- data/lib/nokogiri/ffi/xml/relax_ng.rb +3 -1
- data/lib/nokogiri/hpricot.rb +30 -0
- data/lib/nokogiri/html/document.rb +3 -1
- data/lib/nokogiri/html/document_fragment.rb +1 -1
- data/lib/nokogiri/html/sax/parser.rb +2 -1
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +44 -1
- data/lib/nokogiri/xml/document.rb +8 -1
- data/lib/nokogiri/xml/document_fragment.rb +1 -1
- data/lib/nokogiri/xml/fragment_handler.rb +4 -7
- data/lib/nokogiri/xml/node.rb +9 -6
- data/lib/nokogiri/xml/node_set.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +1 -1
- data/test/css/test_nthiness.rb +2 -3
- data/test/ffi/test_document.rb +6 -6
- data/test/files/2ch.html +108 -0
- data/test/files/shift_jis.xml +5 -0
- data/test/helper.rb +3 -0
- data/test/hpricot/test_alter.rb +9 -9
- data/test/hpricot/test_builder.rb +2 -2
- data/test/hpricot/test_parser.rb +70 -146
- data/test/hpricot/test_paths.rb +2 -2
- data/test/hpricot/test_preserved.rb +2 -2
- data/test/hpricot/test_xml.rb +3 -3
- data/test/html/sax/test_parser.rb +12 -0
- data/test/html/test_builder.rb +6 -4
- data/test/html/test_document.rb +7 -0
- data/test/html/test_document_encoding.rb +17 -0
- data/test/html/test_document_fragment.rb +12 -0
- data/test/html/test_node.rb +5 -2
- data/test/test_convert_xpath.rb +1 -50
- data/test/test_css_cache.rb +1 -12
- data/test/test_nokogiri.rb +7 -0
- data/test/test_reader.rb +14 -0
- data/test/xml/test_document.rb +44 -0
- data/test/xml/test_document_fragment.rb +12 -0
- data/test/xml/test_node.rb +10 -2
- data/test/xml/test_node_encoding.rb +23 -0
- data/test/xml/test_node_set.rb +10 -0
- metadata +48 -46
data/CHANGELOG.ja.rdoc
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
=== 1.3.3 / 2009年7月26日
|
2
|
+
|
3
|
+
* 新しい機能
|
4
|
+
|
5
|
+
* NodeSet#children 全ての子ノードを返すようになった
|
6
|
+
|
7
|
+
* バグの修正
|
8
|
+
|
9
|
+
* libxml-ruby のグローバ ルエラー ハンドラー に優先するようになった
|
10
|
+
* ParseOption#strict を修正
|
11
|
+
* 空のstringを Node#inner_html= に与えた時に生じたSEGVを修正 GH #88
|
12
|
+
* Ruby 1.9 で返したStringのエンコードはUTF-8になった
|
13
|
+
* ドキュメントの根ノードから違うドキュメントの根ノードに移動した時に生じた
|
14
|
+
SEGVを修正 GH #91
|
15
|
+
* ノードをインスタンス化する時のO(n)のペナルティーを修正 GH #101
|
16
|
+
* XMLのドキュメントをHTMLのドキュメントととして出力出来るようになった
|
17
|
+
|
18
|
+
* 廃棄予定
|
19
|
+
|
20
|
+
* Hpricotの互換性レイヤーがNokogiriの1.4.0で除去される予定
|
21
|
+
|
1
22
|
=== 1.3.2 / 2009年6月22日
|
2
23
|
|
3
24
|
* 新しい機能
|
@@ -9,12 +30,12 @@
|
|
9
30
|
* Nokogiri::XML::NodeSet#search はトップレベルのノードを検索するようになった
|
10
31
|
GH #73
|
11
32
|
* Nokogiri::XML::Documentからメソッドに関係する名前空間を取り除いた
|
12
|
-
*
|
13
|
-
* Snow Leopard で Nokogiri
|
14
|
-
* メーリングリストはGoogle Groups
|
33
|
+
* 2回同じ名前空間が追加されたときSEGVする問題を修正した
|
34
|
+
* Snow Leopard で Nokogiri が動くようになった GH #79
|
35
|
+
* メーリングリストはGoogle Groupsの以下のURLに移動した
|
15
36
|
http://groups.google.com/group/nokogiri-talk
|
16
37
|
* HTML フラグメントはコメントとCDATAを正確に扱うようになった
|
17
|
-
* Nokogiri::XML::Document#cloneはdup
|
38
|
+
* Nokogiri::XML::Document#cloneはdupのaliasになった
|
18
39
|
|
19
40
|
* 廃棄予定
|
20
41
|
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
=== 1.3.3 / 2009/07/26
|
2
|
+
|
3
|
+
* New Features
|
4
|
+
|
5
|
+
* NodeSet#children returns all children of all nodes
|
6
|
+
|
7
|
+
* Bugfixes
|
8
|
+
|
9
|
+
* Override libxml-ruby's global error handler
|
10
|
+
* ParseOption#strict fixed
|
11
|
+
* Fixed a segfault when sending an empty string to Node#inner_html= GH #88
|
12
|
+
* String encoding is now set to UTF-8 in Ruby 1.9
|
13
|
+
* Fixed a segfault when moving root nodes between documents. GH #91
|
14
|
+
* Fixed an O(n) penalty on node creation. GH #101
|
15
|
+
* Allowing XML documents to be output as HTML documents
|
16
|
+
|
17
|
+
* Deprecations
|
18
|
+
|
19
|
+
* Hpricot compatibility layer will be removed in 1.4.0
|
20
|
+
|
1
21
|
=== 1.3.2 / 2009-06-22
|
2
22
|
|
3
23
|
* New Features
|
data/Manifest.txt
CHANGED
@@ -176,6 +176,7 @@ test/css/test_parser.rb
|
|
176
176
|
test/css/test_tokenizer.rb
|
177
177
|
test/css/test_xpath_visitor.rb
|
178
178
|
test/ffi/test_document.rb
|
179
|
+
test/files/2ch.html
|
179
180
|
test/files/address_book.rlx
|
180
181
|
test/files/address_book.xml
|
181
182
|
test/files/bar/bar.xsd
|
@@ -185,6 +186,7 @@ test/files/exslt.xslt
|
|
185
186
|
test/files/foo/foo.xsd
|
186
187
|
test/files/po.xml
|
187
188
|
test/files/po.xsd
|
189
|
+
test/files/shift_jis.xml
|
188
190
|
test/files/snuggles.xml
|
189
191
|
test/files/staff.xml
|
190
192
|
test/files/staff.xslt
|
data/Rakefile
CHANGED
@@ -21,18 +21,44 @@ HOE = Hoe.spec 'nokogiri' do
|
|
21
21
|
self.extra_rdoc_files = FileList['*.rdoc']
|
22
22
|
self.clean_globs = [
|
23
23
|
'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
|
24
|
+
'lib/nokogiri/1.{8,9}',
|
25
|
+
'lib/nokogiri/nokogiri.rb',
|
24
26
|
GENERATED_PARSER,
|
25
27
|
GENERATED_TOKENIZER,
|
26
28
|
'cross',
|
27
29
|
]
|
28
30
|
|
29
31
|
%w{ racc rexical rake-compiler }.each do |dep|
|
30
|
-
extra_dev_deps << dep
|
32
|
+
self.extra_dev_deps << [dep, '>= 0']
|
31
33
|
end
|
32
34
|
|
33
35
|
self.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
|
34
36
|
end
|
35
37
|
|
38
|
+
Rake::RDocTask.new('AWESOME') do |rd|
|
39
|
+
rd.main = HOE.readme_file
|
40
|
+
rd.options << '-d' if (`which dot` =~ /\/dot/) unless
|
41
|
+
rd.rdoc_dir = 'doc'
|
42
|
+
|
43
|
+
rd.rdoc_files += HOE.spec.require_paths
|
44
|
+
rd.rdoc_files += HOE.spec.extra_rdoc_files
|
45
|
+
|
46
|
+
title = HOE.spec.rdoc_options.grep(/^(-t|--title)=?$/).first
|
47
|
+
|
48
|
+
if title then
|
49
|
+
rd.options << title
|
50
|
+
|
51
|
+
unless title =~ /=/ then # for ['-t', 'title here']
|
52
|
+
title_index = HOE.spec.rdoc_options.index(title)
|
53
|
+
rd.options << HOE.spec.rdoc_options[title_index + 1]
|
54
|
+
end
|
55
|
+
else
|
56
|
+
title = "#{HOE.name}-#{HOE.version} Documentation"
|
57
|
+
title = "#{HOE.rubyforge_name}'s " + title if HOE.rubyforge_name != HOE.name
|
58
|
+
rd.options << '--title' << title
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
36
62
|
unless java
|
37
63
|
gem 'rake-compiler', '>= 0.4.1'
|
38
64
|
require "rake/extensiontask"
|
@@ -52,32 +78,27 @@ unless java
|
|
52
78
|
"--with-xslt-dir=#{File.join(cross_dir, 'libxslt')}"
|
53
79
|
end
|
54
80
|
|
55
|
-
|
56
|
-
# To build the windows fat binary, do:
|
57
|
-
#
|
58
|
-
# rake fat_binary native gem
|
59
|
-
#
|
60
|
-
# I keep my ruby in multiruby, so my command is like this:
|
61
|
-
#
|
62
|
-
# RAKE19=~/.multiruby/install/1.9.1-p129/bin/rake \
|
63
|
-
# rake fat_binary native gem
|
64
|
-
task 'fat_binary' do
|
65
|
-
rake19 = ENV['RAKE19'] || 'rake1.9'
|
66
|
-
system("rake clean cross compile RUBY_CC_VERSION=1.8.6 FAT_DIR=1.8")
|
67
|
-
system("#{rake19} clean cross compile RUBY_CC_VERSION=1.9.1 FAT_DIR=1.9")
|
81
|
+
file 'lib/nokogiri/nokogiri.rb' do
|
68
82
|
File.open("lib/#{HOE.name}/#{HOE.name}.rb", 'wb') do |f|
|
69
83
|
f.write <<-eoruby
|
70
84
|
require "#{HOE.name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{HOE.name}"
|
71
85
|
eoruby
|
72
86
|
end
|
73
|
-
HOE.spec.extensions = []
|
74
|
-
HOE.spec.platform = 'x86-mswin32'
|
75
|
-
HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
|
76
|
-
HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/*"]
|
77
|
-
HOE.spec.files += Dir["ext/nokogiri/*.dll"]
|
78
87
|
end
|
88
|
+
|
89
|
+
namespace :cross do
|
90
|
+
task :file_list do
|
91
|
+
HOE.spec.platform = 'x86-mswin32'
|
92
|
+
HOE.spec.extensions = []
|
93
|
+
HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
|
94
|
+
HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/#{HOE.name}.so"]
|
95
|
+
HOE.spec.files += Dir["ext/nokogiri/*.dll"]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
79
99
|
CLOBBER.include("lib/nokogiri/nokogiri.{so,dylib,rb,bundle}")
|
80
100
|
CLOBBER.include("lib/nokogiri/1.{8,9}")
|
101
|
+
CLOBBER.include("ext/nokogiri/*.dll")
|
81
102
|
end
|
82
103
|
|
83
104
|
namespace :gem do
|
@@ -103,6 +124,7 @@ namespace :gem do
|
|
103
124
|
HOE.spec.platform = 'java'
|
104
125
|
HOE.spec.files << GENERATED_PARSER
|
105
126
|
HOE.spec.files << GENERATED_TOKENIZER
|
127
|
+
HOE.spec.files += Dir["ext/nokogiri/*.dll"]
|
106
128
|
HOE.spec.extensions = []
|
107
129
|
f.write(HOE.spec.to_ruby)
|
108
130
|
end
|
@@ -137,7 +159,16 @@ libs = %w{
|
|
137
159
|
libxslt-1.1.24.win32
|
138
160
|
}
|
139
161
|
|
162
|
+
lib_dlls = {
|
163
|
+
'iconv-1.9.2.win32' => 'iconv.dll',
|
164
|
+
'zlib-1.2.3.win32' => 'zlib1.dll',
|
165
|
+
'libxml2-2.7.3.win32' => 'libxml2.dll',
|
166
|
+
'libxslt-1.1.24.win32' => 'libxslt.dll',
|
167
|
+
}
|
168
|
+
|
140
169
|
libs.each do |lib|
|
170
|
+
libname = lib.split('-').first
|
171
|
+
|
141
172
|
file "tmp/stash/#{lib}.zip" do |t|
|
142
173
|
puts "downloading #{lib}"
|
143
174
|
FileUtils.mkdir_p('tmp/stash')
|
@@ -146,20 +177,30 @@ libs.each do |lib|
|
|
146
177
|
system("wget #{url} || curl -O #{url}")
|
147
178
|
end
|
148
179
|
end
|
149
|
-
|
180
|
+
|
181
|
+
file "tmp/cross/#{libname}" => ["tmp/stash/#{lib}.zip"] do |t|
|
150
182
|
puts "unzipping #{lib}.zip"
|
151
183
|
FileUtils.mkdir_p('tmp/cross')
|
152
184
|
Dir.chdir('tmp/cross') do
|
153
185
|
sh "unzip ../stash/#{lib}.zip"
|
154
186
|
sh "cp #{lib}/bin/* #{lib}/lib" # put DLL in lib, so dirconfig works
|
155
|
-
sh "cp #{lib}/bin/*.dll ../../ext/nokogiri/"
|
156
187
|
sh "mv #{lib} #{lib.split('-').first}"
|
157
188
|
sh "touch #{lib.split('-').first}"
|
158
189
|
end
|
159
190
|
end
|
191
|
+
|
192
|
+
file "ext/nokogiri/#{lib_dlls[lib]}" => "tmp/cross/#{libname}" do |t|
|
193
|
+
Dir.chdir('tmp/cross') do
|
194
|
+
sh "cp #{libname}/bin/*.dll ../../ext/nokogiri/"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
160
198
|
if Rake::Task.task_defined?(:cross)
|
161
|
-
Rake::Task[:cross].prerequisites << "
|
199
|
+
Rake::Task[:cross].prerequisites << "ext/nokogiri/#{lib_dlls[lib]}"
|
200
|
+
Rake::Task[:cross].prerequisites << "lib/nokogiri/nokogiri.rb"
|
201
|
+
Rake::Task[:cross].prerequisites << "cross:file_list"
|
162
202
|
end
|
203
|
+
Rake::Task['gem:jruby:spec'].prerequisites << "ext/nokogiri/#{lib_dlls[lib]}"
|
163
204
|
end
|
164
205
|
|
165
206
|
require 'tasks/test'
|
@@ -181,8 +222,10 @@ unless windows || java || ENV['NOKOGIRI_FFI']
|
|
181
222
|
end
|
182
223
|
|
183
224
|
Rake::Task[:test].prerequisites << :compile
|
184
|
-
|
185
|
-
|
225
|
+
if Hoe.plugins.include?(:debugging)
|
226
|
+
['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
|
227
|
+
Rake::Task["test:#{task_name}"].prerequisites << :compile
|
228
|
+
end
|
186
229
|
end
|
187
230
|
else
|
188
231
|
[:test, :check_manifest].each do |task_name|
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
2
2
|
|
3
|
+
# :stopdoc:
|
4
|
+
|
3
5
|
require 'mkmf'
|
4
6
|
|
5
7
|
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
@@ -74,7 +76,11 @@ end
|
|
74
76
|
CUSTOM_DASH_I = []
|
75
77
|
|
76
78
|
def nokogiri_find_header header_file, *paths
|
77
|
-
|
79
|
+
# mkmf in ruby 1.8.5 does not have the "checking_message" method
|
80
|
+
message = defined?(checking_message) ?
|
81
|
+
checking_message(header_file, paths) :
|
82
|
+
header_file
|
83
|
+
|
78
84
|
header = cpp_include header_file
|
79
85
|
checking_for message do
|
80
86
|
found = false
|
@@ -128,22 +134,22 @@ def nokogiri_link_command ldflags, opt='', libpath=$LIBPATH
|
|
128
134
|
end
|
129
135
|
|
130
136
|
def with_custom_link
|
131
|
-
|
132
|
-
|
137
|
+
alias :old_link_command :link_command
|
138
|
+
alias :link_command :nokogiri_link_command
|
133
139
|
yield
|
134
|
-
|
135
|
-
|
140
|
+
ensure
|
141
|
+
alias :link_command :old_link_command
|
136
142
|
end
|
137
143
|
|
138
|
-
with_custom_link do
|
139
|
-
with_cppflags $INCFLAGS do
|
144
|
+
#with_custom_link do
|
145
|
+
# with_cppflags $INCFLAGS do
|
140
146
|
have_func('xmlRelaxNGSetParserStructuredErrors')
|
141
147
|
have_func('xmlRelaxNGSetParserStructuredErrors')
|
142
148
|
have_func('xmlRelaxNGSetValidStructuredErrors')
|
143
149
|
have_func('xmlSchemaSetValidStructuredErrors')
|
144
150
|
have_func('xmlSchemaSetParserStructuredErrors')
|
145
|
-
end
|
146
|
-
end
|
151
|
+
# end
|
152
|
+
#end
|
147
153
|
|
148
154
|
if ENV['CPUPROFILE']
|
149
155
|
unless find_library('profiler', 'ProfilerEnable', *LIB_DIRS)
|
@@ -152,3 +158,4 @@ if ENV['CPUPROFILE']
|
|
152
158
|
end
|
153
159
|
|
154
160
|
create_makefile('nokogiri/nokogiri')
|
161
|
+
# :startdoc:
|
@@ -40,7 +40,6 @@ static VALUE read_io( VALUE klass,
|
|
40
40
|
const char * c_enc = (encoding == Qnil) ? NULL : StringValuePtr(encoding);
|
41
41
|
VALUE error_list = rb_ary_new();
|
42
42
|
|
43
|
-
xmlInitParser();
|
44
43
|
xmlResetLastError();
|
45
44
|
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
46
45
|
|
@@ -92,7 +91,6 @@ static VALUE read_memory( VALUE klass,
|
|
92
91
|
int len = RSTRING_LEN(string);
|
93
92
|
VALUE error_list = rb_ary_new();
|
94
93
|
|
95
|
-
xmlInitParser();
|
96
94
|
xmlResetLastError();
|
97
95
|
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
98
96
|
|
data/ext/nokogiri/nokogiri.c
CHANGED
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -46,7 +46,7 @@ int is_2_6_16(void) ;
|
|
46
46
|
({ \
|
47
47
|
VALUE _string = rb_str_new2((const char *)str); \
|
48
48
|
if(NULL != encoding) { \
|
49
|
-
int _enc = rb_enc_find_index(
|
49
|
+
int _enc = rb_enc_find_index("UTF-8"); \
|
50
50
|
if(_enc == -1) \
|
51
51
|
rb_enc_associate_index(_string, rb_enc_find_index("ASCII")); \
|
52
52
|
else \
|
@@ -59,7 +59,7 @@ int is_2_6_16(void) ;
|
|
59
59
|
({ \
|
60
60
|
VALUE _string = rb_str_new((const char *)str, (long)len); \
|
61
61
|
if(NULL != encoding) { \
|
62
|
-
int _enc = rb_enc_find_index(
|
62
|
+
int _enc = rb_enc_find_index("UTF-8"); \
|
63
63
|
if(_enc == -1) \
|
64
64
|
rb_enc_associate_index(_string, rb_enc_find_index("ASCII")); \
|
65
65
|
else \
|
@@ -114,8 +114,7 @@ extern VALUE mNokogiriXslt ;
|
|
114
114
|
#define NOKOGIRI_ROOT_NODE(_node) \
|
115
115
|
({ \
|
116
116
|
nokogiriTuplePtr tuple = (nokogiriTuplePtr)(_node->doc->_private); \
|
117
|
-
|
118
|
-
xmlXPathNodeSetAdd(node_set, _node); \
|
117
|
+
st_insert(tuple->unlinkedNodes, (st_data_t)_node, (st_data_t)_node); \
|
119
118
|
_node; \
|
120
119
|
})
|
121
120
|
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
#include <xml_document.h>
|
2
2
|
|
3
|
+
static int dealloc_node_i(xmlNodePtr key, xmlNodePtr node, xmlDocPtr doc)
|
4
|
+
{
|
5
|
+
switch(node->type) {
|
6
|
+
case XML_ATTRIBUTE_NODE:
|
7
|
+
xmlFreePropList((xmlAttrPtr)node);
|
8
|
+
break;
|
9
|
+
default:
|
10
|
+
if(node->parent == NULL) {
|
11
|
+
xmlAddChild((xmlNodePtr)doc, node);
|
12
|
+
}
|
13
|
+
}
|
14
|
+
return ST_CONTINUE;
|
15
|
+
}
|
16
|
+
|
3
17
|
static void dealloc(xmlDocPtr doc)
|
4
18
|
{
|
5
19
|
NOKOGIRI_DEBUG_START(doc);
|
6
20
|
|
7
|
-
|
8
|
-
xmlNodeSetPtr node_set = tuple->unlinkedNodes;
|
21
|
+
st_table *node_hash = DOC_UNLINKED_NODE_HASH(doc);
|
9
22
|
|
10
23
|
xmlDeregisterNodeFunc func = xmlDeregisterNodeDefault(NULL);
|
11
24
|
|
12
|
-
|
13
|
-
|
14
|
-
xmlNodePtr node = node_set->nodeTab[j];
|
15
|
-
switch(node->type)
|
16
|
-
{
|
17
|
-
case XML_ATTRIBUTE_NODE:
|
18
|
-
xmlFreePropList((xmlAttrPtr)node);
|
19
|
-
break;
|
20
|
-
default:
|
21
|
-
if(node->parent == NULL) {
|
22
|
-
xmlAddChild((xmlNodePtr)doc, node);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
if (node_set->nodeTab != NULL)
|
28
|
-
xmlFree(node_set->nodeTab);
|
29
|
-
xmlFree(node_set);
|
25
|
+
st_foreach(node_hash, dealloc_node_i, (st_data_t)doc);
|
26
|
+
st_free_table(node_hash);
|
30
27
|
|
31
28
|
free(doc->_private);
|
32
29
|
doc->_private = NULL;
|
@@ -68,7 +65,19 @@ static VALUE set_root(VALUE self, VALUE root)
|
|
68
65
|
Data_Get_Struct(self, xmlDoc, doc);
|
69
66
|
Data_Get_Struct(root, xmlNode, new_root);
|
70
67
|
|
68
|
+
xmlNodePtr old_root = NULL;
|
69
|
+
|
70
|
+
/* If the new root's document is not the same as the current document,
|
71
|
+
* then we need to dup the node in to this document. */
|
72
|
+
if(new_root->doc != doc) {
|
73
|
+
old_root = xmlDocGetRootElement(doc);
|
74
|
+
if (!(new_root = xmlDocCopyNode(new_root, doc, 1))) {
|
75
|
+
rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
71
79
|
xmlDocSetRootElement(doc, new_root);
|
80
|
+
if(old_root) NOKOGIRI_ROOT_NODE(old_root);
|
72
81
|
return root;
|
73
82
|
}
|
74
83
|
|
@@ -136,7 +145,6 @@ static VALUE read_io( VALUE klass,
|
|
136
145
|
const char * c_enc = (encoding == Qnil) ? NULL : StringValuePtr(encoding);
|
137
146
|
VALUE error_list = rb_ary_new();
|
138
147
|
|
139
|
-
xmlInitParser();
|
140
148
|
xmlResetLastError();
|
141
149
|
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
142
150
|
|
@@ -187,7 +195,6 @@ static VALUE read_memory( VALUE klass,
|
|
187
195
|
int len = RSTRING_LEN(string);
|
188
196
|
VALUE error_list = rb_ary_new();
|
189
197
|
|
190
|
-
xmlInitParser();
|
191
198
|
xmlResetLastError();
|
192
199
|
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
193
200
|
xmlDocPtr doc = xmlReadMemory(c_buffer, len, c_url, c_enc, NUM2INT(options));
|
@@ -303,7 +310,7 @@ VALUE Nokogiri_wrap_xml_document(VALUE klass, xmlDocPtr doc)
|
|
303
310
|
rb_funcall(rb_doc, rb_intern("initialize"), 0);
|
304
311
|
|
305
312
|
tuple->doc = (void *)rb_doc;
|
306
|
-
tuple->unlinkedNodes =
|
313
|
+
tuple->unlinkedNodes = st_init_numtable_with_size(128);
|
307
314
|
tuple->node_cache = cache;
|
308
315
|
doc->_private = tuple ;
|
309
316
|
|
data/ext/nokogiri/xml_document.h
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
#define NOKOGIRI_XML_DOCUMENT
|
3
3
|
|
4
4
|
#include <nokogiri.h>
|
5
|
+
#include "st.h"
|
5
6
|
|
6
7
|
struct _nokogiriTuple {
|
7
8
|
xmlDocPtr doc;
|
8
|
-
|
9
|
+
st_table *unlinkedNodes;
|
9
10
|
VALUE node_cache;
|
10
11
|
};
|
11
12
|
typedef struct _nokogiriTuple nokogiriTuple;
|
@@ -16,7 +17,7 @@ VALUE Nokogiri_wrap_xml_document(VALUE klass, xmlDocPtr doc);
|
|
16
17
|
|
17
18
|
#define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
|
18
19
|
#define DOC_RUBY_OBJECT(x) ((VALUE)((nokogiriTuplePtr)(x->_private))->doc)
|
19
|
-
#define
|
20
|
+
#define DOC_UNLINKED_NODE_HASH(x) (((nokogiriTuplePtr)(x->_private))->unlinkedNodes)
|
20
21
|
#define DOC_NODE_CACHE(x) ((VALUE)((nokogiriTuplePtr)(x->_private))->node_cache)
|
21
22
|
|
22
23
|
extern VALUE cNokogiriXmlDocument ;
|