don't copy arrays, unless you have to

This commit is contained in:
Ward Wouts 2002-08-07 21:22:18 +00:00
parent 15a4f06afa
commit b5bed34702

View file

@ -92,12 +92,22 @@ class NNTP
putline cmd
end
# def getline
# line = ''
# line.concat @socket.recv 1 until line.length > 2 and line[-1] == "\n" or line[-2..-1] == "\r\n"
# puts '*getline* '+line if @debuglevel > 0
# line = line[0...-2] if line[-2..-1] == "\r\n"
# line = line[0...-1] if "\r\n".include? line[-1].to_s
# return line
# end
def getline
line = ''
line.concat @socket.recv 1 until line.length > 2 and line[-1] == "\n" or line[-2..-1] == "\r\n"
puts '*getline* '+line if @debuglevel > 0
line = line[0...-2] if line[-2..-1] == "\r\n"
line = line[0...-1] if "\r\n".include? line[-1].to_s
line = @socket.readline
print "*getline* '#{line}'" if @debuglevel > 0
line.chomp!("\r\n")
# line.sub!(/\r?\n?$/, '')
# print "*getline* matches end\n" if line == '.'
return line
end
@ -113,14 +123,14 @@ class NNTP
return resp
end
def getlongresp
def getlongresp
resp = getresp
raise NNTPReplyError, resp, caller unless LONGRESP.include? resp[0...3]
list = []
while true
line = getline
break if line == '.'
line = line[1..-1] if line.to_s[0...2] == '..'
line.delete_at(0) if line.to_s[0...2] == '..'
list << line
end
return resp, list