-
Notifications
You must be signed in to change notification settings - Fork 63
/
indent-all.sh
executable file
·46 lines (37 loc) · 939 Bytes
/
indent-all.sh
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
#!/bin/sh
# Usage: indent-all.sh [--check]
set -e
ARTISTIC_STYLE_OPTIONS=/dev/null
export ARTISTIC_STYLE_OPTIONS
tmpfile=''
cleanup() {
test "$tmpfile" != '' && rm -f "$tmpfile"
}
trap cleanup EXIT
astyle_options="--style=linux \
--indent=tab \
--unpad-paren \
--pad-oper \
--pad-header \
--lineend=linux \
--align-pointer=name \
--keep-one-line-statements \
--preserve-date \
--formatted \
--recursive \
--errors-to-stdout"
astyle_paths='lib/\*.c src/\*.c t-tap/\*.c tests/\*.c'
if ! hash astyle 2> /dev/null; then
echo "ERROR: 'astyle' is not installed on the system, cannot continue indenting..." >&2
exit 1
fi
if [ "${1:-}" = "--check" ]; then
tmpfile=$(mktemp)
astyle $astyle_options --dry-run $astyle_paths | tee "$tmpfile"
if grep -q Formatted "$tmpfile"; then
echo "ERROR: astyle regressions found. Run '$0' to fix." >&2
exit 1
fi
exit 0
fi
astyle $astyle_options --suffix=.pre-indent $astyle_paths