Thread: pgsql: Replace pgindent shell script with Perl script. Update perltidy

pgsql: Replace pgindent shell script with Perl script. Update perltidy

From
Bruce Momjian
Date:
Replace pgindent shell script with Perl script.  Update perltidy
instructions to perltidy Perl files that lack Perl file extensions.

pgindent Perl coding by Andrew Dunstan, restructured by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/149ac7d45595f64f7b60833de7f146bc9a599656

Modified Files
--------------
src/tools/pgindent/README       |   15 +-
src/tools/pgindent/pgindent     |  902 +++++++++++++++++++++++----------------
src/tools/pgindent/pgindent.man |   45 ++
3 files changed, 583 insertions(+), 379 deletions(-)


Bruce Momjian <bruce@momjian.us> writes:
> Replace pgindent shell script with Perl script.  Update perltidy
> instructions to perltidy Perl files that lack Perl file extensions.

This version of pgindent is just about completely broken, so far as my
possibly-a-bit-hoary Perl (5.8.7) is concerned.  I think it could be
made more portable without too much effort, but I am wondering what the
heck "\h" is supposed to mean in a regex?

$ pgindent
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 190.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 195.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 206.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 206.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 206.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 212.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 212.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 212.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 228.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 236.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 236.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 247.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 247.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 247.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 247.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 248.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 248.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 269.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 272.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 272.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 272.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 278.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 283.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 294.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 294.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 294.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 297.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 306.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 306.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 318.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 321.
Unrecognized escape \h passed through at src/tools/pgindent/pgindent line 324.
Useless use of a constant in void context at src/tools/pgindent/pgindent line 14.
Use of uninitialized value in concatenation (.) or string at src/tools/pgindent/pgindent line 61.
sh: Syntax error at line 1 : `end of file' is not expected.
Go to the src/tools/entab directory and do 'make' and 'make install'.
This will put the 'entab' command in your path.
Then run src/tools/pgindent/pgindent again.

            regards, tom lane

I wrote:
> This version of pgindent is just about completely broken, so far as my
> possibly-a-bit-hoary Perl (5.8.7) is concerned.  I think it could be
> made more portable without too much effort, but I am wondering what the
> heck "\h" is supposed to mean in a regex?

After a bit of research I found that \h is a relatively recent
abbreviation for "[ \t]".  After making that substitution, and getting
rid of the rather gratuitous use of module Readonly, the script seems
to work OK in a stock Perl 5.8.7 installation.

I'm not sure if we have any project policy for minimum required Perl
version, but I've not found that any of our other Perl scripts don't
work with 5.8.  Should I commit these changes, or are you going to
tell me I need a newer Perl?  And if the latter, what is our minimum
supported version going to be?

            regards, tom lane

Re: pgsql: Replace pgindent shell script with Perl script. Update perltidy

From
Andrew Dunstan
Date:
On 08/04/2012 03:40 PM, Tom Lane wrote:
> I wrote:
>> This version of pgindent is just about completely broken, so far as my
>> possibly-a-bit-hoary Perl (5.8.7) is concerned.  I think it could be
>> made more portable without too much effort, but I am wondering what the
>> heck "\h" is supposed to mean in a regex?
> After a bit of research I found that \h is a relatively recent
> abbreviation for "[ \t]".  After making that substitution, and getting
> rid of the rather gratuitous use of module Readonly, the script seems
> to work OK in a stock Perl 5.8.7 installation.
>
> I'm not sure if we have any project policy for minimum required Perl
> version, but I've not found that any of our other Perl scripts don't
> work with 5.8.  Should I commit these changes, or are you going to
> tell me I need a newer Perl?  And if the latter, what is our minimum
> supported version going to be?
>
>


Well, It's at least in 5.10.1 which dates from 3 years ago. I suspect
it's probably in 5.10.0 which dates from about 5 years ago. I guess this
is the danger of developing on modern systems :-) How old is the
compiler you use for everyday work?

If we keep it we should add a "require 5.10.1;" to the script.

But I don't have a great objection to replacing "\h" with "[ \t]" if
that's the preferred fix.


cheers

andrew




Andrew Dunstan <andrew@dunslane.net> writes:
> On 08/04/2012 03:40 PM, Tom Lane wrote:
>> I'm not sure if we have any project policy for minimum required Perl
>> version, but I've not found that any of our other Perl scripts don't
>> work with 5.8.

> Well, It's at least in 5.10.1 which dates from 3 years ago. I suspect
> it's probably in 5.10.0 which dates from about 5 years ago. I guess this
> is the danger of developing on modern systems :-) How old is the
> compiler you use for everyday work?

I intentionally use oldest-supported-versions of tools on my HPPA box,
to keep us honest on that front.  It's running gcc 2.95.3, since you
asked, but that's not too relevant to the immediate question: what do
we consider our oldest supported version of Perl?  If we decide it's
not 5.8, I'll reinstall that ... but allowing \h seems a pretty lame
excuse for ratcheting up a whole major release series.

            regards, tom lane

Re: pgsql: Replace pgindent shell script with Perl script. Update perltidy

From
Andrew Dunstan
Date:
On 08/04/2012 05:55 PM, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>> On 08/04/2012 03:40 PM, Tom Lane wrote:
>>> I'm not sure if we have any project policy for minimum required Perl
>>> version, but I've not found that any of our other Perl scripts don't
>>> work with 5.8.
>> Well, It's at least in 5.10.1 which dates from 3 years ago. I suspect
>> it's probably in 5.10.0 which dates from about 5 years ago. I guess this
>> is the danger of developing on modern systems :-) How old is the
>> compiler you use for everyday work?
> I intentionally use oldest-supported-versions of tools on my HPPA box,
> to keep us honest on that front.  It's running gcc 2.95.3, since you
> asked, but that's not too relevant to the immediate question: what do
> we consider our oldest supported version of Perl?  If we decide it's
> not 5.8, I'll reinstall that ... but allowing \h seems a pretty lame
> excuse for ratcheting up a whole major release series.
>
>

Sure. I think 5.8.x should be fine. 5.8.1 looks like our minimum to
build plperl:

        ./pl/plperl/plc_perlboot.pl:use 5.008001;


cheers

andrew

Re: pgsql: Replace pgindent shell script with Perl script. Update perltidy

From
Bruce Momjian
Date:
On Sat, Aug  4, 2012 at 05:55:51PM -0400, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
> > On 08/04/2012 03:40 PM, Tom Lane wrote:
> >> I'm not sure if we have any project policy for minimum required Perl
> >> version, but I've not found that any of our other Perl scripts don't
> >> work with 5.8.
>
> > Well, It's at least in 5.10.1 which dates from 3 years ago. I suspect
> > it's probably in 5.10.0 which dates from about 5 years ago. I guess this
> > is the danger of developing on modern systems :-) How old is the
> > compiler you use for everyday work?
>
> I intentionally use oldest-supported-versions of tools on my HPPA box,
> to keep us honest on that front.  It's running gcc 2.95.3, since you
> asked, but that's not too relevant to the immediate question: what do
> we consider our oldest supported version of Perl?  If we decide it's
> not 5.8, I'll reinstall that ... but allowing \h seems a pretty lame
> excuse for ratcheting up a whole major release series.

Tom, please make whatever changes you wish so it works for you.  There
is no reason pgindent should cause a newer Perl to be required.

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

  + It's impossible for everything to be true. +

Bruce Momjian <bruce@momjian.us> writes:
> On Sat, Aug  4, 2012 at 05:55:51PM -0400, Tom Lane wrote:
>>> I'm not sure if we have any project policy for minimum required Perl
>>> version, but I've not found that any of our other Perl scripts don't
>>> work with 5.8.

> Tom, please make whatever changes you wish so it works for you.  There
> is no reason pgindent should cause a newer Perl to be required.

Hearing no other objections, done.

            regards, tom lane