Thread: pgsql: Mention why one C file fails pgindent.

pgsql: Mention why one C file fails pgindent.

From
momjian@postgresql.org (Bruce Momjian)
Date:
Log Message:
-----------
Mention why one C file fails pgindent.

Modified Files:
--------------
    pgsql/src/tools/pgindent:
        README (r1.41 -> r1.42)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/tools/pgindent/README?r1=1.41&r2=1.42)

Re: pgsql: Mention why one C file fails pgindent.

From
Andrew Dunstan
Date:

Bruce Momjian wrote:
> Log Message:
> -----------
> Mention why one C file fails pgindent.
>
> Modified Files:
> --------------
>     pgsql/src/tools/pgindent:
>         README (r1.41 -> r1.42)
>         (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/tools/pgindent/README?r1=1.41&r2=1.42)
>
>

Why not add the file that breaks to
src/tools/pgindent/exclude_file_patterns? (And also maybe the file Tom
just fixed).

And ISTM we should have a list of typdefs for pgindent to ignore anyway.
Currently, the buildfarm ignores:

    'date','interval','timestamp','ANY'

We should probably add 'DECIMAL' to that list.

But really, this list should probably be part of pgindent, not of the
typedef finding code.

cheers

andrew

Re: pgsql: Mention why one C file fails pgindent.

From
Bruce Momjian
Date:
Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
> > Log Message:
> > -----------
> > Mention why one C file fails pgindent.
> >
> > Modified Files:
> > --------------
> >     pgsql/src/tools/pgindent:
> >         README (r1.41 -> r1.42)
> >         (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/tools/pgindent/README?r1=1.41&r2=1.42)
> >
> >

[ Sorry for the late reply.]

> Why not add the file that breaks to
> src/tools/pgindent/exclude_file_patterns? (And also maybe the file Tom
> just fixed).

I thought about that, but right now exclude_file_patterns only has files
who's contents by definition can't be handled by pgindent, or we don't
want to be handled by pgindent.  wparser_def.c is a case where it is a
specific macro that is triggering the problem.

> And ISTM we should have a list of typdefs for pgindent to ignore anyway.
> Currently, the buildfarm ignores:
>
>     'date','interval','timestamp','ANY'
>
> We should probably add 'DECIMAL' to that list.

Yes, we could do that, but looking now, I see that several macros
already use _T to prevent name conflicts, so I have done that with
DECIMAL, now DECIMAL_T;  patch attached.

> But really, this list should probably be part of pgindent, not of the
> typedef finding code.

