Commit 042d9ffc authored by Bruce Momjian's avatar Bruce Momjian

Run newly-configured perltidy script on Perl files.

Run on HEAD and 9.2.
parent d7c73484
#!/usr/bin/perl
use strict;
# make sure we are in a sane environment.
use DBI();
use DBD::Pg();
......@@ -10,7 +11,8 @@ use Getopt::Std;
my %opt;
getopts('d:b:s:veorauc', \%opt);
if ( !( scalar %opt && defined $opt{s} ) ) {
if (!(scalar %opt && defined $opt{s}))
{
print <<EOT;
Usage:
$0 -d DATABASE -s SECTIONS [-b NUMBER] [-v] [-e] [-o] [-r] [-a] [-u]
......@@ -30,27 +32,37 @@ EOT
}
$opt{d} ||= '_int4';
my $dbi=DBI->connect('DBI:Pg:dbname='.$opt{d});
my $dbi = DBI->connect('DBI:Pg:dbname=' . $opt{d});
my %table;
my @where;
$table{message}=1;
$table{message} = 1;
if ( $opt{a} ) {
if ( $opt{r} ) {
if ($opt{a})
{
if ($opt{r})
{
push @where, "message.sections @ '{$opt{s}}'";
} else {
foreach my $sid ( split(/[,\s]+/, $opt{s} )) {
}
else
{
foreach my $sid (split(/[,\s]+/, $opt{s}))
{
push @where, "message.mid = msp$sid.mid";
push @where, "msp$sid.sid = $sid";
$table{"message_section_map msp$sid"}=1;
$table{"message_section_map msp$sid"} = 1;
}
}
} else {
if ( $opt{r} ) {
}
else
{
if ($opt{r})
{
push @where, "message.sections && '{$opt{s}}'";
} else {
}
else
{
$table{message_section_map} = 1;
push @where, "message.mid = message_section_map.mid";
push @where, "message_section_map.sid in ($opt{s})";
......@@ -58,46 +70,64 @@ if ( $opt{a} ) {
}
my $outf;
if ( $opt{c} ) {
$outf = ( $opt{u} ) ? 'count( distinct message.mid )' : 'count( message.mid )';
} else {
$outf = ( $opt{u} ) ? 'distinct( message.mid )' : 'message.mid';
if ($opt{c})
{
$outf =
($opt{u}) ? 'count( distinct message.mid )' : 'count( message.mid )';
}
else
{
$outf = ($opt{u}) ? 'distinct( message.mid )' : 'message.mid';
}
my $sql = "select $outf from ".join(', ', keys %table)." where ".join(' AND ', @where).';';
my $sql =
"select $outf from "
. join(', ', keys %table)
. " where "
. join(' AND ', @where) . ';';
if ( $opt{v} ) {
if ($opt{v})
{
print "$sql\n";
}
if ( $opt{e} ) {
if ($opt{e})
{
$dbi->do("explain $sql");
}
my $t0 = [gettimeofday];
my $count=0;
my $b=$opt{b};
$b||=1;
my $count = 0;
my $b = $opt{b};
$b ||= 1;
my @a;
foreach ( 1..$b ) {
@a=exec_sql($dbi,$sql);
$count=$#a;
foreach (1 .. $b)
{
@a = exec_sql($dbi, $sql);
$count = $#a;
}
my $elapsed = tv_interval ( $t0, [gettimeofday]);
if ( $opt{o} ) {
foreach ( @a ) {
my $elapsed = tv_interval($t0, [gettimeofday]);
if ($opt{o})
{
foreach (@a)
{
print "$_->{mid}\t$_->{sections}\n";
}
}
print sprintf("total: %.02f sec; number: %d; for one: %.03f sec; found %d docs\n", $elapsed, $b, $elapsed/$b, $count+1 );
$dbi -> disconnect;
print sprintf(
"total: %.02f sec; number: %d; for one: %.03f sec; found %d docs\n",
$elapsed, $b, $elapsed / $b,
$count + 1);
$dbi->disconnect;
sub exec_sql {
sub exec_sql
{
my ($dbi, $sql, @keys) = @_;
my $sth=$dbi->prepare($sql) || die;
$sth->execute( @keys ) || die;
my $sth = $dbi->prepare($sql) || die;
$sth->execute(@keys) || die;
my $r;
my @row;
while ( defined ( $r=$sth->fetchrow_hashref ) ) {
while (defined($r = $sth->fetchrow_hashref))
{
push @row, $r;
}
$sth->finish;
......
......@@ -15,28 +15,38 @@ create table message_section_map (
EOT
open(MSG,">message.tmp") || die;
open(MAP,">message_section_map.tmp") || die;
open(MSG, ">message.tmp") || die;
open(MAP, ">message_section_map.tmp") || die;
srand(1);
srand( 1 );
#foreach my $i ( 1..1778 ) {
#foreach my $i ( 1..3443 ) {
#foreach my $i ( 1..5000 ) {
#foreach my $i ( 1..29362 ) {
#foreach my $i ( 1..33331 ) {
#foreach my $i ( 1..83268 ) {
foreach my $i ( 1..200000 ) {
foreach my $i (1 .. 200000)
{
my @sect;
if ( rand() < 0.7 ) {
$sect[0] = int( (rand()**4)*100 );
} else {
if (rand() < 0.7)
{
$sect[0] = int((rand()**4) * 100);
}
else
{
my %hash;
@sect = grep { $hash{$_}++; $hash{$_} <= 1 } map { int( (rand()**4)*100) } 0..( int(rand()*5) );
@sect =
grep { $hash{$_}++; $hash{$_} <= 1 }
map { int((rand()**4) * 100) } 0 .. (int(rand() * 5));
}
if ( $#sect < 0 || rand() < 0.1 ) {
if ($#sect < 0 || rand() < 0.1)
{
print MSG "$i\t\\N\n";
} else {
print MSG "$i\t{".join(',',@sect)."}\n";
}
else
{
print MSG "$i\t{" . join(',', @sect) . "}\n";
map { print MAP "$i\t$_\n" } @sect;
}
}
......@@ -64,12 +74,13 @@ EOT
unlink 'message.tmp', 'message_section_map.tmp';
sub copytable {
sub copytable
{
my $t = shift;
print "COPY $t from stdin;\n";
open( FFF, "$t.tmp") || die;
while(<FFF>) { print; }
open(FFF, "$t.tmp") || die;
while (<FFF>) { print; }
close FFF;
print "\\.\n";
}
......@@ -18,24 +18,32 @@ $rule_5 = $boundary;
print "$rule_5\n";
while (<>) {
# s/ +//g;
if ( /^($rule_1)$/ ) {
while (<>)
{
# s/ +//g;
if (/^($rule_1)$/)
{
print;
}
elsif ( /^($rule_2)$/ ) {
elsif (/^($rule_2)$/)
{
print;
}
elsif ( /^($rule_3)$/ ) {
elsif (/^($rule_3)$/)
{
print;
}
elsif ( /^($rule_4)$/ ) {
elsif (/^($rule_4)$/)
{
print;
}
elsif ( /^($rule_5)$/ ) {
elsif (/^($rule_5)$/)
{
print;
}
else {
else
{
print STDERR "error in $_\n";
}
......
......@@ -2,12 +2,14 @@
# this script will sort any table with the segment data type in its last column
while (<>) {
while (<>)
{
chomp;
push @rows, $_;
}
foreach ( sort {
foreach (
sort {
@ar = split("\t", $a);
$valA = pop @ar;
$valA =~ s/[~<> ]+//g;
......@@ -15,6 +17,7 @@ foreach ( sort {
$valB = pop @ar;
$valB =~ s/[~<> ]+//g;
$valA <=> $valB
} @rows ) {
print "$_\n";;
} @rows)
{
print "$_\n";
}
......@@ -6,11 +6,13 @@
use warnings;
use strict;
print "<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n";
print
"<!-- autogenerated from src/backend/utils/errcodes.txt, do not edit -->\n";
open my $errcodes, $ARGV[0] or die;
while (<$errcodes>) {
while (<$errcodes>)
{
chomp;
# Skip comments
......@@ -18,12 +20,15 @@ while (<$errcodes>) {
next if /^\s*$/;
# Emit section headers
if (/^Section:/) {
if (/^Section:/)
{
# Remove the Section: string
s/^Section: //;
# Escape dashes for SGML
s/-/&mdash;/;
# Wrap PostgreSQL in <productname/>
s/PostgreSQL/<productname>PostgreSQL<\/>/g;
......@@ -38,10 +43,8 @@ while (<$errcodes>) {
die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
(my $sqlstate,
my $type,
my $errcode_macro,
my $condition_name) = ($1, $2, $3, $4);
(my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
($1, $2, $3, $4);
# Skip lines without PL/pgSQL condition names
next unless defined($condition_name);
......
......@@ -25,7 +25,8 @@ process_file($infile);
exit 0;
sub process_file {
sub process_file
{
my $filename = shift;
local *FILE; # need a local filehandle so we can recurse
......@@ -33,18 +34,24 @@ sub process_file {
my $f = $srcdir . '/' . $filename;
open(FILE, $f) || die "could not read $f: $!\n";
while (<FILE>) {
while (<FILE>)
{
# Recursively expand sub-files of the release notes
if (m/^&(release-.*);$/) {
if (m/^&(release-.*);$/)
{
process_file($1 . ".sgml");
next;
}
# Remove <link ...> tags, which might span multiple lines
while (m/<link/) {
if (s/<link\s+linkend[^>]*>//) {
while (m/<link/)
{
if (s/<link\s+linkend[^>]*>//)
{
next;
}
# incomplete tag, so slurp another line
$_ .= <FILE>;
}
......
......@@ -8,12 +8,16 @@ open PACK, $ARGV[1] or die;
my %feature_packages;
while (<PACK>) {
while (<PACK>)
{
chomp;
my ($fid, $pname) = split /\t/;
if ($feature_packages{$fid}) {
if ($feature_packages{$fid})
{
$feature_packages{$fid} .= ", $pname";
} else {
}
else
{
$feature_packages{$fid} = $pname;
}
}
......@@ -24,9 +28,11 @@ open FEAT, $ARGV[2] or die;
print "<tbody>\n";
while (<FEAT>) {
while (<FEAT>)
{
chomp;
my ($feature_id, $feature_name, $subfeature_id, $subfeature_name, $is_supported, $comments) = split /\t/;
my ($feature_id, $feature_name, $subfeature_id,
$subfeature_name, $is_supported, $comments) = split /\t/;
$is_supported eq $yesno || next;
......@@ -37,15 +43,21 @@ while (<FEAT>) {
print " <row>\n";
if ($subfeature_id) {
if ($subfeature_id)
{
print " <entry>$feature_id-$subfeature_id</entry>\n";
} else {
}
else
{
print " <entry>$feature_id</entry>\n";
}
print " <entry>" . $feature_packages{$feature_id} . "</entry>\n";
if ($subfeature_id) {
if ($subfeature_id)
{
print " <entry>$subfeature_name</entry>\n";
} else {
}
else
{
print " <entry>$feature_name</entry>\n";
}
print " <entry>$comments</entry>\n";
......
......@@ -35,8 +35,7 @@ sub Catalogs
'int32' => 'int4',
'Oid' => 'oid',
'NameData' => 'name',
'TransactionId' => 'xid'
);
'TransactionId' => 'xid');
foreach my $input_file (@_)
{
......@@ -49,10 +48,12 @@ sub Catalogs
# Scan the input file.
while (<INPUT_FILE>)
{
# Strip C-style comments.
s;/\*(.|\n)*\*/;;g;
if (m;/\*;)
{
# handle multi-line comments properly.
my $next_line = <INPUT_FILE>;
die "$input_file: ends within C-style comment\n"
......@@ -70,11 +71,12 @@ sub Catalogs
# Push the data into the appropriate data structure.
if (/^DATA\(insert(\s+OID\s+=\s+(\d+))?\s+\(\s*(.*)\s*\)\s*\)$/)
{
push @{ $catalog{data} }, {oid => $2, bki_values => $3};
push @{ $catalog{data} }, { oid => $2, bki_values => $3 };
}
elsif (/^DESCR\(\"(.*)\"\)$/)
{
$most_recent = $catalog{data}->[-1];
# this tests if most recent line is not a DATA() statement
if (ref $most_recent ne 'HASH')
{
......@@ -92,10 +94,12 @@ sub Catalogs
elsif (/^SHDESCR\(\"(.*)\"\)$/)
{
$most_recent = $catalog{data}->[-1];
# this tests if most recent line is not a DATA() statement
if (ref $most_recent ne 'HASH')
{
die "SHDESCR() does not apply to any catalog ($input_file)";
die
"SHDESCR() does not apply to any catalog ($input_file)";
}
if (!defined $most_recent->{oid})
{
......@@ -110,18 +114,19 @@ sub Catalogs
{
$catname = 'toasting';
my ($toast_name, $toast_oid, $index_oid) = ($1, $2, $3);
push @{ $catalog{data} }, "declare toast $toast_oid $index_oid on $toast_name\n";
push @{ $catalog{data} },
"declare toast $toast_oid $index_oid on $toast_name\n";
}
elsif (/^DECLARE_(UNIQUE_)?INDEX\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
{
$catname = 'indexing';
my ($is_unique, $index_name, $index_oid, $using) = ($1, $2, $3, $4);
my ($is_unique, $index_name, $index_oid, $using) =
($1, $2, $3, $4);
push @{ $catalog{data} },
sprintf(
"declare %sindex %s %s %s\n",
$is_unique ? 'unique ' : '',
$index_name, $index_oid, $using
);
$index_name, $index_oid, $using);
}
elsif (/^BUILD_INDICES/)
{
......@@ -136,9 +141,12 @@ sub Catalogs
push @{ $catalogs{names} }, $catname;
$catalog{bootstrap} = /BKI_BOOTSTRAP/ ? ' bootstrap' : '';
$catalog{shared_relation} = /BKI_SHARED_RELATION/ ? ' shared_relation' : '';
$catalog{without_oids} = /BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
$catalog{rowtype_oid} = /BKI_ROWTYPE_OID\((\d+)\)/ ? " rowtype_oid $1" : '';
$catalog{shared_relation} =
/BKI_SHARED_RELATION/ ? ' shared_relation' : '';
$catalog{without_oids} =
/BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
$catalog{rowtype_oid} =
/BKI_ROWTYPE_OID\((\d+)\)/ ? " rowtype_oid $1" : '';
$catalog{schema_macro} = /BKI_SCHEMA_MACRO/ ? 'True' : '';
$declaring_attributes = 1;
}
......@@ -163,7 +171,7 @@ sub Catalogs
$attname = $1;
$atttype .= '[]'; # variable-length only
}
push @{ $catalog{columns} }, {$attname => $atttype};
push @{ $catalog{columns} }, { $attname => $atttype };
}
}
}
......
......@@ -86,8 +86,10 @@ open SHDESCR, '>', $shdescrfile . $tmpext
# to handle those sorts of things is in initdb.c's bootstrap_template1().)
# NB: make sure that the files used here are known to be part of the .bki
# file's dependencies by src/backend/catalog/Makefile.
my $BOOTSTRAP_SUPERUSERID = find_defined_symbol('pg_authid.h', 'BOOTSTRAP_SUPERUSERID');
my $PG_CATALOG_NAMESPACE = find_defined_symbol('pg_namespace.h', 'PG_CATALOG_NAMESPACE');
my $BOOTSTRAP_SUPERUSERID =
find_defined_symbol('pg_authid.h', 'BOOTSTRAP_SUPERUSERID');
my $PG_CATALOG_NAMESPACE =
find_defined_symbol('pg_namespace.h', 'PG_CATALOG_NAMESPACE');
# Read all the input header files into internal data structures
my $catalogs = Catalog::Catalogs(@input_files);
......@@ -103,19 +105,20 @@ my @tables_needing_macros;
our @types;
# produce output, one catalog at a time
foreach my $catname ( @{ $catalogs->{names} } )
foreach my $catname (@{ $catalogs->{names} })
{
# .bki CREATE command for this catalog
my $catalog = $catalogs->{$catname};
print BKI "create $catname $catalog->{relation_oid}"
. $catalog->{shared_relation}
. $catalog->{bootstrap}
. $catalog->{without_oids}
. $catalog->{rowtype_oid}. "\n";
. $catalog->{rowtype_oid} . "\n";
my %bki_attr;
my @attnames;
foreach my $column ( @{ $catalog->{columns} } )
foreach my $column (@{ $catalog->{columns} })
{
my ($attname, $atttype) = %$column;
$bki_attr{$attname} = $atttype;
......@@ -133,9 +136,11 @@ foreach my $catname ( @{ $catalogs->{names} } )
if (defined $catalog->{data})
{
# Ordinary catalog with DATA line(s)
foreach my $row ( @{ $catalog->{data} } )
foreach my $row (@{ $catalog->{data} })
{
# substitute constant values we acquired above
$row->{bki_values} =~ s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g;
$row->{bki_values} =~ s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g;
......@@ -156,20 +161,23 @@ foreach my $catname ( @{ $catalogs->{names} } )
# Write comments to postgres.description and postgres.shdescription
if (defined $row->{descr})
{
printf DESCR "%s\t%s\t0\t%s\n", $row->{oid}, $catname, $row->{descr};
printf DESCR "%s\t%s\t0\t%s\n", $row->{oid}, $catname,
$row->{descr};
}
if (defined $row->{shdescr})
{
printf SHDESCR "%s\t%s\t%s\n", $row->{oid}, $catname, $row->{shdescr};
printf SHDESCR "%s\t%s\t%s\n", $row->{oid}, $catname,
$row->{shdescr};
}
}
}
if ($catname eq 'pg_attribute')
{
# For pg_attribute.h, we generate DATA entries ourselves.
# NB: pg_type.h must come before pg_attribute.h in the input list
# of catalog names, since we use info from pg_type.h here.
foreach my $table_name ( @{ $catalogs->{names} } )
foreach my $table_name (@{ $catalogs->{names} })
{
my $table = $catalogs->{$table_name};
......@@ -200,9 +208,12 @@ foreach my $catname ( @{ $catalogs->{names} } )
}
# Store schemapg entries for later.
$row = emit_schemapg_row($row, grep { $bki_attr{$_} eq 'bool' } @attnames);
push @{ $schemapg_entries{$table_name} },
'{ ' . join(', ', grep { defined $_ }
$row =
emit_schemapg_row($row,
grep { $bki_attr{$_} eq 'bool' } @attnames);
push @{ $schemapg_entries{$table_name} }, '{ '
. join(
', ', grep { defined $_ }
map $row->{$_}, @attnames) . ' }';
}
......@@ -212,14 +223,13 @@ foreach my $catname ( @{ $catalogs->{names} } )
{
$attnum = 0;
my @SYS_ATTRS = (
{ctid => 'tid'},
{oid => 'oid'},
{xmin => 'xid'},
{cmin => 'cid'},
{xmax => 'xid'},
{cmax => 'cid'},
{tableoid => 'oid'}
);
{ ctid => 'tid' },
{ oid => 'oid' },
{ xmin => 'xid' },
{ cmin => 'cid' },
{ xmax => 'xid' },
{ cmax => 'cid' },
{ tableoid => 'oid' });
foreach my $attr (@SYS_ATTRS)
{
$attnum--;
......@@ -228,8 +238,9 @@ foreach my $catname ( @{ $catalogs->{names} } )
$row->{attstattarget} = '0';
# some catalogs don't have oids
next if $table->{without_oids} eq ' without_oids' &&
$row->{attname} eq 'oid';
next
if $table->{without_oids} eq ' without_oids'
&& $row->{attname} eq 'oid';
bki_insert($row, @attnames);
}
......@@ -244,12 +255,12 @@ foreach my $catname ( @{ $catalogs->{names} } )
# (i.e., not contained in a header with a CATALOG() statement) comes here
# Write out declare toast/index statements
foreach my $declaration ( @{ $catalogs->{toasting}->{data} } )
foreach my $declaration (@{ $catalogs->{toasting}->{data} })
{
print BKI $declaration;
}
foreach my $declaration ( @{ $catalogs->{indexing}->{data} } )
foreach my $declaration (@{ $catalogs->{indexing}->{data} })
{
print BKI $declaration;
}
......@@ -331,16 +342,18 @@ sub emit_pgattr_row
# Copy the type data from pg_type, and add some type-dependent items
foreach my $type (@types)
{
if ( defined $type->{typname} && $type->{typname} eq $atttype )
if (defined $type->{typname} && $type->{typname} eq $atttype)
{
$row{atttypid} = $type->{oid};
$row{attlen} = $type->{typlen};
$row{attbyval} = $type->{typbyval};
$row{attstorage} = $type->{typstorage};
$row{attalign} = $type->{typalign};
# set attndims if it's an array type
$row{attndims} = $type->{typcategory} eq 'A' ? '1' : '0';
$row{attcollation} = $type->{typcollation};
# attnotnull must be set true if the type is fixed-width and
# prior columns are too --- compare DefineAttr in bootstrap.c.
# oidvector and int2vector are also treated as not-nullable.
......@@ -350,7 +363,8 @@ sub emit_pgattr_row
$type->{typname} eq 'oidvector' ? 't'
: $type->{typname} eq 'int2vector' ? 't'
: $type->{typlen} eq 'NAMEDATALEN' ? 't'
: $type->{typlen} > 0 ? 't' : 'f';
: $type->{typlen} > 0 ? 't'
: 'f';
}
else
{
......@@ -370,9 +384,8 @@ sub emit_pgattr_row
attinhcount => '0',
attacl => '_null_',
attoptions => '_null_',
attfdwoptions => '_null_'
);
return {%PGATTR_DEFAULTS, %row};
attfdwoptions => '_null_');
return { %PGATTR_DEFAULTS, %row };
}
# Write a pg_attribute entry to postgres.bki
......@@ -421,6 +434,7 @@ sub find_defined_symbol
my ($catalog_header, $symbol) = @_;
for my $path (@include_path)
{
# Make sure include path ends in a slash.
if (substr($path, -1) ne '/')
{
......
......@@ -50,7 +50,7 @@ my $catalogs = Catalog::Catalogs($infile);
# Collect the raw data from pg_proc.h.
my @fmgr = ();
my @attnames;
foreach my $column ( @{ $catalogs->{pg_proc}->{columns} } )
foreach my $column (@{ $catalogs->{pg_proc}->{columns} })
{
push @attnames, keys %$column;
}
......@@ -58,6 +58,7 @@ foreach my $column ( @{ $catalogs->{pg_proc}->{columns} } )
my $data = $catalogs->{pg_proc}->{data};
foreach my $row (@$data)
{
# To construct fmgroids.h and fmgrtab.c, we need to inspect some
# of the individual data fields. Just splitting on whitespace
# won't work, because some quoted fields might contain internal
......@@ -73,13 +74,11 @@ foreach my $row (@$data)
next if $row->{prolang} ne '12';
push @fmgr,
{
oid => $row->{oid},
{ oid => $row->{oid},
strict => $row->{proisstrict},
retset => $row->{proretset},
nargs => $row->{pronargs},
prosrc => $row->{prosrc},
};
prosrc => $row->{prosrc}, };
# Hack to work around memory leak in some versions of Perl
$row = undef;
......@@ -160,10 +159,10 @@ qq|/*-------------------------------------------------------------------------
# Emit #define's and extern's -- only one per prosrc value
my %seenit;
foreach my $s (sort {$a->{oid} <=> $b->{oid}} @fmgr)
foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
{
next if $seenit{$s->{prosrc}};
$seenit{$s->{prosrc}} = 1;
next if $seenit{ $s->{prosrc} };
$seenit{ $s->{prosrc} } = 1;
print H "#define F_" . uc $s->{prosrc} . " $s->{oid}\n";
print T "extern Datum $s->{prosrc} (PG_FUNCTION_ARGS);\n";
}
......@@ -173,10 +172,10 @@ print T "\nconst FmgrBuiltin fmgr_builtins[] = {\n";
my %bmap;
$bmap{'t'} = 'true';
$bmap{'f'} = 'false';
foreach my $s (sort {$a->{oid} <=> $b->{oid}} @fmgr)
foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
{
print T
" { $s->{oid}, \"$s->{prosrc}\", $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, $s->{prosrc} },\n";
" { $s->{oid}, \"$s->{prosrc}\", $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, $s->{prosrc} },\n";
}
# And add the file footers.
......
......@@ -6,12 +6,14 @@
use warnings;
use strict;
print "/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print
"/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print "/* there is deliberately not an #ifndef ERRCODES_H here */\n";
open my $errcodes, $ARGV[0] or die;
while (<$errcodes>) {
while (<$errcodes>)
{
chomp;
# Skip comments
......@@ -19,19 +21,22 @@ while (<$errcodes>) {
next if /^\s*$/;
# Emit a comment for each section header
if (/^Section:(.*)/) {
if (/^Section:(.*)/)
{
my $header = $1;
$header =~ s/^\s+//;
print "\n/* $header */\n";
next;
}
die "unable to parse errcodes.txt" unless /^([^\s]{5})\s+[EWS]\s+([^\s]+)/;
die "unable to parse errcodes.txt"
unless /^([^\s]{5})\s+[EWS]\s+([^\s]+)/;
(my $sqlstate, my $errcode_macro) = ($1, $2);
# Split the sqlstate letters
$sqlstate = join ",", split "", $sqlstate;
# And quote them
$sqlstate =~ s/([^,])/'$1'/g;
......
......@@ -33,68 +33,82 @@ require "ucs2utf.pl";
#
$in_file = "BIG5.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = $code;
$array{$utf} = $code;
}
}
close( FILE );
close(FILE);
$in_file = "CP950.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
# Pick only the ETEN extended characters in the range 0xf9d6 - 0xf9dc
# from CP950.TXT
if( $code >= 0x80 && $ucs >= 0x0080 &&
$code >= 0xf9d6 && $code <= 0xf9dc ){
if ( $code >= 0x80
&& $ucs >= 0x0080
&& $code >= 0xf9d6
&& $code <= 0xf9dc)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = $code;
$array{$utf} = $code;
}
}
close( FILE );
close(FILE);
$file = lc("utf8_to_big5.map");
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapBIG5[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -107,67 +121,81 @@ close(FILE);
#
$in_file = "BIG5.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$in_file = "CP950.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
# Pick only the ETEN extended characters in the range 0xf9d6 - 0xf9dc
# from CP950.TXT
if( $code >= 0x80 && $ucs >= 0x0080 &&
$code >= 0xf9d6 && $code <= 0xf9dc ){
if ( $code >= 0x80
&& $ucs >= 0x0080
&& $code >= 0xf9d6
&& $code <= 0xf9dc)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = lc("big5_to_utf8.map");
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapBIG5[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -22,43 +22,51 @@ require "ucs2utf.pl";
$in_file = "GB2312.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = ($code | 0x8080);
$array{$utf} = ($code | 0x8080);
}
}
close( FILE );
close(FILE);
#
# first, generate UTF8 --> EUC_CN table
#
$file = "utf8_to_euc_cn.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_CN[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -71,39 +79,47 @@ close(FILE);
#
reset 'array';
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
$code |= 0x8080;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = "euc_cn_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_CN[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -15,15 +15,17 @@ $TEST = 1;
$in_file = "euc-jis-2004-std.txt";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
reset 'array1';
reset 'comment';
reset 'comment1';
while($line = <FILE> ){
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
while ($line = <FILE>)
{
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u1 = $2;
$u2 = $3;
......@@ -34,70 +36,89 @@ while($line = <FILE> ){
$ucs = hex($u2);
$utf2 = &ucs2utf($ucs);
$str = sprintf "%08x%08x", $utf1, $utf2;
$array1{ $str } = $code;
$comment1{ $str } = $rest;
$array1{$str} = $code;
$comment1{$str} = $rest;
$count1++;
next;
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) {
}
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u = $2;
$rest = "U+" . $u . $3;
} else {
}
else
{
next;
}
$ucs = hex($u);
$code = hex($c);
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = $code;
$comment{ $code } = $rest;
$array{$utf} = $code;
$comment{$code} = $rest;
}
close( FILE );
close(FILE);
$file = "utf8_to_euc_jis_2004.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_utf_to_local ULmapEUC_JIS_2004[] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
printf FILE " {0x%08x, 0x%06x} /* %s */\n", $index, $code, $comment{ $code };
} else {
printf FILE " {0x%08x, 0x%06x}, /* %s */\n", $index, $code, $comment{ $code };
if ($count == 0)
{
printf FILE " {0x%08x, 0x%06x} /* %s */\n", $index, $code,
$comment{$code};
}
else
{
printf FILE " {0x%08x, 0x%06x}, /* %s */\n", $index, $code,
$comment{$code};
}
}
print FILE "};\n";
close(FILE);
if ($TEST == 1) {
if ($TEST == 1)
{
$file1 = "utf8.data";
$file2 = "euc_jis_2004.data";
open( FILE1, "> $file1" ) || die( "cannot open $file1" );
open( FILE2, "> $file2" ) || die( "cannot open $file2" );
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
if ($code > 0x00 && $code != 0x09 && $code != 0x0a && $code != 0x0d &&
$code != 0x5c &&
($code < 0x80 ||
($code >= 0x8ea1 && $code <= 0x8efe) ||
($code >= 0x8fa1a1 && $code <= 0x8ffefe) ||
($code >= 0xa1a1 && $code <= 0x8fefe))) {
for ($i = 3; $i >= 0; $i--) {
open(FILE1, "> $file1") || die("cannot open $file1");
open(FILE2, "> $file2") || die("cannot open $file2");
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
if ( $code > 0x00
&& $code != 0x09
&& $code != 0x0a
&& $code != 0x0d
&& $code != 0x5c
&& ( $code < 0x80
|| ($code >= 0x8ea1 && $code <= 0x8efe)
|| ($code >= 0x8fa1a1 && $code <= 0x8ffefe)
|| ($code >= 0xa1a1 && $code <= 0x8fefe)))
{
for ($i = 3; $i >= 0; $i--)
{
$s = $i * 8;
$mask = 0xff << $s;
print FILE1 pack("C", ($index & $mask) >> $s) if $index & $mask;
print FILE1 pack("C", ($index & $mask) >> $s)
if $index & $mask;
print FILE2 pack("C", ($code & $mask) >> $s) if $code & $mask;
}
print FILE1 "\n";
......@@ -107,45 +128,61 @@ if ($TEST == 1) {
}
$file = "utf8_to_euc_jis_2004_combined.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {\n";
print FILE
"static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {\n";
for $index ( sort {$a cmp $b} keys( %array1 ) ){
$code = $array1{ $index };
for $index (sort { $a cmp $b } keys(%array1))
{
$code = $array1{$index};
$count1--;
if( $count1 == 0 ){
printf FILE " {0x%s, 0x%s, 0x%06x} /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index };
} else {
printf FILE " {0x%s, 0x%s, 0x%06x}, /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index };
if ($count1 == 0)
{
printf FILE " {0x%s, 0x%s, 0x%06x} /* %s */\n", substr($index, 0, 8),
substr($index, 8, 8), $code, $comment1{$index};
}
else
{
printf FILE " {0x%s, 0x%s, 0x%06x}, /* %s */\n",
substr($index, 0, 8), substr($index, 8, 8), $code,
$comment1{$index};
}
}
print FILE "};\n";
close(FILE);
if ($TEST == 1) {
for $index ( sort {$a cmp $b} keys( %array1 ) ){
$code = $array1{ $index };
if ($code > 0x00 && $code != 0x09 && $code != 0x0a && $code != 0x0d &&
$code != 0x5c &&
($code < 0x80 ||
($code >= 0x8ea1 && $code <= 0x8efe) ||
($code >= 0x8fa1a1 && $code <= 0x8ffefe) ||
($code >= 0xa1a1 && $code <= 0x8fefe))) {
if ($TEST == 1)
{
for $index (sort { $a cmp $b } keys(%array1))
{
$code = $array1{$index};
if ( $code > 0x00
&& $code != 0x09
&& $code != 0x0a
&& $code != 0x0d
&& $code != 0x5c
&& ( $code < 0x80
|| ($code >= 0x8ea1 && $code <= 0x8efe)
|| ($code >= 0x8fa1a1 && $code <= 0x8ffefe)
|| ($code >= 0xa1a1 && $code <= 0x8fefe)))
{
$v1 = hex(substr($index, 0, 8));
$v2 = hex(substr($index, 8, 8));
for ($i = 3; $i >= 0; $i--) {
for ($i = 3; $i >= 0; $i--)
{
$s = $i * 8;
$mask = 0xff << $s;
print FILE1 pack("C", ($v1 & $mask) >> $s) if $v1 & $mask;
print FILE2 pack("C", ($code & $mask) >> $s) if $code & $mask;
}
for ($i = 3; $i >= 0; $i--) {
for ($i = 3; $i >= 0; $i--)
{
$s = $i * 8;
$mask = 0xff << $s;
print FILE1 pack("C", ($v2 & $mask) >> $s) if $v2 & $mask;
......@@ -162,15 +199,17 @@ if ($TEST == 1) {
$in_file = "euc-jis-2004-std.txt";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
reset 'array1';
reset 'comment';
reset 'comment1';
while($line = <FILE> ){
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
while ($line = <FILE>)
{
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u1 = $2;
$u2 = $3;
......@@ -181,46 +220,57 @@ while($line = <FILE> ){
$ucs = hex($u2);
$utf2 = &ucs2utf($ucs);
$str = sprintf "%08x%08x", $utf1, $utf2;
$array1{ $code } = $str;
$comment1{ $code } = $rest;
$array1{$code} = $str;
$comment1{$code} = $rest;
$count1++;
next;
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) {
}
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u = $2;
$rest = "U+" . $u . $3;
} else {
}
else
{
next;
}
$ucs = hex($u);
$code = hex($c);
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $code } = $utf;
$comment{ $utf } = $rest;
$array{$code} = $utf;
$comment{$utf} = $rest;
}
close( FILE );
close(FILE);
$file = "euc_jis_2004_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_local_to_utf LUmapEUC_JIS_2004[] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
printf FILE " {0x%06x, 0x%08x} /* %s */\n", $index, $code, $comment{ $code };
} else {
printf FILE " {0x%06x, 0x%08x}, /* %s */\n", $index, $code, $comment{ $code };
if ($count == 0)
{
printf FILE " {0x%06x, 0x%08x} /* %s */\n", $index, $code,
$comment{$code};
}
else
{
printf FILE " {0x%06x, 0x%08x}, /* %s */\n", $index, $code,
$comment{$code};
}
}
......@@ -228,19 +278,26 @@ print FILE "};\n";
close(FILE);
$file = "euc_jis_2004_to_utf8_combined.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {\n";
print FILE
"static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {\n";
for $index ( sort {$a <=> $b} keys( %array1 ) ){
$code = $array1{ $index };
for $index (sort { $a <=> $b } keys(%array1))
{
$code = $array1{$index};
$count1--;
if( $count1 == 0 ){
printf FILE " {0x%06x, 0x%s, 0x%s} /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index };
} else {
printf FILE " {0x%06x, 0x%s, 0x%s}, /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index };
if ($count1 == 0)
{
printf FILE " {0x%06x, 0x%s, 0x%s} /* %s */\n", $index,
substr($code, 0, 8), substr($code, 8, 8), $comment1{$index};
}
else
{
printf FILE " {0x%06x, 0x%s, 0x%s}, /* %s */\n", $index,
substr($code, 0, 8), substr($code, 8, 8), $comment1{$index};
}
}
......
......@@ -36,102 +36,118 @@ require "ucs2utf.pl";
#
$in_file = "JIS0201.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
# add single shift 2
$array{ $utf } = ($code | 0x8e00);
$array{$utf} = ($code | 0x8e00);
}
}
close( FILE );
close(FILE);
#
# JIS0208
#
$in_file = "JIS0208.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $s, $c, $u, $rest ) = split;
($s, $c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = ($code | 0x8080);
$array{$utf} = ($code | 0x8080);
}
}
close( FILE );
close(FILE);
#
# JIS0212
#
$in_file = "JIS0212.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = ($code | 0x8f8080);
$array{$utf} = ($code | 0x8f8080);
}
}
close( FILE );
close(FILE);
#
# first, generate UTF8 --> EUC_JP table
#
$file = "utf8_to_euc_jp.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_JP[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -148,100 +164,116 @@ close(FILE);
#
$in_file = "JIS0201.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
# add single shift 2
$code |= 0x8e00;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
#
# JIS0208
#
$in_file = "JIS0208.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $s, $c, $u, $rest ) = split;
($s, $c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
$code |= 0x8080;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
#
# JIS0212
#
$in_file = "JIS0212.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
$code |= 0x8f8080;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = "euc_jp_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_JP[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -22,43 +22,51 @@ require "ucs2utf.pl";
$in_file = "KSX1001.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = ($code | 0x8080);
$array{$utf} = ($code | 0x8080);
}
}
close( FILE );
close(FILE);
#
# first, generate UTF8 --> EUC_KR table
#
$file = "utf8_to_euc_kr.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_KR[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -71,39 +79,47 @@ close(FILE);
#
reset 'array';
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
$code |= 0x8080;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = "euc_kr_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -23,53 +23,66 @@ require "ucs2utf.pl";
$in_file = "CNS11643.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$plane = ($code & 0x1f0000) >> 16;
if ($plane > 16) {
if ($plane > 16)
{
printf STDERR "Warning: invalid plane No.$plane. ignored\n";
next;
}
if ($plane == 1) {
$array{ $utf } = (($code & 0xffff) | 0x8080);
} else {
$array{ $utf } = (0x8ea00000 + ($plane << 16)) | (($code & 0xffff) | 0x8080);
if ($plane == 1)
{
$array{$utf} = (($code & 0xffff) | 0x8080);
}
else
{
$array{$utf} =
(0x8ea00000 + ($plane << 16)) | (($code & 0xffff) | 0x8080);
}
}
}
close( FILE );
close(FILE);
#
# first, generate UTF8 --> EUC_TW table
#
$file = "utf8_to_euc_tw.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_TW[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -82,50 +95,60 @@ close(FILE);
#
reset 'array';
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
$plane = ($code & 0x1f0000) >> 16;
if ($plane > 16) {
if ($plane > 16)
{
printf STDERR "Warning: invalid plane No.$plane. ignored\n";
next;
}
if ($plane == 1) {
if ($plane == 1)
{
$c = (($code & 0xffff) | 0x8080);
$array{ $c } = $utf;
$array{$c} = $utf;
$count++;
}
$c = (0x8ea00000 + ($plane << 16)) | (($code & 0xffff) | 0x8080);
$array{ $c } = $utf;
$array{$c} = $utf;
}
}
close( FILE );
close(FILE);
$file = "euc_tw_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_TW[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -18,28 +18,32 @@ require "ucs2utf.pl";
$in_file = "ISO10646-GB18030.TXT";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $u, $c, $rest ) = split;
($u, $c, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = $code;
$array{$utf} = $code;
}
}
close( FILE );
close(FILE);
#
......@@ -47,15 +51,19 @@ close( FILE );
#
$file = "utf8_to_gb18030.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapGB18030[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -69,38 +77,46 @@ close(FILE);
#
reset 'array';
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $u, $c, $rest ) = split;
($u, $c, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate code: %04x\n", $ucs;
next;
}
$count++;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = "gb18030_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapGB18030[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -13,15 +13,17 @@ require "ucs2utf.pl";
$in_file = "sjis-0213-2004-std.txt";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
reset 'array1';
reset 'comment';
reset 'comment1';
while($line = <FILE> ){
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
while ($line = <FILE>)
{
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u1 = $2;
$u2 = $3;
......@@ -32,46 +34,59 @@ while($line = <FILE> ){
$ucs = hex($u2);
$utf2 = &ucs2utf($ucs);
$str = sprintf "%08x%08x", $utf1, $utf2;
$array1{ $str } = $code;
$comment1{ $str } = $rest;
$array1{$str} = $code;
$comment1{$str} = $rest;
$count1++;
next;
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) {
}
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u = $2;
$rest = "U+" . $u . $3;
} else {
}
else
{
next;
}
$ucs = hex($u);
$code = hex($c);
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %08x UCS: %04x Shift JIS: %04x\n",$utf, $ucs, $code;
if ($array{$utf} ne "")
{
printf STDERR
"Warning: duplicate UTF8: %08x UCS: %04x Shift JIS: %04x\n", $utf,
$ucs, $code;
next;
}
$count++;
$array{ $utf } = $code;
$comment{ $code } = $rest;
$array{$utf} = $code;
$comment{$code} = $rest;
}
close( FILE );
close(FILE);
$file = "utf8_to_shift_jis_2004.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_utf_to_local ULmapSHIFT_JIS_2004[] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
printf FILE " {0x%08x, 0x%06x} /* %s */\n", $index, $code, $comment{ $code };
} else {
printf FILE " {0x%08x, 0x%06x}, /* %s */\n", $index, $code, $comment{ $code };
if ($count == 0)
{
printf FILE " {0x%08x, 0x%06x} /* %s */\n", $index, $code,
$comment{$code};
}
else
{
printf FILE " {0x%08x, 0x%06x}, /* %s */\n", $index, $code,
$comment{$code};
}
}
......@@ -79,19 +94,27 @@ print FILE "};\n";
close(FILE);
$file = "utf8_to_shift_jis_2004_combined.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {\n";
print FILE
"static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {\n";
for $index ( sort {$a cmp $b} keys( %array1 ) ){
$code = $array1{ $index };
for $index (sort { $a cmp $b } keys(%array1))
{
$code = $array1{$index};
$count1--;
if( $count1 == 0 ){
printf FILE " {0x%s, 0x%s, 0x%04x} /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index };
} else {
printf FILE " {0x%s, 0x%s, 0x%04x}, /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index };
if ($count1 == 0)
{
printf FILE " {0x%s, 0x%s, 0x%04x} /* %s */\n", substr($index, 0, 8),
substr($index, 8, 8), $code, $comment1{$index};
}
else
{
printf FILE " {0x%s, 0x%s, 0x%04x}, /* %s */\n",
substr($index, 0, 8), substr($index, 8, 8), $code,
$comment1{$index};
}
}
......@@ -102,15 +125,17 @@ close(FILE);
$in_file = "sjis-0213-2004-std.txt";
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
reset 'array1';
reset 'comment';
reset 'comment1';
while($line = <FILE> ){
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) {
while ($line = <FILE>)
{
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u1 = $2;
$u2 = $3;
......@@ -121,47 +146,60 @@ while($line = <FILE> ){
$ucs = hex($u2);
$utf2 = &ucs2utf($ucs);
$str = sprintf "%08x%08x", $utf1, $utf2;
$array1{ $code } = $str;
$comment1{ $code } = $rest;
$array1{$code} = $str;
$comment1{$code} = $rest;
$count1++;
next;
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) {
}
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
{
$c = $1;
$u = $2;
$rest = "U+" . $u . $3;
} else {
}
else
{
next;
}
$ucs = hex($u);
$code = hex($c);
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate UTF-8: %08x UCS: %04x Shift JIS: %04x\n",$utf, $ucs, $code;
printf STDERR "Previous value: UTF-8: %08x\n", $array{ $utf };
if ($array{$code} ne "")
{
printf STDERR
"Warning: duplicate UTF-8: %08x UCS: %04x Shift JIS: %04x\n", $utf,
$ucs, $code;
printf STDERR "Previous value: UTF-8: %08x\n", $array{$utf};
next;
}
$count++;
$array{ $code } = $utf;
$comment{ $utf } = $rest;
$array{$code} = $utf;
$comment{$utf} = $rest;
}
close( FILE );
close(FILE);
$file = "shift_jis_2004_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFTJIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_local_to_utf LUmapSHIFT_JIS_2004[] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
printf FILE " {0x%04x, 0x%08x} /* %s */\n", $index, $code, $comment{ $code };
} else {
printf FILE " {0x%04x, 0x%08x}, /* %s */\n", $index, $code, $comment{ $code };
if ($count == 0)
{
printf FILE " {0x%04x, 0x%08x} /* %s */\n", $index, $code,
$comment{$code};
}
else
{
printf FILE " {0x%04x, 0x%08x}, /* %s */\n", $index, $code,
$comment{$code};
}
}
......@@ -169,19 +207,26 @@ print FILE "};\n";
close(FILE);
$file = "shift_jis_2004_to_utf8_combined.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n";
print FILE
"static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n";
for $index ( sort {$a <=> $b} keys( %array1 ) ){
$code = $array1{ $index };
for $index (sort { $a <=> $b } keys(%array1))
{
$code = $array1{$index};
$count1--;
if( $count1 == 0 ){
printf FILE " {0x%04x, 0x%s, 0x%s} /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index };
} else {
printf FILE " {0x%04x, 0x%s, 0x%s}, /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index };
if ($count1 == 0)
{
printf FILE " {0x%04x, 0x%s, 0x%s} /* %s */\n", $index,
substr($code, 0, 8), substr($code, 8, 8), $comment1{$index};
}
else
{
printf FILE " {0x%04x, 0x%s, 0x%s}, /* %s */\n", $index,
substr($code, 0, 8), substr($code, 8, 8), $comment1{$index};
}
}
......
......@@ -24,58 +24,66 @@ require "ucs2utf.pl";
$in_file = "CP932.TXT";
$count = 0;
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if((( $code >= 0xed40 )
&& ( $code <= 0xeefc ))
|| (( $code >= 0x8754 )
&&( $code <= 0x875d ))
|| ( $code == 0x878a )
|| ( $code == 0x8782 )
|| ( $code == 0x8784 )
|| ( $code == 0xfa5b )
|| ( $code == 0xfa54 )
|| (( $code >= 0x8790 )
&& ( $code <= 0x8792 ))
|| (( $code >= 0x8795 )
&& ( $code <= 0x8797 ))
|| (( $code >= 0x879a )
&& ( $code <= 0x879c )))
if ((($code >= 0xed40) && ($code <= 0xeefc))
|| ( ($code >= 0x8754)
&& ($code <= 0x875d))
|| ($code == 0x878a)
|| ($code == 0x8782)
|| ($code == 0x8784)
|| ($code == 0xfa5b)
|| ($code == 0xfa54)
|| ( ($code >= 0x8790)
&& ($code <= 0x8792))
|| ( ($code >= 0x8795)
&& ($code <= 0x8797))
|| ( ($code >= 0x879a)
&& ($code <= 0x879c)))
{
printf STDERR "Warning: duplicate UTF8 : UCS=0x%04x SJIS=0x%04x\n",$ucs,$code;
printf STDERR
"Warning: duplicate UTF8 : UCS=0x%04x SJIS=0x%04x\n", $ucs,
$code;
next;
}
$count++;
$array{ $utf } = $code;
$array{$utf} = $code;
}
}
close( FILE );
close(FILE);
#
# first, generate UTF8 --> SJIS table
#
$file = "utf8_to_sjis.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapSJIS[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -87,37 +95,44 @@ close(FILE);
# then generate SJIS --> UTF8 table
#
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
$count = 0;
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080 ){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
$count++;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = "sjis_to_utf8.map";
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapSJIS[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -46,52 +46,60 @@ require "ucs2utf.pl";
'KOI8U' => 'KOI8-U.TXT',
'GBK' => 'CP936.TXT',
'UHC' => 'CP949.TXT',
'JOHAB' => 'JOHAB.TXT',
);
'JOHAB' => 'JOHAB.TXT',);
@charsets = keys(filename);
@charsets = @ARGV if scalar(@ARGV);
foreach $charset (@charsets) {
foreach $charset (@charsets)
{
#
# first, generate UTF8-> charset table
#
#
# first, generate UTF8-> charset table
#
$in_file = $filename{$charset};
open( FILE, $in_file ) || die( "cannot open $in_file" );
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if( $code >= 0x80 && $ucs >= 0x0080){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $utf } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$utf} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $utf } = $code;
$array{$utf} = $code;
}
}
close( FILE );
close(FILE);
$file = lc("utf8_to_${charset}.map");
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmap${charset}[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$code = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$code = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
......@@ -99,42 +107,50 @@ foreach $charset (@charsets) {
print FILE "};\n";
close(FILE);
#
# then generate character set code ->UTF8 table
#
open( FILE, $in_file ) || die( "cannot open $in_file" );
#
# then generate character set code ->UTF8 table
#
open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
while( <FILE> ){
while (<FILE>)
{
chop;
if( /^#/ ){
if (/^#/)
{
next;
}
( $c, $u, $rest ) = split;
($c, $u, $rest) = split;
$ucs = hex($u);
$code = hex($c);
if($code >= 0x80 && $ucs >= 0x0080){
if ($code >= 0x80 && $ucs >= 0x0080)
{
$utf = &ucs2utf($ucs);
if( $array{ $code } ne "" ){
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs;
if ($array{$code} ne "")
{
printf STDERR "Warning: duplicate UTF8: %04x\n", $ucs;
next;
}
$count++;
$array{ $code } = $utf;
$array{$code} = $utf;
}
}
close( FILE );
close(FILE);
$file = lc("${charset}_to_utf8.map");
open( FILE, "> $file" ) || die( "cannot open $file" );
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmap${charset}[ $count ] = {\n";
for $index ( sort {$a <=> $b} keys( %array ) ){
$utf = $array{ $index };
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
$count--;
if( $count == 0 ){
if ($count == 0)
{
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
} else {
}
else
{
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}
......
......@@ -4,24 +4,32 @@
# src/backend/utils/mb/Unicode/ucs2utf.pl
# convert UCS-4 to UTF-8
#
sub ucs2utf {
local($ucs) = @_;
sub ucs2utf
{
local ($ucs) = @_;
local $utf;
if ($ucs <= 0x007f) {
if ($ucs <= 0x007f)
{
$utf = $ucs;
} elsif ($ucs > 0x007f && $ucs <= 0x07ff) {
}
elsif ($ucs > 0x007f && $ucs <= 0x07ff)
{
$utf = (($ucs & 0x003f) | 0x80) | ((($ucs >> 6) | 0xc0) << 8);
} elsif ($ucs > 0x07ff && $ucs <= 0xffff) {
$utf = ((($ucs >> 12) | 0xe0) << 16) |
(((($ucs & 0x0fc0) >> 6) | 0x80) << 8) |
(($ucs & 0x003f) | 0x80);
} else {
$utf = ((($ucs >> 18) | 0xf0) << 24) |
}
elsif ($ucs > 0x07ff && $ucs <= 0xffff)
{
$utf =
((($ucs >> 12) | 0xe0) << 16) |
(((($ucs & 0x0fc0) >> 6) | 0x80) << 8) | (($ucs & 0x003f) | 0x80);
}
else
{
$utf =
((($ucs >> 18) | 0xf0) << 24) |
(((($ucs & 0x3ffff) >> 12) | 0x80) << 16) |
(((($ucs & 0x0fc0) >> 6) | 0x80) << 8) |
(($ucs & 0x003f) | 0x80);
(((($ucs & 0x0fc0) >> 6) | 0x80) << 8) | (($ucs & 0x003f) | 0x80);
}
return($utf);
return ($utf);
}
1;
......@@ -22,14 +22,17 @@
use strict;
my $docdir = $ARGV[0] or die "$0: missing required argument: docdir\n";
my $hfile = $ARGV[1] . '.h' or die "$0: missing required argument: output file\n";
my $hfile = $ARGV[1] . '.h'
or die "$0: missing required argument: output file\n";
my $cfile = $ARGV[1] . '.c';
my $hfilebasename;
if ($hfile =~ m!.*/([^/]+)$!) {
if ($hfile =~ m!.*/([^/]+)$!)
{
$hfilebasename = $1;
}
else {
else
{
$hfilebasename = $hfile;
}
......@@ -44,8 +47,7 @@ open(HFILE, ">$hfile")
open(CFILE, ">$cfile")
or die "$0: could not open output file '$cfile': $!\n";
print HFILE
"/*
print HFILE "/*
* *** Do not change this file by hand. It is automatically
* *** generated from the DocBook documentation.
*
......@@ -72,8 +74,7 @@ struct _helpStruct
";
print CFILE
"/*
print CFILE "/*
* *** Do not change this file by hand. It is automatically
* *** generated from the DocBook documentation.
*
......@@ -90,7 +91,8 @@ my $maxlen = 0;
my %entries;
foreach my $file (sort readdir DIR) {
foreach my $file (sort readdir DIR)
{
my (@cmdnames, $cmddesc, $cmdsynopsis);
$file =~ /\.sgml$/ or next;
......@@ -99,15 +101,24 @@ foreach my $file (sort readdir DIR) {
close FILE;
# Ignore files that are not for SQL language statements
$filecontent =~ m!<refmiscinfo>\s*SQL - Language Statements\s*</refmiscinfo>!i
$filecontent =~
m!<refmiscinfo>\s*SQL - Language Statements\s*</refmiscinfo>!i
or next;
# Collect multiple refnames
LOOP: { $filecontent =~ m!\G.*?<refname>\s*([a-z ]+?)\s*</refname>!cgis and push @cmdnames, $1 and redo LOOP; }
$filecontent =~ m!<refpurpose>\s*(.+?)\s*</refpurpose>!is and $cmddesc = $1;
$filecontent =~ m!<synopsis>\s*(.+?)\s*</synopsis>!is and $cmdsynopsis = $1;
LOOP:
{
$filecontent =~ m!\G.*?<refname>\s*([a-z ]+?)\s*</refname>!cgis
and push @cmdnames, $1
and redo LOOP;
}
$filecontent =~ m!<refpurpose>\s*(.+?)\s*</refpurpose>!is
and $cmddesc = $1;
$filecontent =~ m!<synopsis>\s*(.+?)\s*</synopsis>!is
and $cmdsynopsis = $1;
if (@cmdnames && $cmddesc && $cmdsynopsis) {
if (@cmdnames && $cmddesc && $cmdsynopsis)
{
s/\"/\\"/g foreach @cmdnames;
$cmddesc =~ s/<[^>]+>//g;
......@@ -118,10 +129,12 @@ foreach my $file (sort readdir DIR) {
my $nl_count = () = $cmdsynopsis =~ /\n/g;
$cmdsynopsis =~ m!</>! and die "$0:$file: null end tag not supported in synopsis\n";
$cmdsynopsis =~ m!</>!
and die "$0:$file: null end tag not supported in synopsis\n";
$cmdsynopsis =~ s/%/%%/g;
while ($cmdsynopsis =~ m!<(\w+)[^>]*>(.+?)</\1[^>]*>!) {
while ($cmdsynopsis =~ m!<(\w+)[^>]*>(.+?)</\1[^>]*>!)
{
my $match = $2;
$match =~ s/<[^>]+>//g;
$match =~ s/%%/%/g;
......@@ -131,30 +144,37 @@ foreach my $file (sort readdir DIR) {
$cmdsynopsis =~ s/\r?\n/\\n/g;
$cmdsynopsis =~ s/\"/\\"/g;
foreach my $cmdname (@cmdnames) {
$entries{$cmdname} = { cmddesc => $cmddesc, cmdsynopsis => $cmdsynopsis, params => \@params, nl_count => $nl_count };
$maxlen = ($maxlen >= length $cmdname) ? $maxlen : length $cmdname;
foreach my $cmdname (@cmdnames)
{
$entries{$cmdname} = {
cmddesc => $cmddesc,
cmdsynopsis => $cmdsynopsis,
params => \@params,
nl_count => $nl_count };
$maxlen =
($maxlen >= length $cmdname) ? $maxlen : length $cmdname;
}
}
else {
else
{
die "$0: parsing file '$file' failed (N='@cmdnames' D='$cmddesc')\n";
}
}
foreach (sort keys %entries) {
my $prefix = "\t"x5 . ' ';
foreach (sort keys %entries)
{
my $prefix = "\t" x 5 . ' ';
my $id = $_;
$id =~ s/ /_/g;
my $synopsis = "\"$entries{$_}{cmdsynopsis}\"";
$synopsis =~ s/\\n/\\n"\n$prefix"/g;
my @args = ("buf",
$synopsis,
map("_(\"$_\")", @{$entries{$_}{params}}));
my @args =
("buf", $synopsis, map("_(\"$_\")", @{ $entries{$_}{params} }));
print HFILE "extern void sql_help_$id(PQExpBuffer buf);\n";
print CFILE "void
sql_help_$id(PQExpBuffer buf)
{
\tappendPQExpBuffer(".join(",\n$prefix", @args).");
\tappendPQExpBuffer(" . join(",\n$prefix", @args) . ");
}
";
......@@ -164,7 +184,8 @@ print HFILE "
static const struct _helpStruct QL_HELP[] = {
";
foreach (sort keys %entries) {
foreach (sort keys %entries)
{
my $id = $_;
$id =~ s/ /_/g;
print HFILE " { \"$_\",
......@@ -180,7 +201,9 @@ print HFILE "
};
#define QL_HELP_COUNT ".scalar(keys %entries)." /* number of help items */
#define QL_HELP_COUNT "
. scalar(keys %entries)
. " /* number of help items */
#define QL_MAX_CMD_LEN $maxlen /* largest strlen(cmd) */
......
......@@ -39,12 +39,11 @@ my %replace_line = (
'ExecuteStmtEXECUTEnameexecute_param_clause' =>
'EXECUTE prepared_name execute_param_clause execute_rest',
'ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEnameexecute_param_clause' =>
'CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause',
'ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEnameexecute_param_clause'
=> 'CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause',
'PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt' =>
'PREPARE prepared_name prep_type_clause AS PreparableStmt'
);
'PREPARE prepared_name prep_type_clause AS PreparableStmt');
my $block = '';
my $yaccmode = 0;
......@@ -62,7 +61,7 @@ while (<GRAM>)
$yaccmode++;
}
if ( $yaccmode != 1 )
if ($yaccmode != 1)
{
next;
}
......@@ -80,12 +79,12 @@ while (<GRAM>)
s|\*\/| */ |g;
# Now split the line into individual fields
my $n = ( @arr = split( ' ' ) );
my $n = (@arr = split(' '));
# Go through each field in turn
for ( my $fieldIndexer = 0 ; $fieldIndexer < $n ; $fieldIndexer++ )
for (my $fieldIndexer = 0; $fieldIndexer < $n; $fieldIndexer++)
{
if ( $arr[$fieldIndexer] eq '*/' && $comment )
if ($arr[$fieldIndexer] eq '*/' && $comment)
{
$comment = 0;
next;
......@@ -94,36 +93,37 @@ while (<GRAM>)
{
next;
}
elsif ( $arr[$fieldIndexer] eq '/*' )
elsif ($arr[$fieldIndexer] eq '/*')
{
# start of a multiline comment
$comment = 1;
next;
}
elsif ( $arr[$fieldIndexer] eq '//' )
elsif ($arr[$fieldIndexer] eq '//')
{
next;
}
elsif ( $arr[$fieldIndexer] eq '}' )
elsif ($arr[$fieldIndexer] eq '}')
{
$brace_indent--;
next;
}
elsif ( $arr[$fieldIndexer] eq '{' )
elsif ($arr[$fieldIndexer] eq '{')
{
$brace_indent++;
next;
}
if ( $brace_indent > 0 )
if ($brace_indent > 0)
{
next;
}
if ( $arr[$fieldIndexer] eq ';' || $arr[$fieldIndexer] eq '|' )
if ($arr[$fieldIndexer] eq ';' || $arr[$fieldIndexer] eq '|')
{
$block = $non_term_id . $block;
if ( $replace_line{$block} )
if ($replace_line{$block})
{
$block = $non_term_id . $replace_line{$block};
$block =~ tr/ |//d;
......@@ -132,8 +132,8 @@ while (<GRAM>)
$cc++;
$block = '';
}
elsif ( ( $arr[$fieldIndexer] =~ '[A-Za-z0-9]+:' )
|| $arr[ $fieldIndexer + 1 ] eq ':' )
elsif (($arr[$fieldIndexer] =~ '[A-Za-z0-9]+:')
|| $arr[ $fieldIndexer + 1 ] eq ':')
{
$non_term_id = $arr[$fieldIndexer];
$non_term_id =~ tr/://d;
......@@ -157,14 +157,14 @@ $cc = 0;
open ECPG, $filename or die $!;
while (<ECPG>)
{
if ( !/^ECPG:/ )
if (!/^ECPG:/)
{
next;
}
my @Fld = split( ' ', $_, 3 );
my @Fld = split(' ', $_, 3);
$cc++;
if ( not exists $found{ $Fld[1] } )
if (not exists $found{ $Fld[1] })
{
print $Fld[1], " is not used for building parser!\n";
$ret = 1;
......
This diff is collapsed.
......@@ -7,60 +7,70 @@ PostgreSQL::InServer::Util::bootstrap();
# globals
sub ::is_array_ref {
sub ::is_array_ref
{
return ref($_[0]) =~ m/^(?:PostgreSQL::InServer::)?ARRAY$/;
}
sub ::encode_array_literal {
sub ::encode_array_literal
{
my ($arg, $delim) = @_;
return $arg unless(::is_array_ref($arg));
return $arg unless (::is_array_ref($arg));
$delim = ', ' unless defined $delim;
my $res = '';
foreach my $elem (@$arg) {
foreach my $elem (@$arg)
{
$res .= $delim if length $res;
if (ref $elem) {
if (ref $elem)
{
$res .= ::encode_array_literal($elem, $delim);
}
elsif (defined $elem) {
elsif (defined $elem)
{
(my $str = $elem) =~ s/(["\\])/\\$1/g;
$res .= qq("$str");
}
else {
else
{
$res .= 'NULL';
}
}
return qq({$res});
}
sub ::encode_array_constructor {
sub ::encode_array_constructor
{
my $arg = shift;
return ::quote_nullable($arg) unless ::is_array_ref($arg);
my $res = join ", ", map {
(ref $_) ? ::encode_array_constructor($_)
: ::quote_nullable($_)
} @$arg;
my $res = join ", ",
map { (ref $_) ? ::encode_array_constructor($_) : ::quote_nullable($_) }
@$arg;
return "ARRAY[$res]";
}
{
package PostgreSQL::InServer;
use strict;
use warnings;
sub plperl_warn {
package PostgreSQL::InServer;
use strict;
use warnings;
sub plperl_warn
{
(my $msg = shift) =~ s/\(eval \d+\) //g;
chomp $msg;
&::elog(&::WARNING, $msg);
}
$SIG{__WARN__} = \&plperl_warn;
}
$SIG{__WARN__} = \&plperl_warn;
sub plperl_die {
sub plperl_die
{
(my $msg = shift) =~ s/\(eval \d+\) //g;
die $msg;
}
$SIG{__DIE__} = \&plperl_die;
}
$SIG{__DIE__} = \&plperl_die;
sub mkfuncsrc {
sub mkfuncsrc
{
my ($name, $imports, $prolog, $src) = @_;
my $BEGIN = join "\n", map {
......@@ -70,36 +80,40 @@ sub mkfuncsrc {
$BEGIN &&= "BEGIN { $BEGIN }";
return qq[ package main; sub { $BEGIN $prolog $src } ];
}
}
sub mkfunc {
sub mkfunc
{
no strict; # default to no strict for the eval
no warnings; # default to no warnings for the eval
my $ret = eval(mkfuncsrc(@_));
$@ =~ s/\(eval \d+\) //g if $@;
return $ret;
}
}
1;
1;
}
{
package PostgreSQL::InServer::ARRAY;
use strict;
use warnings;
use overload
'""'=>\&to_str,
'@{}'=>\&to_arr;
package PostgreSQL::InServer::ARRAY;
use strict;
use warnings;
use overload
'""' => \&to_str,
'@{}' => \&to_arr;
sub to_str {
sub to_str
{
my $self = shift;
return ::encode_typed_literal($self->{'array'}, $self->{'typeoid'});
}
}
sub to_arr {
sub to_arr
{
return shift->{'array'};
}
}
1;
1;
}
......@@ -8,7 +8,7 @@ use Opcode qw(opset opset_to_ops opdesc);
my $plperl_opmask_h = shift
or die "Usage: $0 <output_filename.h>\n";
my $plperl_opmask_tmp = $plperl_opmask_h."tmp";
my $plperl_opmask_tmp = $plperl_opmask_h . "tmp";
END { unlink $plperl_opmask_tmp }
open my $fh, ">", "$plperl_opmask_tmp"
......@@ -19,31 +19,36 @@ printf $fh " memset(opmask, 1, MAXO);\t/* disable all */ \\\n";
printf $fh " /* then allow some... */ \\\n";
my @allowed_ops = (
# basic set of opcodes
qw[:default :base_math !:base_io sort time],
# require is safe because we redirect the opcode
# entereval is safe as the opmask is now permanently set
# caller is safe because the entire interpreter is locked down
qw[require entereval caller],
# These are needed for utf8_heavy.pl:
# dofile is safe because we redirect the opcode like require above
# print is safe because the only writable filehandles are STDOUT & STDERR
# prtf (printf) is safe as it's the same as print + sprintf
qw[dofile print prtf],
# Disallow these opcodes that are in the :base_orig optag
# (included in :default) but aren't considered sufficiently safe
qw[!dbmopen !setpgrp !setpriority],
# custom is not deemed a likely security risk as it can't be generated from
# perl so would only be seen if the DBA had chosen to load a module that
# used it. Even then it's unlikely to be seen because it's typically
# generated by compiler plugins that operate after PL_op_mask checks.
# But we err on the side of caution and disable it
qw[!custom],
);
qw[!custom],);
printf $fh " /* ALLOWED: @allowed_ops */ \\\n";
foreach my $opname (opset_to_ops(opset(@allowed_ops))) {
foreach my $opname (opset_to_ops(opset(@allowed_ops)))
{
printf $fh qq{ opmask[OP_%-12s] = 0;\t/* %s */ \\\n},
uc($opname), opdesc($opname);
}
......
......@@ -32,8 +32,7 @@ GetOptions(
'prefix=s' => \my $opt_prefix,
'name=s' => \my $opt_name,
'strip=s' => \my $opt_strip,
'selftest!' => sub { exit selftest() },
) or exit 1;
'selftest!' => sub { exit selftest() },) or exit 1;
die "No text files specified"
unless @ARGV;
......@@ -45,7 +44,8 @@ print qq{
*/
};
for my $src_file (@ARGV) {
for my $src_file (@ARGV)
{
(my $macro = $src_file) =~ s/ .*? (\w+) (?:\.\w+) $/$1/x;
......@@ -55,7 +55,8 @@ for my $src_file (@ARGV) {
printf qq{#define %s%s \\\n},
$opt_prefix || '',
($opt_name) ? $opt_name : uc $macro;
while (<$src_fh>) {
while (<$src_fh>)
{
chomp;
next if $opt_strip and m/$opt_strip/o;
......@@ -74,7 +75,8 @@ print "/* end */\n";
exit 0;
sub selftest {
sub selftest
{
my $tmp = "text2macro_tmp";
my $string = q{a '' '\\'' "" "\\"" "\\\\" "\\\\n" b};
......
......@@ -6,12 +6,14 @@
use warnings;
use strict;
print "/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print
"/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print "/* there is deliberately not an #ifndef PLERRCODES_H here */\n";
open my $errcodes, $ARGV[0] or die;
while (<$errcodes>) {
while (<$errcodes>)
{
chomp;
# Skip comments
......@@ -23,10 +25,8 @@ while (<$errcodes>) {
die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
(my $sqlstate,
my $type,
my $errcode_macro,
my $condition_name) = ($1, $2, $3, $4);
(my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
($1, $2, $3, $4);
# Skip non-errors
next unless $type eq 'E';
......
......@@ -6,12 +6,14 @@
use warnings;
use strict;
print "/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print
"/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
print "/* there is deliberately not an #ifndef SPIEXCEPTIONS_H here */\n";
open my $errcodes, $ARGV[0] or die;
while (<$errcodes>) {
while (<$errcodes>)
{
chomp;
# Skip comments
......@@ -23,10 +25,8 @@ while (<$errcodes>) {
die unless /^([^\s]{5})\s+([EWS])\s+([^\s]+)(?:\s+)?([^\s]+)?/;
(my $sqlstate,
my $type,
my $errcode_macro,
my $condition_name) = ($1, $2, $3, $4);
(my $sqlstate, my $type, my $errcode_macro, my $condition_name) =
($1, $2, $3, $4);
# Skip non-errors
next unless $type eq 'E';
......@@ -37,8 +37,8 @@ while (<$errcodes>) {
# Change some_error_condition to SomeErrorCondition
$condition_name =~ s/([a-z])([^_]*)(?:_|$)/\u$1$2/g;
print "{ \"spiexceptions.$condition_name\", " .
"\"$condition_name\", $errcode_macro },\n";
print "{ \"spiexceptions.$condition_name\", "
. "\"$condition_name\", $errcode_macro },\n";
}
close $errcodes;
......@@ -2,10 +2,10 @@
use locale;
open(INFILE, "<$ARGV[0]");
chop(my(@words) = <INFILE>);
chop(my (@words) = <INFILE>);
close(INFILE);
$"="\n";
my(@result) = sort @words;
$" = "\n";
my (@result) = sort @words;
print "@result\n";
......@@ -10,9 +10,9 @@ $DBNAME = 'perftest';
# This describtion for all DBMS supported by test
# DBMS_name => [FrontEnd, DestroyDB command, CreateDB command]
%DBMS = (
'pgsql' => ["psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME"]
);
%DBMS =
('pgsql' =>
[ "psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME" ]);
# Tests to run: test' script, test' description, ...
# Test' script is in form
......@@ -34,30 +34,37 @@ $DBNAME = 'perftest';
# an idea of what can be done for features unsupported by an DBMS.)
#
@perftests = (
# It speed up things
'connection.ntm', 'DB connection startup (no timing)',
# Just connection startup time (echo "" | psql ... - for PgSQL)
'connection', 'DB connection startup',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
# 8192 inserts in single xaction
'inssimple T', '8192 INSERTs INTO SIMPLE (1 xact)',
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
# 8192 inserts in 8192 xactions
'inssimple', '8192 INSERTs INTO SIMPLE (8192 xacts)',
'vacuum.ntm', 'Vacuum (no timing)',
# Fast (after table filled with data) index creation test
'crtsimpleidx', 'Create INDEX on SIMPLE',
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
'crtsimpleidx.ntm', 'Create INDEX on SIMPLE (no timing)',
# 8192 inserts in single xaction into table with index
'inssimple T', '8192 INSERTs INTO SIMPLE with INDEX (1 xact)',
# 8192 SELECT * FROM simple WHERE justint = <random_key> in single xaction
'slcsimple T', '8192 random INDEX scans on SIMPLE (1 xact)',
# SELECT * FROM simple ORDER BY justint
'orbsimple', 'ORDER BY SIMPLE',
);
# It speed up things
'connection.ntm', 'DB connection startup (no timing)',
# Just connection startup time (echo "" | psql ... - for PgSQL)
'connection', 'DB connection startup',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
# 8192 inserts in single xaction
'inssimple T', '8192 INSERTs INTO SIMPLE (1 xact)',
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
# 8192 inserts in 8192 xactions
'inssimple', '8192 INSERTs INTO SIMPLE (8192 xacts)',
'vacuum.ntm', 'Vacuum (no timing)',
# Fast (after table filled with data) index creation test
'crtsimpleidx', 'Create INDEX on SIMPLE',
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
'crtsimpleidx.ntm', 'Create INDEX on SIMPLE (no timing)',
# 8192 inserts in single xaction into table with index
'inssimple T', '8192 INSERTs INTO SIMPLE with INDEX (1 xact)',
# 8192 SELECT * FROM simple WHERE justint = <random_key> in single xaction
'slcsimple T', '8192 random INDEX scans on SIMPLE (1 xact)',
# SELECT * FROM simple ORDER BY justint
'orbsimple', 'ORDER BY SIMPLE',);
#
# It seems that nothing below need to be changed
......@@ -78,60 +85,64 @@ print "(Re)create DataBase $DBNAME\n";
$ResFile = "Results.$TestDBMS";
$TmpFile = "Tmp.$TestDBMS";
open (SAVEOUT, ">&STDOUT");
open (STDOUT, ">/dev/null") or die;
open (SAVEERR, ">&STDERR");
open (STDERR, ">$TmpFile") or die;
select (STDERR); $| = 1;
open(SAVEOUT, ">&STDOUT");
open(STDOUT, ">/dev/null") or die;
open(SAVEERR, ">&STDERR");
open(STDERR, ">$TmpFile") or die;
select(STDERR);
$| = 1;
for ($i = 0; $i <= $#perftests; $i++)
{
$test = $perftests[$i];
($test, $XACTBLOCK) = split (/ /, $test);
($test, $XACTBLOCK) = split(/ /, $test);
$runtest = $test;
if ( $test =~ /\.ntm/ )
if ($test =~ /\.ntm/)
{
#
# No timing for this queries
#
close (STDERR); # close $TmpFile
open (STDERR, ">/dev/null") or die;
close(STDERR); # close $TmpFile
open(STDERR, ">/dev/null") or die;
$runtest =~ s/\.ntm//;
}
else
{
close (STDOUT);
close(STDOUT);
open(STDOUT, ">&SAVEOUT");
print STDOUT "\nRunning: $perftests[$i+1] ...";
close (STDOUT);
open (STDOUT, ">/dev/null") or die;
select (STDERR); $| = 1;
close(STDOUT);
open(STDOUT, ">/dev/null") or die;
select(STDERR);
$| = 1;
printf "$perftests[$i+1]: ";
}
do "sqls/$runtest";
# Restore STDERR to $TmpFile
if ( $test =~ /\.ntm/ )
if ($test =~ /\.ntm/)
{
close (STDERR);
open (STDERR, ">>$TmpFile") or die;
close(STDERR);
open(STDERR, ">>$TmpFile") or die;
}
select (STDERR); $| = 1;
select(STDERR);
$| = 1;
$i++;
}
close (STDERR);
close(STDERR);
open(STDERR, ">&SAVEERR");
open (TMPF, "<$TmpFile") or die;
open (RESF, ">$ResFile") or die;
open(TMPF, "<$TmpFile") or die;
open(RESF, ">$ResFile") or die;
while (<TMPF>)
{
$str = $_;
($test, $rtime) = split (/:/, $str);
($tmp, $rtime, $rest) = split (/[ ]+/, $rtime);
($test, $rtime) = split(/:/, $str);
($tmp, $rtime, $rest) = split(/[ ]+/, $rtime);
print RESF "$test: $rtime\n";
}
......@@ -32,22 +32,33 @@ my $cur_nonterminal;
# We parse the input and emit warnings on the fly.
my $in_grammar = 0;
while (<>) {
while (<>)
{
my $rule_number;
my $rhs;
# We only care about the "Grammar" part of the input.
if (m/^Grammar$/) {
if (m/^Grammar$/)
{
$in_grammar = 1;
} elsif (m/^Terminal/) {
}
elsif (m/^Terminal/)
{
$in_grammar = 0;
} elsif ($in_grammar) {
if (m/^\s*(\d+)\s+(\S+):\s+(.*)$/) {
}
elsif ($in_grammar)
{
if (m/^\s*(\d+)\s+(\S+):\s+(.*)$/)
{
# first rule for nonterminal
$rule_number = $1;
$cur_nonterminal = $2;
$rhs = $3;
} elsif (m/^\s*(\d+)\s+\|\s+(.*)$/) {
}
elsif (m/^\s*(\d+)\s+\|\s+(.*)$/)
{
# additional rule for nonterminal
$rule_number = $1;
$rhs = $2;
......@@ -55,18 +66,23 @@ while (<>) {
}
# Process rule if we found one
if (defined $rule_number) {
if (defined $rule_number)
{
# deconstruct the RHS
$rhs =~ s|^/\* empty \*/$||;
my @rhs = split '\s', $rhs;
print "Rule $rule_number: $cur_nonterminal := @rhs\n" if $debug;
# We complain if the nonterminal appears as the last RHS element
# but not elsewhere, since "expr := expr + expr" is reasonable
my $lastrhs = pop @rhs;
if (defined $lastrhs &&
$cur_nonterminal eq $lastrhs &&
!grep { $cur_nonterminal eq $_ } @rhs) {
print "Right recursion in rule $rule_number: $cur_nonterminal := $rhs\n";
if ( defined $lastrhs
&& $cur_nonterminal eq $lastrhs
&& !grep { $cur_nonterminal eq $_ } @rhs)
{
print
"Right recursion in rule $rule_number: $cur_nonterminal := $rhs\n";
}
}
}
......
......@@ -10,15 +10,19 @@ use strict;
my $errors = 0;
my $path;
sub error(@) {
sub error(@)
{
print STDERR @_;
$errors = 1;
}
if (@ARGV) {
if (@ARGV)
{
$path = $ARGV[0];
shift @ARGV;
} else {
}
else
{
$path = ".";
}
......@@ -39,21 +43,28 @@ my $comment;
my @arr;
my %keywords;
line: while (<GRAM>) {
line: while (<GRAM>)
{
chomp; # strip record separator
$S = $_;
# Make sure any braces are split
$s = '{', $S =~ s/$s/ { /g;
$s = '}', $S =~ s/$s/ } /g;
# Any comments are split
$s = '[/][*]', $S =~ s#$s# /* #g;
$s = '[*][/]', $S =~ s#$s# */ #g;
if (!($kcat)) {
if (!($kcat))
{
# Is this the beginning of a keyword list?
foreach $k (keys %keyword_categories) {
if ($S =~ m/^($k):/) {
foreach $k (keys %keyword_categories)
{
if ($S =~ m/^($k):/)
{
$kcat = $k;
next line;
}
......@@ -65,50 +76,64 @@ line: while (<GRAM>) {
$n = (@arr = split(' ', $S));
# Ok, we're in a keyword list. Go through each field in turn
for (my $fieldIndexer = 0; $fieldIndexer < $n; $fieldIndexer++) {
if ($arr[$fieldIndexer] eq '*/' && $comment) {
for (my $fieldIndexer = 0; $fieldIndexer < $n; $fieldIndexer++)
{
if ($arr[$fieldIndexer] eq '*/' && $comment)
{
$comment = 0;
next;
}
elsif ($comment) {
elsif ($comment)
{
next;
}
elsif ($arr[$fieldIndexer] eq '/*') {
elsif ($arr[$fieldIndexer] eq '/*')
{
# start of a multiline comment
$comment = 1;
next;
}
elsif ($arr[$fieldIndexer] eq '//') {
elsif ($arr[$fieldIndexer] eq '//')
{
next line;
}
if ($arr[$fieldIndexer] eq ';') {
if ($arr[$fieldIndexer] eq ';')
{
# end of keyword list
$kcat = '';
next;
}
if ($arr[$fieldIndexer] eq '|') {
if ($arr[$fieldIndexer] eq '|')
{
next;
}
# Put this keyword into the right list
push @{$keywords{$kcat}}, $arr[$fieldIndexer];
push @{ $keywords{$kcat} }, $arr[$fieldIndexer];
}
}
close GRAM;
# Check that all keywords are in alphabetical order
my ($prevkword, $kword, $bare_kword);
foreach $kcat (keys %keyword_categories) {
foreach $kcat (keys %keyword_categories)
{
$prevkword = '';
foreach $kword (@{$keywords{$kcat}}) {
foreach $kword (@{ $keywords{$kcat} })
{
# Some keyword have a _P suffix. Remove it for the comparison.
$bare_kword = $kword;
$bare_kword =~ s/_P$//;
if ($bare_kword le $prevkword) {
error "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
if ($bare_kword le $prevkword)
{
error
"'$bare_kword' after '$prevkword' in $kcat list is misplaced";
$errors = 1;
}
$prevkword = $bare_kword;
......@@ -120,8 +145,9 @@ foreach $kcat (keys %keyword_categories) {
# UNRESERVED_KEYWORD. Each inner hash is a keyed by keyword id, e.g. ABORT_P
# with a dummy value.
my %kwhashes;
while ( my ($kcat, $kcat_id) = each(%keyword_categories) ) {
@arr = @{$keywords{$kcat}};
while (my ($kcat, $kcat_id) = each(%keyword_categories))
{
@arr = @{ $keywords{$kcat} };
my $hash;
foreach my $item (@arr) { $hash->{$item} = 1 }
......@@ -137,47 +163,64 @@ open(KWLIST, $kwlist_filename) || die("Could not open : $kwlist_filename");
my $prevkwstring = '';
my $bare_kwname;
my %kwhash;
kwlist_line: while (<KWLIST>) {
my($line) = $_;
kwlist_line: while (<KWLIST>)
{
my ($line) = $_;
if ($line =~ /^PG_KEYWORD\(\"(.*)\", (.*), (.*)\)/)
{
my($kwstring) = $1;
my($kwname) = $2;
my($kwcat_id) = $3;
my ($kwstring) = $1;
my ($kwname) = $2;
my ($kwcat_id) = $3;
# Check that the list is in alphabetical order
if ($kwstring le $prevkwstring) {
error "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
if ($kwstring le $prevkwstring)
{
error
"'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
}
$prevkwstring = $kwstring;
# Check that the keyword string is valid: all lower-case ASCII chars
if ($kwstring !~ /^[a-z_]*$/) {
error "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
if ($kwstring !~ /^[a-z_]*$/)
{
error
"'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
}
# Check that the keyword name is valid: all upper-case ASCII chars
if ($kwname !~ /^[A-Z_]*$/) {
error "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
if ($kwname !~ /^[A-Z_]*$/)
{
error
"'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
}
# Check that the keyword string matches keyword name
$bare_kwname = $kwname;
$bare_kwname =~ s/_P$//;
if ($bare_kwname ne uc($kwstring)) {
error "keyword name '$kwname' doesn't match keyword string '$kwstring'";
if ($bare_kwname ne uc($kwstring))
{
error
"keyword name '$kwname' doesn't match keyword string '$kwstring'";
}
# Check that the keyword is present in the grammar
%kwhash = %{$kwhashes{$kwcat_id}};
%kwhash = %{ $kwhashes{$kwcat_id} };
if (!(%kwhash))
{
if (!(%kwhash)) {
#error "Unknown kwcat_id: $kwcat_id";
} else {
if (!($kwhash{$kwname})) {
}
else
{
if (!($kwhash{$kwname}))
{
error "'$kwname' not present in $kwcat_id section of gram.y";
} else {
}
else
{
# Remove it from the hash, so that we can complain at the end
# if there's keywords left that were not found in kwlist.h
delete $kwhashes{$kwcat_id}->{$kwname};
......@@ -188,11 +231,13 @@ kwlist_line: while (<KWLIST>) {
close KWLIST;
# Check that we've paired up all keywords from gram.y with lines in kwlist.h
while ( my ($kwcat, $kwcat_id) = each(%keyword_categories) ) {
%kwhash = %{$kwhashes{$kwcat_id}};
while (my ($kwcat, $kwcat_id) = each(%keyword_categories))
{
%kwhash = %{ $kwhashes{$kwcat_id} };
for my $kw ( keys %kwhash ) {
error "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
for my $kw (keys %kwhash)
{
error "'$kw' found in gram.y $kwcat category, but not in kwlist.h";
}
}
......
......@@ -15,14 +15,17 @@ use Tie::File;
my $pgdg = 'PostgreSQL Global Development Group';
my $cc = 'Copyright \(c\) ';
# year-1900 is what localtime(time) puts in element 5
my $year = 1900 + ${[localtime(time)]}[5];
my $year = 1900 + ${ [ localtime(time) ] }[5];
print "Using current year: $year\n";
find({wanted => \&wanted, no_chdir => 1}, '.');
find({ wanted => \&wanted, no_chdir => 1 }, '.');
sub wanted
{
sub wanted {
# prevent corruption of git indexes by ignoring any .git/
if ($_ eq '.git')
{
......@@ -30,17 +33,21 @@ sub wanted {
return;
}
return if ! -f $File::Find::name || -l $File::Find::name;
return if !-f $File::Find::name || -l $File::Find::name;
# skip file names with binary extensions
# How are these updated? bjm 2012-01-02
return if ($_ =~ m/\.(ico|bin)$);
return
if (
$_ =~ m/\.(ico|bin)$);
my @lines;
tie @lines, "Tie::File", $File::Find::name;
foreach my $line (@lines) {
# We only care about lines with a copyright notice.
next unless $line =~ m/$cc.*$pgdg/;
next unless $line =~ m/$cc . *$pgdg /;
# We stop when we've done one substitution. This is both for
# efficiency and, at least in the case of this program, for
# correctness.
......@@ -51,6 +58,8 @@ sub wanted {
untie @lines;
}
print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too.\n";
print "Also update ./COPYRIGHT and doc/src/sgml/legal.sgml in all back branches.\n";
print
"Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too.\n";
print
"Also update ./COPYRIGHT and doc/src/sgml/legal.sgml in all back branches.\n";
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -81,12 +81,12 @@ sub DetermineVisualStudioVersion
if (!defined($nmakeVersion))
{
# Determine version of nmake command, to set proper version of visual studio
# we use nmake as it has existed for a long time and still exists in visual studio 2010
open(P,"nmake /? 2>&1 |")
# Determine version of nmake command, to set proper version of visual studio
# we use nmake as it has existed for a long time and still exists in visual studio 2010
open(P, "nmake /? 2>&1 |")
|| croak
"Unable to determine Visual Studio version: The nmake command wasn't found.";
while(<P>)
"Unable to determine Visual Studio version: The nmake command wasn't found.";
while (<P>)
{
chomp;
if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/)
......@@ -96,17 +96,17 @@ sub DetermineVisualStudioVersion
}
close(P);
}
elsif($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/)
elsif ($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/)
{
return _GetVisualStudioVersion($1, $2);
}
croak
"Unable to determine Visual Studio version: The nmake version could not be determined.";
"Unable to determine Visual Studio version: The nmake version could not be determined.";
}
sub _GetVisualStudioVersion
{
my($major, $minor) = @_;
my ($major, $minor) = @_;
if ($major > 10)
{
carp
......
......@@ -52,7 +52,8 @@ elsif ($ARGV[0] ne "RELEASE")
if ($buildwhat and $vcver eq '10.00')
{
system("msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf");
system(
"msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf");
}
elsif ($buildwhat)
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -10,10 +10,13 @@ use warnings;
use Mkvcbuild;
chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');
die 'Must run from root or msvc directory'
unless (-d 'src\tools\msvc' && -d 'src');
die 'Could not find config_default.pl' unless (-f 'src/tools/msvc/config_default.pl');
print "Warning: no config.pl found, using default.\n" unless (-f 'src/tools/msvc/config.pl');
die 'Could not find config_default.pl'
unless (-f 'src/tools/msvc/config_default.pl');
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';
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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