forked from DataDog/dd-trace-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcformat.sh
executable file
·32 lines (27 loc) · 1.04 KB
/
cformat.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
#!/bin/bash
set -e
# For more modern versions:
# clang-format --style="\{BasedOnStyle: Mozilla, IndentWidth: 4, ColumnLimit: 120\}" --dry-run -Werror file.c
# would be enough…
clean ()
{
rm -f "$CFORMAT_TMP"
}
trap clean EXIT
if [[ "$1" == "update" ]]
then
THIS_PATH="$(realpath "$0")"
THIS_DIR="$(dirname $(dirname "$THIS_PATH"))"
for file in $(find "$THIS_DIR" -name '*.[c|cpp|h]' | grep -v '.riot/' | grep -v 'ddtrace/vendor/' | grep -v 'ddtrace/appsec/_iast/_taint_tracking/cmake-build-debug/' | grep -v '^ddtrace/appsec/_iast/_taint_tracking/_vendor/')
do
clang-format --style="{BasedOnStyle: Mozilla, IndentWidth: 4, ColumnLimit: 120}" -i "$file"
done
else
git ls-files '*.c' '*.cpp' '*.h' | grep -v '^ddtrace/vendor/' | grep -v '^ddtrace/appsec/_iast/_taint_tracking/_vendor/' | while read filename
do
CFORMAT_TMP=`mktemp`
clang-format --style="{BasedOnStyle: Mozilla, IndentWidth: 4, ColumnLimit: 120}" "$filename" > "$CFORMAT_TMP"
diff -u "$filename" "$CFORMAT_TMP"
rm -f "$CFORMAT_TMP"
done
fi