On 2016-05-27 08:13, Piotr Stefaniak wrote:
I'm trying to see if FreeBSD indent can successfully do pg_bsd_indent's job. So far I had to fix one thing, which is not adding a space after a cast operator, for which they added no option to turn it off. Currently I'm fighting one other bug, but I think that'll be it.
So... after fixing 12 times more bugs that I had anticipated (see the list at the end of this email; also see attached patches.tgz if you want to apply the patches yourself), my "fork" of FreeBSD indent(1) can do pg_bsd_indent's job if you pass it three additional parameters (-nut -cli1 -sac), producing a 6600-line unified diff, mostly of desired changes (see freebsd-indent.diff.gz for details).
I'm in the process of pushing my changes upstream, but I was already told that it's too late to get them into 11.0-RELEASE. Personally, I don't mind that, hoping that the upstream will accept them eventually.
I'm also hoping it'll be easier to reinvent GNU indent's -tsn ("set tabsize to n spaces") option for FreeBSD indent than it would be for any other of the forks that aren't GNU. I envision that to be the first step to getting rid of some of the work-arounds pgindent does, mainly running entab and detab as pre- and post-processing steps.
That and more I'll probably do later.
If porting FreeBSD indent to PostgreSQL's sources turns out to be successful, there will be a choice between rebasing pg_bsd_indent on that and picking specific patches and applying it on PG's fork of indent(1).
At this point I think it wouldn't make any sense to port any changes to current pg_bsd_indent.
The full list of changes I made to FreeBSD's indent(1) as of r289677: [bugfix] Fix typo in keyword "typedef".[bugfix] Avoid out of bound access of array codebuf pointed into by s_code.
[bugfix] Avoid out of bound access of array ps.paren_indents. [bugfix] Avoid out of bound access of array in_buffer. [bugfix] Avoid potential use-after-free.[bugfix] Semicolons inside struct declarations don't end the declarations.
[bugfix] Support "f" and "F" floating constant suffixes.[bugfix] Removed whitespace shouldn't be considered in column calculations.
[bugfix] Don't add surplus space on empty lines in comments. [bugfix] Bail out if there's no more space on the parser stack. [bugfix] Consistently indent declarations. [bugfix] Don't ignore the fact that offsetof is a keyword. [cleanup] Make definition of opchar conditional. [cleanup] Remove dead code relating to unix-style comments. [cleanup] Simplify pr_comment().[cleanup] Deduplicate code that decided if a comment needs a blank line at the top.
[bugfix] Fix wrapping of some lines in comments.[bugfix] Untangle the connection between pr_comment.c and io.c, fixing at least two bugs
[feature] Add -sac (space after cast) and -nsac options. [bugfix] Don't newline on cpp lines like #endif unless -bacc is on.[feature] Add -U option for providing a file containing list of types.
[optimization] Use bsearch() for looking up type keywords.
freebsd-indent.diff.gz
Description: application/gzip
patches.tgz
Description: application/compressed-tar
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers