summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorPeter Eisentraut2017-03-27 02:24:13 +0000
committerPeter Eisentraut2017-03-27 12:18:22 +0000
commitfacde2a98f0b5f7689b4e30a9e7376e926e733b8 (patch)
treeab8b2cc1b2bd47b7db5e2def26d8eca4ce6ca438 /src/tools
parentde4da168d57de812bb30d359394b7913635d21a9 (diff)
Clean up Perl code according to perlcritic
Fix all perlcritic warnings of severity level 5, except in src/backend/utils/Gen_dummy_probes.pl, which is automatically generated. Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/fix-old-flex-code.pl4
-rw-r--r--src/tools/msvc/Install.pm10
-rw-r--r--src/tools/msvc/Mkvcbuild.pm2
-rw-r--r--src/tools/msvc/Project.pm28
-rw-r--r--src/tools/msvc/Solution.pm162
-rw-r--r--src/tools/msvc/build.pl8
-rw-r--r--src/tools/msvc/builddoc.pl2
-rw-r--r--src/tools/msvc/gendef.pl18
-rwxr-xr-xsrc/tools/msvc/install.pl4
-rw-r--r--src/tools/msvc/mkvcbuild.pl4
-rw-r--r--src/tools/msvc/pgbison.pl4
-rw-r--r--src/tools/msvc/pgflex.pl12
-rw-r--r--src/tools/msvc/vcregress.pl19
-rwxr-xr-xsrc/tools/pginclude/pgcheckdefines32
-rwxr-xr-xsrc/tools/pgindent/pgindent5
-rwxr-xr-xsrc/tools/version_stamp.pl6
-rwxr-xr-xsrc/tools/win32tzlist.pl6
17 files changed, 163 insertions, 163 deletions
diff --git a/src/tools/fix-old-flex-code.pl b/src/tools/fix-old-flex-code.pl
index 8dafcae15e2..bc868dfd7f6 100644
--- a/src/tools/fix-old-flex-code.pl
+++ b/src/tools/fix-old-flex-code.pl
@@ -25,7 +25,7 @@ my $filename = shift;
# Suck in the whole file.
local $/ = undef;
my $cfile;
-open($cfile, $filename) || die "opening $filename for reading: $!";
+open($cfile, '<', $filename) || die "opening $filename for reading: $!";
my $ccode = <$cfile>;
close($cfile);
@@ -45,7 +45,7 @@ $ccode =~ s|(struct yyguts_t \* yyg = \(struct yyguts_t\*\)yyscanner; /\* This v
|s;
# Write the modified file back out.
-open($cfile, ">$filename") || die "opening $filename for writing: $!";
+open($cfile, '>', $filename) || die "opening $filename for writing: $!";
print $cfile $ccode;
close($cfile);
diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index b81f4dd809c..35ad5b8a440 100644
--- a/src/tools/msvc/Install.pm
+++ b/src/tools/msvc/Install.pm
@@ -58,8 +58,8 @@ sub Install
# suppress warning about harmless redeclaration of $config
no warnings 'misc';
- require "config_default.pl";
- require "config.pl" if (-f "config.pl");
+ do "config_default.pl";
+ do "config.pl" if (-f "config.pl");
}
chdir("../../..") if (-f "../../../configure");
@@ -367,7 +367,7 @@ sub GenerateConversionScript
$sql .=
"COMMENT ON CONVERSION pg_catalog.$name IS 'conversion for $se to $de';\n\n";
}
- open($F, ">$target/share/conversion_create.sql")
+ open($F, '>', "$target/share/conversion_create.sql")
|| die "Could not write to conversion_create.sql\n";
print $F $sql;
close($F);
@@ -409,7 +409,7 @@ sub GenerateTsearchFiles
$mf =~ /^LANGUAGES\s*=\s*(.*)$/m
|| die "Could not find LANGUAGES line in snowball Makefile\n";
my @pieces = split /\s+/, $1;
- open($F, ">$target/share/snowball_create.sql")
+ open($F, '>', "$target/share/snowball_create.sql")
|| die "Could not write snowball_create.sql";
print $F read_file('src/backend/snowball/snowball_func.sql.in');
@@ -735,7 +735,7 @@ sub read_file
my $t = $/;
undef $/;
- open($F, $filename) || die "Could not open file $filename\n";
+ open($F, '<', $filename) || die "Could not open file $filename\n";
my $txt = <$F>;
close($F);
$/ = $t;
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 12f73f344cf..ba1bf6d97a8 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -825,7 +825,7 @@ sub GenerateContribSqlFiles
$dn =~ s/\.sql$//;
$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
my $o;
- open($o, ">contrib/$n/$out")
+ open($o, '>', "contrib/$n/$out")
|| croak "Could not write to contrib/$n/$d";
print $o $cont;
close($o);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index faf1a683f66..9817b9439a9 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -310,12 +310,12 @@ sub AddResourceFile
if (Solution::IsNewer("$dir/win32ver.rc", 'src/port/win32ver.rc'))
{
print "Generating win32ver.rc for $dir\n";
- open(I, 'src/port/win32ver.rc')
+ open(my $i, '<', 'src/port/win32ver.rc')
|| confess "Could not open win32ver.rc";
- open(O, ">$dir/win32ver.rc")
+ open(my $o, '>', "$dir/win32ver.rc")
|| confess "Could not write win32ver.rc";
my $icostr = $ico ? "IDI_ICON ICON \"src/port/$ico.ico\"" : "";
- while (<I>)
+ while (<$i>)
{
s/FILEDESC/"$desc"/gm;
s/_ICO_/$icostr/gm;
@@ -324,11 +324,11 @@ sub AddResourceFile
{
s/VFT_APP/VFT_DLL/gm;
}
- print O;
+ print $o $_;
}
+ close($o);
+ close($i);
}
- close(O);
- close(I);
$self->AddFile("$dir/win32ver.rc");
}
@@ -357,13 +357,13 @@ sub Save
$self->DisableLinkerWarnings('4197') if ($self->{platform} eq 'x64');
# Dump the project
- open(F, ">$self->{name}$self->{filenameExtension}")
+ open(my $f, '>', "$self->{name}$self->{filenameExtension}")
|| croak(
"Could not write to $self->{name}$self->{filenameExtension}\n");
- $self->WriteHeader(*F);
- $self->WriteFiles(*F);
- $self->Footer(*F);
- close(F);
+ $self->WriteHeader($f);
+ $self->WriteFiles($f);
+ $self->Footer($f);
+ close($f);
}
sub GetAdditionalLinkerDependencies
@@ -397,7 +397,7 @@ sub read_file
my $t = $/;
undef $/;
- open($F, $filename) || croak "Could not open file $filename\n";
+ open($F, '<', $filename) || croak "Could not open file $filename\n";
my $txt = <$F>;
close($F);
$/ = $t;
@@ -412,8 +412,8 @@ sub read_makefile
my $t = $/;
undef $/;
- open($F, "$reldir/GNUmakefile")
- || open($F, "$reldir/Makefile")
+ open($F, '<', "$reldir/GNUmakefile")
+ || open($F, '<', "$reldir/Makefile")
|| confess "Could not open $reldir/Makefile\n";
my $txt = <$F>;
close($F);
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index ff9064f923d..abac2c74026 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -102,14 +102,14 @@ sub IsNewer
sub copyFile
{
my ($src, $dest) = @_;
- open(I, $src) || croak "Could not open $src";
- open(O, ">$dest") || croak "Could not open $dest";
- while (<I>)
+ open(my $i, '<', $src) || croak "Could not open $src";
+ open(my $o, '>', $dest) || croak "Could not open $dest";
+ while (<$i>)
{
- print O;
+ print $o $_;
}
- close(I);
- close(O);
+ close($i);
+ close($o);
}
sub GenerateFiles
@@ -118,9 +118,9 @@ sub GenerateFiles
my $bits = $self->{platform} eq 'Win32' ? 32 : 64;
# Parse configure.in to get version numbers
- open(C, "configure.in")
+ open(my $c, '<', "configure.in")
|| confess("Could not open configure.in for reading\n");
- while (<C>)
+ while (<$c>)
{
if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/)
{
@@ -133,7 +133,7 @@ sub GenerateFiles
$self->{majorver} = sprintf("%d", $1);
}
}
- close(C);
+ close($c);
confess "Unable to parse configure.in for all variables!"
if ($self->{strver} eq '' || $self->{numver} eq '');
@@ -146,91 +146,91 @@ sub GenerateFiles
if (IsNewer("src/include/pg_config.h", "src/include/pg_config.h.win32"))
{
print "Generating pg_config.h...\n";
- open(I, "src/include/pg_config.h.win32")
+ open(my $i, '<', "src/include/pg_config.h.win32")
|| confess "Could not open pg_config.h.win32\n";
- open(O, ">src/include/pg_config.h")
+ open(my $o, '>', "src/include/pg_config.h")
|| confess "Could not write to pg_config.h\n";
my $extraver = $self->{options}->{extraver};
$extraver = '' unless defined $extraver;
- while (<I>)
+ while (<$i>)
{
s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}$extraver"};
s{PG_VERSION_NUM \d+}{PG_VERSION_NUM $self->{numver}};
s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ", $bits-bit"};
- print O;
+ print $o $_;
}
- print O "#define PG_MAJORVERSION \"$self->{majorver}\"\n";
- print O "#define LOCALEDIR \"/share/locale\"\n"
+ print $o "#define PG_MAJORVERSION \"$self->{majorver}\"\n";
+ print $o "#define LOCALEDIR \"/share/locale\"\n"
if ($self->{options}->{nls});
- print O "/* defines added by config steps */\n";
- print O "#ifndef IGNORE_CONFIGURED_SETTINGS\n";
- print O "#define USE_ASSERT_CHECKING 1\n"
+ print $o "/* defines added by config steps */\n";
+ print $o "#ifndef IGNORE_CONFIGURED_SETTINGS\n";
+ print $o "#define USE_ASSERT_CHECKING 1\n"
if ($self->{options}->{asserts});
- print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap});
- print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib});
- print O "#define USE_OPENSSL 1\n" if ($self->{options}->{openssl});
- print O "#define ENABLE_NLS 1\n" if ($self->{options}->{nls});
+ print $o "#define USE_LDAP 1\n" if ($self->{options}->{ldap});
+ print $o "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib});
+ print $o "#define USE_OPENSSL 1\n" if ($self->{options}->{openssl});
+ print $o "#define ENABLE_NLS 1\n" if ($self->{options}->{nls});
- print O "#define BLCKSZ ", 1024 * $self->{options}->{blocksize}, "\n";
- print O "#define RELSEG_SIZE ",
+ print $o "#define BLCKSZ ", 1024 * $self->{options}->{blocksize}, "\n";
+ print $o "#define RELSEG_SIZE ",
(1024 / $self->{options}->{blocksize}) *
$self->{options}->{segsize} *
1024, "\n";
- print O "#define XLOG_BLCKSZ ",
+ print $o "#define XLOG_BLCKSZ ",
1024 * $self->{options}->{wal_blocksize}, "\n";
- print O "#define XLOG_SEG_SIZE (", $self->{options}->{wal_segsize},
+ print $o "#define XLOG_SEG_SIZE (", $self->{options}->{wal_segsize},
" * 1024 * 1024)\n";
if ($self->{options}->{float4byval})
{
- print O "#define USE_FLOAT4_BYVAL 1\n";
- print O "#define FLOAT4PASSBYVAL true\n";
+ print $o "#define USE_FLOAT4_BYVAL 1\n";
+ print $o "#define FLOAT4PASSBYVAL true\n";
}
else
{
- print O "#define FLOAT4PASSBYVAL false\n";
+ print $o "#define FLOAT4PASSBYVAL false\n";
}
if ($self->{options}->{float8byval})
{
- print O "#define USE_FLOAT8_BYVAL 1\n";
- print O "#define FLOAT8PASSBYVAL true\n";
+ print $o "#define USE_FLOAT8_BYVAL 1\n";
+ print $o "#define FLOAT8PASSBYVAL true\n";
}
else
{
- print O "#define FLOAT8PASSBYVAL false\n";
+ print $o "#define FLOAT8PASSBYVAL false\n";
}
if ($self->{options}->{uuid})
{
- print O "#define HAVE_UUID_OSSP\n";
- print O "#define HAVE_UUID_H\n";
+ print $o "#define HAVE_UUID_OSSP\n";
+ print $o "#define HAVE_UUID_H\n";
}
if ($self->{options}->{xml})
{
- print O "#define HAVE_LIBXML2\n";
- print O "#define USE_LIBXML\n";
+ print $o "#define HAVE_LIBXML2\n";
+ print $o "#define USE_LIBXML\n";
}
if ($self->{options}->{xslt})
{
- print O "#define HAVE_LIBXSLT\n";
- print O "#define USE_LIBXSLT\n";
+ print $o "#define HAVE_LIBXSLT\n";
+ print $o "#define USE_LIBXSLT\n";
}
if ($self->{options}->{gss})
{
- print O "#define ENABLE_GSS 1\n";
+ print $o "#define ENABLE_GSS 1\n";
}
if (my $port = $self->{options}->{"--with-pgport"})
{
- print O "#undef DEF_PGPORT\n";
- print O "#undef DEF_PGPORT_STR\n";
- print O "#define DEF_PGPORT $port\n";
- print O "#define DEF_PGPORT_STR \"$port\"\n";
+ print $o "#undef DEF_PGPORT\n";
+ print $o "#undef DEF_PGPORT_STR\n";
+ print $o "#define DEF_PGPORT $port\n";
+ print $o "#define DEF_PGPORT_STR \"$port\"\n";
}
- print O "#define VAL_CONFIGURE \""
+ print $o "#define VAL_CONFIGURE \""
. $self->GetFakeConfigure() . "\"\n";
- print O "#endif /* IGNORE_CONFIGURED_SETTINGS */\n";
- close(O);
- close(I);
+ print $o "#endif /* IGNORE_CONFIGURED_SETTINGS */\n";
+ close($o);
+ close($i);
}
if (IsNewer(
@@ -379,17 +379,17 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
my $d = ($year - 100) . "$yday";
- open(I, '<', 'src/interfaces/libpq/libpq.rc.in')
+ open(my $i, '<', 'src/interfaces/libpq/libpq.rc.in')
|| confess "Could not open libpq.rc.in";
- open(O, '>', 'src/interfaces/libpq/libpq.rc')
+ open(my $o, '>', 'src/interfaces/libpq/libpq.rc')
|| confess "Could not open libpq.rc";
- while (<I>)
+ while (<$i>)
{
s/(VERSION.*),0/$1,$d/;
- print O;
+ print $o;
}
- close(I);
- close(O);
+ close($i);
+ close($o);
}
if (IsNewer('src/bin/psql/sql_help.h', 'src/bin/psql/create_help.pl'))
@@ -415,23 +415,23 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
'src/interfaces/ecpg/include/ecpg_config.h.in'))
{
print "Generating ecpg_config.h...\n";
- open(O, '>', 'src/interfaces/ecpg/include/ecpg_config.h')
+ open(my $o, '>', 'src/interfaces/ecpg/include/ecpg_config.h')
|| confess "Could not open ecpg_config.h";
- print O <<EOF;
+ print $o <<EOF;
#if (_MSC_VER > 1200)
#define HAVE_LONG_LONG_INT_64
#define ENABLE_THREAD_SAFETY 1
EOF
- print O "#endif\n";
- close(O);
+ print $o "#endif\n";
+ close($o);
}
unless (-f "src/port/pg_config_paths.h")
{
print "Generating pg_config_paths.h...\n";
- open(O, '>', 'src/port/pg_config_paths.h')
+ open(my $o, '>', 'src/port/pg_config_paths.h')
|| confess "Could not open pg_config_paths.h";
- print O <<EOF;
+ print $o <<EOF;
#define PGBINDIR "/bin"
#define PGSHAREDIR "/share"
#define SYSCONFDIR "/etc"
@@ -445,7 +445,7 @@ EOF
#define HTMLDIR "/doc"
#define MANDIR "/man"
EOF
- close(O);
+ close($o);
}
my $mf = Project::read_file('src/backend/catalog/Makefile');
@@ -474,13 +474,13 @@ EOF
}
}
- open(O, ">doc/src/sgml/version.sgml")
+ open(my $o, '>', "doc/src/sgml/version.sgml")
|| croak "Could not write to version.sgml\n";
- print O <<EOF;
+ print $o <<EOF;
<!ENTITY version "$self->{strver}">
<!ENTITY majorversion "$self->{majorver}">
EOF
- close(O);
+ close($o);
}
sub GenerateDefFile
@@ -490,18 +490,18 @@ sub GenerateDefFile
if (IsNewer($deffile, $txtfile))
{
print "Generating $deffile...\n";
- open(I, $txtfile) || confess("Could not open $txtfile\n");
- open(O, ">$deffile") || confess("Could not open $deffile\n");
- print O "LIBRARY $libname\nEXPORTS\n";
- while (<I>)
+ open(my $if, '<', $txtfile) || confess("Could not open $txtfile\n");
+ open(my $of, '>', $deffile) || confess("Could not open $deffile\n");
+ print $of "LIBRARY $libname\nEXPORTS\n";
+ while (<$if>)
{
next if (/^#/);
next if (/^\s*$/);
my ($f, $o) = split;
- print O " $f @ $o\n";
+ print $of " $f @ $o\n";
}
- close(O);
- close(I);
+ close($of);
+ close($if);
}
}
@@ -575,19 +575,19 @@ sub Save
}
}
- open(SLN, ">pgsql.sln") || croak "Could not write to pgsql.sln\n";
- print SLN <<EOF;
+ open(my $sln, '>', "pgsql.sln") || croak "Could not write to pgsql.sln\n";
+ print $sln <<EOF;
Microsoft Visual Studio Solution File, Format Version $self->{solutionFileVersion}
# $self->{visualStudioName}
EOF
- print SLN $self->GetAdditionalHeaders();
+ print $sln $self->GetAdditionalHeaders();
foreach my $fld (keys %{ $self->{projects} })
{
foreach my $proj (@{ $self->{projects}->{$fld} })
{
- print SLN <<EOF;
+ print $sln <<EOF;
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}$proj->{filenameExtension}", "$proj->{guid}"
EndProject
EOF
@@ -595,14 +595,14 @@ EOF
if ($fld ne "")
{
$flduid{$fld} = Win32::GuidGen();
- print SLN <<EOF;
+ print $sln <<EOF;
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "$fld", "$fld", "$flduid{$fld}"
EndProject
EOF
}
}
- print SLN <<EOF;
+ print $sln <<EOF;
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|$self->{platform}= Debug|$self->{platform}
@@ -615,7 +615,7 @@ EOF
{
foreach my $proj (@{ $self->{projects}->{$fld} })
{
- print SLN <<EOF;
+ print $sln <<EOF;
$proj->{guid}.Debug|$self->{platform}.ActiveCfg = Debug|$self->{platform}
$proj->{guid}.Debug|$self->{platform}.Build.0 = Debug|$self->{platform}
$proj->{guid}.Release|$self->{platform}.ActiveCfg = Release|$self->{platform}
@@ -624,7 +624,7 @@ EOF
}
}
- print SLN <<EOF;
+ print $sln <<EOF;
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -637,15 +637,15 @@ EOF
next if ($fld eq "");
foreach my $proj (@{ $self->{projects}->{$fld} })
{
- print SLN "\t\t$proj->{guid} = $flduid{$fld}\n";
+ print $sln "\t\t$proj->{guid} = $flduid{$fld}\n";
}
}
- print SLN <<EOF;
+ print $sln <<EOF;
EndGlobalSection
EndGlobal
EOF
- close(SLN);
+ close($sln);
}
sub GetFakeConfigure
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index 2e7c54853a6..72460642907 100644
--- a/src/tools/msvc/build.pl
+++ b/src/tools/msvc/build.pl
@@ -23,17 +23,17 @@ use Mkvcbuild;
if (-e "src/tools/msvc/buildenv.pl")
{
- require "src/tools/msvc/buildenv.pl";
+ do "src/tools/msvc/buildenv.pl";
}
elsif (-e "./buildenv.pl")
{
- require "./buildenv.pl";
+ do "./buildenv.pl";
}
# set up the project
our $config;
-require "config_default.pl";
-require "config.pl" if (-f "src/tools/msvc/config.pl");
+do "config_default.pl";
+do "config.pl" if (-f "src/tools/msvc/config.pl");
my $vcver = Mkvcbuild::mkvcbuild($config);
diff --git a/src/tools/msvc/builddoc.pl b/src/tools/msvc/builddoc.pl
index 2b56ced43ce..e0b5c50b342 100644
--- a/src/tools/msvc/builddoc.pl
+++ b/src/tools/msvc/builddoc.pl
@@ -18,7 +18,7 @@ chdir '../../..' if (-d '../msvc' && -d '../../../src');
noversion() unless -e 'doc/src/sgml/version.sgml';
-require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
+do 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
my $docroot = $ENV{DOCROOT};
die "bad DOCROOT '$docroot'" unless ($docroot && -d $docroot);
diff --git a/src/tools/msvc/gendef.pl b/src/tools/msvc/gendef.pl
index 3bcff7ffaf6..64227c2dce5 100644
--- a/src/tools/msvc/gendef.pl
+++ b/src/tools/msvc/gendef.pl
@@ -32,8 +32,8 @@ sub dumpsyms
sub extract_syms
{
my ($symfile, $def) = @_;
- open(F, "<$symfile") || die "Could not open $symfile for $_\n";
- while (<F>)
+ open(my $f, '<', $symfile) || die "Could not open $symfile for $_\n";
+ while (<$f>)
{
# Expected symbol lines look like:
@@ -115,14 +115,14 @@ sub extract_syms
# whatever came last.
$def->{ $pieces[6] } = $pieces[3];
}
- close(F);
+ close($f);
}
sub writedef
{
my ($deffile, $platform, $def) = @_;
- open(DEF, ">$deffile") || die "Could not write to $deffile\n";
- print DEF "EXPORTS\n";
+ open(my $fh, '>', $deffile) || die "Could not write to $deffile\n";
+ print $fh "EXPORTS\n";
foreach my $f (sort keys %{$def})
{
my $isdata = $def->{$f} eq 'data';
@@ -135,14 +135,14 @@ sub writedef
# decorated with the DATA option for variables.
if ($isdata)
{
- print DEF " $f DATA\n";
+ print $fh " $f DATA\n";
}
else
{
- print DEF " $f\n";
+ print $fh " $f\n";
}
}
- close(DEF);
+ close($fh);
}
@@ -174,7 +174,7 @@ print "Generating $defname.DEF from directory $ARGV[0], platform $platform\n";
my %def = ();
-while (<$ARGV[0]/*.obj>)
+while (<$ARGV[0]/*.obj>) ## no critic (RequireGlobFunction);
{
my $objfile = $_;
my $symfile = $objfile;
diff --git a/src/tools/msvc/install.pl b/src/tools/msvc/install.pl
index bde5b7c793a..b2d7f9e040b 100755
--- a/src/tools/msvc/install.pl
+++ b/src/tools/msvc/install.pl
@@ -14,11 +14,11 @@ use Install qw(Install);
if (-e "src/tools/msvc/buildenv.pl")
{
- require "src/tools/msvc/buildenv.pl";
+ do "src/tools/msvc/buildenv.pl";
}
elsif (-e "./buildenv.pl")
{
- require "./buildenv.pl";
+ do "./buildenv.pl";
}
my $target = shift || Usage();
diff --git a/src/tools/msvc/mkvcbuild.pl b/src/tools/msvc/mkvcbuild.pl
index 6f1c42e5044..9255dff022d 100644
--- a/src/tools/msvc/mkvcbuild.pl
+++ b/src/tools/msvc/mkvcbuild.pl
@@ -19,7 +19,7 @@ print "Warning: no config.pl found, using default.\n"
unless (-f 'src/tools/msvc/config.pl');
our $config;
-require 'src/tools/msvc/config_default.pl';
-require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
+do 'src/tools/msvc/config_default.pl';
+do 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
Mkvcbuild::mkvcbuild($config);
diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl
index 31e75403f59..e799d900fe0 100644
--- a/src/tools/msvc/pgbison.pl
+++ b/src/tools/msvc/pgbison.pl
@@ -7,7 +7,7 @@ use File::Basename;
# assume we are in the postgres source root
-require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
+do 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
my ($bisonver) = `bison -V`; # grab first line
$bisonver = (split(/\s+/, $bisonver))[3]; # grab version number
@@ -38,7 +38,7 @@ $output =~ s/gram\.c$/pl_gram.c/ if $input =~ /src.pl.plpgsql.src.gram\.y$/;
my $makefile = dirname($input) . "/Makefile";
my ($mf, $make);
-open($mf, $makefile);
+open($mf, '<', $makefile);
local $/ = undef;
$make = <$mf>;
close($mf);
diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl
index fab0efa79fb..67397ba6446 100644
--- a/src/tools/msvc/pgflex.pl
+++ b/src/tools/msvc/pgflex.pl
@@ -10,7 +10,7 @@ $ENV{CYGWIN} = 'nodosfilewarning';
# assume we are in the postgres source root
-require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
+do 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
my ($flexver) = `flex -V`; # grab first line
$flexver = (split(/\s+/, $flexver))[1];
@@ -41,7 +41,7 @@ elsif (!-e $input)
# get flex flags from make file
my $makefile = dirname($input) . "/Makefile";
my ($mf, $make);
-open($mf, $makefile);
+open($mf, '<', $makefile);
local $/ = undef;
$make = <$mf>;
close($mf);
@@ -53,7 +53,7 @@ if ($? == 0)
{
# Check for "%option reentrant" in .l file.
my $lfile;
- open($lfile, $input) || die "opening $input for reading: $!";
+ open($lfile, '<', $input) || die "opening $input for reading: $!";
my $lcode = <$lfile>;
close($lfile);
if ($lcode =~ /\%option\sreentrant/)
@@ -69,18 +69,18 @@ if ($? == 0)
# For reentrant scanners (like the core scanner) we do not
# need to (and must not) change the yywrap definition.
my $cfile;
- open($cfile, $output) || die "opening $output for reading: $!";
+ open($cfile, '<', $output) || die "opening $output for reading: $!";
my $ccode = <$cfile>;
close($cfile);
$ccode =~ s/yywrap\(n\)/yywrap()/;
- open($cfile, ">$output") || die "opening $output for writing: $!";
+ open($cfile, '>', $output) || die "opening $output for writing: $!";
print $cfile $ccode;
close($cfile);
}
if ($flexflags =~ /\s-b\s/)
{
my $lexback = "lex.backup";
- open($lfile, $lexback) || die "opening $lexback for reading: $!";
+ open($lfile, '<', $lexback) || die "opening $lexback for reading: $!";
my $lexbacklines = <$lfile>;
close($lfile);
my $linecount = $lexbacklines =~ tr /\n/\n/;
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index f1b9819cd2e..d9367f8fd5a 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -20,8 +20,8 @@ chdir "../../.." if (-d "../../../src/tools/msvc");
my $topdir = getcwd();
my $tmp_installdir = "$topdir/tmp_install";
-require 'src/tools/msvc/config_default.pl';
-require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
+do 'src/tools/msvc/config_default.pl';
+do 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
# buildenv.pl is for specifying the build environment settings
# it should contain lines like:
@@ -29,7 +29,7 @@ require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
if (-e "src/tools/msvc/buildenv.pl")
{
- require "src/tools/msvc/buildenv.pl";
+ do "src/tools/msvc/buildenv.pl";
}
my $what = shift || "";
@@ -505,8 +505,8 @@ sub upgradecheck
sub fetchRegressOpts
{
my $handle;
- open($handle, "<GNUmakefile")
- || open($handle, "<Makefile")
+ open($handle, '<', "GNUmakefile")
+ || open($handle, '<', "Makefile")
|| die "Could not open Makefile";
local ($/) = undef;
my $m = <$handle>;
@@ -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)
@@ -540,8 +541,8 @@ sub fetchTests
{
my $handle;
- open($handle, "<GNUmakefile")
- || open($handle, "<Makefile")
+ open($handle, '<', "GNUmakefile")
+ || open($handle, '<', "Makefile")
|| die "Could not open Makefile";
local ($/) = undef;
my $m = <$handle>;
diff --git a/src/tools/pginclude/pgcheckdefines b/src/tools/pginclude/pgcheckdefines
index e166efa08da..aa7c9c2fc13 100755
--- a/src/tools/pginclude/pgcheckdefines
+++ b/src/tools/pginclude/pgcheckdefines
@@ -42,25 +42,25 @@ my $MAKE = "make";
#
my (@cfiles, @hfiles);
-open PIPE, "$FIND * -type f -name '*.c' |"
+open my $pipe, '-|', "$FIND * -type f -name '*.c'"
or die "can't fork: $!";
-while (<PIPE>)
+while (<$pipe>)
{
chomp;
push @cfiles, $_;
}
-close PIPE or die "$FIND failed: $!";
+close $pipe or die "$FIND failed: $!";
-open PIPE, "$FIND * -type f -name '*.h' |"
+open $pipe, '-|', "$FIND * -type f -name '*.h'"
or die "can't fork: $!";
-while (<PIPE>)
+while (<$pipe>)
{
chomp;
push @hfiles, $_
unless m|^src/include/port/|
|| m|^src/backend/port/\w+/|;
}
-close PIPE or die "$FIND failed: $!";
+close $pipe or die "$FIND failed: $!";
#
# For each .h file, extract all the symbols it #define's, and add them to
@@ -71,16 +71,16 @@ my %defines;
foreach my $hfile (@hfiles)
{
- open HFILE, $hfile
+ open my $fh, '<', $hfile
or die "can't open $hfile: $!";
- while (<HFILE>)
+ while (<$fh>)
{
if (m/^\s*#\s*define\s+(\w+)/)
{
$defines{$1}{$hfile} = 1;
}
}
- close HFILE;
+ close $fh;
}
#
@@ -124,9 +124,9 @@ foreach my $file (@hfiles, @cfiles)
my ($CPPFLAGS, $CFLAGS, $CFLAGS_SL, $PTHREAD_CFLAGS, $CC);
- open PIPE, "$MAKECMD |"
+ open $pipe, '-|', "$MAKECMD"
or die "can't fork: $!";
- while (<PIPE>)
+ while (<$pipe>)
{
if (m/^CPPFLAGS :?= (.*)/)
{
@@ -166,9 +166,9 @@ foreach my $file (@hfiles, @cfiles)
#
my @includes = ();
my $COMPILE = "$CC $CPPFLAGS $CFLAGS -H -E $fname";
- open PIPE, "$COMPILE 2>&1 >/dev/null |"
+ open $pipe, '-|', "$COMPILE 2>&1 >/dev/null"
or die "can't fork: $!";
- while (<PIPE>)
+ while (<$pipe>)
{
if (m/^\.+ (.*)/)
{
@@ -211,10 +211,10 @@ foreach my $file (@hfiles, @cfiles)
# We assume #ifdef isn't continued across lines, and that defined(foo)
# isn't split across lines either
#
- open FILE, $fname
+ open my $fh, '<', $fname
or die "can't open $file: $!";
my $inif = 0;
- while (<FILE>)
+ while (<$fh>)
{
my $line = $_;
if ($line =~ m/^\s*#\s*ifdef\s+(\w+)/)
@@ -241,7 +241,7 @@ foreach my $file (@hfiles, @cfiles)
}
}
}
- close FILE;
+ close $fh;
chdir $topdir or die "can't chdir to $topdir: $!";
}
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index 0d3859d029d..0f3a1ba69a7 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -159,8 +159,7 @@ sub process_exclude
while (my $line = <$eh>)
{
chomp $line;
- my $rgx;
- eval " \$rgx = qr!$line!;";
+ my $rgx = qr!$line!;
@files = grep { $_ !~ /$rgx/ } @files if $rgx;
}
close($eh);
@@ -435,7 +434,7 @@ sub diff
sub run_build
{
- eval "use LWP::Simple;";
+ eval "use LWP::Simple;"; ## no critic (ProhibitStringyEval);
my $code_base = shift || '.';
my $save_dir = getcwd();
diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl
index dc9173f2343..f973dd950c7 100755
--- a/src/tools/version_stamp.pl
+++ b/src/tools/version_stamp.pl
@@ -80,8 +80,8 @@ my $padnumericversion = sprintf("%d%04d", $majorversion, $numericminor);
# (this also ensures we're in the right directory)
my $aconfver = "";
-open(FILE, "configure.in") || die "could not read configure.in: $!\n";
-while (<FILE>)
+open(my $fh, '<', "configure.in") || die "could not read configure.in: $!\n";
+while (<$fh>)
{
if (
m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/)
@@ -90,7 +90,7 @@ m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/)
last;
}
}
-close(FILE);
+close($fh);
$aconfver ne ""
|| die "could not find autoconf version number in configure.in\n";
diff --git a/src/tools/win32tzlist.pl b/src/tools/win32tzlist.pl
index 6345465b193..0bdcc3610ff 100755
--- a/src/tools/win32tzlist.pl
+++ b/src/tools/win32tzlist.pl
@@ -58,11 +58,11 @@ $basekey->Close();
# Fetch all timezones currently in the file
#
my @file_zones;
-open(TZFILE, "<$tzfile") or die "Could not open $tzfile!\n";
+open(my $tzfh, '<', $tzfile) or die "Could not open $tzfile!\n";
my $t = $/;
undef $/;
-my $pgtz = <TZFILE>;
-close(TZFILE);
+my $pgtz = <$tzfh>;
+close($tzfh);
$/ = $t;
# Attempt to locate and extract the complete win32_tzmap struct