forked from ecmwf/multio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat-sources.sh
More file actions
executable file
·24 lines (19 loc) · 888 Bytes
/
Copy pathformat-sources.sh
File metadata and controls
executable file
·24 lines (19 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# Usage: find . \( -iname "*.h" -or -iname "*.c" -or -iname "*.cc" \) -exec ./format-sources.sh {} \;
for f in $@
do
base="$(basename "$f")"
ext="${base##*.}"
if [ "${ext}" == "h" ] || [ "${ext}" == "c" ] || [ "${ext}" == "cc" ]
then
# apply clang-format file .clang-format in top dir
clang-format -i -style=file -fallback-style=none $f
# divider lines with 120 chars
perl -pi -e 's#^//-+$#//----------------------------------------------------------------------------------------------------------------------#g' $f
perl -pi -e 's#^//=+$#//----------------------------------------------------------------------------------------------------------------------#g' $f
fi
# remove trailing spaces
perl -pi -e 's# +$##g' $f
# remove trailing newlines
perl -0777 -pi -e 's/\s*\z/\n/' $f
done