chomp_uffs_perror.rb 495 B

12345678910111213141516171819202122232425
  1. #usage:
  2. # find . -name "*.c" | xargs /usr/bin/ruby path/to/chomp_uffs_perror.rb
  3. #
  4. ARGV.each do |file|
  5. lines = []
  6. count = 0
  7. File.open(file).each_line do |line|
  8. if line =~ /^(.*uffs_Perror.+)PFX(\s*".+)$/
  9. lines << ($1 + $2)
  10. count += 1
  11. #puts ($1 + $2)
  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
  24. end