fix ymap warnings? this is nicer anyways

This commit is contained in:
Ward Wouts 2005-02-02 17:15:52 +00:00
parent 4381df3cf9
commit 4dadd9ace5

View file

@ -1,4 +1,4 @@
# $Dwarf: yenc.rb,v 1.13 2005/01/31 14:08:33 ward Exp $
# $Dwarf: yenc.rb,v 1.14 2005/02/01 10:16:03 ward Exp $
# $Source$
#
@ -25,12 +25,12 @@ class YEnc
class << self
Debuglevel = 0
@@ymap = {}
def ydecode(data, outfile=nil)
unless @ymap
@ymap = {}
if @@ymap.empty?
(-106..255).each do |b|
@ymap[b]=((b-42)%256)
@@ymap[b]=((b-42)%256)
end
end
@ -65,7 +65,7 @@ def _ydecode_line(line)
end
end
# begin
ostr << @ymap[line[i].to_i]
ostr << @@ymap[line[i].to_i]
# rescue TypeError
# puts "this should not happen!!!"
# puts "line[i] contents: '#{line[i]}'\n"
@ -133,7 +133,7 @@ def _ydecode_file(file, outfile)
part = $4.to_i
crc = $6
if size != bytes
print "part size mismatch, is #{bytes}, should be #{size}\n"
print "#{Thread.current.inspect} part size mismatch, is #{bytes}, should be #{size}\n"
end
if part == nil
return mode, filename
@ -141,7 +141,7 @@ def _ydecode_file(file, outfile)
total += bytes
if total >= totalsize
if total != totalsize
print "total size mismatch, is #{total}, should be #{totalsize}\n"
print "#{Thread.current.inspect} total size mismatch, is #{total}, should be #{totalsize}\n"
end
return mode, filename
end
@ -169,7 +169,7 @@ def _ydecode_file(file, outfile)
skip = false
b = $2
e = $4
print " next part begin #{b}, end #{e}\n"
print " #{Thread.current.inspect} next part begin #{b}, end #{e}\n"
if b.to_i == oldpartbegin && e.to_i == oldpartend
print "Skipping duplicate part\n"
skip = true
@ -179,7 +179,7 @@ def _ydecode_file(file, outfile)
oldpartend = e.to_i
oldpartbegin = b.to_i
else
raise PermError, "Parts not continuous! last end #{oldpartend}, begin #{b}"
raise PermError, "#{Thread.current.inspect} Parts not continuous! last end #{oldpartend}, begin #{b}"
end
next
end
@ -251,7 +251,7 @@ def _ydecode_array(data)
size = $2.to_i
crc = $4
if size != decode.length
print "size mismatch, was #{decode.length}, should be #{size}\n"
print "#{Thread.current.inspect} size mismatch, was #{decode.length}, should be #{size}\n"
end
dec = [ decode ]
return mode, filename, dec
@ -260,7 +260,7 @@ def _ydecode_array(data)
skip = false
b = $2
e = $4
print " next part begin #{b}, end #{e}\n"
print " #{Thread.current.inspect} next part begin #{b}, end #{e}\n"
if b.to_i == oldpartbegin && e.to_i == oldpartend
print "Skipping duplicate part\n"
skip = true
@ -270,7 +270,7 @@ def _ydecode_array(data)
oldpartend = e.to_i
oldpartbegin = b.to_i
else
raise PermError, "Parts not continuous! last end #{oldpartend}, begin #{b}"
raise PermError, "#{Thread.current.inspect} Parts not continuous! last end #{oldpartend}, begin #{b}"
end
next
end