Use while instead of loop

This commit is contained in:
Kazuhiro NISHIYAMA 2019-12-17 09:46:45 +09:00 committed by Kazuhiro NISHIYAMA
parent 9d3ffcfbfc
commit 299db37957
Notes: git 2019-12-17 21:56:34 +09:00

View File

@ -631,9 +631,7 @@ module Net
with_binary(true) do with_binary(true) do
begin begin
conn = transfercmd(cmd, rest_offset) conn = transfercmd(cmd, rest_offset)
loop do while data = conn.read(blocksize)
data = conn.read(blocksize)
break if data == nil
yield(data) yield(data)
end end
conn.shutdown(Socket::SHUT_WR) conn.shutdown(Socket::SHUT_WR)
@ -658,9 +656,7 @@ module Net
with_binary(false) do with_binary(false) do
begin begin
conn = transfercmd(cmd) conn = transfercmd(cmd)
loop do while line = conn.gets
line = conn.gets
break if line == nil
yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?) yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
end end
conn.shutdown(Socket::SHUT_WR) conn.shutdown(Socket::SHUT_WR)
@ -688,9 +684,7 @@ module Net
with_binary(true) do with_binary(true) do
begin begin
conn = transfercmd(cmd) conn = transfercmd(cmd)
loop do while buf = file.read(blocksize)
buf = file.read(blocksize)
break if buf == nil
conn.write(buf) conn.write(buf)
yield(buf) if block_given? yield(buf) if block_given?
end end
@ -723,9 +717,7 @@ module Net
with_binary(false) do with_binary(false) do
begin begin
conn = transfercmd(cmd) conn = transfercmd(cmd)
loop do while buf = file.gets
buf = file.gets
break if buf == nil
if buf[-2, 2] != CRLF if buf[-2, 2] != CRLF
buf = buf.chomp + CRLF buf = buf.chomp + CRLF
end end