Re: pgindent and multiline string constants

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgindent and multiline string constants
Date: 2007-11-28 17:58:03
Message-ID: 200711281758.lASHw3g21853@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Somehow pgindent appears to do odd things with multiline string constants,
> > such as
>
> > somefunc(&blah,
> > "lots of text"
> > "with mulitple lines"
> > "like this");
>
> > Afterwards this looks more like this:
>
> > somefunc(&blah,
> > "lots of text"
> > "with mulitple lines"
> > "like this");
>
> Sometimes it does that to keep the lines from extending past column 80.
> I'm not sure that this is an improvement :-(, but anyway you can fix it
> by breaking the string literal into smaller chunks so that there's no
> line-wrapping going on in an 80-column view.

Yes, I talked to Peter via IM on this. A good example is xml.c::3033
that looks like this:

appendStringInfo(&result,
" <xsd:restriction base=\"xsd:long\">\n"
" <xsd:maxInclusive value=\"" INT64_FORMAT "\"/>\n"
" <xsd:minInclusive value=\"" INT64_FORMAT "\"/>\n"
" </xsd:restriction>\n",
(((uint64) 1) << (sizeof(int64) * 8 - 1)) - 1,
(((uint64) 1) << (sizeof(int64) * 8 - 1)));

The problem is that the lines with INT64_FORMAT are shifted to the left
to be < 80 characters. What is really odd is line 3071 where the first
and third quote lines are short enough to shift to the left, while the
second line is so long that it doesn't to shift it at all:

appendStringInfo(&result,
" <xsd:restriction base=\"xsd:time\">\n"
" <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"/>\n"
" </xsd:restriction>\n", typmod - VARHDRSZ, tz);

Not sure what we can do to improve pgindent in this area. It treats
these strings like function parameters, trying to keep them <80.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message sulfinu 2007-11-28 18:11:00 Re: String encoding during connection "handshake"
Previous Message Tom Lane 2007-11-28 17:45:30 Re: jaguar is up