File indexing completed on 2024-04-21 04:47:54
0001 #!/usr/bin/ruby 0002 ########################################################################### 0003 # This script puts a DEBUG_BLOCK in every method of a given C++ file. # 0004 # Use with caution. # 0005 # # 0006 # Copyright # 0007 # (C) 2008 Casey Link <unnamedrambler@gmail.com> # 0008 # # 0009 # This program is free software; you can redistribute it and/or modify # 0010 # it under the terms of the GNU General Public License as published by # 0011 # the Free Software Foundation; either version 2 of the License, or # 0012 # (at your option) any later version. # 0013 # # 0014 # This program is distributed in the hope that it will be useful, # 0015 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 0016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 0017 # GNU General Public License for more details. # 0018 # # 0019 # You should have received a copy of the GNU General Public License # 0020 # along with this program; if not, write to the # 0021 # Free Software Foundation, Inc., # 0022 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # 0023 ########################################################################### 0024 0025 if ARGV.size < 1 0026 print "USAGE: #{__FILE__} <filename> \n" 0027 exit 0028 end 0029 0030 regex = Regexp.new(/^.+::(.+)\(.*\)\s*(?:const)*\s*(?::\s*(?:\s*.+\(.*\))*)*\s*\{\s*(?:DEBUG_BLOCK)*/) 0031 f = File.new(ARGV[0]) 0032 string = f.read 0033 news = string.gsub(regex){ |s| 0034 if not s.include? "DEBUG_BLOCK" 0035 "#{$&}\n\tDEBUG_BLOCK\n" 0036 else 0037 $& 0038 end 0039 } 0040 print news 0041