rubyfy
This commit is contained in:
parent
2747b95b18
commit
beeeefe317
1 changed files with 19 additions and 19 deletions
|
|
@ -27,17 +27,17 @@ Debuglevel = 0
|
|||
def uudecode(data, outfile=nil)
|
||||
case data.class.to_s
|
||||
when "Array"
|
||||
print "Calling _uudecode_array\n" if Debuglevel>0
|
||||
puts "Calling _uudecode_array" if Debuglevel>0
|
||||
mode, filename, body = _uudecode_array(data)
|
||||
when "File", "Tempfile"
|
||||
unless outfile
|
||||
print "uudecode: need outfile\n"
|
||||
puts "uudecode: need outfile"
|
||||
exit
|
||||
end
|
||||
print "Calling _uudecode_file\n" if Debuglevel>0
|
||||
puts "Calling _uudecode_file" if Debuglevel>0
|
||||
mode, filename, body = _uudecode_file(data, outfile)
|
||||
else
|
||||
print "Funny stuff in uudecode. Data of class \"#{data.class.to_s}\"\n"
|
||||
puts "Funny stuff in uudecode. Data of class \"#{data.class.to_s}\""
|
||||
end
|
||||
return mode, filename, body
|
||||
end
|
||||
|
|
@ -56,30 +56,30 @@ def _uudecode_file(file, outfile)
|
|||
print "line: #{line}" if Debuglevel > 0
|
||||
if line =~ /^begin(.*)/
|
||||
m = $1
|
||||
print "beginning matched; rest: #{m}\n" if Debuglevel > 0
|
||||
puts "beginning matched; rest: #{m}" if Debuglevel > 0
|
||||
if m =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/
|
||||
mode = $2
|
||||
filename = $4
|
||||
print "found beginning\n" if Debuglevel > 0
|
||||
puts "found beginning" if Debuglevel > 0
|
||||
else
|
||||
print "mode, file set to defaults: #{m}\n"
|
||||
puts "mode, file set to defaults: #{m}"
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if file.eof
|
||||
print "Not UUencoded!\n"
|
||||
puts "Not UUencoded!"
|
||||
return false
|
||||
end
|
||||
print "c: #{c} mark: #{mark} lines: #{lines}\n" if Debuglevel > 1
|
||||
puts "c: #{c} mark: #{mark} lines: #{lines}" if Debuglevel > 1
|
||||
|
||||
while (! file.eof)
|
||||
if Debuglevel > 1
|
||||
c = file.pos
|
||||
if c > mark
|
||||
print "#{percent}%\n"
|
||||
print "c: #{c} mark: #{mark} lines: #{lines}\n" if Debuglevel > 1
|
||||
puts "#{percent}%"
|
||||
puts "c: #{c} mark: #{mark} lines: #{lines}" if Debuglevel > 1
|
||||
percent += 1
|
||||
mark = (lines/100)*(percent+1)
|
||||
end
|
||||
|
|
@ -93,7 +93,7 @@ def _uudecode_file(file, outfile)
|
|||
outfile.print line.unpack("u")
|
||||
end
|
||||
|
||||
print "No \"end\" found!!!\n"
|
||||
puts "No \"end\" found!!!"
|
||||
#return mode, file, outfile
|
||||
return false
|
||||
end
|
||||
|
|
@ -115,13 +115,13 @@ def _uudecode_array(data)
|
|||
while (i < data.length)
|
||||
if data[i] =~ /^begin(.*)/
|
||||
m = $1
|
||||
print "beginning matched; rest: #{m}\n" if Debuglevel > 0
|
||||
puts "beginning matched; rest: #{m}" if Debuglevel > 0
|
||||
if m =~ /^(\s+(\d+))?(\s+(.*?\S))?\s*\Z/
|
||||
mode = $2
|
||||
filename = $4
|
||||
print "found beginning\n" if Debuglevel > 0
|
||||
puts "found beginning" if Debuglevel > 0
|
||||
else
|
||||
print "mode, filename set to defaults: #{m}\n"
|
||||
puts "mode, filename set to defaults: #{m}"
|
||||
end
|
||||
break
|
||||
end
|
||||
|
|
@ -129,15 +129,15 @@ def _uudecode_array(data)
|
|||
end
|
||||
|
||||
unless (i < data.length)
|
||||
print "Not UUencoded!\n"
|
||||
puts "Not UUencoded!"
|
||||
return false
|
||||
end
|
||||
|
||||
while (i < data.length)
|
||||
if Debuglevel > 1
|
||||
if c > mark
|
||||
print "#{percent}%\n"
|
||||
print "c: #{c} mark: #{mark} lines: #{lines} i: #{i}\n" if Debuglevel > 1
|
||||
puts "#{percent}%"
|
||||
puts "c: #{c} mark: #{mark} lines: #{lines} i: #{i}" if Debuglevel > 1
|
||||
percent += 1
|
||||
mark = (lines/100)*(percent+1)
|
||||
end
|
||||
|
|
@ -158,7 +158,7 @@ def _uudecode_array(data)
|
|||
end
|
||||
end
|
||||
|
||||
print "No \"end\" found!!!\n"
|
||||
puts "No \"end\" found!!!"
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue