Commit eee22892 authored by Magnus Hagander's avatar Magnus Hagander

Make a run with perltidy to format the code. Per request from Andrew Dunstan.

parent 576027bb
This diff is collapsed.
...@@ -63,3 +63,11 @@ Get from http://www.zlib.net ...@@ -63,3 +63,11 @@ Get from http://www.zlib.net
libxml2 and libxslt - required for XML support libxml2 and libxslt - required for XML support
Get from http://www.zlatkovic.com/pub/libxml or build from source from Get from http://www.zlatkovic.com/pub/libxml or build from source from
http://xmlsoft.org. Note that libxml2 requires iconv. http://xmlsoft.org. Note that libxml2 requires iconv.
Code indention
--------------
If the perl code is modified, use perltidy on it since pgindent won't
touch perl code. Use the following commandline:
perltidy -b -bl -nsfs -naws -l=100 *.pl *.pm
This diff is collapsed.
...@@ -3,20 +3,20 @@ use strict; ...@@ -3,20 +3,20 @@ use strict;
use warnings; use warnings;
our $config = { our $config = {
asserts=>1, # --enable-cassert asserts=>1, # --enable-cassert
integer_datetimes=>1, # --enable-integer-datetimes integer_datetimes=>1, # --enable-integer-datetimes
nls=>undef, # --enable-nls=<path> nls=>undef, # --enable-nls=<path>
tcl=>'c:\tcl', # --with-tls=<path> tcl=>'c:\tcl', # --with-tls=<path>
perl=>'c:\perl', # --with-perl perl=>'c:\perl', # --with-perl
python=>'c:\python24', # --with-python=<path> python=>'c:\python24', # --with-python=<path>
krb5=>'c:\prog\pgsql\depend\krb5', # --with-krb5=<path> krb5=>'c:\prog\pgsql\depend\krb5', # --with-krb5=<path>
ldap=>1, # --with-ldap ldap=>1, # --with-ldap
openssl=>'c:\openssl', # --with-ssl=<path> openssl=>'c:\openssl', # --with-ssl=<path>
pthread=>'c:\prog\pgsql\depend\pthread', pthread=>'c:\prog\pgsql\depend\pthread',
xml=>'c:\prog\pgsql\depend\libxml2', xml=>'c:\prog\pgsql\depend\libxml2',
xslt=>'c:\prog\pgsql\depend\libxslt', xslt=>'c:\prog\pgsql\depend\libxslt',
iconv=>'c:\prog\pgsql\depend\iconv', iconv=>'c:\prog\pgsql\depend\iconv',
zlib=>'c:\prog\pgsql\depend\zlib'# --with-zlib=<path> zlib=>'c:\prog\pgsql\depend\zlib'# --with-zlib=<path>
}; };
1; 1;
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/tools/msvc/genbki.pl,v 1.4 2007/02/19 14:05:42 mha Exp $ # $PostgreSQL: pgsql/src/tools/msvc/genbki.pl,v 1.5 2007/03/12 19:10:50 mha Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -25,24 +25,28 @@ $version =~ /^(\d+\.\d+)/ || die "Bad format verison $version\n"; ...@@ -25,24 +25,28 @@ $version =~ /^(\d+\.\d+)/ || die "Bad format verison $version\n";
my $majorversion = $1; my $majorversion = $1;
my $pgext = read_file("src/include/pg_config_manual.h"); my $pgext = read_file("src/include/pg_config_manual.h");
$pgext =~ /^#define\s+NAMEDATALEN\s+(\d+)$/mg || die "Could not read NAMEDATALEN from pg_config_manual.h\n"; $pgext =~ /^#define\s+NAMEDATALEN\s+(\d+)$/mg
|| die "Could not read NAMEDATALEN from pg_config_manual.h\n";
my $namedatalen = $1; my $namedatalen = $1;
my $pgauthid = read_file("src/include/catalog/pg_authid.h"); my $pgauthid = read_file("src/include/catalog/pg_authid.h");
$pgauthid =~ /^#define\s+BOOTSTRAP_SUPERUSERID\s+(\d+)$/mg || die "Could not read BOOTSTRAUP_SUPERUSERID from pg_authid.h\n"; $pgauthid =~ /^#define\s+BOOTSTRAP_SUPERUSERID\s+(\d+)$/mg
|| die "Could not read BOOTSTRAUP_SUPERUSERID from pg_authid.h\n";
my $bootstrapsuperuserid = $1; my $bootstrapsuperuserid = $1;
my $pgnamespace = read_file("src/include/catalog/pg_namespace.h"); my $pgnamespace = read_file("src/include/catalog/pg_namespace.h");
$pgnamespace =~ /^#define\s+PG_CATALOG_NAMESPACE\s+(\d+)$/mg || die "Could not read PG_CATALOG_NAMESPACE from pg_namespace.h\n"; $pgnamespace =~ /^#define\s+PG_CATALOG_NAMESPACE\s+(\d+)$/mg
|| die "Could not read PG_CATALOG_NAMESPACE from pg_namespace.h\n";
my $pgcatalognamespace = $1; my $pgcatalognamespace = $1;
my $indata = ""; my $indata = "";
while (my $f = shift) { while (my $f = shift)
$indata .= read_file($f); {
$indata .= "\n"; $indata .= read_file($f);
$indata .= "\n";
} }
# Strip C comments, from perl FAQ 4.27 # Strip C comments, from perl FAQ 4.27
$indata =~ s{/\*.*?\*/}{}gs; $indata =~ s{/\*.*?\*/}{}gs;
$indata =~ s{;\s*$}{}gm; $indata =~ s{;\s*$}{}gm;
...@@ -73,112 +77,143 @@ my $nc = 0; ...@@ -73,112 +77,143 @@ my $nc = 0;
my $inside = 0; my $inside = 0;
my @attr; my @attr;
my @types; my @types;
foreach my $line (split /\n/, $indata) {
if ($line =~ /^DATA\((.*)\)$/m) { foreach my $line (split /\n/, $indata)
my $data = $1; {
my @fields = split /\s+/,$data; if ($line =~ /^DATA\((.*)\)$/m)
if ($#fields >=4 && $fields[0] eq "insert" && $fields[1] eq "OID" && $fields[2] eq "=") { {
$oid = $fields[3]; my $data = $1;
} my @fields = split /\s+/,$data;
else { if ($#fields >=4 && $fields[0] eq "insert" && $fields[1] eq "OID" && $fields[2] eq "=")
$oid = 0; {
} $oid = $fields[3];
$data =~ s/\s{2,}/ /g; }
$bki .= $data . "\n"; else
} {
elsif ($line =~ /^DESCR\("(.*)"\)$/m){ $oid = 0;
if ($oid != 0) { }
$desc .= sprintf("%d\t%s\t0\t%s\n", $oid, $catalog, $1); $data =~ s/\s{2,}/ /g;
} $bki .= $data . "\n";
} }
elsif ($line =~ /^SHDESCR\("(.*)"\)$/m) { elsif ($line =~ /^DESCR\("(.*)"\)$/m)
if ($oid != 0) { {
$shdesc .= sprintf("%d\t%s\t%s\n", $oid, $catalog, $1); if ($oid != 0)
} {
} $desc .= sprintf("%d\t%s\t0\t%s\n", $oid, $catalog, $1);
elsif ($line =~ /^DECLARE_(UNIQUE_)?INDEX\((.*)\)$/m) { }
if ($reln_open) { }
$bki .= "close $catalog\n"; elsif ($line =~ /^SHDESCR\("(.*)"\)$/m)
$reln_open = 0; {
} if ($oid != 0)
my $u = $1?" unique":""; {
my @fields = split /,/,$2,3; $shdesc .= sprintf("%d\t%s\t%s\n", $oid, $catalog, $1);
$fields[2] =~ s/\s{2,}/ /g; }
$bki .= "declare$u index $fields[0] $fields[1] $fields[2]\n"; }
} elsif ($line =~ /^DECLARE_(UNIQUE_)?INDEX\((.*)\)$/m)
elsif ($line =~ /^DECLARE_TOAST\((.*)\)$/m) { {
if ($reln_open) { if ($reln_open)
$bki .= "close $catalog\n"; {
$reln_open = 0; $bki .= "close $catalog\n";
} $reln_open = 0;
my @fields = split /,/,$1; }
my $u = $1?" unique":"";
my @fields = split /,/,$2,3;
$fields[2] =~ s/\s{2,}/ /g;
$bki .= "declare$u index $fields[0] $fields[1] $fields[2]\n";
}
elsif ($line =~ /^DECLARE_TOAST\((.*)\)$/m)
{
if ($reln_open)
{
$bki .= "close $catalog\n";
$reln_open = 0;
}
my @fields = split /,/,$1;
$bki .= "declare toast $fields[1] $fields[2] on $fields[0]\n"; $bki .= "declare toast $fields[1] $fields[2] on $fields[0]\n";
} }
elsif ($line =~ /^BUILD_INDICES/) { elsif ($line =~ /^BUILD_INDICES/)
$bki .= "build indices\n"; {
} $bki .= "build indices\n";
elsif ($line =~ /^CATALOG\((.*)\)(.*)$/m) { }
if ($reln_open) { elsif ($line =~ /^CATALOG\((.*)\)(.*)$/m)
$bki .= "close $catalog\n"; {
$reln_open = 0; if ($reln_open)
} {
my $rest = $2; $bki .= "close $catalog\n";
my @fields = split /,/,$1; $reln_open = 0;
$catalog = $fields[0]; }
$oid = $fields[1]; my $rest = $2;
$bootstrap=$shared_relation=$without_oids=""; my @fields = split /,/,$1;
if ($rest =~ /BKI_BOOTSTRAP/) { $catalog = $fields[0];
$bootstrap = "bootstrap "; $oid = $fields[1];
} $bootstrap=$shared_relation=$without_oids="";
if ($rest =~ /BKI_SHARED_RELATION/) { if ($rest =~ /BKI_BOOTSTRAP/)
$shared_relation = "shared_relation "; {
} $bootstrap = "bootstrap ";
if ($rest =~ /BKI_WITHOUT_OIDS/) { }
$without_oids = "without_oids "; if ($rest =~ /BKI_SHARED_RELATION/)
} {
$nc++; $shared_relation = "shared_relation ";
$inside = 1; }
next; if ($rest =~ /BKI_WITHOUT_OIDS/)
} {
if ($inside==1) { $without_oids = "without_oids ";
next if ($line =~ /{/); }
if ($line =~ /}/) { $nc++;
# Last line $inside = 1;
$bki .= "create $bootstrap$shared_relation$without_oids$catalog $oid\n (\n"; next;
my $first = 1; }
for (my $i = 0; $i <= $#attr; $i++) { if ($inside==1)
if ($first == 1) { {
$first = 0; next if ($line =~ /{/);
} else { if ($line =~ /}/)
$bki .= ",\n"; {
}
$bki .= " " . $attr[$i] . " = " . $types[$i]; # Last line
} $bki .= "create $bootstrap$shared_relation$without_oids$catalog $oid\n (\n";
$bki .= "\n )\n"; my $first = 1;
undef(@attr); for (my $i = 0; $i <= $#attr; $i++)
undef(@types); {
$reln_open = 1; if ($first == 1)
$inside = 0; {
if ($bootstrap eq "") { $first = 0;
$bki .= "open $catalog\n"; }
} else
next; {
} $bki .= ",\n";
# inside catalog definition, so keep sucking up attributes }
my @fields = split /\s+/,$line; $bki .= " " . $attr[$i] . " = " . $types[$i];
if ($fields[1] =~ /(.*)\[.*\]/) { #Array attribute }
push @attr, $1; $bki .= "\n )\n";
push @types, $fields[0] . '[]'; undef(@attr);
} undef(@types);
else { $reln_open = 1;
push @attr, $fields[1]; $inside = 0;
push @types, $fields[0]; if ($bootstrap eq "")
} {
next; $bki .= "open $catalog\n";
} }
next;
}
# inside catalog definition, so keep sucking up attributes
my @fields = split /\s+/,$line;
if ($fields[1] =~ /(.*)\[.*\]/)
{ #Array attribute
push @attr, $1;
push @types, $fields[0] . '[]';
}
else
{
push @attr, $fields[1];
push @types, $fields[0];
}
next;
}
} }
if ($reln_open == 1) { if ($reln_open == 1)
$bki .= "close $catalog\n"; {
$bki .= "close $catalog\n";
} }
open(O,">$prefix.bki") || die "Could not write $prefix.bki\n"; open(O,">$prefix.bki") || die "Could not write $prefix.bki\n";
...@@ -192,22 +227,24 @@ open(O,">$prefix.shdescription") || die "Could not write $prefix.shdescription\n ...@@ -192,22 +227,24 @@ open(O,">$prefix.shdescription") || die "Could not write $prefix.shdescription\n
print O $shdesc; print O $shdesc;
close(O); close(O);
sub Usage { sub Usage
print "Usage: genbki.pl <version> <prefix> <input1> [<input2> <input3>...]\n"; {
exit(1); print "Usage: genbki.pl <version> <prefix> <input1> [<input2> <input3>...]\n";
exit(1);
} }
sub read_file { sub read_file
my $filename = shift; {
my $F; my $filename = shift;
my $t = $/; my $F;
my $t = $/;
undef $/;
open($F, $filename) || die "Could not open file $filename\n"; undef $/;
my $txt = <$F>; open($F, $filename) || die "Could not open file $filename\n";
close($F); my $txt = <$F>;
$/ = $t; close($F);
$/ = $t;
return $txt;
return $txt;
} }
...@@ -3,36 +3,39 @@ my @def; ...@@ -3,36 +3,39 @@ my @def;
die "Usage: gendef.pl <modulepath>\n" unless ($ARGV[0] =~ /\\([^\\]+$)/); die "Usage: gendef.pl <modulepath>\n" unless ($ARGV[0] =~ /\\([^\\]+$)/);
my $defname = uc $1; my $defname = uc $1;
if (-f "$ARGV[0]/$defname.def") { if (-f "$ARGV[0]/$defname.def")
print "Not re-generating $defname.DEF, file already exists.\n"; {
exit(0); print "Not re-generating $defname.DEF, file already exists.\n";
exit(0);
} }
print "Generating $defname.DEF from directory $ARGV[0]\n"; print "Generating $defname.DEF from directory $ARGV[0]\n";
while (<$ARGV[0]/*.obj>) { while (<$ARGV[0]/*.obj>)
{
print "."; print ".";
system("dumpbin /symbols /out:symbols.out $_ >NUL") && die "Could not call dumpbin"; system("dumpbin /symbols /out:symbols.out $_ >NUL") && die "Could not call dumpbin";
open(F, "<symbols.out") || die "Could not open symbols.out for $_\n"; open(F, "<symbols.out") || die "Could not open symbols.out for $_\n";
while (<F>) { while (<F>)
s/\(\)//g; {
next unless /^\d/; s/\(\)//g;
my @pieces = split ; next unless /^\d/;
next unless $pieces[6]; my @pieces = split;
next if ($pieces[2] eq "UNDEF"); next unless $pieces[6];
next unless ($pieces[4] eq "External"); next if ($pieces[2] eq "UNDEF");
next if $pieces[6] =~ /^@/; next unless ($pieces[4] eq "External");
next if $pieces[6] =~ /^\(/; next if $pieces[6] =~ /^@/;
next if $pieces[6] =~ /^__real/; next if $pieces[6] =~ /^\(/;
next if $pieces[6] =~ /^__imp/; next if $pieces[6] =~ /^__real/;
next if $pieces[6] =~ /NULL_THUNK_DATA$/; next if $pieces[6] =~ /^__imp/;
next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/; next if $pieces[6] =~ /NULL_THUNK_DATA$/;
next if $pieces[6] =~ /^__NULL_IMPORT/; next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/;
next if $pieces[6] =~ /^__NULL_IMPORT/;
push @def, $pieces[6]; push @def, $pieces[6];
} }
close(F); close(F);
unlink("symbols.out"); unlink("symbols.out");
} }
print "\n"; print "\n";
...@@ -40,13 +43,15 @@ open(DEF,">$ARGV[0]/$defname.def") || die "Could not write to $defname\n"; ...@@ -40,13 +43,15 @@ open(DEF,">$ARGV[0]/$defname.def") || die "Could not write to $defname\n";
print DEF "EXPORTS\n"; print DEF "EXPORTS\n";
my $i = 0; my $i = 0;
my $last = ""; my $last = "";
foreach my $f (sort @def) { foreach my $f (sort @def)
next if ($f eq $last); {
$last = $f; next if ($f eq $last);
$f =~ s/^_//; $last = $f;
$i++; $f =~ s/^_//;
# print DEF " $f \@ $i\n"; # ordinaled exports? $i++;
print DEF " $f\n";
# print DEF " $f \@ $i\n"; # ordinaled exports?
print DEF " $f\n";
} }
close(DEF); close(DEF);
print "Generated $i symbols\n"; print "Generated $i symbols\n";
...@@ -10,159 +10,193 @@ my $target = shift || Usage(); ...@@ -10,159 +10,193 @@ my $target = shift || Usage();
chdir("../../..") if (-f "../../../configure"); chdir("../../..") if (-f "../../../configure");
my $conf = ""; my $conf = "";
if (-d "debug") { if (-d "debug")
$conf = "debug"; {
$conf = "debug";
} }
if (-d "release") { if (-d "release")
$conf = "release"; {
$conf = "release";
} }
die "Could not find debug or release binaries" if ($conf eq ""); die "Could not find debug or release binaries" if ($conf eq "");
print "Installing for $conf\n"; print "Installing for $conf\n";
EnsureDirectories ('bin','lib','share','share/timezonesets'); EnsureDirectories('bin','lib','share','share/timezonesets');
CopySolutionOutput($conf, $target); CopySolutionOutput($conf, $target);
copy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll'); copy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
CopySetOfFiles('config files', "*.sample", $target . '/share/'); CopySetOfFiles('config files', "*.sample", $target . '/share/');
CopySetOfFiles('timezone names', 'src\timezone\tznames\*.txt', $target . '/share/timezonesets/'); CopySetOfFiles('timezone names', 'src\timezone\tznames\*.txt', $target . '/share/timezonesets/');
CopyFiles('timezone sets', $target . '/share/timezonesets/', 'src/timezone/tznames/', 'Default','Australia','India'); CopyFiles(
'timezone sets',
$target . '/share/timezonesets/',
'src/timezone/tznames/', 'Default','Australia','India'
);
CopySetOfFiles('BKI files', "src\\backend\\catalog\\postgres.*", $target .'/share/'); CopySetOfFiles('BKI files', "src\\backend\\catalog\\postgres.*", $target .'/share/');
CopySetOfFiles('SQL files', "src\\backend\\catalog\\*.sql", $target . '/share/'); CopySetOfFiles('SQL files', "src\\backend\\catalog\\*.sql", $target . '/share/');
CopyFiles('Information schema data', $target . '/share/', 'src/backend/catalog/', 'sql_features.txt'); CopyFiles(
'Information schema data',
$target . '/share/',
'src/backend/catalog/', 'sql_features.txt'
);
GenerateConversionScript(); GenerateConversionScript();
GenerateTimezoneFiles(); GenerateTimezoneFiles();
sub Usage { sub Usage
print "Usage: install.pl <targetdir>\n"; {
exit(1); print "Usage: install.pl <targetdir>\n";
exit(1);
} }
sub EnsureDirectories { sub EnsureDirectories
mkdir $target unless -d ($target); {
while (my $d = shift) { mkdir $target unless -d ($target);
mkdir $target . '/' . $d unless -d ($target . '/' . $d); while (my $d = shift)
} {
mkdir $target . '/' . $d unless -d ($target . '/' . $d);
}
} }
sub CopyFiles { sub CopyFiles
my $what = shift; {
my $target = shift; my $what = shift;
my $basedir = shift; my $target = shift;
my $basedir = shift;
print "Copying $what";
while (my $f = shift) { print "Copying $what";
print "."; while (my $f = shift)
$f = $basedir . $f; {
die "No file $f\n" if (! -f $f); print ".";
copy($f, $target . basename($f)) || croak "Could not copy $f to $target" . basename($f) . " to $target" . basename($f) . "\n"; $f = $basedir . $f;
} die "No file $f\n" if (!-f $f);
print "\n"; copy($f, $target . basename($f))
|| croak "Could not copy $f to $target"
. basename($f)
. " to $target"
. basename($f) . "\n";
}
print "\n";
} }
sub CopySetOfFiles { sub CopySetOfFiles
my $what = shift; {
my $spec = shift; my $what = shift;
my $target = shift; my $spec = shift;
my $D; my $target = shift;
my $D;
print "Copying $what";
open($D, "dir /b /s $spec |") || croak "Could not list $spec\n"; print "Copying $what";
while (<$D>) { open($D, "dir /b /s $spec |") || croak "Could not list $spec\n";
chomp; while (<$D>)
next if /regress/; # Skip temporary install in regression subdir {
my $tgt = $target . basename($_); chomp;
print "."; next if /regress/; # Skip temporary install in regression subdir
copy($_, $tgt) || croak "Could not copy $_: $!\n"; my $tgt = $target . basename($_);
} print ".";
close($D); copy($_, $tgt) || croak "Could not copy $_: $!\n";
print "\n"; }
close($D);
print "\n";
} }
sub CopySolutionOutput { sub CopySolutionOutput
my $conf = shift; {
my $target = shift; my $conf = shift;
my $rem = qr{Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"\) = "([^"]+)"}; my $target = shift;
my $rem = qr{Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"\) = "([^"]+)"};
my $sln = read_file("pgsql.sln") || croak "Could not open pgsql.sln\n";
print "Copying build output files..."; my $sln = read_file("pgsql.sln") || croak "Could not open pgsql.sln\n";
while ($sln =~ $rem) { print "Copying build output files...";
my $pf = $1; while ($sln =~ $rem)
my $dir; {
my $ext; my $pf = $1;
my $dir;
$sln =~ s/$rem//; my $ext;
my $proj = read_file("$pf.vcproj") || croak "Could not open $pf.vcproj\n"; $sln =~ s/$rem//;
if ($proj !~ qr{ConfigurationType="([^"]+)"}) {
croak "Could not parse $pf.vcproj\n"; my $proj = read_file("$pf.vcproj") || croak "Could not open $pf.vcproj\n";
} if ($proj !~ qr{ConfigurationType="([^"]+)"})
if ($1 == 1) { {
$dir = "bin"; croak "Could not parse $pf.vcproj\n";
$ext = "exe"; }
} if ($1 == 1)
elsif ($1 == 2) { {
$dir = "lib"; $dir = "bin";
$ext = "dll"; $ext = "exe";
} }
else { elsif ($1 == 2)
# Static lib, such as libpgport, only used internally during build, don't install {
next; $dir = "lib";
} $ext = "dll";
copy("$conf\\$pf\\$pf.$ext","$target\\$dir\\$pf.$ext") || croak "Could not copy $pf.$ext\n"; }
print "."; else
} {
print "\n";
# Static lib, such as libpgport, only used internally during build, don't install
next;
}
copy("$conf\\$pf\\$pf.$ext","$target\\$dir\\$pf.$ext") || croak "Could not copy $pf.$ext\n";
print ".";
}
print "\n";
} }
sub GenerateConversionScript { sub GenerateConversionScript
my $sql = ""; {
my $F; my $sql = "";
my $F;
print "Generating conversion proc script...";
my $mf = read_file('src/backend/utils/mb/conversion_procs/Makefile'); print "Generating conversion proc script...";
$mf =~ s{\\\s*[\r\n]+}{}mg; my $mf = read_file('src/backend/utils/mb/conversion_procs/Makefile');
$mf =~ /^CONVERSIONS\s*=\s*(.*)$/m || die "Could not find CONVERSIONS line in conversions Makefile\n"; $mf =~ s{\\\s*[\r\n]+}{}mg;
my @pieces = split /\s+/,$1; $mf =~ /^CONVERSIONS\s*=\s*(.*)$/m
while ($#pieces > 0) { || die "Could not find CONVERSIONS line in conversions Makefile\n";
my $name = shift @pieces; my @pieces = split /\s+/,$1;
my $se = shift @pieces; while ($#pieces > 0)
my $de = shift @pieces; {
my $func = shift @pieces; my $name = shift @pieces;
my $obj = shift @pieces; my $se = shift @pieces;
$sql .= "-- $se --> $de\n"; my $de = shift @pieces;
$sql .= "CREATE OR REPLACE FUNCTION $func (INTEGER, INTEGER, CSTRING, INTERNAL, INTEGER) RETURNS VOID AS '\$libdir/$obj', '$func' LANGUAGE C STRICT;\n"; my $func = shift @pieces;
$sql .= "DROP CONVERSION pg_catalog.$name;\n"; my $obj = shift @pieces;
$sql .= "CREATE DEFAULT CONVERSION pg_catalog.$name FOR '$se' TO '$de' FROM $func;\n"; $sql .= "-- $se --> $de\n";
} $sql .=
open($F,">$target/share/conversion_create.sql") || die "Could not write to conversion_create.sql\n"; "CREATE OR REPLACE FUNCTION $func (INTEGER, INTEGER, CSTRING, INTERNAL, INTEGER) RETURNS VOID AS '\$libdir/$obj', '$func' LANGUAGE C STRICT;\n";
print $F $sql; $sql .= "DROP CONVERSION pg_catalog.$name;\n";
close($F); $sql .= "CREATE DEFAULT CONVERSION pg_catalog.$name FOR '$se' TO '$de' FROM $func;\n";
print "\n"; }
open($F,">$target/share/conversion_create.sql")
|| die "Could not write to conversion_create.sql\n";
print $F $sql;
close($F);
print "\n";
} }
sub GenerateTimezoneFiles { sub GenerateTimezoneFiles
my $mf = read_file("src/timezone/Makefile"); {
$mf =~ s{\\\s*[\r\n]+}{}mg; my $mf = read_file("src/timezone/Makefile");
$mf =~ /^TZDATA\s*:?=\s*(.*)$/m || die "Could not find TZDATA row in timezone makefile\n"; $mf =~ s{\\\s*[\r\n]+}{}mg;
my @tzfiles = split /\s+/,$1; $mf =~ /^TZDATA\s*:?=\s*(.*)$/m || die "Could not find TZDATA row in timezone makefile\n";
unshift @tzfiles,''; my @tzfiles = split /\s+/,$1;
print "Generating timezone files..."; unshift @tzfiles,'';
system("$conf\\zic\\zic -d $target/share/timezone " . join(" src/timezone/data/", @tzfiles)); print "Generating timezone files...";
print "\n"; system("$conf\\zic\\zic -d $target/share/timezone " . join(" src/timezone/data/", @tzfiles));
print "\n";
} }
sub read_file
{
my $filename = shift;
my $F;
my $t = $/;
sub read_file { undef $/;
my $filename = shift; open($F, $filename) || die "Could not open file $filename\n";
my $F; my $txt = <$F>;
my $t = $/; close($F);
$/ = $t;
undef $/; return $txt;
open($F, $filename) || die "Could not open file $filename\n";
my $txt = <$F>;
close($F);
$/ = $t;
return $txt;
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment