Hi All, 

I just tried to get pgindent to work and I ran into a few snags

1)

I tried the src/tools/pgindent/indent.bsd.patch on two recent
versions of bsd indent. One from the current version of openbsd, and
one from freebsd RELENG_3. In neither case the patch applied cleanly.


The code in indent around the area of the second patch segment 
*** 186,192 ****
                                *e_token++ = *buf_ptr++;
                        }
                }
!           if (*buf_ptr == 'L' || *buf_ptr == 'l')
                *e_token++ = *buf_ptr++;
        }
        else

now looks like this

            while (1) {
                if (!(seensfx & 1) &&
                        (*buf_ptr == 'U' || *buf_ptr == 'u')) {
                    CHECK_SIZE_TOKEN;
                    *e_token++ = *buf_ptr++;
                    seensfx |= 1;
                    continue;
                }
                if (!(seensfx & 2) &&
                        (*buf_ptr == 'L' || *buf_ptr == 'l')) {
                    CHECK_SIZE_TOKEN;
                    if (buf_ptr[1] == buf_ptr[0])
                        *e_token++ = *buf_ptr++;
                    *e_token++ = *buf_ptr++;
                    seensfx |= 2;
                    continue;
                }
                break;

Without understanding what the code is meant to do, I am guessing that
the second patch is no longer necessary.

Also, in the openbsd source the specials buffer is automatically
resized, so it seems that neither part of the patch is necessary for
recent openbsd sources.

2) 

I compiled and tried both bsd distributions. And ran into the
following problem with pgindent.

The test in pgindent for the gnu vesion doesn't work.

indent -version -npro </dev/null >/dev/null 2>&1
if [ "$?" -eq 0 ]
then    echo "You appear to have GNU indent rather than BSD indent." >&2
        echo "See the pgindent/README file for a description of its
problems." >
&2
        EXTRA_OPTS="-ncdb -bli0 -npcs -cli4"
else    echo "Hope you installed /src/tools/pgindent/indent.bsd.patch."
>&2
        EXTRA_OPTS="-bbb -cli1"
fi


I think that you need to use
indent --version -npro </dev/null >/dev/null 2>&1

On my system (Redhat Linux 5.?) I get

   aims2-bernie:$ indent --version
   GNU indent 1.9.1
   aims2-bernie:$ echo $?
   0
   aims2-bernie:$ bsdindent --version
   bsdindent: Command line: unknown parameter "--version"
   aims2-bernie:$ echo $?
   1

( That is with 'bsdindent' as the patched freebsd indent )


3) 

Finally, the result of running 

  find . -name '*.[ch]' -type f -print | egrep -v '\+\+|/odbc/|s_lock.h'
| xargs -n100 pgindent

on a fresh copy of the 6.5 sources with either the openbsd or patched
bsd indent is the following

Hope you installed /src/tools/pgindent/indent.bsd.patch.
Hope you installed /src/tools/pgindent/indent.bsd.patch.
./backend/parser/gram.c
Error@5251: #if stack overflow
Error@5252: #if stack overflow
Error@5263: Unmatched #endif
Error@5264: Unmatched #endif
Hope you installed /src/tools/pgindent/indent.bsd.patch.
Hope you installed /src/tools/pgindent/indent.bsd.patch.
Hope you installed /src/tools/pgindent/indent.bsd.patch.
Hope you installed /src/tools/pgindent/indent.bsd.patch.
Hope you installed /src/tools/pgindent/indent.bsd.patch.
Hope you installed /src/tools/pgindent/indent.bsd.patch.
./interfaces/ecpg/test/header_test.h
Error@19: Stuff missing from end of file.

Are the errors normal or do I still not have a correctly working
version?

Bernie Frankpitt

Thu, 09 Sep 1999 19:21:07 +0000
Bernard Frankpitt <frankpit@pop.dn.net>
pgindent
> Hi All, 
> 
> I just tried to get pgindent to work and I ran into a few snags
>                         }
>                 }
> !           if (*buf_ptr == 'L' || *buf_ptr == 'l')
>                 *e_token++ = *buf_ptr++;
>         }

> 
>             while (1) {
>                 if (!(seensfx & 1) &&
>                         (*buf_ptr == 'U' || *buf_ptr == 'u')) {
>                     CHECK_SIZE_TOKEN;
>                     *e_token++ = *buf_ptr++;
>                     seensfx |= 1;

> Also, in the openbsd source the specials buffer is automatically
> resized, so it seems that neither part of the patch is necessary for
> recent openbsd sources.

Great.  Your version looks nice.  BSDI also has fixed the buffer size
problem, but it was easier to just send people a patch to apply, rather
than illegally sending out their changes.

> 
> I think that you need to use
> indent --version -npro </dev/null >/dev/null 2>&1
> 
> On my system (Redhat Linux 5.?) I get
> 
>    aims2-bernie:$ indent --version
>    GNU indent 1.9.1
>    aims2-bernie:$ echo $?
>    0
>    aims2-bernie:$ bsdindent --version
>    bsdindent: Command line: unknown parameter "--version"
>    aims2-bernie:$ echo $?
>    1
> 
> ( That is with 'bsdindent' as the patched freebsd indent )


Good.  OK, new test is:

	indent --version </dev/null >/dev/null 2>&1
	if [ "$?" -eq 0 ]
	then    echo "You do not appear to have 'indent' installed on your
	system." >&2
	        exit 1
	fi

> 
> 
> 3) 
> 
> Finally, the result of running 
> 
>   find . -name '*.[ch]' -type f -print | egrep -v '\+\+|/odbc/|s_lock.h'
> | xargs -n100 pgindent
> 
> on a fresh copy of the 6.5 sources with either the openbsd or patched
> bsd indent is the following
> 
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> ./backend/parser/gram.c
> Error@5251: #if stack overflow
> Error@5252: #if stack overflow
> Error@5263: Unmatched #endif
> Error@5264: Unmatched #endif

This is expected.  Gram.c is generated from gram.y, so there is no real
need to indent it.

> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> ./interfaces/ecpg/test/header_test.h
> Error@19: Stuff missing from end of file.

I haven't seen the egcs problem.  In this case, it is getting confused
by the inline SQL commands.  No cause for concern.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Thu, 9 Sep 1999 15:44:44 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] pgindent