-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_cppcheck
executable file
·53 lines (43 loc) · 980 Bytes
/
run_cppcheck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
fnmatch() {
case "$2" in ($1) return 0; break ;; esac
return 1
}
fnfilter() {
local m="$1"; shift
for f in $@ ; do
if fnmatch "$m" "$f" ; then
printf "%s " "$f"
fi
done
}
fnfilter_out() {
local m="$1"; shift
for f in $@ ; do
if ! fnmatch "$m" "$f" ; then
printf "%s ""$f"
fi
done
}
CPPCHECK=${CPPCHECK:-cppcheck}
while [ "x$1" != "x" ] && [ "x$1" != "x--" ] ; do
f="$1"
case "$f" in
cppcheck) f="" ;;
cppcheck-inconclusive) f="--inconclusive" ;;
cppcheck-check-config) f="--check-config" ;;
esac
CPPCHECK_FLAGS="$CPPCHECK_FLAGS $f"
shift
done
if [ "x$1" = "x--" ] ; then
shift
fi
shift # the 1st one is a compiler name
COMPILE_INCLUDES="$(fnfilter '-[IDU]*' "$@")"
COMPILE_SOURCES="$(fnfilter_out '-*' "$@")"
COMPILE_SOURCES="$(fnfilter_out '*.h' "$COMPILE_SOURCES")"
echo
echo ${CPPCHECK} ${CPPCHECK_FLAGS} ${COMPILE_INCLUDES} ${COMPILE_SOURCES}
echo
${CPPCHECK} ${CPPCHECK_FLAGS} ${COMPILE_INCLUDES} ${COMPILE_SOURCES}