Alvaro Herrera wrote:
> Excerpts from Tom Lane's message of lun abr 25 20:48:42 -0300 2011:
> > Andrew Dunstan <and...@dunslane.net> writes:
> 
> > > Well, that way you'll have a handful of -Ttypdef parameters for each 
> > > invocation of indent instead of a gazillion of them. No more command 
> > > line length issues.
> > 
> > Well, -Ttypedef is wrong on its face.  Right would be a switch
> > specifying the name of the file to read the typedef list from.
> > Then you don't need massive script-level infrastructure to try
> > to spoonfeed that data to the program doing the work.
> 
> I gather that Andrew will be working on replacing the pgindent shell
> script with a Perl script, but this new script will still rely on our
> patched BSD indent, right?
> 
> Of course, it would make sense to further patch indent so that it
> accepts typedefs in a file instead of thousands of -T switches, but that
> seems orthogonal.

I have done as you suggested, modifying our version of BSD indent to
allow a file of typedefs to be processed.  I also renamed the download
and binary to 'pg_bsd_indent' so it can be installed on a system that
already has 'indent'.  It should propogate to the ftp mirrors in a few
hours.  Even after we go to Perl, this is still a necessary change.

I have modified the pgindent script to use this new flag, and applied
those changes, attached.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/src/tools/pgindent/README b/src/tools/pgindent/README
new file mode 100644
index e81e85d..7504650
*** a/src/tools/pgindent/README
--- b/src/tools/pgindent/README
*************** pgindent
*** 6,31 ****
  This can format all PostgreSQL *.c and *.h files, but excludes *.y, and
  *.l files.
  
! 1) Change directory to the top of the build tree.
  
! 2) Download the typedef file from the buildfarm:
  
  	wget -O src/tools/pgindent/typedefs.list http://buildfarm.postgresql.org/cgi-bin/typedefs.pl
  
! 3) Remove all derived files (pgindent has trouble with one of the flex macros):
  
  	gmake maintainer-clean
  
! 4) Run pgindent:
  
  	find . -name '*.[ch]' -type f -print | \
  	egrep -v -f src/tools/pgindent/exclude_file_patterns | \
  	xargs -n100 pgindent src/tools/pgindent/typedefs.list
  
! 5) Remove any files that generate errors and restore their original
     versions.
  
! 6) Do a full test build:
  
  	run configure
  	# stop is only necessary if it's going to install in a location with an
--- 6,33 ----
  This can format all PostgreSQL *.c and *.h files, but excludes *.y, and
  *.l files.
  
! 1) Install pg_bsd_indent (see below for details)
  
! 2) Change directory to the top of the build tree.
! 
! 3) Download the typedef file from the buildfarm:
  
  	wget -O src/tools/pgindent/typedefs.list http://buildfarm.postgresql.org/cgi-bin/typedefs.pl
  
! 4) Remove all derived files (pgindent has trouble with one of the flex macros):
  
  	gmake maintainer-clean
  
! 5) Run pgindent:
  
  	find . -name '*.[ch]' -type f -print | \
  	egrep -v -f src/tools/pgindent/exclude_file_patterns | \
  	xargs -n100 pgindent src/tools/pgindent/typedefs.list
  
! 6) Remove any files that generate errors and restore their original
     versions.
  
! 7) Do a full test build:
  
  	run configure
  	# stop is only necessary if it's going to install in a location with an
*************** This can format all PostgreSQL *.c and *
*** 38,54 ****
  
  ---------------------------------------------------------------------------
  
! We have standardized on NetBSD's indent.  We have fixed a few bugs which
! requre the NetBSD source to be patched with indent.bsd.patch patch.  A
! fully patched version is available at ftp://ftp.postgresql.org/pub/dev.
  
  GNU indent, version 2.2.6, has several problems, and is not recommended.
  These bugs become pretty major when you are doing >500k lines of code.
  If you don't believe me, take a directory and make a copy.  Run pgindent
  on the copy using GNU indent, and do a diff -r. You will see what I
! mean. GNU indent does some things better, but mangles too.
  
! Notes about excluded files:
  
  src/include/storage/s_lock.h is excluded because it contains assembly code
  that pgindent tends to mess up.
--- 40,67 ----
  
  ---------------------------------------------------------------------------
  
