diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:41 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:41 -0800 |
commit | 648161bb0edfc3d43db63caed5cc5213bc6cb78f (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /WebKitTools/Scripts/clean-header-guards | |
parent | a65af38181ac7d34544586bdb5cd004de93897ad (diff) | |
download | external_webkit-648161bb0edfc3d43db63caed5cc5213bc6cb78f.zip external_webkit-648161bb0edfc3d43db63caed5cc5213bc6cb78f.tar.gz external_webkit-648161bb0edfc3d43db63caed5cc5213bc6cb78f.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'WebKitTools/Scripts/clean-header-guards')
-rwxr-xr-x | WebKitTools/Scripts/clean-header-guards | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/WebKitTools/Scripts/clean-header-guards b/WebKitTools/Scripts/clean-header-guards deleted file mode 100755 index 2bad046..0000000 --- a/WebKitTools/Scripts/clean-header-guards +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/ruby - -require 'find' -require 'optparse' - -options = {} -OptionParser.new do |opts| - opts.banner = "Usage: clean-header-guards [options]" - - opts.on("--prefix [PREFIX]", "Append a header prefix to all guards") do |prefix| - options[:prefix] = prefix - end -end.parse! - -IgnoredFilenamePatterns = [ - # ignore headers which are known not to have guard - /WebCorePrefix/, - /ForwardingHeaders/, - %r|bindings/objc|, - /vcproj/, # anything inside a vcproj is in the windows wasteland - - # we don't own any of these headers - %r|icu/unicode|, - %r|platform/graphics/cairo|, - %r|platform/image-decoders|, - - /config.h/ # changing this one sounds scary -].freeze - -IgnoreFileNamesPattern = Regexp.union(*IgnoredFilenamePatterns).freeze - -Find::find(".") do |filename| - next unless filename =~ /\.h$/ - next if filename.match(IgnoreFileNamesPattern) - - File.open(filename, "r+") do |file| - contents = file.read - match_results = contents.match(/#ifndef (\S+)\n#define \1/s) - if match_results - current_guard = match_results[1] - new_guard = File.basename(filename).sub('.', '_') - new_guard = options[:prefix] + '_' + new_guard if options[:prefix] - contents.gsub!(/#{current_guard}\b/, new_guard) - else - puts "Ignoring #{filename}, failed to find existing header guards." - end - tmp_filename = filename + ".tmp" - File.open(tmp_filename, "w+") do |new_file| - new_file.write(contents) - end - File.rename tmp_filename, filename - end -end |