1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Partial fix so STDIN#scanf works with new STDIN#pos behavior

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
dblack 2004-03-01 14:25:40 +00:00
parent 933fb96a12
commit b0c388896a

View file

@ -331,7 +331,6 @@ module Scanf
def initialize(str) def initialize(str)
@spec_string = str @spec_string = str
h = '[A-Fa-f0-9]' h = '[A-Fa-f0-9]'
@re_string, @handler = @re_string, @handler =
@ -523,7 +522,7 @@ module Scanf
end end
def to_s def to_s
@spec_string @specs.join('')
end end
def prune(n=matched_count) def prune(n=matched_count)
@ -592,7 +591,7 @@ class IO
return block_scanf(str,&b) if b return block_scanf(str,&b) if b
return [] unless str.size > 0 return [] unless str.size > 0
start_position = pos start_position = pos rescue 0
matched_so_far = 0 matched_so_far = 0
source_buffer = "" source_buffer = ""
result_buffer = [] result_buffer = []
@ -601,7 +600,7 @@ class IO
fstr = Scanf::FormatString.new(str) fstr = Scanf::FormatString.new(str)
loop do loop do
if eof if eof || (tty? &&! fstr.match(source_buffer))
final_result.concat(result_buffer) final_result.concat(result_buffer)
break break
end end
@ -616,6 +615,7 @@ class IO
result_buffer.replace(current_match) result_buffer.replace(current_match)
next next
end end
elsif (fstr.matched_count == fstr.spec_count - 1) elsif (fstr.matched_count == fstr.spec_count - 1)
if /\A\s*\z/.match(fstr.string_left) if /\A\s*\z/.match(fstr.string_left)
break if spec.count_space? break if spec.count_space?