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$ # $Source$
# #
@ -25,12 +25,12 @@ class YEnc
class << self class << self
Debuglevel = 0 Debuglevel = 0
@@ymap = {}
def ydecode(data, outfile=nil) def ydecode(data, outfile=nil)
unless @ymap if @@ymap.empty?
@ymap = {}
(-106..255).each do |b| (-106..255).each do |b|
@ymap[b]=((b-42)%256) @@ymap[b]=((b-42)%256)
end end
end end
@ -65,7 +65,7 @@ def _ydecode_line(line)
end end
end end
# begin # begin
ostr << @ymap[line[i].to_i] ostr << @@ymap[line[i].to_i]
# rescue TypeError # rescue TypeError
# puts "this should not happen!!!" # puts "this should not happen!!!"
# puts "line[i] contents: '#{line[i]}'\n" # puts "line[i] contents: '#{line[i]}'\n"
@ -133,7 +133,7 @@ def _ydecode_file(file, outfile)
part = $4.to_i part = $4.to_i
crc = $6 crc = $6
if size != bytes 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 end
if part == nil if part == nil
return mode, filename return mode, filename
@ -141,7 +141,7 @@ def _ydecode_file(file, outfile)
total += bytes total += bytes
if total >= totalsize if total >= totalsize
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 end
return mode, filename return mode, filename
end end
@ -169,7 +169,7 @@ def _ydecode_file(file, outfile)
skip = false skip = false
b = $2 b = $2
e = $4 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 if b.to_i == oldpartbegin && e.to_i == oldpartend
print "Skipping duplicate part\n" print "Skipping duplicate part\n"
skip = true skip = true
@ -179,7 +179,7 @@ def _ydecode_file(file, outfile)
oldpartend = e.to_i oldpartend = e.to_i
oldpartbegin = b.to_i oldpartbegin = b.to_i
else 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 end
next next
end end
@ -251,7 +251,7 @@ def _ydecode_array(data)
size = $2.to_i size = $2.to_i
crc = $4 crc = $4
if size != decode.length 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 end
dec = [ decode ] dec = [ decode ]
return mode, filename, dec return mode, filename, dec
@ -260,7 +260,7 @@ def _ydecode_array(data)
skip = false skip = false
b = $2 b = $2
e = $4 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 if b.to_i == oldpartbegin && e.to_i == oldpartend
print "Skipping duplicate part\n" print "Skipping duplicate part\n"
skip = true skip = true
@ -270,7 +270,7 @@ def _ydecode_array(data)
oldpartend = e.to_i oldpartend = e.to_i
oldpartbegin = b.to_i oldpartbegin = b.to_i
else 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 end
next next
end end