fix-logs-all 837 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. #
  3. # Usage: fix-logs-all [DIR]
  4. #
  5. # Fixes logging macros and messages in SER source files in DIR
  6. # directory (recursively).
  7. #
  8. # See doc/logging-api.txt and fix-logs script for details.
  9. #
  10. # $Id$
  11. # <filename>.ORIG backup files is created for each processed file.
  12. # If TEST is set, it only prints a "patch" file.
  13. #
  14. find ${1:-.} -type f \( -name "*.[chy]" -o -name "*.lex" -o -name "*.cc" \) | \
  15. grep -v "/dprint\.[hc]$" | \
  16. while read file; do
  17. echo "=== $file"
  18. if ! test "$TEST"; then
  19. mv "$file" "$file.ORIG"
  20. fi
  21. if expr match "$file" ".*/modules/" >/dev/null; then
  22. module=$(basename $(dirname $file))
  23. fi
  24. if ! test "$TEST"; then
  25. fix-logs "$module" < "$file.ORIG" > "$file"
  26. else
  27. fix-logs "$module" < "$file" > "$file.NEW"
  28. diff "$file.NEW" "$file"
  29. rm "$file.NEW"
  30. fi
  31. done