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