diff --git a/encode/yenc.rb b/encode/yenc.rb index b039b57..8424a9e 100644 --- a/encode/yenc.rb +++ b/encode/yenc.rb @@ -97,12 +97,14 @@ def _ydecode_file(file, outfile) if line.match(/^\=ybegin\s+(.*line\=.*)/) m = $1 puts " #{Thread.current.inspect} ybegin match; rest: #{m}" if Debuglevel > 0 - 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 - totalsize = $8.to_i - filename = $10 + print "full line: #{line}" if Debuglevel > 0 + if matchdata = m.match(/^\s*(part\=(?\d+)\s+)?(total\=(?\d+)\s+)?(line\=(?\d+))(\s*size\=(?\d+))(\s*name=(?.*?\S))\s*$/) or + matchdata = m.match(/^\s*(part\=(?\d+)\s+)?(total\=(?\d+)\s+)?(size\=(?\d+))(\s*line\=(?\d+))(\s*name=(?.*?\S))\s*$/) + part = matchdata[:part].to_i + total = matchdata[:total].to_i + linesize = matchdata[:linesize].to_i + totalsize = matchdata[:totalsize].to_i + filename = matchdata[:filename] if Debuglevel > 0 print "found beginning" if part != nil @@ -161,12 +163,13 @@ def _ydecode_file(file, outfile) closure = false m = $1 search_begin = false - 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 - totalsize = $8.to_i - filename = $10 + if matchdata = m.match(/^\s*(part\=(?\d+)\s+)?(total\=(?\d+)\s+)?(line\=(?\d+))(\s*size\=(?\d+))(\s*name=(?.*?\S))\s*$/) or + matchdata = m.match(/^\s*(part\=(?\d+)\s+)?(total\=(?\d+)\s+)?(size\=(?\d+))(\s*line\=(?\d+))(\s*name=(?.*?\S))\s*$/) + part = matchdata[:part].to_i + total = matchdata[:total].to_i + linesize = matchdata[:linesize].to_i + totalsize = matchdata[:totalsize].to_i + filename = matchdata[:filename] puts "found beginning of part #{part}, linesize = #{linesize}, size = #{totalsize}, filename = #{filename}" if Debuglevel > 0 end next @@ -230,13 +233,14 @@ def _ydecode_array(data) if data[i].match(/^\=ybegin\s+(.*line\=.*)/) m = $1 puts " #{Thread.current.inspect} ybegin match; rest: #{m}" if Debuglevel > 0 - 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 - size = $8.to_i - filename = $10 - puts " #{Thread.current.inspect} found beginning, linesize = #{linesize}, size = #{size}, filename = #{filename}" if Debuglevel > 0 + if matchdata = m.match(/^\s*(part\=(?\d+)\s+)?(total\=(?\d+)\s+)?(line\=(?\d+))(\s*size\=(?\d+))(\s*name=(?.*?\S))\s*$/) or + matchdata = m.match(/^\s*(part\=(?\d+)\s+)?(total\=(?\d+)\s+)?(size\=(?\d+))(\s*line\=(?\d+))(\s*name=(?.*?\S))\s*$/) + part = matchdata[:part].to_i + total = matchdata[:total].to_i + linesize = matchdata[:linesize].to_i + totalsize = matchdata[:totalsize].to_i + filename = matchdata[:filename] + puts " #{Thread.current.inspect} found beginning, linesize = #{linesize}, size = #{totalsize}, filename = #{filename}" if Debuglevel > 0 i += 1 break else @@ -317,8 +321,9 @@ def get_filename(data) i = 0 while i < data.length line = data[i] - if line.match(/=ybegin\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*?\S))\s*$/m) - return $10 + if matchdata = line.match(/=ybegin\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(?.*?\S))\s*$/m) or + matchdata = line.match(/=ybegin\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(size\=(\d+))(\s*line\=(\d+))(\s*name=(?.*?\S))\s*$/m) + return matchdata[:filename] end i += 1 end