Debug Blockify a whole file

Casey Link unnamedrambler at gmail.com
Sat Jul 12 06:09:39 CEST 2008


Use with caution.

#!/usr/bin/ruby

# DebugBlockify.rb

if ARGV.size < 1

  print "USAGE: #{__FILE__} <filename> \n"

  exit

end



regex = Regexp.new(/^.+::(.+)\(.*\)\s*(?:const)*\s*(?::\s*(?:\s*.+\(.*\))*)*\s*\{\s*(?:DEBUG_BLOCK)*/)

f = File.new(ARGV[0])

string = f.read

f.close()
fixed = string.gsub(regex){ |s|

  if not s.include? "DEBUG_BLOCK"

    "#{$&}\n\tDEBUG_BLOCK\n"

  else

    $&

  end

}

print fixed


More information about the Amarok-devel mailing list