Refactor script, make it more verbose about XML formatting
This commit is contained in:
parent
ad9d580e5f
commit
3d968b08da
29
runastyle
29
runastyle
|
@ -18,6 +18,9 @@ fi
|
|||
|
||||
RCFILE=.astylerc
|
||||
|
||||
#
|
||||
# Functions to format C/C++ source code
|
||||
#
|
||||
function formatCplusplus {
|
||||
"$ASTYLE" --options=$RCFILE "$1"
|
||||
}
|
||||
|
@ -26,6 +29,20 @@ function formatCplusplusRecursive {
|
|||
"$ASTYLE" --options=$RCFILE --recursive "$1"
|
||||
}
|
||||
|
||||
#
|
||||
# Function to format XML files
|
||||
#
|
||||
function formatXML {
|
||||
xmllint --format -o "$1_" "$1"
|
||||
if cmp -s "$1_" "$1"; then
|
||||
rm -f "$1_"
|
||||
echo Unchanged $1
|
||||
else
|
||||
mv -f "$1_" "$1"
|
||||
echo Formatted $1
|
||||
fi
|
||||
}
|
||||
|
||||
formatCplusplus "cli/*.cpp"
|
||||
formatCplusplus "cli/*.h"
|
||||
formatCplusplus "democlient/*.cpp"
|
||||
|
@ -44,18 +61,6 @@ 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?
|
||||
for CFGFILE in cfg/*.cfg
|
||||
|
|
Loading…
Reference in New Issue