xref: /nrf52832-nimble/rt-thread/components/dfs/filesystems/uffs/tools/format_code.rb (revision 104654410c56c573564690304ae786df310c91fc)
1#usage:
2#	find . -name "*.c" | xargs /usr/bin/ruby path/to/format_code.rb
3#
4
5ARGV.each do |file|
6	lines = []
7	count = 0
8	File.open(file).each_line do |line|
9		if line =~ /^(.*)\s$/
10			lines << $1.dup
11			count += 1
12		else
13			lines << line
14		end
15	end
16	if count > 0
17		f = File.open(file, "w")
18		lines.each do |s|
19			f.puts s
20		end
21		f.close
22		puts "Fix file #{file}, modified lines: #{count}"
23	end
24end
25