Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/net/sftp/operations/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ def gets(sep_or_limit=$/, limit=Float::INFINITY)
sep_string
end

search_from = 0
loop do
at = @buffer.index(delim) if delim
at = @buffer.index(delim, search_from) if delim
if at
offset = [at + delim.length, lim].min
@pos += offset
Expand All @@ -110,11 +111,14 @@ def gets(sep_or_limit=$/, limit=Float::INFINITY)
@pos += lim
line, @buffer = @buffer[0,lim], @buffer[lim..-1]
return line
elsif !fill
return nil if @buffer.empty?
@pos += @buffer.length
line, @buffer = @buffer, ""
return line
else
search_from = [@buffer.length - delim.length + 1, 0].max if delim
unless fill
return nil if @buffer.empty?
@pos += @buffer.length
line, @buffer = @buffer, ""
return line
end
end
end
end
Expand Down