blob: 2c9371fbc5bd75dbf4ada6a44eb572cac05b214a (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/sh
#
# This can format all PostgreSQL *.c and *.h files,
# excluding libpq++, *.y, and *.l files.
#
# On 09/06/1997, from the top directory, I ran:
#
# find . -name '*.[ch]' -type f -print | grep -v '++' | xargs -n100 PGINDENT
#
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
indent -st </dev/null >/dev/null
if [ "$?" -ne 0 ]
then echo "You do not appear to have 'indent' installed on your system." >&2
exit 1
fi
for FILE
do
cat $FILE |
sed 's;/\* *---;/*---X_X;g' |
sed 's;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
\2;g' | # workaround for indent bug
detab -t4 -qc |
sed 's;^DATA(.*$;/*&*/;' >/tmp/$$a # protect backslashes in DATA()
indent -bad -bap -bbb -bc -bl -d0 -cdb -cli1 -nce -nfc1 -di12 -i4 -l75 \
-lp -nip -npro /tmp/$$a >/tmp/$$ 2>&1
if [ "$?" -ne 0 -o -s /tmp/$$ ]
then echo "$FILE"
cat /tmp/$$
fi
cat /tmp/$$a |
sed 's;^/\*\(DATA(.*\)\*/$;\1;' |
sed 's;/\*---X_X;/* ---;g' |
sed 's;^static[ ][ ]*;static ;g' | # workaround indent bug
detab -t8 -qc |
entab -t4 -qc >/tmp/$$ && cat /tmp/$$ >$FILE
done
# The 'for' loop makes these backup files useless
# so delete them
rm -f *a.BAK
|