This commit is contained in:
amai2012 2019-02-07 19:57:01 +01:00
parent 5e7f491bd4
commit ad9d580e5f
1 changed files with 14 additions and 14 deletions

View File

@ -11,19 +11,19 @@ ASTYLE="${ASTYLE-astyle}"
DETECTED_VERSION=$("$ASTYLE" --version 2>&1 | awk '{ print $NF; }') DETECTED_VERSION=$("$ASTYLE" --version 2>&1 | awk '{ print $NF; }')
if [ "$DETECTED_VERSION" != "${ASTYLE_VERSION}" ]; then if [ "$DETECTED_VERSION" != "${ASTYLE_VERSION}" ]; then
echo "You should use version: ${ASTYLE_VERSION}" echo "You should use version: ${ASTYLE_VERSION}"
echo "Detected version: ${DETECTED_VERSION}" echo "Detected version: ${DETECTED_VERSION}"
exit 1 exit 1
fi fi
RCFILE=.astylerc RCFILE=.astylerc
function formatCplusplus { function formatCplusplus {
"$ASTYLE" --options=$RCFILE "$1" "$ASTYLE" --options=$RCFILE "$1"
} }
function formatCplusplusRecursive { function formatCplusplusRecursive {
RCFILE=.astylerc RCFILE=.astylerc
"$ASTYLE" --options=$RCFILE --recursive "$1" "$ASTYLE" --options=$RCFILE --recursive "$1"
} }
formatCplusplus "cli/*.cpp" formatCplusplus "cli/*.cpp"
@ -48,23 +48,23 @@ formatCplusplusRecursive "samples/*.cpp"
# sed -i "s/\t/ /g" test/test*.cpp # sed -i "s/\t/ /g" test/test*.cpp
function formatXML { function formatXML {
xmllint --format -o "$1_" "$1" xmllint --format -o "$1_" "$1"
if cmp -s "$1_" "$1"; then if cmp -s "$1_" "$1"; then
rm -f "$1_" rm -f "$1_"
else else
mv -f "$1_" "$1" mv -f "$1_" "$1"
fi fi
} }
# format config files # format config files
# TODO: use other tool than xmllint? use tabs instead of spaces? # TODO: use other tool than xmllint? use tabs instead of spaces?
for CFGFILE in cfg/*.cfg for CFGFILE in cfg/*.cfg
do do
formatXML "$CFGFILE" formatXML "$CFGFILE"
done done
for PLATFORMFILE in platforms/*.xml for PLATFORMFILE in platforms/*.xml
do do
formatXML "$PLATFORMFILE" formatXML "$PLATFORMFILE"
done done
formatXML man/cppcheck.1.xml formatXML man/cppcheck.1.xml