mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-01 19:45:33 +08:00
Use 'use strict' in all Perl programs
This commit is contained in:
parent
175ff6598e
commit
933b46644c
@ -1,20 +1,23 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
$integer = '[+-]?[0-9]+';
|
|
||||||
$real = '[+-]?[0-9]+\.[0-9]+';
|
|
||||||
|
|
||||||
$RANGE = '(\.\.)(\.)?';
|
use strict;
|
||||||
$PLUMIN = q(\'\+\-\');
|
|
||||||
$FLOAT = "(($integer)|($real))([eE]($integer))?";
|
|
||||||
$EXTENSION = '<|>|~';
|
|
||||||
|
|
||||||
$boundary = "($EXTENSION)?$FLOAT";
|
my $integer = '[+-]?[0-9]+';
|
||||||
$deviation = $FLOAT;
|
my $real = '[+-]?[0-9]+\.[0-9]+';
|
||||||
|
|
||||||
$rule_1 = $boundary . $PLUMIN . $deviation;
|
my $RANGE = '(\.\.)(\.)?';
|
||||||
$rule_2 = $boundary . $RANGE . $boundary;
|
my $PLUMIN = q(\'\+\-\');
|
||||||
$rule_3 = $boundary . $RANGE;
|
my $FLOAT = "(($integer)|($real))([eE]($integer))?";
|
||||||
$rule_4 = $RANGE . $boundary;
|
my $EXTENSION = '<|>|~';
|
||||||
$rule_5 = $boundary;
|
|
||||||
|
my $boundary = "($EXTENSION)?$FLOAT";
|
||||||
|
my $deviation = $FLOAT;
|
||||||
|
|
||||||
|
my $rule_1 = $boundary . $PLUMIN . $deviation;
|
||||||
|
my $rule_2 = $boundary . $RANGE . $boundary;
|
||||||
|
my $rule_3 = $boundary . $RANGE;
|
||||||
|
my $rule_4 = $RANGE . $boundary;
|
||||||
|
my $rule_5 = $boundary;
|
||||||
|
|
||||||
|
|
||||||
print "$rule_5\n";
|
print "$rule_5\n";
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
# this script will sort any table with the segment data type in its last column
|
# this script will sort any table with the segment data type in its last column
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my @rows;
|
||||||
|
|
||||||
while (<>)
|
while (<>)
|
||||||
{
|
{
|
||||||
chomp;
|
chomp;
|
||||||
@ -10,11 +14,11 @@ while (<>)
|
|||||||
|
|
||||||
foreach (
|
foreach (
|
||||||
sort {
|
sort {
|
||||||
@ar = split("\t", $a);
|
my @ar = split("\t", $a);
|
||||||
$valA = pop @ar;
|
my $valA = pop @ar;
|
||||||
$valA =~ s/[~<> ]+//g;
|
$valA =~ s/[~<> ]+//g;
|
||||||
@ar = split("\t", $b);
|
@ar = split("\t", $b);
|
||||||
$valB = pop @ar;
|
my $valB = pop @ar;
|
||||||
$valB =~ s/[~<> ]+//g;
|
$valB =~ s/[~<> ]+//g;
|
||||||
$valA <=> $valB
|
$valA <=> $valB
|
||||||
} @rows)
|
} @rows)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
# doc/src/sgml/mk_feature_tables.pl
|
# doc/src/sgml/mk_feature_tables.pl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
my $yesno = $ARGV[0];
|
my $yesno = $ARGV[0];
|
||||||
|
|
||||||
open PACK, $ARGV[1] or die;
|
open PACK, $ARGV[1] or die;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# src/pl/plperl/plc_perlboot.pl
|
# src/pl/plperl/plc_perlboot.pl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
use 5.008001;
|
use 5.008001;
|
||||||
use vars qw(%_SHARED $_TD);
|
use vars qw(%_SHARED $_TD);
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#! /usr/bin/perl
|
#! /usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
use locale;
|
use locale;
|
||||||
|
|
||||||
open(INFILE, "<$ARGV[0]");
|
open(INFILE, "<$ARGV[0]");
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
# src/tools/msvc/build.pl
|
# src/tools/msvc/build.pl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -68,6 +70,6 @@ else
|
|||||||
|
|
||||||
# report status
|
# report status
|
||||||
|
|
||||||
$status = $? >> 8;
|
my $status = $? >> 8;
|
||||||
|
|
||||||
exit $status;
|
exit $status;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
my @def;
|
|
||||||
|
|
||||||
use warnings;
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use warnings;
|
||||||
use 5.8.0;
|
use 5.8.0;
|
||||||
use File::Spec::Functions qw(splitpath catpath);
|
use File::Spec::Functions qw(splitpath catpath);
|
||||||
use List::Util qw(max);
|
use List::Util qw(max);
|
||||||
|
|
||||||
|
my @def;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Script that generates a .DEF file for all objects in a directory
|
# Script that generates a .DEF file for all objects in a directory
|
||||||
#
|
#
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
# src/tools/msvc/pgflex.pl
|
# src/tools/msvc/pgflex.pl
|
||||||
|
|
||||||
# silence flex bleatings about file path style
|
|
||||||
$ENV{CYGWIN} = 'nodosfilewarning';
|
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
|
||||||
|
# silence flex bleatings about file path style
|
||||||
|
$ENV{CYGWIN} = 'nodosfilewarning';
|
||||||
|
|
||||||
# assume we are in the postgres source root
|
# assume we are in the postgres source root
|
||||||
|
|
||||||
require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
|
require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
|
||||||
|
@ -20,14 +20,16 @@
|
|||||||
# src/tools/pginclude/pgcheckdefines
|
# src/tools/pginclude/pgcheckdefines
|
||||||
#
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
use Cwd;
|
use Cwd;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
|
||||||
$topdir = cwd();
|
my $topdir = cwd();
|
||||||
|
|
||||||
# Programs to use
|
# Programs to use
|
||||||
$FIND = "find";
|
my $FIND = "find";
|
||||||
$MAKE = "make";
|
my $MAKE = "make";
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build arrays of all the .c and .h files in the tree
|
# Build arrays of all the .c and .h files in the tree
|
||||||
@ -38,6 +40,8 @@ $MAKE = "make";
|
|||||||
# Including these .h files would clutter the list of define'd symbols and
|
# Including these .h files would clutter the list of define'd symbols and
|
||||||
# cause a lot of false-positive results.
|
# cause a lot of false-positive results.
|
||||||
#
|
#
|
||||||
|
my (@cfiles, @hfiles);
|
||||||
|
|
||||||
open PIPE, "$FIND * -type f -name '*.c' |"
|
open PIPE, "$FIND * -type f -name '*.c' |"
|
||||||
or die "can't fork: $!";
|
or die "can't fork: $!";
|
||||||
while (<PIPE>)
|
while (<PIPE>)
|
||||||
@ -63,7 +67,9 @@ close PIPE or die "$FIND failed: $!";
|
|||||||
# a hash table. To cover the possibility of multiple .h files defining
|
# a hash table. To cover the possibility of multiple .h files defining
|
||||||
# the same symbol, we make each hash entry a hash of filenames.
|
# the same symbol, we make each hash entry a hash of filenames.
|
||||||
#
|
#
|
||||||
foreach $hfile (@hfiles)
|
my %defines;
|
||||||
|
|
||||||
|
foreach my $hfile (@hfiles)
|
||||||
{
|
{
|
||||||
open HFILE, $hfile
|
open HFILE, $hfile
|
||||||
or die "can't open $hfile: $!";
|
or die "can't open $hfile: $!";
|
||||||
@ -82,9 +88,9 @@ foreach $hfile (@hfiles)
|
|||||||
# files it #include's. Then extract all the symbols it tests for defined-ness,
|
# files it #include's. Then extract all the symbols it tests for defined-ness,
|
||||||
# and check each one against the previously built hashtable.
|
# and check each one against the previously built hashtable.
|
||||||
#
|
#
|
||||||
foreach $file (@hfiles, @cfiles)
|
foreach my $file (@hfiles, @cfiles)
|
||||||
{
|
{
|
||||||
($fname, $fpath) = fileparse($file);
|
my ($fname, $fpath) = fileparse($file);
|
||||||
chdir $fpath or die "can't chdir to $fpath: $!";
|
chdir $fpath or die "can't chdir to $fpath: $!";
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -96,16 +102,18 @@ foreach $file (@hfiles, @cfiles)
|
|||||||
# hence printing multiple definitions --- we keep the last one, which
|
# hence printing multiple definitions --- we keep the last one, which
|
||||||
# should come from the current Makefile.
|
# should come from the current Makefile.
|
||||||
#
|
#
|
||||||
|
my $MAKECMD;
|
||||||
|
|
||||||
if (-f "Makefile" || -f "GNUmakefile")
|
if (-f "Makefile" || -f "GNUmakefile")
|
||||||
{
|
{
|
||||||
$MAKECMD = "$MAKE -qp";
|
$MAKECMD = "$MAKE -qp";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$subdir = $fpath;
|
my $subdir = $fpath;
|
||||||
chop $subdir;
|
chop $subdir;
|
||||||
$top_builddir = "..";
|
my $top_builddir = "..";
|
||||||
$tmp = $fpath;
|
my $tmp = $fpath;
|
||||||
while (($tmp = dirname($tmp)) ne '.')
|
while (($tmp = dirname($tmp)) ne '.')
|
||||||
{
|
{
|
||||||
$top_builddir = $top_builddir . "/..";
|
$top_builddir = $top_builddir . "/..";
|
||||||
@ -113,6 +121,9 @@ foreach $file (@hfiles, @cfiles)
|
|||||||
$MAKECMD =
|
$MAKECMD =
|
||||||
"$MAKE -qp 'subdir=$subdir' 'top_builddir=$top_builddir' -f '$top_builddir/src/Makefile.global'";
|
"$MAKE -qp 'subdir=$subdir' 'top_builddir=$top_builddir' -f '$top_builddir/src/Makefile.global'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my ($CPPFLAGS, $CFLAGS, $CFLAGS_SL, $PTHREAD_CFLAGS, $CC);
|
||||||
|
|
||||||
open PIPE, "$MAKECMD |"
|
open PIPE, "$MAKECMD |"
|
||||||
or die "can't fork: $!";
|
or die "can't fork: $!";
|
||||||
while (<PIPE>)
|
while (<PIPE>)
|
||||||
@ -153,15 +164,15 @@ foreach $file (@hfiles, @cfiles)
|
|||||||
# "gcc -H" reports inclusions on stderr as "... filename" where the
|
# "gcc -H" reports inclusions on stderr as "... filename" where the
|
||||||
# number of dots varies according to nesting depth.
|
# number of dots varies according to nesting depth.
|
||||||
#
|
#
|
||||||
@includes = ();
|
my @includes = ();
|
||||||
$COMPILE = "$CC $CPPFLAGS $CFLAGS -H -E $fname";
|
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: $!";
|
or die "can't fork: $!";
|
||||||
while (<PIPE>)
|
while (<PIPE>)
|
||||||
{
|
{
|
||||||
if (m/^\.+ (.*)/)
|
if (m/^\.+ (.*)/)
|
||||||
{
|
{
|
||||||
$include = $1;
|
my $include = $1;
|
||||||
|
|
||||||
# Ignore system headers (absolute paths); but complain if a
|
# Ignore system headers (absolute paths); but complain if a
|
||||||
# .c file includes a system header before any PG header.
|
# .c file includes a system header before any PG header.
|
||||||
@ -176,7 +187,7 @@ foreach $file (@hfiles, @cfiles)
|
|||||||
$include =~ s|^\./||;
|
$include =~ s|^\./||;
|
||||||
|
|
||||||
# Make path relative to top of tree
|
# Make path relative to top of tree
|
||||||
$ipath = $fpath;
|
my $ipath = $fpath;
|
||||||
while ($include =~ s|^\.\./||)
|
while ($include =~ s|^\.\./||)
|
||||||
{
|
{
|
||||||
$ipath = dirname($ipath) . "/";
|
$ipath = dirname($ipath) . "/";
|
||||||
@ -202,19 +213,17 @@ foreach $file (@hfiles, @cfiles)
|
|||||||
#
|
#
|
||||||
open FILE, $fname
|
open FILE, $fname
|
||||||
or die "can't open $file: $!";
|
or die "can't open $file: $!";
|
||||||
$inif = 0;
|
my $inif = 0;
|
||||||
while (<FILE>)
|
while (<FILE>)
|
||||||
{
|
{
|
||||||
$line = $_;
|
my $line = $_;
|
||||||
if ($line =~ m/^\s*#\s*ifdef\s+(\w+)/)
|
if ($line =~ m/^\s*#\s*ifdef\s+(\w+)/)
|
||||||
{
|
{
|
||||||
$symbol = $1;
|
checkit($file, $1, @includes);
|
||||||
&checkit;
|
|
||||||
}
|
}
|
||||||
if ($line =~ m/^\s*#\s*ifndef\s+(\w+)/)
|
if ($line =~ m/^\s*#\s*ifndef\s+(\w+)/)
|
||||||
{
|
{
|
||||||
$symbol = $1;
|
checkit($file, $1, @includes);
|
||||||
&checkit;
|
|
||||||
}
|
}
|
||||||
if ($line =~ m/^\s*#\s*if\s+/)
|
if ($line =~ m/^\s*#\s*if\s+/)
|
||||||
{
|
{
|
||||||
@ -224,8 +233,7 @@ foreach $file (@hfiles, @cfiles)
|
|||||||
{
|
{
|
||||||
while ($line =~ s/\bdefined(\s+|\s*\(\s*)(\w+)//)
|
while ($line =~ s/\bdefined(\s+|\s*\(\s*)(\w+)//)
|
||||||
{
|
{
|
||||||
$symbol = $2;
|
checkit($file, $2, @includes);
|
||||||
&checkit;
|
|
||||||
}
|
}
|
||||||
if (!($line =~ m/\\$/))
|
if (!($line =~ m/\\$/))
|
||||||
{
|
{
|
||||||
@ -243,6 +251,7 @@ exit 0;
|
|||||||
# Check an is-defined reference
|
# Check an is-defined reference
|
||||||
sub checkit
|
sub checkit
|
||||||
{
|
{
|
||||||
|
my ($file, $symbol, @includes) = @_;
|
||||||
|
|
||||||
# Ignore if symbol isn't defined in any PG include files
|
# Ignore if symbol isn't defined in any PG include files
|
||||||
if (!defined $defines{$symbol})
|
if (!defined $defines{$symbol})
|
||||||
@ -258,10 +267,10 @@ sub checkit
|
|||||||
# occur after the use of the symbol. Given our normal file layout,
|
# occur after the use of the symbol. Given our normal file layout,
|
||||||
# however, the risk is minimal.
|
# however, the risk is minimal.
|
||||||
#
|
#
|
||||||
foreach $deffile (keys %{ $defines{$symbol} })
|
foreach my $deffile (keys %{ $defines{$symbol} })
|
||||||
{
|
{
|
||||||
return if $deffile eq $file;
|
return if $deffile eq $file;
|
||||||
foreach $reffile (@includes)
|
foreach my $reffile (@includes)
|
||||||
{
|
{
|
||||||
return if $deffile eq $reffile;
|
return if $deffile eq $reffile;
|
||||||
}
|
}
|
||||||
@ -273,7 +282,7 @@ sub checkit
|
|||||||
#
|
#
|
||||||
if ($file =~ m/\.h$/)
|
if ($file =~ m/\.h$/)
|
||||||
{
|
{
|
||||||
foreach $deffile (keys %{ $defines{$symbol} })
|
foreach my $deffile (keys %{ $defines{$symbol} })
|
||||||
{
|
{
|
||||||
return if $deffile eq 'src/include/c.h';
|
return if $deffile eq 'src/include/c.h';
|
||||||
return if $deffile eq 'src/include/postgres.h';
|
return if $deffile eq 'src/include/postgres.h';
|
||||||
@ -284,7 +293,7 @@ sub checkit
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@places = keys %{ $defines{$symbol} };
|
my @places = keys %{ $defines{$symbol} };
|
||||||
print "$file references $symbol, defined in @places\n";
|
print "$file references $symbol, defined in @places\n";
|
||||||
|
|
||||||
# print "includes: @includes\n";
|
# print "includes: @includes\n";
|
||||||
|
@ -20,14 +20,18 @@
|
|||||||
# "devel", "alphaN", "betaN", "rcN".
|
# "devel", "alphaN", "betaN", "rcN".
|
||||||
#
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
# Major version is hard-wired into the script. We update it when we branch
|
# Major version is hard-wired into the script. We update it when we branch
|
||||||
# a new development version.
|
# a new development version.
|
||||||
$majorversion = 10;
|
my $majorversion = 10;
|
||||||
|
|
||||||
# Validate argument and compute derived variables
|
# Validate argument and compute derived variables
|
||||||
$minor = shift;
|
my $minor = shift;
|
||||||
defined($minor) || die "$0: missing required argument: minor-version\n";
|
defined($minor) || die "$0: missing required argument: minor-version\n";
|
||||||
|
|
||||||
|
my ($dotneeded, $numericminor);
|
||||||
|
|
||||||
if ($minor =~ m/^\d+$/)
|
if ($minor =~ m/^\d+$/)
|
||||||
{
|
{
|
||||||
$dotneeded = 1;
|
$dotneeded = 1;
|
||||||
@ -58,6 +62,8 @@ else
|
|||||||
die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
|
die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $fullversion;
|
||||||
|
|
||||||
# Create various required forms of the version number
|
# Create various required forms of the version number
|
||||||
if ($dotneeded)
|
if ($dotneeded)
|
||||||
{
|
{
|
||||||
@ -67,13 +73,13 @@ else
|
|||||||
{
|
{
|
||||||
$fullversion = $majorversion . $minor;
|
$fullversion = $majorversion . $minor;
|
||||||
}
|
}
|
||||||
$numericversion = $majorversion . "." . $numericminor;
|
my $numericversion = $majorversion . "." . $numericminor;
|
||||||
$padnumericversion = sprintf("%d%04d", $majorversion, $numericminor);
|
my $padnumericversion = sprintf("%d%04d", $majorversion, $numericminor);
|
||||||
|
|
||||||
# Get the autoconf version number for eventual nag message
|
# Get the autoconf version number for eventual nag message
|
||||||
# (this also ensures we're in the right directory)
|
# (this also ensures we're in the right directory)
|
||||||
|
|
||||||
$aconfver = "";
|
my $aconfver = "";
|
||||||
open(FILE, "configure.in") || die "could not read configure.in: $!\n";
|
open(FILE, "configure.in") || die "could not read configure.in: $!\n";
|
||||||
while (<FILE>)
|
while (<FILE>)
|
||||||
{
|
{
|
||||||
@ -90,7 +96,7 @@ $aconfver ne ""
|
|||||||
|
|
||||||
# Update configure.in and other files that contain version numbers
|
# Update configure.in and other files that contain version numbers
|
||||||
|
|
||||||
$fixedfiles = "";
|
my $fixedfiles = "";
|
||||||
|
|
||||||
sed_file("configure.in",
|
sed_file("configure.in",
|
||||||
"-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
|
"-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
|
||||||
|
Loading…
Reference in New Issue
Block a user