cppcheck/runastyle

72 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# The version check in this script is used to avoid commit battles
2011-06-22 13:20:36 +02:00
# between different developers that use different astyle versions as
# different versions might have different output (this has happened in
# the past).
# If project management wishes to take a newer astyle version into use
# just change this string to match the start of astyle version string.
ASTYLE_VERSION="3.0.1"
ASTYLE="${ASTYLE-astyle}"
DETECTED_VERSION=$("$ASTYLE" --version 2>&1 | awk '{ print $NF; }')
if [ "$DETECTED_VERSION" != "${ASTYLE_VERSION}" ]; then
echo "You should use version: ${ASTYLE_VERSION}"
echo "Detected version: ${DETECTED_VERSION}"
exit 1
fi
RCFILE=.astylerc
function formatCplusplus {
"$ASTYLE" --options=$RCFILE "$1"
}
function formatCplusplusRecursive {
RCFILE=.astylerc
"$ASTYLE" --options=$RCFILE --recursive "$1"
}
formatCplusplus "cli/*.cpp"
formatCplusplus "cli/*.h"
formatCplusplus "democlient/*.cpp"
formatCplusplus "gui/*.cpp"
formatCplusplus "gui/*.h"
formatCplusplusRecursive "gui/test/*.cpp"
formatCplusplusRecursive "gui/test/*.h"
formatCplusplus "lib/*.cpp"
formatCplusplus "lib/*.h"
formatCplusplus "test/*.cpp"
formatCplusplus "test/cfg/*.c"
formatCplusplus "test/cfg/*.cpp"
formatCplusplus "test/*.h"
formatCplusplus "tools/*.cpp"
formatCplusplusRecursive "tools/*.h"
formatCplusplusRecursive "samples/*.c"
formatCplusplusRecursive "samples/*.cpp"
# Convert tabs to spaces.. even in strings
# sed -i "s/\t/ /g" test/test*.cpp
function formatXML {
xmllint --format -o "$1_" "$1"
if cmp -s "$1_" "$1"; then
rm -f "$1_"
else
mv -f "$1_" "$1"
fi
}
# format config files
# TODO: use other tool than xmllint? use tabs instead of spaces?
2014-10-16 06:38:18 +02:00
for CFGFILE in cfg/*.cfg
do
formatXML "$CFGFILE"
2014-10-16 06:38:18 +02:00
done
2018-02-16 09:08:38 +01:00
for PLATFORMFILE in platforms/*.xml
do
formatXML "$PLATFORMFILE"
2018-02-16 09:08:38 +01:00
done
formatXML man/cppcheck.1.xml
formatXML cppcheck-errors.rng