-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyle.sh
executable file
·39 lines (33 loc) · 878 Bytes
/
style.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
#!/usr/bin/env bash
wdir=$(cd "$(dirname "$0")"; pwd)
srcdir="${1:-$wdir}"
[ -d "$srcdir" ] || exit 1
remove_eol_spaces=no
function format_source {
if ! type -path clang-format &> /dev/null; then
echo "clang-format is not installed" >&2
exit 1;
fi
if ! [ -d "$srcdir" ]; then
echo "source code directory not found at [$srcdir]" >&2
exit 1;
fi
find "$srcdir" -iname \*.c \
-o -iname \*.h |
xargs -n 1 -I@ clang-format -style=LLVM -i @
if [ "$remove_eol_spaces" = yes ]; then
find "$srcdir" -iname \*.c \
-o -iname \*.h |
xargs -n 1 -I@ sed -i 's!\s*$!!' @
fi
}
function check_malloc {
find "$srcdir" -iname \*.c \
-o -iname \*.h |
while read f; do
egrep -q -w 'malloc|realloc' "$f" &&
echo "$f not using zmalloc/xrealloc" >&2
done
}
#format_source
check_malloc