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