summaryrefslogtreecommitdiff
path: root/components/dfs/filesystems/uffs/tools/format_code.rb
blob: 7847db236abcfc4f7bb731ad7e9e4a4ed5dcbc3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#usage:
#	find . -name "*.c" | xargs /usr/bin/ruby path/to/format_code.rb
#

ARGV.each do |file|
	lines = []
	count = 0
	File.open(file).each_line do |line|
		if line =~ /^(.*)\s$/
			lines << $1.dup
			count += 1
		else
			lines << line
		end
	end
	if count > 0
		f = File.open(file, "w")
		lines.each do |s|
			f.puts s
		end
		f.close
		puts "Fix file #{file}, modified lines: #{count}"
	end
end