#!/usr/bin/ruby -w
require 'find'

lines = Array.new

Find.find(".") do |path|
  next unless File.file?(path)
  if (path =~ /.java$/) then
    file = File.new(path, "r")
    while (line = file.gets)
      line.chomp!
      if (line =~ /\t/) then
        found_problems = true
        line.gsub!("\t", '    ')
      end
      while (line =~ / $/)
        found_problems = true
        line.chop!
      end
      #puts '"' + line + '"'
      lines << line
    end
    if (found_problems) then
      file = File.new(path, "w")
      lines.each do |l|
        file.puts l
      end
    end
    lines.clear()
  end
end
exit 0

Add script to zap annoying hard-tabs
Add script to zap annoying hard-tabs

Hard tabs mess up diffs and are against our coding standard. Eclipse apparently
cannot be trusted to keep hard tabs out of files, no matter what settings you
use. Eclipse also likes to consider hard tabs as 4 spaces, whereas everyone
else in the known universe prints them as 8.

This script searches the current directory for java files. It converts all
hard tabs in these files to 4 spaces. It also zaps spaces on the end of lines,
which are also against our coding standard (and Linus').
