speed up ydecoding a little
This commit is contained in:
parent
7a7d053b96
commit
ffe0a85311
1 changed files with 37 additions and 35 deletions
|
|
@ -719,9 +719,9 @@ def _ydecode_file(file, outfile)
|
||||||
total = 0
|
total = 0
|
||||||
oldpartend = 0
|
oldpartend = 0
|
||||||
|
|
||||||
ymap=[]
|
ymap = {}
|
||||||
(0..255).each do |b|
|
(-106..255).each do |b|
|
||||||
ymap.push((b-42+256)%256)
|
ymap[b]=((b-42)%256)
|
||||||
end
|
end
|
||||||
|
|
||||||
while (! file.eof)
|
while (! file.eof)
|
||||||
|
|
@ -828,28 +828,11 @@ def _ydecode_file(file, outfile)
|
||||||
i += 1
|
i += 1
|
||||||
line[i] -= 64
|
line[i] -= 64
|
||||||
end
|
end
|
||||||
ostr << ((line[i] - 42) % 256)
|
ostr << ymap[line[i]]
|
||||||
# outfile.putc((line[i] - 42) % 256)
|
|
||||||
# ostr << ymap[line[i]%255]
|
|
||||||
i += 1
|
i += 1
|
||||||
end
|
end
|
||||||
outfile << ostr
|
outfile << ostr
|
||||||
bytes += ostr.length
|
bytes += ostr.length
|
||||||
|
|
||||||
# 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
|
end
|
||||||
|
|
||||||
print "No \"=yend\" found!!!\n"
|
print "No \"=yend\" found!!!\n"
|
||||||
|
|
@ -866,6 +849,11 @@ def _ydecode_array(data)
|
||||||
percent = 0
|
percent = 0
|
||||||
mark = lines/100
|
mark = lines/100
|
||||||
|
|
||||||
|
ymap = {}
|
||||||
|
(-106..255).each do |b|
|
||||||
|
ymap[b]=((b-42)%256)
|
||||||
|
end
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while (i < data.length)
|
while (i < data.length)
|
||||||
if data[i] =~ /^\=ybegin\s+(.*line\=.*)/
|
if data[i] =~ /^\=ybegin\s+(.*line\=.*)/
|
||||||
|
|
@ -918,21 +906,35 @@ def _ydecode_array(data)
|
||||||
# print "#{i}: linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
# print "#{i}: linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
||||||
# end
|
# end
|
||||||
|
|
||||||
special = 0
|
i = 0
|
||||||
str = ""
|
ll = line.length
|
||||||
line.each_byte { |b|
|
ostr = ''
|
||||||
if special == 0
|
while i < ll
|
||||||
if b == 0x3d
|
if line[i] == 0x3d
|
||||||
special = 1
|
i += 1
|
||||||
next
|
line[i] -= 64
|
||||||
end
|
end
|
||||||
else
|
ostr << ymap[line[i]]
|
||||||
special = 0
|
i += 1
|
||||||
b = (b - 64) % 256
|
|
||||||
end
|
end
|
||||||
str << ((b - 42) % 256).chr
|
decode << ostr
|
||||||
}
|
bytes += ostr.length
|
||||||
decode << str
|
|
||||||
|
# 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"
|
print "${i}: no \"=yend\" found!!!\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue