fix for ruby >2.0
This commit is contained in:
parent
f75852302f
commit
67009d7ef5
4 changed files with 25 additions and 24 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# $Dwarf: uu_test.rb,v 1.1 2003/04/20 16:33:02 ward Exp $
|
# $Dwarf: uu_test.rb,v 1.1 2003/04/20 16:33:02 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
require '../uuencode.rb'
|
require '../uuencode.rb'
|
||||||
require 'ftools'
|
require 'fileutils'
|
||||||
|
|
||||||
def test1
|
def test1
|
||||||
print "Test 1: decoding a file\n"
|
print "Test 1: decoding a file\n"
|
||||||
|
|
@ -16,7 +16,7 @@ def test1
|
||||||
print " Failed, mode should be 644, but is #{mode}\n"
|
print " Failed, mode should be 644, but is #{mode}\n"
|
||||||
elsif filename != "testdata"
|
elsif filename != "testdata"
|
||||||
print " Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
print " Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
||||||
elsif ! File.compare("testdata", tmpfile.path)
|
elsif ! FileUtils.compare_file("testdata", tmpfile.path)
|
||||||
print " Failed, result doesn't match reference data\n"
|
print " Failed, result doesn't match reference data\n"
|
||||||
else
|
else
|
||||||
print " Succesful\n"
|
print " Succesful\n"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/local/bin/ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# $Dwarf: yenc_test.rb,v 1.1 2003/04/20 18:32:39 ward Exp $
|
# $Dwarf: yenc_test.rb,v 1.1 2003/04/20 18:32:39 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
require '../yenc.rb'
|
require '../yenc.rb'
|
||||||
require 'ftools'
|
require 'fileutils'
|
||||||
|
|
||||||
def test1
|
def test1
|
||||||
print "Test 1: decoding a file\n"
|
print "Test 1: decoding a file\n"
|
||||||
|
|
@ -14,7 +14,8 @@ def test1
|
||||||
mode, filename, body = YEnc.ydecode(file, tmpfile)
|
mode, filename, body = YEnc.ydecode(file, tmpfile)
|
||||||
if filename != "testdata"
|
if filename != "testdata"
|
||||||
print "Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
print "Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
||||||
elsif ! File.compare("testdata", tmpfile.path)
|
elsif ! FileUtils.compare_file("testdata", tmpfile.path)
|
||||||
|
FileUtils.cp(tmpfile.path, "/tmp/bla")
|
||||||
print "Failed, result doesn't match reference data\n"
|
print "Failed, result doesn't match reference data\n"
|
||||||
else
|
else
|
||||||
print "Succesful\n"
|
print "Succesful\n"
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ def _uudecode_file(file, outfile)
|
||||||
if line =~ /^begin(.*)/
|
if line =~ /^begin(.*)/
|
||||||
m = $1
|
m = $1
|
||||||
puts "beginning matched; rest: #{m}" if Debuglevel > 0
|
puts "beginning matched; rest: #{m}" if Debuglevel > 0
|
||||||
if m =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/
|
if m.match(/^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/)
|
||||||
mode = $2
|
mode = $2
|
||||||
filename = $4
|
filename = $4
|
||||||
puts "found beginning" if Debuglevel > 0
|
puts "found beginning" if Debuglevel > 0
|
||||||
|
|
@ -89,8 +89,8 @@ def _uudecode_file(file, outfile)
|
||||||
return mode, filename if line =~ /^end/
|
return mode, filename if line =~ /^end/
|
||||||
next if line =~ /[a-z]/
|
next if line =~ /[a-z]/
|
||||||
next if line == nil
|
next if line == nil
|
||||||
next unless ((((line[0] - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i
|
next unless ((((line[0].ord - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i
|
||||||
outfile.print line.unpack("u")
|
line.unpack("u").each{|x| outfile.print x}
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "No \"end\" found!!!"
|
puts "No \"end\" found!!!"
|
||||||
|
|
@ -116,7 +116,7 @@ def _uudecode_array(data)
|
||||||
if data[i] =~ /^begin(.*)/
|
if data[i] =~ /^begin(.*)/
|
||||||
m = $1
|
m = $1
|
||||||
puts "beginning matched; rest: #{m}" if Debuglevel > 0
|
puts "beginning matched; rest: #{m}" if Debuglevel > 0
|
||||||
if m =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/
|
if m.match(/^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/)
|
||||||
mode = $2
|
mode = $2
|
||||||
filename = $4
|
filename = $4
|
||||||
puts "found beginning" if Debuglevel > 0
|
puts "found beginning" if Debuglevel > 0
|
||||||
|
|
@ -149,7 +149,7 @@ def _uudecode_array(data)
|
||||||
next if line =~ /[a-z]/
|
next if line =~ /[a-z]/
|
||||||
next if line == nil
|
next if line == nil
|
||||||
begin
|
begin
|
||||||
next unless ((((line[0] - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i
|
next unless ((((line[0].ord - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i
|
||||||
rescue NoMethodError
|
rescue NoMethodError
|
||||||
return false
|
return false
|
||||||
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].ord]
|
||||||
# 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"
|
||||||
|
|
@ -90,10 +90,10 @@ def _ydecode_file(file, outfile)
|
||||||
while (! file.eof)
|
while (! file.eof)
|
||||||
line = file.gets
|
line = file.gets
|
||||||
print "line: #{line}" if Debuglevel > 0
|
print "line: #{line}" if Debuglevel > 0
|
||||||
if line =~ /^\=ybegin\s+(.*line\=.*)/
|
if line.match(/^\=ybegin\s+(.*line\=.*)/)
|
||||||
m = $1
|
m = $1
|
||||||
puts "ybegin match; rest: #{m}" if Debuglevel > 0
|
puts "ybegin match; rest: #{m}" if Debuglevel > 0
|
||||||
if m =~ /^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/
|
if m.match(/^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/)
|
||||||
part = $2.to_i
|
part = $2.to_i
|
||||||
total = $4.to_i
|
total = $4.to_i
|
||||||
linesize = $6.to_i
|
linesize = $6.to_i
|
||||||
|
|
@ -126,9 +126,9 @@ def _ydecode_file(file, outfile)
|
||||||
line = file.gets
|
line = file.gets
|
||||||
line.chop!
|
line.chop!
|
||||||
|
|
||||||
if line =~ /^=yend\s+(.*)\Z/
|
if line.match(/^=yend\s+(.*)\Z/)
|
||||||
m = $1
|
m = $1
|
||||||
m =~ /(\s*size=(\d+)\s+)(\s*part=(\d+))?(\s+crc32=(\S+))?/
|
m.match(/(\s*size=(\d+)\s+)(\s*part=(\d+))?(\s+crc32=(\S+))?/)
|
||||||
size = $2.to_i
|
size = $2.to_i
|
||||||
part = $4.to_i
|
part = $4.to_i
|
||||||
crc = $6
|
crc = $6
|
||||||
|
|
@ -149,10 +149,10 @@ def _ydecode_file(file, outfile)
|
||||||
bytes = 0
|
bytes = 0
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if search_begin && line =~ /^\=ybegin\s+(.*)\Z/
|
if search_begin && line.match(/^\=ybegin\s+(.*)\Z/)
|
||||||
m = $1
|
m = $1
|
||||||
search_begin = false
|
search_begin = false
|
||||||
if m =~ /^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/
|
if m.match(/^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/)
|
||||||
part = $2.to_i
|
part = $2.to_i
|
||||||
total = $4.to_i
|
total = $4.to_i
|
||||||
linesize = $6.to_i
|
linesize = $6.to_i
|
||||||
|
|
@ -165,7 +165,7 @@ def _ydecode_file(file, outfile)
|
||||||
if search_begin == true
|
if search_begin == true
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
if line.match(/^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/)
|
||||||
skip = false
|
skip = false
|
||||||
b = $2
|
b = $2
|
||||||
e = $4
|
e = $4
|
||||||
|
|
@ -216,10 +216,10 @@ def _ydecode_array(data)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while (i < data.length)
|
while (i < data.length)
|
||||||
if data[i] =~ /^\=ybegin\s+(.*line\=.*)/
|
if data[i].match(/^\=ybegin\s+(.*line\=.*)/)
|
||||||
m = $1
|
m = $1
|
||||||
puts "ybegin match; rest: #{m}" if Debuglevel > 0
|
puts "ybegin match; rest: #{m}" if Debuglevel > 0
|
||||||
if m =~ /^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/
|
if m.match(/^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/)
|
||||||
part = $2.to_i
|
part = $2.to_i
|
||||||
total = $4.to_i
|
total = $4.to_i
|
||||||
linesize = $6.to_i
|
linesize = $6.to_i
|
||||||
|
|
@ -247,7 +247,7 @@ def _ydecode_array(data)
|
||||||
puts "at #{i} need to go to #{data.length}" if Debuglevel > 1
|
puts "at #{i} need to go to #{data.length}" if Debuglevel > 1
|
||||||
print "line: #{line}" if Debuglevel > 0
|
print "line: #{line}" if Debuglevel > 0
|
||||||
i += 1
|
i += 1
|
||||||
if line =~ /^\=yend(\s+size=(\d+))(\s+crc32=(\S+))?/
|
if line.match(/^\=yend(\s+size=(\d+))(\s+crc32=(\S+))?/)
|
||||||
size = $2.to_i
|
size = $2.to_i
|
||||||
crc = $4
|
crc = $4
|
||||||
if size != decode.length
|
if size != decode.length
|
||||||
|
|
@ -256,7 +256,7 @@ def _ydecode_array(data)
|
||||||
dec = [ decode ]
|
dec = [ decode ]
|
||||||
return mode, filename, dec
|
return mode, filename, dec
|
||||||
end
|
end
|
||||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
if line.match(/^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/)
|
||||||
skip = false
|
skip = false
|
||||||
b = $2
|
b = $2
|
||||||
e = $4
|
e = $4
|
||||||
|
|
@ -306,7 +306,7 @@ def get_filename(data)
|
||||||
i = 0
|
i = 0
|
||||||
while i < data.length
|
while i < data.length
|
||||||
line = data[i]
|
line = data[i]
|
||||||
if line =~ /=ybegin\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/m
|
if line.match(/=ybegin\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/m)
|
||||||
return $10
|
return $10
|
||||||
end
|
end
|
||||||
i += 1
|
i += 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue