summaryrefslogtreecommitdiff
path: root/src/tools/pgindent/pgcppindent
blob: 59ddf4baca329553ee8241cfa73178041c561c4f (plain)
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
#!/bin/sh

# src/tools/pgindent/pgcppindent

trap "rm -f /tmp/$$ /tmp/$$a" 0 1 2 3 15
entab </dev/null >/dev/null
if [ "$?" -ne 0 ]
then	echo "Go to the src/tools/entab directory and do a 'make' and 'make install'." >&2
	echo "This will put the 'entab' command in your path." >&2
	echo "Then run $0 again."
	exit 1
fi
astyle --version </dev/null >/dev/null 2>&1
if [ "$?" -eq 0 ]
then	echo "You do not appear to have 'astyle' installed on your system." >&2
	exit 1
fi

for FILE
do
	astyle --style=ansi -b -p -S < "$FILE" >/tmp/$$ 2>/tmp/$$a
	if [ "$?" -ne 0 -o -s /tmp/$$a ]
	then	echo "$FILE"
		cat /tmp/$$a
	fi
	cat /tmp/$$ |
	entab -t4 -qc |
	cat >/tmp/$$a && cat /tmp/$$a >"$FILE"
done