Re: backslashes in pgindent

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Luke Lonergan <llonergan(at)greenplum(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: backslashes in pgindent
Date: 2005-07-16 11:47:06
Message-ID: 200507161147.j6GBl6k13566@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Luke Lonergan wrote:
> Bruce,
>
> On 7/15/05 9:59 PM, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
>
> > Actually, mine returns ')' too for the last command. I didn't copy
> > that into the email. How about the top tests? Notice I get an error on
> > the first one without the backslash. Are you OK escaping '(' but not
> > ')'? That might be a solution.
>
> You know, I'm not sure - I don't know the intended meaning of this line:
>
> awk ' BEGIN {line1 = ""; line2 = ""}
> {
> line2 = $0;
> if (NR >= 2)
> print line1;
> if (NR >= 2 &&
> line2 ~ "^{[ ]*$" &&
> line1 !~ "^struct" &&
> line1 !~ "^enum" &&
> line1 !~ "^typedef" &&
> line1 !~ "^extern[ ][ ]*\"C\"" &&
> line1 !~ "=" &&
> =====> line1 ~ "\)")
> print "int pgindent_func_no_var_fix;";
> line1 = line2;
> }
> END
>
> Is the escaped paren within "" meant to be a literal?

Yes, all parentheses tests in pgindent are meant to test literals. The
'\(' is required so it doesn't think it is defining a regex group.

Here is the output from my tests:

$ echo '('|awk '$0 ~ /(/ {print $0}'
awk: cmd. line:1: fatal: Unmatched ( or \(: /(/
$ echo '('|awk '$0 ~ /\(/ {print $0}'
(
$ echo ')'|awk '$0 ~ /)/ {print $0}'
)
$ echo ')'|awk '$0 ~ /\)/ {print $0}'
)

I just tried a machine that has awk 3.1.3 (you have 3.1.4) and I see:

$ echo '('|awk '$0 ~ /(/ {print $0}'
awk: cmd. line:1: fatal: Invalid regular expression: /(/
$ echo '('|awk '$0 ~ /\(/ {print $0}'
(
$ echo ')'|awk '$0 ~ /)/ {print $0}'
)
$ echo ')'|awk '$0 ~ /\)/ {print $0}'
)

which exactly matches the 3.0.4 version I usually use. What are your
outputs for these tests? Have you tried the current CVS version of
pgindent? I think it might now work for you.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-07-16 14:54:57 Re: [HACKERS] 4 pgcrypto regressions failures - 1 unsolved
Previous Message Marko Kreen 2005-07-16 10:07:41 Re: [HACKERS] 4 pgcrypto regressions failures - 1 unsolved