try_parse.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # Echo the name of every argument of this script that is not "perfect"
  3. # according to coccinelle's --parse-c.
  4. #
  5. # If $TOR_COCCI_EXCEPTIONS_FILE is non-empty, skip any files that match the
  6. # patterns in the exception file, according to "grep -f"
  7. #
  8. # If VERBOSE is non-empty, log spatch errors and skipped files.
  9. top="$(dirname "$0")/../.."
  10. exitcode=0
  11. for fn in "$@"; do
  12. if test "${TOR_COCCI_EXCEPTIONS_FILE}" ; then
  13. skip_fn=$(echo "$fn" | grep -f "${TOR_COCCI_EXCEPTIONS_FILE}")
  14. if test "${skip_fn}" ; then
  15. if test "${VERBOSE}" != ""; then
  16. echo "Skipping '${skip_fn}'"
  17. fi
  18. continue
  19. fi
  20. fi
  21. if spatch --macro-file-builtins \
  22. "$top"/scripts/coccinelle/tor-coccinelle.h \
  23. --defined COCCI \
  24. --parse-c "$fn" \
  25. 2>/dev/null | grep "perfect = 1" > /dev/null; then
  26. : # it's perfect
  27. else
  28. echo "$fn"
  29. if test "${VERBOSE}" != ""; then
  30. spatch --macro-file-builtins \
  31. "$top"/scripts/coccinelle/tor-coccinelle.h \
  32. --defined COCCI \
  33. --parse-c "$fn"
  34. fi
  35. exitcode=1
  36. fi
  37. done
  38. exit "$exitcode"