pgindent cleanup - Mailing list pgsql-hackers

From Andrew Dunstan
Subject pgindent cleanup
Date
Msg-id 4BB76350.6090404@dunslane.net
Whole thread Raw
Responses Re: pgindent cleanup  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Following up Tom's complaint about behaviour of pgindent, I have been
wrestling with it a bit. I noticed several things.

First awk on my box spits out fairly useless warnings about regular
expressions containing a literal '\*'. These warnings are silenced by
replacing those with '[*]', which should have the same effect.

Second, the script issues warnings about how somebody hopes that I
installed indent.bsd.patch. Yes I did, and the messages are just
annoying noise, so I propose to get rid of them. The usual rule of unix
utilities is to be silent on success, and I think we should follow it.

Third, as mentioned in that other thread I think we  should put the
exclusion of certain typedef symbols into the pgindent script.

The attached patch does all three of these things.

I'm not done yet - I am seeing issues with at least two files:
contrib/fuzzystrmatch/dmetaphone.c and
src/backend/tsearch/wparser_def.c, that I need to chase down.

Ideally, this hodegpodge of awk and sed pipes would be replaced by a
perl script that would do all that inline much more efficiently, along
with some more features. But that's a longer term project.

cheers

andrew
*** src/tools/pgindent/pgindent    2009-06-15 18:09:49.000000000 -0400
--- /usr/local/bin/pgindent    2010-04-03 11:46:29.000000000 -0400
***************
*** 39,45 ****
  then    echo "You appear to have GNU indent rather than BSD indent." >&2
      echo "See the pgindent/README file for a description of its problems." >&2
      EXTRA_OPTS="-cdb -bli0 -npcs -cli4 -sc"
! else    echo "Hope you installed /src/tools/pgindent/indent.bsd.patch." >&2
      EXTRA_OPTS="-cli1"
  fi

--- 39,45 ----
  then    echo "You appear to have GNU indent rather than BSD indent." >&2
      echo "See the pgindent/README file for a description of its problems." >&2
      EXTRA_OPTS="-cdb -bli0 -npcs -cli4 -sc"
! else
      EXTRA_OPTS="-cli1"
  fi

***************
*** 138,144 ****
  # 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 \
!         `cat "$TYPEDEFS" | sed -e '/^$/d' -e 's/.*/-T& /'` \
          /tmp/$$a >/tmp/$$ 2>&1

      if [ "$?" -ne 0 -o -s /tmp/$$ ]
--- 138,144 ----
  # 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/$$ ]
***************
*** 226,232 ****
                  skips--;
              if (line1 ~ /    *{$/ &&
                  line2 ~ /^$/ &&
!                 line3 ~ /        *\/\*$/)
              {
                  print line1;
                  print line3;
--- 226,232 ----
                  skips--;
              if (line1 ~ /    *{$/ &&
                  line2 ~ /^$/ &&
!                 line3 ~ /        *\/[*]$/)
              {
                  print line1;
                  print line3;
***************
*** 252,258 ****
          {
              if (NR != 1)
              {
!                 if ($0 ~ "/\* _PGMV")
                  {
                      # remove tag
                      sub(" _PGMV", "", $0);
--- 252,258 ----
          {
              if (NR != 1)
              {
!                 if ($0 ~ "/[*] _PGMV")
                  {
                      # remove tag
                      sub(" _PGMV", "", $0);

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Proposal: Add JSON support
Next
From: Boszormenyi Zoltan
Date:
Subject: ECPG doesn't delete its output file in case of an error