Refactor runastyle script: introduce functions
This commit is contained in:
parent
acebfac176
commit
b92b06d900
64
runastyle
64
runastyle
|
@ -18,44 +18,54 @@ fi
|
||||||
|
|
||||||
RCFILE=.astylerc
|
RCFILE=.astylerc
|
||||||
|
|
||||||
"$ASTYLE" --options=$RCFILE cli/*.cpp
|
function formatCplusplus {
|
||||||
"$ASTYLE" --options=$RCFILE cli/*.h
|
"$ASTYLE" --options=$RCFILE "$1"
|
||||||
"$ASTYLE" --options=$RCFILE democlient/*.cpp
|
}
|
||||||
"$ASTYLE" --options=$RCFILE gui/*.cpp
|
function formatCplusplusRecursive {
|
||||||
"$ASTYLE" --options=$RCFILE gui/*.h
|
RCFILE=.astylerc
|
||||||
"$ASTYLE" --options=$RCFILE --recursive "gui/test/*.cpp"
|
"$ASTYLE" --options=$RCFILE --recursive "$1"
|
||||||
"$ASTYLE" --options=$RCFILE --recursive "gui/test/*.h"
|
}
|
||||||
"$ASTYLE" --options=$RCFILE lib/*.cpp
|
|
||||||
"$ASTYLE" --options=$RCFILE lib/*.h
|
|
||||||
"$ASTYLE" --options=$RCFILE test/*.cpp
|
|
||||||
"$ASTYLE" --options=$RCFILE test/cfg/*.c
|
|
||||||
"$ASTYLE" --options=$RCFILE test/cfg/*.cpp
|
|
||||||
"$ASTYLE" --options=$RCFILE test/*.h
|
|
||||||
|
|
||||||
"$ASTYLE" --options=$RCFILE --recursive "tools/*.cpp"
|
formatCplusplus cli/*.cpp
|
||||||
"$ASTYLE" --options=$RCFILE --recursive "tools/*.h"
|
formatCplusplus cli/*.h
|
||||||
|
formatCplusplus democlient/*.cpp
|
||||||
"$ASTYLE" --options=$RCFILE --recursive "samples/*.c"
|
formatCplusplus gui/*.cpp
|
||||||
"$ASTYLE" --options=$RCFILE --recursive "samples/*.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
|
# Convert tabs to spaces.. even in strings
|
||||||
# sed -i "s/\t/ /g" test/test*.cpp
|
# 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
|
# 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
|
||||||
xmllint --format -o "${CFGFILE}_" "$CFGFILE"
|
formatXML "$CFGFILE"
|
||||||
mv -f "${CFGFILE}_" "$CFGFILE"
|
|
||||||
done
|
done
|
||||||
for PLATFORMFILE in platforms/*.xml
|
for PLATFORMFILE in platforms/*.xml
|
||||||
do
|
do
|
||||||
xmllint --format -o "${PLATFORMFILE}_" "$PLATFORMFILE"
|
formatXML "$PLATFORMFILE"
|
||||||
mv -f "${PLATFORMFILE}_" "$PLATFORMFILE"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
xmllint --format -o man/cppcheck.1.xml_ man/cppcheck.1.xml
|
formatXML man/cppcheck.1.xml
|
||||||
mv -f man/cppcheck.1.xml_ man/cppcheck.1.xml
|
formatXML cppcheck-errors.rng
|
||||||
|
|
||||||
xmllint --format -o cppcheck-errors_.rng cppcheck-errors.rng
|
|
||||||
mv cppcheck-errors_.rng cppcheck-errors.rng
|
|
||||||
|
|
Loading…
Reference in New Issue