Re: pgindent and multiline string constants

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: pgindent and multiline string constants
Дата
Msg-id 200711281758.lASHw3g21853@momjian.us
обсуждение исходный текст
Ответ на Re: pgindent and multiline string constants  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.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@momjian.us>        http://momjian.us EnterpriseDB
http://postgres.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: jaguar is up
Следующее
От: sulfinu@gmail.com
Дата:
Сообщение: Re: String encoding during connection "handshake"