#!/usr/bin/ruby

require 'optparse'

LengthThreshold = 70

argparams = ARGV.getopts("i:", "nowrite")

if argparams["i"].nil?
  STDERR.print "No file is given.\n"
  exit
end

in_filename = argparams["i"]

in_file = open( in_filename, "r" )
while line = in_file.gets

  if line[0].downcase == 'c' then
    puts line
  else

#    if line.length <= LengthThreshold then
#      puts line
#    else
#      indexcomma = line.slice(0..LengthThreshold-1).rindex(",")
#      line1 = line.slice(0..indexcomma)
#      line2 = "     + " + line.slice((indexcomma+1)..(line.size-1))
#      puts line1
#      puts line2
#    end

    while line.length > LengthThreshold do
      indexcomma = line.slice(0..LengthThreshold-1).rindex(",")
      line1 = line.slice(0..indexcomma)
      puts line1
      line  = "     + " + line.slice((indexcomma+1)..(line.size-1))
    end
    puts line

  end

end
in_file.close
