do part checking in array decode too
This commit is contained in:
parent
b5761f863e
commit
8843a9d9a2
1 changed files with 38 additions and 55 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#################################
|
||||
#
|
||||
# $Dwarf: yenc.rb,v 1.3 2003/04/20 18:31:17 ward Exp $
|
||||
# $Dwarf: yenc.rb,v 1.4 2003/04/20 20:15:34 ward Exp $
|
||||
# $Source$
|
||||
#
|
||||
# article.rb
|
||||
|
|
@ -61,8 +61,10 @@ def _ydecode_file(file, outfile)
|
|||
file.pos = 0
|
||||
bytes = 0
|
||||
total = 0
|
||||
oldpartbegin = 0
|
||||
oldpartend = 0
|
||||
search_begin = false
|
||||
skip = false
|
||||
|
||||
while (! file.eof)
|
||||
line = file.gets
|
||||
|
|
@ -143,11 +145,18 @@ def _ydecode_file(file, outfile)
|
|||
next
|
||||
end
|
||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
||||
skip = false
|
||||
b = $2
|
||||
e = $4
|
||||
print " next part begin #{b}, end #{e}\n"
|
||||
if b.to_i == oldpartbegin && e.to_i == oldpartend
|
||||
print "Skipping duplicate part\n"
|
||||
skip = true
|
||||
next
|
||||
end
|
||||
if b.to_i == oldpartend + 1
|
||||
oldpartend = e.to_i
|
||||
oldpartbegin = b.to_i
|
||||
else
|
||||
raise PermError, "Parts not continuous! last end #{oldpartend}, begin #{b}"
|
||||
end
|
||||
|
|
@ -160,22 +169,13 @@ def _ydecode_file(file, outfile)
|
|||
# print "linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
||||
# end
|
||||
|
||||
# i = 0
|
||||
# ll = line.length
|
||||
# ostr = ''
|
||||
# while i < ll
|
||||
# if line[i] == 0x3d
|
||||
# i += 1
|
||||
# line[i] -= 64
|
||||
# end
|
||||
# ostr << ymap[line[i]]
|
||||
# i += 1
|
||||
# end
|
||||
if !skip
|
||||
print "line: #{line}" if Debuglevel > 0
|
||||
ostr = _ydecode_line(line)
|
||||
outfile << ostr
|
||||
bytes += ostr.length
|
||||
end
|
||||
end
|
||||
|
||||
print "No \"=yend\" found!!!\n"
|
||||
return mode, filename, outfile
|
||||
|
|
@ -192,11 +192,6 @@ def _ydecode_array(data)
|
|||
percent = 0
|
||||
mark = lines/100
|
||||
|
||||
# ymap = {}
|
||||
# (-106..255).each do |b|
|
||||
# ymap[b]=((b-42)%256)
|
||||
# end
|
||||
|
||||
i = 0
|
||||
while (i < data.length)
|
||||
if data[i] =~ /^\=ybegin\s+(.*line\=.*)/
|
||||
|
|
@ -238,8 +233,22 @@ def _ydecode_array(data)
|
|||
dec = [ decode ]
|
||||
return mode, filename, dec
|
||||
end
|
||||
if line =~ /^\=ypart.*\Z/
|
||||
# ignore for now
|
||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
||||
skip = false
|
||||
b = $2
|
||||
e = $4
|
||||
print " next part begin #{b}, end #{e}\n"
|
||||
if b.to_i == oldpartbegin && e.to_i == oldpartend
|
||||
print "Skipping duplicate part\n"
|
||||
skip = true
|
||||
next
|
||||
end
|
||||
if b.to_i == oldpartend + 1
|
||||
oldpartend = e.to_i
|
||||
oldpartbegin = b.to_i
|
||||
else
|
||||
raise PermError, "Parts not continuous! last end #{oldpartend}, begin #{b}"
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
@ -249,38 +258,12 @@ def _ydecode_array(data)
|
|||
# print "#{i}: linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
||||
# end
|
||||
|
||||
# j = 0
|
||||
# ll = line.length
|
||||
# ostr = ''
|
||||
# while j < ll
|
||||
# if line[j] == 0x3d
|
||||
# j += 1
|
||||
# line[j] -= 64
|
||||
# end
|
||||
# ostr << ymap[line[j]]
|
||||
# j += 1
|
||||
# end
|
||||
# decode << ostr
|
||||
# bytes += ostr.length
|
||||
if !skip
|
||||
print "line: #{line}" if Debuglevel > 0
|
||||
ostr = _ydecode_line(line)
|
||||
decode << ostr
|
||||
bytes += ostr.length
|
||||
|
||||
# special = 0
|
||||
# str = ""
|
||||
# line.each_byte { |b|
|
||||
# if special == 0
|
||||
# if b == 0x3d
|
||||
# special = 1
|
||||
# next
|
||||
# end
|
||||
# else
|
||||
# special = 0
|
||||
# b = (b - 64) % 256
|
||||
# end
|
||||
# str << ((b - 42) % 256).chr
|
||||
# }
|
||||
# decode << str
|
||||
end
|
||||
end
|
||||
|
||||
print "${i}: no \"=yend\" found!!!\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue