else
{
die
- "unknown column option $attopt on column $attname";
+ "unknown or misformatted column option $attopt on column $attname";
}
if ($column{forcenull} and $column{forcenotnull})
}
# Find a symbol defined in a particular header file and extract the value.
-#
-# The include path has to be passed as a reference to an array.
+# include_path should be the path to src/include/.
sub FindDefinedSymbol
{
my ($catalog_header, $include_path, $symbol) = @_;
+ my $value;
- for my $path (@$include_path)
+ # Make sure include path ends in a slash.
+ if (substr($include_path, -1) ne '/')
{
-
- # Make sure include path ends in a slash.
- if (substr($path, -1) ne '/')
- {
- $path .= '/';
- }
- my $file = $path . $catalog_header;
- next if !-f $file;
- open(my $find_defined_symbol, '<', $file) || die "$file: $!";
- while (<$find_defined_symbol>)
+ $include_path .= '/';
+ }
+ my $file = $include_path . $catalog_header;
+ open(my $find_defined_symbol, '<', $file) || die "$file: $!";
+ while (<$find_defined_symbol>)
+ {
+ if (/^#define\s+\Q$symbol\E\s+(\S+)/)
{
- if (/^#define\s+\Q$symbol\E\s+(\S+)/)
- {
- return $1;
- }
+ $value = $1;
+ last;
}
- close $find_defined_symbol;
- die "$file: no definition found for $symbol\n";
}
- die "$catalog_header: not found in any include directory\n";
+ close $find_defined_symbol;
+ return $value if defined $value;
+ die "$file: no definition found for $symbol\n";
}
# Similar to FindDefinedSymbol, but looks in the bootstrap metadata.
}
# Emit Anum_* constants
- print $def
- sprintf("#define Anum_%s_%s %s\n", $catname, $attname, $attnum);
+ printf $def "#define Anum_%s_%s %s\n", $catname, $attname, $attnum;
}
print $bki "\n )\n";
}
print $bki "close $catname\n";
- print $def sprintf("\n#endif\t\t\t\t\t\t\t/* %s_D_H */\n", uc $catname);
+ printf $def "\n#endif\t\t\t\t\t\t\t/* %s_D_H */\n", uc $catname;
# Close and rename definition header
close $def;
# Collect arguments
my @input_files;
my $output_path = '';
-my @include_path;
+my $include_path;
while (@ARGV)
{
}
elsif ($arg =~ /^-I/)
{
- push @include_path, length($arg) > 2 ? substr($arg, 2) : shift @ARGV;
+ $include_path = length($arg) > 2 ? substr($arg, 2) : shift @ARGV;
}
else
{
}
# Sanity check arguments.
-die "No input files.\n" if !@input_files;
-die "No include path; you must specify -I at least once.\n" if !@include_path;
+die "No input files.\n" if !@input_files;
+die "No include path; you must specify -I.\n" if !$include_path;
# Read all the input files into internal data structures.
# Note: We pass data file names as arguments and then look for matching
# Fetch some values for later.
my $FirstBootstrapObjectId =
- Catalog::FindDefinedSymbol('access/transam.h', \@include_path,
+ Catalog::FindDefinedSymbol('access/transam.h', $include_path,
'FirstBootstrapObjectId');
my $INTERNALlanguageId =
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
open my $tfh, '>', $tabfile . $tmpext
or die "Could not open $tabfile$tmpext: $!";
-print $ofh
- qq|/*-------------------------------------------------------------------------
+print $ofh <<OFH;
+/*-------------------------------------------------------------------------
*
* fmgroids.h
* Macros that define the OIDs of built-in functions.
* its equivalent macro will be defined with the lowest OID among those
* entries.
*/
-|;
+OFH
-print $pfh
- qq|/*-------------------------------------------------------------------------
+print $pfh <<PFH;
+/*-------------------------------------------------------------------------
*
* fmgrprotos.h
* Prototypes for built-in functions.
#include "fmgr.h"
-|;
+PFH
-print $tfh
- qq|/*-------------------------------------------------------------------------
+print $tfh <<TFH;
+/*-------------------------------------------------------------------------
*
* fmgrtab.c
* The function manager's table of internal functions.
#include "utils/fmgrtab.h"
#include "utils/fmgrprotos.h"
-|;
+TFH
# Emit #define's and extern's -- only one per prosrc value
my %seenit;
# And add the file footers.
-print $ofh "\n#endif /* FMGROIDS_H */\n";
-print $pfh "\n#endif /* FMGRPROTOS_H */\n";
+print $ofh "\n#endif\t\t\t\t\t\t\t/* FMGROIDS_H */\n";
+print $pfh "\n#endif\t\t\t\t\t\t\t/* FMGRPROTOS_H */\n";
close($ofh);
close($pfh);
open my $dat, '>', $datfile
or die "can't open $datfile: $!";
- # Write the data.
foreach my $data (@{ $catalog_data{$catname} })
{
# Also push FirstBootstrapObjectId to serve as a terminator for the last gap.
my $FirstBootstrapObjectId =
- Catalog::FindDefinedSymbol('access/transam.h', [".."],
+ Catalog::FindDefinedSymbol('access/transam.h', '..',
'FirstBootstrapObjectId');
push @{$oids}, $FirstBootstrapObjectId;