Hard to say on that one.  I can easily add a filter file;  I should also
rewrite it in perl and try out GUN indent too, but I have no idea what
day that will be.  :-(

Thanks for the ideas.

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

  + It's impossible for everything to be true. +
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c
index f3c7817..40eca64 100644
*** a/src/backend/tsearch/wparser_def.c
--- b/src/backend/tsearch/wparser_def.c
***************
*** 47,53 ****
  #define HWORD            17
  #define URLPATH            18
  #define FILEPATH        19
! #define DECIMAL            20
  #define SIGNEDINT        21
  #define UNSIGNEDINT        22
  #define XMLENTITY        23
--- 47,53 ----
  #define HWORD            17
  #define URLPATH            18
  #define FILEPATH        19
! #define DECIMAL_T        20
  #define SIGNEDINT        21
  #define UNSIGNEDINT        22
  #define XMLENTITY        23
*************** static const TParserStateActionItem acti
*** 1150,1161 ****
  };

  static const TParserStateActionItem actionTPS_InUDecimal[] = {
!     {p_isEOF, 0, A_BINGO, TPS_Base, DECIMAL, NULL},
      {p_isdigit, 0, A_NEXT, TPS_InUDecimal, 0, NULL},
      {p_iseqC, '.', A_PUSH, TPS_InVersionFirst, 0, NULL},
      {p_iseqC, 'e', A_PUSH, TPS_InMantissaFirst, 0, NULL},
      {p_iseqC, 'E', A_PUSH, TPS_InMantissaFirst, 0, NULL},
!     {NULL, 0, A_BINGO, TPS_Base, DECIMAL, NULL}
  };

  static const TParserStateActionItem actionTPS_InDecimalFirst[] = {
--- 1150,1161 ----
  };

  static const TParserStateActionItem actionTPS_InUDecimal[] = {
!     {p_isEOF, 0, A_BINGO, TPS_Base, DECIMAL_T, NULL},
      {p_isdigit, 0, A_NEXT, TPS_InUDecimal, 0, NULL},
      {p_iseqC, '.', A_PUSH, TPS_InVersionFirst, 0, NULL},
      {p_iseqC, 'e', A_PUSH, TPS_InMantissaFirst, 0, NULL},
      {p_iseqC, 'E', A_PUSH, TPS_InMantissaFirst, 0, NULL},
!     {NULL, 0, A_BINGO, TPS_Base, DECIMAL_T, NULL}
  };

  static const TParserStateActionItem actionTPS_InDecimalFirst[] = {
*************** static const TParserStateActionItem acti
*** 1165,1176 ****
  };

  static const TParserStateActionItem actionTPS_InDecimal[] = {
!     {p_isEOF, 0, A_BINGO, TPS_Base, DECIMAL, NULL},
      {p_isdigit, 0, A_NEXT, TPS_InDecimal, 0, NULL},
      {p_iseqC, '.', A_PUSH, TPS_InVerVersion, 0, NULL},
      {p_iseqC, 'e', A_PUSH, TPS_InMantissaFirst, 0, NULL},
      {p_iseqC, 'E', A_PUSH, TPS_InMantissaFirst, 0, NULL},
!     {NULL, 0, A_BINGO, TPS_Base, DECIMAL, NULL}
  };

  static const TParserStateActionItem actionTPS_InVerVersion[] = {
--- 1165,1176 ----
  };

  static const TParserStateActionItem actionTPS_InDecimal[] = {
!     {p_isEOF, 0, A_BINGO, TPS_Base, DECIMAL_T, NULL},
      {p_isdigit, 0, A_NEXT, TPS_InDecimal, 0, NULL},
      {p_iseqC, '.', A_PUSH, TPS_InVerVersion, 0, NULL},
      {p_iseqC, 'e', A_PUSH, TPS_InMantissaFirst, 0, NULL},
      {p_iseqC, 'E', A_PUSH, TPS_InMantissaFirst, 0, NULL},
!     {NULL, 0, A_BINGO, TPS_Base, DECIMAL_T, NULL}
  };

  static const TParserStateActionItem actionTPS_InVerVersion[] = {
*************** prsd_end(PG_FUNCTION_ARGS)
*** 2006,2012 ****
  #define HLIDSKIP(x)     ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
  #define XMLHLIDSKIP(x)  ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
  #define NONWORDTOKEN(x) ( (x)==SPACE || HLIDREPLACE(x) || HLIDSKIP(x) )
! #define NOENDTOKEN(x)    ( NONWORDTOKEN(x) || (x)==SCIENTIFIC || (x)==VERSIONNUMBER || (x)==DECIMAL || (x)==SIGNEDINT
||(x)==UNSIGNEDINT || TS_IDIGNORE(x) ) 

  typedef struct
  {
--- 2006,2012 ----
  #define HLIDSKIP(x)     ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
  #define XMLHLIDSKIP(x)  ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
  #define NONWORDTOKEN(x) ( (x)==SPACE || HLIDREPLACE(x) || HLIDSKIP(x) )
! #define NOENDTOKEN(x)    ( NONWORDTOKEN(x) || (x)==SCIENTIFIC || (x)==VERSIONNUMBER || (x)==DECIMAL_T ||
(x)==SIGNEDINT|| (x)==UNSIGNEDINT || TS_IDIGNORE(x) ) 

  typedef struct
  {
diff --git a/src/tools/pgindent/README b/src/tools/pgindent/README
index 0fedfa9..8fbf59f 100644
*** a/src/tools/pgindent/README
--- b/src/tools/pgindent/README
*************** This can format all PostgreSQL *.c and *
*** 23,30 ****
      xargs -n100 pgindent src/tools/pgindent/typedefs.list

  5) Remove any files that generate errors and restore their original
!    versions, e.g. ./src/backend/tsearch/wparser_def.c has problems
!    because of a DECIMAL listed as a typedef.

  6) Do a full test build:

--- 23,29 ----
      xargs -n100 pgindent src/tools/pgindent/typedefs.list

  5) Remove any files that generate errors and restore their original
!    versions.

  6) Do a full test build: