Skip to content

Commit

Permalink
Merge pull request #3321 from BsAtHome/fix_cppcheck_file-c-or-cxx
Browse files Browse the repository at this point in the history
Differentiate between C and C++ in cppcheck.sh when called with files from command line
  • Loading branch information
BsAtHome authored Feb 4, 2025
2 parents ae11bc0 + 360a295 commit 869c034
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions scripts/cppcheck.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

if ! command -v cppcheck; then
if ! command -v cppcheck > /dev/null; then
echo "E: Please install the program 'cppcheck' prior to executing this script."
exit 1
fi

nproc=2
if command -v nproc; then
if command -v nproc > /dev/null; then
nproc=$(nproc)
fi

Expand All @@ -31,7 +31,14 @@ cd "$(dirname "$0")/../src" || { echo "Could not change directory to '$(dirname
if [ $# -gt 0 ]; then
for f in "$@"; do
if [ -r "$f" ]; then
cppcheck -I"$(dirname "$f")" "${CPPCHKCC[@]}" "$f"
case "$f" in
*.hh|*.cc)
cppcheck -I"$(dirname "$f")" "${CPPCHKCX[@]}" "$f"
;;
*.h|*.c)
cppcheck -I"$(dirname "$f")" "${CPPCHKCC[@]}" "$f"
;;
esac
else
echo "Cannot read file '$f'"
fi
Expand Down

0 comments on commit 869c034

Please sign in to comment.