@@ -195,11 +195,9 @@ def pull_event
195
195
return [ :end_document ] if empty?
196
196
return @stack . shift if @stack . size > 0
197
197
#STDERR.puts @source.encoding
198
- @source . read if @source . buffer . size <2
199
198
#STDERR.puts "BUFFER = #{@source.buffer.inspect}"
200
199
if @document_status == nil
201
- #@source.consume( /^\s*/um )
202
- word = @source . match ( /^((?:\s +)|(?:<[^>]*>))/um )
200
+ word = @source . match ( /\A ((?:\s +)|(?:<[^>]*>))/um )
203
201
word = word [ 1 ] unless word . nil?
204
202
#STDERR.puts "WORD = #{word.inspect}"
205
203
case word
@@ -257,18 +255,16 @@ def pull_event
257
255
@stack << [ :end_doctype ]
258
256
end
259
257
return args
260
- when /^ \s +/
258
+ when /\A \s +/
261
259
else
262
260
@document_status = :after_doctype
263
- @source . read if @source . buffer . size <2
264
- md = @source . match ( /\s */um , true )
265
261
if @source . encoding == "UTF-8"
266
262
@source . buffer . force_encoding ( ::Encoding ::UTF_8 )
267
263
end
268
264
end
269
265
end
270
266
if @document_status == :in_doctype
271
- md = @source . match ( /\s *(.*?>)/um )
267
+ md = @source . match ( /\A \ s *(.*?>)/um )
272
268
case md [ 1 ]
273
269
when SYSTEMENTITY
274
270
match = @source . match ( SYSTEMENTITY , true ) [ 1 ]
@@ -349,7 +345,11 @@ def pull_event
349
345
return [ :end_doctype ]
350
346
end
351
347
end
348
+ if @document_status == :after_doctype
349
+ @source . match ( /\A \s */um , true )
350
+ end
352
351
begin
352
+ @source . read if @source . buffer . size <2
353
353
if @source . buffer [ 0 ] == ?<
354
354
if @source . buffer [ 1 ] == ?/
355
355
@nsstack . shift
@@ -392,6 +392,7 @@ def pull_event
392
392
unless md
393
393
raise REXML ::ParseException . new ( "malformed XML: missing tag start" , @source )
394
394
end
395
+ @document_status = :in_element
395
396
prefixes = Set . new
396
397
prefixes << md [ 2 ] if md [ 2 ]
397
398
@nsstack . unshift ( curr_ns = Set . new )
0 commit comments