diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/cppcheck/cppcheck.sh | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/tools/cppcheck/cppcheck.sh b/tools/cppcheck/cppcheck.sh index d586fd4a1c..5f07e09624 100755 --- a/tools/cppcheck/cppcheck.sh +++ b/tools/cppcheck/cppcheck.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # cppcheck.sh @@ -31,18 +31,32 @@ CPPCHECK_DIR=`dirname $0` THREADS=4 QUIET="--quiet" -SUPPRESSIONS="$CPPCHECK_DIR/suppressions" -INCLUDES="$CPPCHECK_DIR/includes" +SUPPRESSIONS="--suppressions-list=$CPPCHECK_DIR/suppressions" +INCLUDES="--includes-file=$CPPCHECK_DIR/includes" +MODE="gcc" -if [ $# -gt 0 ]; then +while getopts "ahj:" OPTCHAR ; do + case $OPTCHAR in + a) SUPPRESSIONS=" " ;; + h) MODE="html" ;; + j) THREADS="$OPTARG" ;; + esac +done +shift $(($OPTIND-1)) + +if [ "$MODE" = "gcc" ]; then TEMPLATE="gcc" - TARGET=$* -else +elif [ "$MODE" = "html" ]; then echo "<html><body><table border=1>" echo "<tr><th>File</th><th>Line</th><th>Severity</th>" echo "<th>Message</th><th>ID</th></tr>" TEMPLATE="<tr><td>{file}</td><td>{line}</td><td>{severity}</td><td>{message}</td><td>{id}</td></tr>" +fi + +if [ $# -eq 0 ]; then TARGET="." +else + TARGET=$@ fi # Use a little-documented feature of the shell to pass SIGINTs only to the @@ -50,12 +64,24 @@ fi # runs and we aren't left with broken HTML. trap : INT -$CPPCHECK --force --enable=style $QUIET \ - --suppressions-list=$SUPPRESSIONS \ - --includes-file=$INCLUDES \ - --template=$TEMPLATE \ +$CPPCHECK --force --enable=style $QUIET \ + $SUPPRESSIONS $INCLUDES \ + --template=$TEMPLATE \ -j $THREADS $TARGET 2>&1 -if [ $# -eq 0 ]; then +if [ "$MODE" = "html" ]; then echo "</table></body></html>" fi + +# +# Editor modelines - http://www.wireshark.org/tools/modelines.html +# +# Local variables: +# c-basic-offset: 4 +# tab-width: 8 +# indent-tabs-mode: nil +# End: +# +# vi: set shiftwidth=4 tabstop=8 expandtab: +# :indentSize=4:tabSize=8:noTabs=true: +# |