diff --git a/runastyle b/runastyle index a343bb828..218cb1ab5 100755 --- a/runastyle +++ b/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