try to speed up ydecoding
This commit is contained in:
parent
97cec78a66
commit
fdd4a45195
1 changed files with 30 additions and 13 deletions
|
|
@ -255,6 +255,7 @@ def get_body(server, message)
|
|||
rescue Net::NNTPReplyError
|
||||
print "Caught Net::NNTPReplyError reading article #{message} from #{server} (get_body)\n"
|
||||
print "Error: #{$!}\n"
|
||||
print "Status: #{$?}\n"
|
||||
return false
|
||||
rescue EOFError
|
||||
print "Caught EOFError reading article #{message} from #{server} (get_body)\n"
|
||||
|
|
@ -710,6 +711,11 @@ def _ydecode_file(file, outfile)
|
|||
total = 0
|
||||
oldpartend = 0
|
||||
|
||||
ymap=[]
|
||||
(0..255).each do |b|
|
||||
ymap.push((b-42+256)%256)
|
||||
end
|
||||
|
||||
while (! file.eof)
|
||||
line = file.gets
|
||||
print "line: #{line}" if Debuglevel > 0
|
||||
|
|
@ -747,7 +753,7 @@ def _ydecode_file(file, outfile)
|
|||
while (! file.eof)
|
||||
print "at #{file.pos} need to go to #{lines}\n" if Debuglevel > 1
|
||||
line = file.gets
|
||||
line = line[0 ... line.length - 1]
|
||||
line.chomp!
|
||||
|
||||
if line =~ /^=yend\s+(.*)\Z/
|
||||
m = $1
|
||||
|
|
@ -805,20 +811,31 @@ def _ydecode_file(file, outfile)
|
|||
# if line.length != linesize
|
||||
# print "linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
||||
# end
|
||||
special = 0
|
||||
line.each_byte { |b|
|
||||
if special == 0
|
||||
if b == 0x3d
|
||||
special = 1
|
||||
next
|
||||
|
||||
i = 0
|
||||
while i < line.length
|
||||
if line[i] == '='
|
||||
i += 1
|
||||
line[i] -= 64
|
||||
end
|
||||
else
|
||||
special = 0
|
||||
b = (b - 64) % 256
|
||||
end
|
||||
outfile.putc((b - 42) % 256)
|
||||
outfile.putc ymap[line[i]]
|
||||
bytes += 1
|
||||
}
|
||||
end
|
||||
|
||||
# special = 0
|
||||
# line.each_byte { |b|
|
||||
# if special == 0
|
||||
# if b == 0x3d
|
||||
# special = 1
|
||||
# next
|
||||
# end
|
||||
# else
|
||||
# special = 0
|
||||
# b = (b - 64) % 256
|
||||
# end
|
||||
# outfile.putc((b - 42) % 256)
|
||||
# bytes += 1
|
||||
# }
|
||||
end
|
||||
|
||||
print "No \"=yend\" found!!!\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue