Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csnNo-0002si-Hf for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Mar 2017 09:25:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1csnNo-0006KF-4N for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Mar 2017 09:25:44 +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 1csnMI-0003ao-L0 for pgsql-hackers@postgresql.org; Tue, 28 Mar 2017 09:24:10 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1csnMF-0002VS-KL for pgsql-hackers@postgresql.org; Tue, 28 Mar 2017 09:24:09 +0000 Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1csnM6-0000Q6-8T; Tue, 28 Mar 2017 11:24:00 +0200 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1csnM5-00046Q-VF; Tue, 28 Mar 2017 11:23:58 +0200 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: Tom Lane Cc: Peter Eisentraut , pgsql-hackers@postgresql.org Subject: Re: [COMMITTERS] pgsql: Clean up Perl code according to perlcritic References: <14575.1490652977@sss.pgh.pa.us> <4193.1490662733@sss.pgh.pa.us> Mail-Copies-To: nobody Date: Tue, 28 Mar 2017 10:23:57 +0100 In-Reply-To: <4193.1490662733@sss.pgh.pa.us> (Tom Lane's message of "Mon, 27 Mar 2017 20:58:53 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Exiscan-Spam-Score: -3.7 (---) X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Pg-Spam-Score: -4.2 (----) 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 Tom Lane writes: > I wrote: >> Peter Eisentraut writes: >>> Clean up Perl code according to perlcritic > >> This seems to have broken the regression tests (specifically, dblink) >> on at least some of the Windows buildfarm critters. > > I'm hardly a Perl expert, but it looks to me like the culprit is this > hunk in vcregress.pl: > > @@ -521,8 +521,9 @@ sub fetchRegressOpts > # an unhandled variable reference. Ignore anything that isn't an > # option starting with "--". > @opts = grep { > - s/\Q$(top_builddir)\E/\"$topdir\"/; > - $_ !~ /\$\(/ && $_ =~ /^--/ > + my $x = $_; > + $x =~ s/\Q$(top_builddir)\E/\"$topdir\"/; > + $x !~ /\$\(/ && $x =~ /^--/ > } split(/\s+/, $1); > } > if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m) > > The first line in that block is actually intending to modify the value > it's inspecting, and perlcritic's "improved" version carefully removes > the side-effect. > > No doubt there are cleaner ways to do that (the comments in "man perlfunc" > about this coding technique are not positive), but this way is not > cleaner, it is broken. I suggest splitting the substitution and filtering part into separate map and grep calls, for clarity. The substituion is crying out for the /r regex modifier to avoid the local variable, but that's only available since perl 5.14. diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index d9367f8..cf93a60 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -520,11 +520,9 @@ sub fetchRegressOpts # Substitute known Makefile variables, then ignore options that retain # an unhandled variable reference. Ignore anything that isn't an # option starting with "--". - @opts = grep { - my $x = $_; - $x =~ s/\Q$(top_builddir)\E/\"$topdir\"/; - $x !~ /\$\(/ && $x =~ /^--/ - } split(/\s+/, $1); + @opts = grep { !/\$\(/ && /^--/ } + map { (my $x = $_) =~ s/\Q$(top_builddir)\E/\"$topdir\"/; $x;} + split(/\s+/, $1); } if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m) { - ilmari -- "The surreality of the universe tends towards a maximum" -- Skud's Law "Never formulate a law or axiom that you're not prepared to live with the consequences of." -- Skud's Meta-Law -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers