Skip site navigation (1) Skip section navigation (2)

WIP pgindent replacement

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: WIP pgindent replacement
Date: 2011-06-22 00:27:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Attached is a WIP possible replacement for pgindent. Instead of a shell 
script invoking a mishmash of awk and sed, some of which is pretty 
impenetrable, it uses a single engine (perl) to do all the pre and post 
indent processing. Of course, if your regex-fu and perl-fu is not up the 
scratch this too might be impenetrable, but all but a couple of the 
recipes are reduced to single lines, and I'd argue that they are all at 
least as comprehensible as what they replace.

Attached also is a diff file showing what it does differently from the 
existing script. I think that these are all things where the new script 
is more correct than the existing script. Most of the changes come into 
two categories:

    * places where the existing script fails to combine the function
      return type and the function name on a single line in function
    * places where unwanted blank lines are removed by the new script
      but not by the existing script.

Features include:

    * command line compatibility with the existing script, so you can do:
      find ../../.. -name '*.[ch]' -type f -print | egrep -v -f
      exclude_file_patterns | xargs -n100 ./ typedefs.list
    * a new way of doing the same thing much more nicely:
      ./ --search-base=../../.. --typedefs=typedefs.list
    * only passes relevant typedefs to indent, not the whole huge list
    * should in principle be runnable on Windows, unlike existing script
      (I haven't tested yet)
    * no semantic tab literals; tabs are only generated using \t and
      tested for using \t, \h or \s as appropriate. This makes debugging
      the script much less frustrating. If something looks like a space
      it should be a space.

In one case I used perl's extended regex mode to comment a fairly hairy 
regex. This should probably be done a bit more, maybe for all of them.

If anybody is so inclined, this could be used as a basis for removing 
the use of bsd indent altogether, as has been suggested before, as well 
as external entab/detab.

Comments welcome.



Description: application/x-perl (9.7 KB)
Attachment: indent.diff
Description: text/x-patch (14.8 KB)


pgsql-hackers by date

Next:From: Robert HaasDate: 2011-06-22 01:50:14
Subject: Re: [v9.2] DROP Reworks Part.0 - 'missing_ok' support of get_object_address
Previous:From: Dan McGeeDate: 2011-06-22 00:11:04
Subject: pg_upgrade version check improvements and small fixes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group