On 04/17/2011 09:51 AM, Andrew Dunstan wrote:


On 04/17/2011 04:26 AM, Andrew Dunstan wrote:


Now we could certainly make this quite a bit slicker. Apart from anything else, we should change the indent source code tarball so it unpacks into its own directory. Having it unpack into the current directory is ugly and unfriendly. And we should get rid of the "make clean" line in the install target of entab's makefile, which just seems totally ill-conceived.

It might also be worth setting it up so that instead of having to pass a path to a typedefs file on the command line, we default to a file sitting in, say, /usr/local/etc. Then you'd just be able to say "pgindent my_file.c".



OK, I have most of these bits.

A new tarball of indent is available at
<http://developer.postgresql.org/~andrew/indent.netbsd.patched.tgz> and if everyone agrees I'll push it out to the mirrors.

Attached are two patches, one to remove some infelicity in the entab makefile, and the other to allow skipping specifying the typedefs file location either by setting it in an environment variable or by putting it in a hard coded location.



... and this one has a typo fixed.

cheers

andrew


diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index 05f69ef..02f2b93 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -13,13 +13,32 @@
 #
 #	void x(struct xxc * a);
 
-if [ "$#" -lt 2 ]
-then	echo "Usage:  $(basename $0) typedefs file [...]" 1>&2
-	exit 1
+# look for typedefs in the first argument, if there is a second argument and
+# the first argument contains the string 'typedef' in its name, or in the
+# environment setting PGTYPEDEFS, or in a hardcoded location, whichever
+# matches first.
+
+
+if [ $# -gt 1 ]
+then
+	case `basename $0` in
+		*typedef*) 
+			TYPDEFS=$1
+			shift
+			;;
+		*)
+			;;
+	esac
 fi
 
-TYPEDEFS="$1"
-shift
+test -z "$TYPEDEFS" && TYPEDEFS=$PGTYPEDEFS
+test -z "$TYPEDEFS" && TYPEDEFS=/usr/local/etc/pgtypedefs.list
+
+if [ ! -f "$TYPEDEFS" ]
+then
+	echo "Cannot find typedefs file '$TYPEDEFS'"
+	exit 1
+fi 
 
 if [ -z "$INDENT" ]
 then
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to