1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Run newly-configured perltidy script on Perl files.

Run on HEAD and 9.2.
This commit is contained in:
Bruce Momjian
2012-07-04 21:47:49 -04:00
parent d7c734841b
commit 042d9ffc28
53 changed files with 3253 additions and 2593 deletions

View File

@ -16,8 +16,7 @@ sub _new
my $good_types = {
lib => 1,
exe => 1,
dll => 1,
};
dll => 1, };
confess("Bad project type: $type\n") unless exists $good_types->{$type};
my $self = {
name => $name,
@ -33,8 +32,7 @@ sub _new
solution => $solution,
disablewarnings => '4018;4244;4273;4102;4090;4267',
disablelinkerwarnings => '',
platform => $solution->{platform},
};
platform => $solution->{platform}, };
bless($self, $classname);
return $self;
@ -50,11 +48,11 @@ sub AddFile
sub AddFiles
{
my $self = shift;
my $dir = shift;
my $dir = shift;
while (my $f = shift)
{
$self->{files}->{$dir . "\\" . $f} = 1;
$self->{files}->{ $dir . "\\" . $f } = 1;
}
}
@ -63,7 +61,7 @@ sub ReplaceFile
my ($self, $filename, $newname) = @_;
my $re = "\\\\$filename\$";
foreach my $file (keys %{$self->{files}})
foreach my $file (keys %{ $self->{files} })
{
# Match complete filename
@ -89,9 +87,9 @@ sub ReplaceFile
sub RemoveFile
{
my ($self, $filename) = @_;
my $orig = scalar keys %{$self->{files}};
my $orig = scalar keys %{ $self->{files} };
delete $self->{files}->{$filename};
if ($orig > scalar keys %{$self->{files}})
if ($orig > scalar keys %{ $self->{files} })
{
return;
}
@ -101,7 +99,7 @@ sub RemoveFile
sub RelocateFiles
{
my ($self, $targetdir, $proc) = @_;
foreach my $f (keys %{$self->{files}})
foreach my $f (keys %{ $self->{files} })
{
my $r = &$proc($f);
if ($r)
@ -118,8 +116,9 @@ sub AddReference
while (my $ref = shift)
{
push @{$self->{references}},$ref;
$self->AddLibrary("__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib");
push @{ $self->{references} }, $ref;
$self->AddLibrary(
"__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib");
}
}
@ -132,10 +131,10 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
push @{$self->{libraries}}, $lib;
push @{ $self->{libraries} }, $lib;
if ($dbgsuffix)
{
push @{$self->{suffixlib}}, $lib;
push @{ $self->{suffixlib} }, $lib;
}
}
@ -170,8 +169,8 @@ sub FullExportDLL
my ($self, $libname) = @_;
$self->{builddef} = 1;
$self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def";
$self->{implib} = "__CFGNAME__\\$self->{name}\\$libname";
$self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def";
$self->{implib} = "__CFGNAME__\\$self->{name}\\$libname";
}
sub UseDef
@ -188,8 +187,8 @@ sub AddDir
my $t = $/;
undef $/;
open($MF,"$reldir\\Makefile")
|| open($MF,"$reldir\\GNUMakefile")
open($MF, "$reldir\\Makefile")
|| open($MF, "$reldir\\GNUMakefile")
|| croak "Could not open $reldir\\Makefile\n";
my $mf = <$MF>;
close($MF);
@ -197,11 +196,11 @@ sub AddDir
$mf =~ s{\\\s*[\r\n]+}{}mg;
if ($mf =~ m{^(?:SUB)?DIRS[^=]*=\s*(.*)$}mg)
{
foreach my $subdir (split /\s+/,$1)
foreach my $subdir (split /\s+/, $1)
{
next
if $subdir eq "\$(top_builddir)/src/timezone"
; #special case for non-standard include
; #special case for non-standard include
next
if $reldir . "\\" . $subdir eq "src\\backend\\port\\darwin";
@ -210,13 +209,13 @@ sub AddDir
}
while ($mf =~ m{^(?:EXTRA_)?OBJS[^=]*=\s*(.*)$}m)
{
my $s = $1;
my $s = $1;
my $filter_re = qr{\$\(filter ([^,]+),\s+\$\(([^\)]+)\)\)};
while ($s =~ /$filter_re/)
{
# Process $(filter a b c, $(VAR)) expressions
my $list = $1;
my $list = $1;
my $filter = $2;
$list =~ s/\.o/\.c/g;
my @pieces = split /\s+/, $list;
@ -239,12 +238,13 @@ sub AddDir
}
$s =~ s/$filter_re/$matches/;
}
foreach my $f (split /\s+/,$s)
foreach my $f (split /\s+/, $s)
{
next if $f =~ /^\s*$/;
next if $f eq "\\";
next if $f =~ /\/SUBSYS.o$/;
$f =~ s/,$//; # Remove trailing comma that can show up from filter stuff
$f =~ s/,$//
; # Remove trailing comma that can show up from filter stuff
next unless $f =~ /.*\.o$/;
$f =~ s/\.o$/\.c/;
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
@ -264,14 +264,15 @@ sub AddDir
# Match rules that pull in source files from different directories, eg
# pgstrcasecmp.c rint.c snprintf.c: % : $(top_srcdir)/src/port/%
my $replace_re = qr{^([^:\n\$]+\.c)\s*:\s*(?:%\s*: )?\$(\([^\)]+\))\/(.*)\/[^\/]+$}m;
my $replace_re =
qr{^([^:\n\$]+\.c)\s*:\s*(?:%\s*: )?\$(\([^\)]+\))\/(.*)\/[^\/]+$}m;
while ($mf =~ m{$replace_re}m)
{
my $match = $1;
my $top = $2;
my $match = $1;
my $top = $2;
my $target = $3;
$target =~ s{/}{\\}g;
my @pieces = split /\s+/,$match;
my @pieces = split /\s+/, $match;
foreach my $fn (@pieces)
{
if ($top eq "(top_srcdir)")
@ -296,7 +297,7 @@ sub AddDir
my $desc = $1;
my $ico;
if ($mf =~ /^PGAPPICON\s*=\s*(.*)$/m) { $ico = $1; }
$self->AddResourceFile($reldir,$desc,$ico);
$self->AddResourceFile($reldir, $desc, $ico);
}
$/ = $t;
}
@ -305,15 +306,18 @@ sub AddResourceFile
{
my ($self, $dir, $desc, $ico) = @_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
my $d = ($year - 100) . "$yday";
if (Solution::IsNewer("$dir\\win32ver.rc",'src\port\win32ver.rc'))
if (Solution::IsNewer("$dir\\win32ver.rc", 'src\port\win32ver.rc'))
{
print "Generating win32ver.rc for $dir\n";
open(I,'src\port\win32ver.rc') || confess "Could not open win32ver.rc";
open(O,">$dir\\win32ver.rc") || confess "Could not write win32ver.rc";
my $icostr = $ico?"IDI_ICON ICON \"src/port/$ico.ico\"":"";
open(I, 'src\port\win32ver.rc')
|| confess "Could not open win32ver.rc";
open(O, ">$dir\\win32ver.rc")
|| confess "Could not write win32ver.rc";
my $icostr = $ico ? "IDI_ICON ICON \"src/port/$ico.ico\"" : "";
while (<I>)
{
s/FILEDESC/"$desc"/gm;
@ -335,7 +339,8 @@ sub DisableLinkerWarnings
{
my ($self, $warnings) = @_;
$self->{disablelinkerwarnings} .= ',' unless ($self->{disablelinkerwarnings} eq '');
$self->{disablelinkerwarnings} .= ','
unless ($self->{disablelinkerwarnings} eq '');
$self->{disablelinkerwarnings} .= $warnings;
}
@ -343,20 +348,21 @@ sub Save
{
my ($self) = @_;
# If doing DLL and haven't specified a DEF file, do a full export of all symbols
# in the project.
# If doing DLL and haven't specified a DEF file, do a full export of all symbols
# in the project.
if ($self->{type} eq "dll" && !$self->{def})
{
$self->FullExportDLL($self->{name} . ".lib");
}
# Warning 4197 is about double exporting, disable this per
# http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99193
# Warning 4197 is about double exporting, disable this per
# http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99193
$self->DisableLinkerWarnings('4197') if ($self->{platform} eq 'x64');
# Dump the project
open(F, ">$self->{name}$self->{filenameExtension}")
|| croak("Could not write to $self->{name}$self->{filenameExtension}\n");
|| croak(
"Could not write to $self->{name}$self->{filenameExtension}\n");
$self->WriteHeader(*F);
$self->WriteFiles(*F);
$self->Footer(*F);
@ -366,12 +372,12 @@ sub Save
sub GetAdditionalLinkerDependencies
{
my ($self, $cfgname, $seperator) = @_;
my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd";
my $libcfg = (uc $cfgname eq "RELEASE") ? "MD" : "MDd";
my $libs = '';
foreach my $lib (@{$self->{libraries}})
foreach my $lib (@{ $self->{libraries} })
{
my $xlib = $lib;
foreach my $slib (@{$self->{suffixlib}})
foreach my $slib (@{ $self->{suffixlib} })
{
if ($slib eq $lib)
{