On 05/18/2018 02:02 PM, Andrew Dunstan wrote:

These two small patches allow us to run "perl -cw" cleanly on all our perl code.


One patch silences a warning from convutils.pl about the unportability of the literal 0x100000000. We've run for many years without this giving us a problem, so I think we can turn the warning off pretty safely.


The other patch provides a dummy library that emulates just enough of the Win32 perl infrastructure to allow us to run these checks. That means that Unix-based developers who might want to make changes in the msvc code can actually run a check against their code without having to put it on a Windows machine. The invocation goes like this (to check Mkvcbuild.pl for example):


   PERL5LIB=src/tools/msvc/dummylib perl -cw src/tools/Mkvcbuild.pm


This also allows us to check src/tools/win32tzlist.pl.


In due course I'll submit a script to automate this syntax checking.





Here is the latest version of the second patch, this time with warnings about redefinition of some subroutines suppressed. These mostly occur because in a few cases we have multiple packages in a single file.

This allows the following command to pass cleanly:

   { find . -type f -a -name '*.p[lm]' -print; find . -type f -perm
   -100 -exec file {} \; -print | egrep -i ':.*perl[0-9]*\>' |cut -d:
   -f1 ; } | sort -u |
   
PERL5LIB=src/test/perl:src/test/ssl:src/bin/pg_rewind:src/backend/catalog:src/backend/utils/mb/Unicode:src/tools/msvc/dummylib:src/tools/msvc
   xargs -L 1 perl -cw

cheers

andrew



--
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 27397ba..86979df 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -11,6 +11,8 @@ use strict;
 use warnings;
 use base qw(Project);
 
+no warnings qw(redefine);
+
 sub _new
 {
 	my $classname = shift;
@@ -399,6 +401,8 @@ use strict;
 use warnings;
 use base qw(MSBuildProject);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -420,6 +424,8 @@ use strict;
 use warnings;
 use base qw(MSBuildProject);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -464,6 +470,8 @@ use strict;
 use warnings;
 use base qw(VC2012Project);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -487,6 +495,8 @@ use strict;
 use warnings;
 use base qw(VC2012Project);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -510,6 +520,8 @@ use strict;
 use warnings;
 use base qw(VC2012Project);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 261c913..0d35546 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -229,6 +229,7 @@ sub AddDir
 
 				if ($filter eq "LIBOBJS")
 				{
+					no warnings qw(once);
 					if (grep(/$p/, @main::pgportfiles, @main::pgcommonfiles)
 						== 1)
 					{
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 8f0b355..1440989 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -10,6 +10,8 @@ use strict;
 use warnings;
 use VSObjectFactory;
 
+no warnings qw(redefine);
+
 sub _new
 {
 	my $classname = shift;
@@ -768,6 +770,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -791,6 +795,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -815,6 +821,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -839,6 +847,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -863,6 +873,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -889,6 +901,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -915,6 +929,8 @@ use strict;
 use warnings;
 use base qw(Solution);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
diff --git a/src/tools/msvc/VCBuildProject.pm b/src/tools/msvc/VCBuildProject.pm
index 03b890b..ad613b3 100644
--- a/src/tools/msvc/VCBuildProject.pm
+++ b/src/tools/msvc/VCBuildProject.pm
@@ -11,6 +11,8 @@ use strict;
 use warnings;
 use base qw(Project);
 
+no warnings qw(redefine);
+
 sub _new
 {
 	my $classname = shift;
@@ -268,6 +270,8 @@ use strict;
 use warnings;
 use base qw(VCBuildProject);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
@@ -289,6 +293,8 @@ use strict;
 use warnings;
 use base qw(VCBuildProject);
 
+no warnings qw(redefine);
+
 sub new
 {
 	my $classname = shift;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index eea59c5..8a5f8f9 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -20,6 +20,8 @@ our (@ISA, @EXPORT);
 @ISA    = qw(Exporter);
 @EXPORT = qw(CreateSolution CreateProject DetermineVisualStudioVersion);
 
+no warnings qw(redefine);
+
 sub CreateSolution
 {
 	my $visualStudioVersion = shift;

Reply via email to