One other thing I'd like to do while we're changing this stuff is to get rid of the need for entab/detab. Right now, after doing all the other work, my copy of pgindent is running the code through detab and then entab so as to match the old decisions about how to represent whitespace (ie, as spaces or tabs). This is grotty as can be. I managed to tweak bsdindent so that its output matches what entab would do, by dint of the attached patch, which implements the rule "use a space instead of a tab if the tab would only move one column and we don't need another tab after it". (I think entab is being weird with the second half of that rule, but if I remove it, I get circa a thousand lines of invisible whitespace changes; probably better not to deal with those. With no patch at all, just letting bsdindent do what it does now, there's circa ten thousand changed lines.)
Unless Piotr objects, I propose to add another switch to bsdindent that selects this behavior, and then we can drop entab, removing another impediment to getting pgindent working. regards, tom lane
diff -ur /home/postgres/freebsd_indent/indent.c ./indent.c --- /home/postgres/freebsd_indent/indent.c 2017-06-13 11:53:59.474524563 -0400 +++ ./indent.c 2017-06-16 15:41:53.515416614 -0400 @@ -1275,7 +1275,7 @@ CHECK_SIZE_CODE(cur_dec_ind / tabsize); while ((tpos = tabsize * (1 + pos / tabsize)) <= cur_dec_ind) { - *e_code++ = '\t'; + *e_code++ = (tpos > pos + 1 || cur_dec_ind >= tpos + tabsize) ? '\t' : ' '; pos = tpos; } } diff -ur /home/postgres/freebsd_indent/io.c ./io.c --- /home/postgres/freebsd_indent/io.c 2017-06-13 11:53:59.475524587 -0400 +++ ./io.c 2017-06-16 15:42:47.686762023 -0400 @@ -399,7 +399,7 @@ int tcur; while ((tcur = tabsize * (1 + (curr - 1) / tabsize) + 1) <= target) { - putc('\t', output); + putc((tcur > curr + 1 || target >= tcur + tabsize) ? '\t' : ' ', output); curr = tcur; } }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers