Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLxOD-0008LK-52 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jun 2017 19:58:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dLxOC-0000af-OJ for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jun 2017 19:58:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dLxMb-0003W2-Qc for pgsql-hackers@postgresql.org; Fri, 16 Jun 2017 19:57:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dLxMZ-0001UI-K0 for pgsql-hackers@postgresql.org; Fri, 16 Jun 2017 19:57:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v5GJulRw029591; Fri, 16 Jun 2017 15:56:47 -0400 From: Tom Lane To: Bruce Momjian cc: Andres Freund , Peter Eisentraut , Alvaro Herrera , Robert Haas , Stephen Frost , "pgsql-hackers@postgresql.org" , Piotr Stefaniak Subject: Re: Preliminary results for proposed new pgindent implementation In-reply-to: <20170616190441.GB5081@momjian.us> References: <20170519173111.zp6igkcg53egdy4s@alvherre.pgsql> <29275.1497624664@sss.pgh.pa.us> <8827.1497633050@sss.pgh.pa.us> <20170616171946.qqy5tapovsamkxyg@alap3.anarazel.de> <9900.1497634441@sss.pgh.pa.us> <20170616180534.cdpduuq5a4twxuru@alap3.anarazel.de> <12302.1497637380@sss.pgh.pa.us> <20170616184238.GA5081@momjian.us> <20170616185406.jpwq6o6ghpvprxmi@alap3.anarazel.de> <20170616190441.GB5081@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Fri, 16 Jun 2017 15:04:41 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <29412.1497642725.0@sss.pgh.pa.us> Date: Fri, 16 Jun 2017 15:56:47 -0400 Message-ID: <29590.1497643007@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29412.1497642725.1@sss.pgh.pa.us> 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 ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="wip-tweak-tabbing-behavior.patch"; charset="us-ascii" Content-ID: <29412.1497642725.2@sss.pgh.pa.us> Content-Description: wip-tweak-tabbing-behavior.patch Content-Transfer-Encoding: quoted-printable diff -ur /home/postgres/freebsd_indent/indent.c ./indent.c --- /home/postgres/freebsd_indent/indent.c 2017-06-13 11:53:59.474524563 -0= 400 +++ ./indent.c 2017-06-16 15:41:53.515416614 -0400 @@ -1275,7 +1275,7 @@ =20 CHECK_SIZE_CODE(cur_dec_ind / tabsize); while ((tpos =3D tabsize * (1 + pos / tabsize)) <=3D cur_dec_ind) { - *e_code++ =3D '\t'; + *e_code++ =3D (tpos > pos + 1 || cur_dec_ind >=3D tpos + tabsize) ? '= \t' : ' '; pos =3D 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; =20 while ((tcur =3D tabsize * (1 + (curr - 1) / tabsize) + 1) <=3D target) { - putc('\t', output); + putc((tcur > curr + 1 || target >=3D tcur + tabsize) ? '\t' : ' ', ou= tput); curr =3D tcur; } } ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers ------- =_aaaaaaaaaa0--