aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/scanf.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/scanf.rb b/lib/scanf.rb
index aeff61c115..c4da747afe 100644
--- a/lib/scanf.rb
+++ b/lib/scanf.rb
@@ -656,10 +656,11 @@ class IO
# Sub-ideal, since another FS gets created in scanf.
# But used here to determine the number of specifiers.
fstr = Scanf::FormatString.new(str)
+ last_spec = fstr.last_spec
begin
current = scanf(str)
final.push(yield(current)) unless current.empty?
- end until eof || current.size < fstr.spec_count
+ end until eof || fstr.last_spec_tried == last_spec
return final
end
end