-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathformat.sh
More file actions
37 lines (25 loc) · 833 Bytes
/
format.sh
File metadata and controls
37 lines (25 loc) · 833 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
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# echo "#lang format" > tmp.rkt
# cat $1 >> tmp.rkt
echo "Running formatter on $1"
# racket /Users/seba/cp/format/format/run-direct.rkt $1 > formatted.h
# /Users/seba/cp/format/run-direct $1 > formatted.h
formatter="racket /Users/seba/cp/format/format/run-direct.rkt"
if [ -f ./run-formatter ]; then
formatter="./run-formatter"
fi
$formatter $1 > formatted.h
if [[ $? -ne 0 ]]; then
echo "Running formatter on $1 failed!"
exit
fi
g++-13 -E -dD -P -fpreprocessed $1 2> /dev/null | tr -d '[:space:]' > orig.txt
g++-13 -E -dD -P -fpreprocessed formatted.h 2> /dev/null | tr -d '[:space:]' > preproc.txt
diff -w orig.txt preproc.txt
if [[ $? -ne 0 ]]; then
echo "Formatting changed diff for $1!"
exit
fi
cp formatted.h $1
rm formatted.h orig.txt preproc.txt
echo "Successfully formatted $1!"