forked from danmar/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runastyle
executable file
·79 lines (71 loc) · 1.97 KB
/
runastyle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# The version check in this script is used to avoid commit battles
# 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
#
# Functions to format C/C++ source code
#
function formatCplusplus {
"$ASTYLE" --options=$RCFILE "$1"
}
function formatCplusplusRecursive {
RCFILE=.astylerc
"$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"
formatCplusplus "gui/*.cpp"
formatCplusplus "gui/*.h"
formatCplusplusRecursive "gui/test/*.cpp"
formatCplusplusRecursive "gui/test/*.h"
formatCplusplus "lib/*.cpp"
formatCplusplus "lib/*.h"
formatCplusplus "oss-fuzz/*.cpp"
formatCplusplus "oss-fuzz/*.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"
# format config files
# TODO: use other tool than xmllint? use tabs instead of spaces?
for CFGFILE in cfg/*.cfg
do
formatXML "$CFGFILE"
done
for PLATFORMFILE in platforms/*.xml
do
formatXML "$PLATFORMFILE"
done
formatXML man/cppcheck.1.xml
formatXML cppcheck-errors.rng
formatXML rules/*.xml