Skip to content

Commit d54ae2a

Browse files
committed
Add C++ indent tool.
1 parent 2e58024 commit d54ae2a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/tools/pgindent/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ following options:
3737

3838
find . \( -name '*.java' -o -name '*.java.in' \) -print |
3939
xargs -n100 pgjindent
40+
---------------------------------------------------------------------------
41+
42+
For cpp, we use astyle, http://astyle.sourceforge.net/, with the
43+
following options:
44+
45+
find src/interfaces/libpq++ -name '*.[ch]' -print |
46+
xargs -n100 pgcppindent
47+

src/tools/pgindent/pgcppindent

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
trap "rm -f /tmp/$$ /tmp/$$a" 0 1 2 3 15
4+
entab </dev/null >/dev/null
5+
if [ "$?" -ne 0 ]
6+
then echo "Go to the src/tools/entab directory and do a 'make' and 'make install'." >&2
7+
echo "This will put the 'entab' command in your path." >&2
8+
echo "Then run $0 again."
9+
exit 1
10+
fi
11+
astyle --version </dev/null >/dev/null 2>&1
12+
if [ "$?" -eq 0 ]
13+
then echo "You do not appear to have 'astyle' installed on your system." >&2
14+
exit 1
15+
fi
16+
17+
for FILE
18+
do
19+
astyle --style=ansi -b -p -S < "$FILE" >/tmp/$$ 2>/tmp/$$a
20+
if [ "$?" -ne 0 -o -s /tmp/$$a ]
21+
then echo "$FILE"
22+
cat /tmp/$$a
23+
fi
24+
cat /tmp/$$ |
25+
entab -t4 -qc |
26+
cat >/tmp/$$a && cat /tmp/$$a >"$FILE"
27+
done

0 commit comments

Comments
 (0)