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 $
|
||||
# $Source$
|
||||
|
||||
require '../uuencode.rb'
|
||||
require 'ftools'
|
||||
require 'fileutils'
|
||||
|
||||
def test1
|
||||
print "Test 1: decoding a file\n"
|
||||
|
|
@ -16,7 +16,7 @@ def test1
|
|||
print " Failed, mode should be 644, but is #{mode}\n"
|
||||
elsif filename != "testdata"
|
||||
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"
|
||||
else
|
||||
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 $
|
||||
# $Source$
|
||||
|
||||
require '../yenc.rb'
|
||||
require 'ftools'
|
||||
require 'fileutils'
|
||||
|
||||
def test1
|
||||
print "Test 1: decoding a file\n"
|
||||
|
|
@ -14,7 +14,8 @@ def test1
|
|||
mode, filename, body = YEnc.ydecode(file, tmpfile)
|
||||
if filename != "testdata"
|
||||
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"
|
||||
else
|
||||
print "Succesful\n"
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def _uudecode_file(file, outfile)
|
|||
if line =~ /^begin(.*)/
|
||||
m = $1
|
||||
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
|
||||
filename = $4
|
||||
puts "found beginning" if Debuglevel > 0
|
||||
|
|
@ -89,8 +89,8 @@ def _uudecode_file(file, outfile)
|
|||
return mode, filename if line =~ /^end/
|
||||
next if line =~ /[a-z]/
|
||||
next if line == nil
|
||||
next unless ((((line[0] - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i
|
||||
outfile.print line.unpack("u")
|
||||
next unless ((((line[0].ord - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i
|
||||
line.unpack("u").each{|x| outfile.print x}
|
||||
end
|
||||
|
||||
puts "No \"end\" found!!!"
|
||||
|
|
@ -116,7 +116,7 @@ def _uudecode_array(data)
|
|||
if data[i] =~ /^begin(.*)/
|
||||
m = $1
|
||||
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
|
||||
filename = $4
|
||||
puts "found beginning" if Debuglevel > 0
|
||||
|
|
@ -149,7 +149,7 @@ def _uudecode_array(data)
|
|||
next if line =~ /[a-z]/
|
||||
next if line == nil
|
||||
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
|
||||
return false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def _ydecode_line(line)
|
|||
end
|
||||
end
|
||||
# begin
|
||||
ostr << @@ymap[line[i].to_i]
|
||||
ostr << @@ymap[line[i].ord]
|
||||
# rescue TypeError
|
||||
# puts "this should not happen!!!"
|
||||
# puts "line[i] contents: '#{line[i]}'\n"
|
||||
|
|
@ -90,10 +90,10 @@ def _ydecode_file(file, outfile)
|
|||
while (! file.eof)
|
||||
line = file.gets
|
||||
print "line: #{line}" if Debuglevel > 0
|
||||
if line =~ /^\=ybegin\s+(.*line\=.*)/
|
||||
if line.match(/^\=ybegin\s+(.*line\=.*)/)
|
||||
m = $1
|
||||
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
|
||||
total = $4.to_i
|
||||
linesize = $6.to_i
|
||||
|
|
@ -126,9 +126,9 @@ def _ydecode_file(file, outfile)
|
|||
line = file.gets
|
||||
line.chop!
|
||||
|
||||
if line =~ /^=yend\s+(.*)\Z/
|
||||
if line.match(/^=yend\s+(.*)\Z/)
|
||||
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
|
||||
part = $4.to_i
|
||||
crc = $6
|
||||
|
|
@ -149,10 +149,10 @@ def _ydecode_file(file, outfile)
|
|||
bytes = 0
|
||||
next
|
||||
end
|
||||
if search_begin && line =~ /^\=ybegin\s+(.*)\Z/
|
||||
if search_begin && line.match(/^\=ybegin\s+(.*)\Z/)
|
||||
m = $1
|
||||
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
|
||||
total = $4.to_i
|
||||
linesize = $6.to_i
|
||||
|
|
@ -165,7 +165,7 @@ def _ydecode_file(file, outfile)
|
|||
if search_begin == true
|
||||
next
|
||||
end
|
||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
||||
if line.match(/^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/)
|
||||
skip = false
|
||||
b = $2
|
||||
e = $4
|
||||
|
|
@ -216,10 +216,10 @@ def _ydecode_array(data)
|
|||
|
||||
i = 0
|
||||
while (i < data.length)
|
||||
if data[i] =~ /^\=ybegin\s+(.*line\=.*)/
|
||||
if data[i].match(/^\=ybegin\s+(.*line\=.*)/)
|
||||
m = $1
|
||||
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
|
||||
total = $4.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
|
||||
print "line: #{line}" if Debuglevel > 0
|
||||
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
|
||||
crc = $4
|
||||
if size != decode.length
|
||||
|
|
@ -256,7 +256,7 @@ def _ydecode_array(data)
|
|||
dec = [ decode ]
|
||||
return mode, filename, dec
|
||||
end
|
||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
||||
if line.match(/^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/)
|
||||
skip = false
|
||||
b = $2
|
||||
e = $4
|
||||
|
|
@ -306,7 +306,7 @@ def get_filename(data)
|
|||
i = 0
|
||||
while i < data.length
|
||||
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
|
||||
end
|
||||
i += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue