]> granicus.if.org Git - postgresql/commitdiff
Add C++ indent tool.
authorBruce Momjian <bruce@momjian.us>
Sat, 15 Jun 2002 19:13:04 +0000 (19:13 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 15 Jun 2002 19:13:04 +0000 (19:13 +0000)
src/tools/pgindent/README
src/tools/pgindent/pgcppindent [new file with mode: 0755]

index ec8f96bb16eac314e65a366b4e439c772798e165..aae95173a8339dfd4fc60c38350ebd11fe9138a1 100644 (file)
@@ -37,3 +37,11 @@ following options:
 
        find . \( -name '*.java' -o -name '*.java.in' \) -print |
                xargs -n100 pgjindent
+---------------------------------------------------------------------------
+
+For cpp, we use astyle, http://astyle.sourceforge.net/, with the
+following options:
+
+       find src/interfaces/libpq++ -name '*.[ch]' -print |
+               xargs -n100 pgcppindent
+
diff --git a/src/tools/pgindent/pgcppindent b/src/tools/pgindent/pgcppindent
new file mode 100755 (executable)
index 0000000..ee27cf5
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+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