! BSD indent
! ----------
! 
! We have standardized on NetBSD's indent, and renamed it pg_bsd_indent. 
! We have fixed a few bugs which requre the NetBSD source to be patched
! with indent.bsd.patch patch.  A fully patched version is available at
! ftp://ftp.postgresql.org/pub/dev.
  
  GNU indent, version 2.2.6, has several problems, and is not recommended.
  These bugs become pretty major when you are doing >500k lines of code.
  If you don't believe me, take a directory and make a copy.  Run pgindent
  on the copy using GNU indent, and do a diff -r. You will see what I
! mean. GNU indent does some things better, but mangles too.  For details,
! see:
  
! 	http://archives.postgresql.org/pgsql-hackers/2003-10/msg00374.php
! 	http://archives.postgresql.org/pgsql-hackers/2011-04/msg01436.php
! 
! ---------------------------------------------------------------------------
! 
! Notes about excluded files
! --------------------------
  
  src/include/storage/s_lock.h is excluded because it contains assembly code
  that pgindent tends to mess up.
*************** should not be changed.
*** 63,70 ****
  
  ---------------------------------------------------------------------------
  
! Obsolete typedef list creation instructions:
! --------------------------------------------
  
  To use pgindent:
  
--- 76,83 ----
  
  ---------------------------------------------------------------------------
  
! Obsolete typedef list creation instructions
! -------------------------------------------
  
  To use pgindent:
  
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
new file mode 100755
index 05f69ef..eeb6f5d
*** a/src/tools/pgindent/pgindent
--- b/src/tools/pgindent/pgindent
*************** fi
*** 21,32 ****
  TYPEDEFS="$1"
  shift
  
! if [ -z "$INDENT" ]
! then
! 	INDENT=indent
! fi
  
  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
--- 21,32 ----
  TYPEDEFS="$1"
  shift
  
! [ -z "$INDENT" ] && INDENT=pg_bsd_indent
  
  trap "rm -f /tmp/$$ /tmp/$$a" 0 1 2 3 15
+ 
+ # check the environment
+ 
  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
*************** then	echo "Go to the src/tools/entab dir
*** 36,42 ****
  fi
  $INDENT -? </dev/null >/dev/null 2>&1
  if [ "$?" -ne 1 ]
! then	echo "You do not appear to have 'indent' installed on your system." >&2
  	exit 1
  fi
  $INDENT -gnu </dev/null >/dev/null 2>&1
--- 36,46 ----
  fi
  $INDENT -? </dev/null >/dev/null 2>&1
  if [ "$?" -ne 1 ]
! then	echo "You do not appear to have '$INDENT' installed on your system." >&2
! 	exit 1
! fi
! if [ "`$INDENT -V`" != "$INDENT 1.0" ]
! then	echo "You do not appear to have $INDENT version 1.0 installed on your system." >&2
  	exit 1
  fi
  $INDENT -gnu </dev/null >/dev/null 2>&1
*************** do
*** 140,149 ****
  # Protect wrapping in CATALOG().
  	sed 's;^CATALOG(.*$;/*&*/;' >/tmp/$$a
  
  # We get the list of typedef's from /src/tools/find_typedef
  	$INDENT -bad -bap -bc -bl -d0 -cdb -nce -nfc1 -di12 -i4 -l79 \
! 		-lp -nip -npro -bbb $EXTRA_OPTS \
! 		`egrep -v '^(FD_SET|date|interval|timestamp|ANY)$' "$TYPEDEFS" | sed -e '/^$/d' -e 's/.*/-T& /'` \
  		/tmp/$$a >/tmp/$$ 2>&1
  
  	if [ "$?" -ne 0 -o -s /tmp/$$ ]
--- 144,154 ----
  # Protect wrapping in CATALOG().
  	sed 's;^CATALOG(.*$;/*&*/;' >/tmp/$$a
  
+ 	egrep -v '^(FD_SET|date|interval|timestamp|ANY)$' "$TYPEDEFS" | sed -e '/^$/d' > /tmp/$$b
+ 
  # We get the list of typedef's from /src/tools/find_typedef
  	$INDENT -bad -bap -bc -bl -d0 -cdb -nce -nfc1 -di12 -i4 -l79 \
! 		-lp -nip -npro -bbb $EXTRA_OPTS -U/tmp/$$b \
  		/tmp/$$a >/tmp/$$ 2>&1
  
  	if [ "$?" -ne 0 -o -s /tmp/$$ ]
-- 
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