mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files. The pgindent part of this is pretty small, consisting mainly of fixing up self-inflicted formatting damage from patches that hadn't bothered to add their new typedefs to typedefs.list. In order to keep it from making anything worse, I manually added a dozen or so typedefs that appeared in the existing typedefs.list but not in the buildfarm's list. Perhaps we should formalize that, or better find a way to get those typedefs into the automatic list. pgperltidy is as opinionated as always, and reformat-dat-files too.
This commit is contained in:
@@ -315,72 +315,72 @@ sub ParseData
|
||||
my $catname = $1;
|
||||
my $data = [];
|
||||
|
||||
# Scan the input file.
|
||||
while (<$ifd>)
|
||||
# Scan the input file.
|
||||
while (<$ifd>)
|
||||
{
|
||||
my $hash_ref;
|
||||
|
||||
if (/{/)
|
||||
{
|
||||
my $hash_ref;
|
||||
# Capture the hash ref
|
||||
# NB: Assumes that the next hash ref can't start on the
|
||||
# same line where the present one ended.
|
||||
# Not foolproof, but we shouldn't need a full parser,
|
||||
# since we expect relatively well-behaved input.
|
||||
|
||||
if (/{/)
|
||||
# Quick hack to detect when we have a full hash ref to
|
||||
# parse. We can't just use a regex because of values in
|
||||
# pg_aggregate and pg_proc like '{0,0}'. This will need
|
||||
# work if we ever need to allow unbalanced braces within
|
||||
# a field value.
|
||||
my $lcnt = tr/{//;
|
||||
my $rcnt = tr/}//;
|
||||
|
||||
if ($lcnt == $rcnt)
|
||||
{
|
||||
# Capture the hash ref
|
||||
# NB: Assumes that the next hash ref can't start on the
|
||||
# same line where the present one ended.
|
||||
# Not foolproof, but we shouldn't need a full parser,
|
||||
# since we expect relatively well-behaved input.
|
||||
|
||||
# Quick hack to detect when we have a full hash ref to
|
||||
# parse. We can't just use a regex because of values in
|
||||
# pg_aggregate and pg_proc like '{0,0}'. This will need
|
||||
# work if we ever need to allow unbalanced braces within
|
||||
# a field value.
|
||||
my $lcnt = tr/{//;
|
||||
my $rcnt = tr/}//;
|
||||
|
||||
if ($lcnt == $rcnt)
|
||||
# We're treating the input line as a piece of Perl, so we
|
||||
# need to use string eval here. Tell perlcritic we know what
|
||||
# we're doing.
|
||||
eval "\$hash_ref = $_"; ## no critic (ProhibitStringyEval)
|
||||
if (!ref $hash_ref)
|
||||
{
|
||||
# We're treating the input line as a piece of Perl, so we
|
||||
# need to use string eval here. Tell perlcritic we know what
|
||||
# we're doing.
|
||||
eval "\$hash_ref = $_"; ## no critic (ProhibitStringyEval)
|
||||
if (!ref $hash_ref)
|
||||
{
|
||||
die "$input_file: error parsing line $.:\n$_\n";
|
||||
}
|
||||
|
||||
# Annotate each hash with the source line number.
|
||||
$hash_ref->{line_number} = $.;
|
||||
|
||||
# Expand tuples to their full representation.
|
||||
AddDefaultValues($hash_ref, $schema, $catname);
|
||||
die "$input_file: error parsing line $.:\n$_\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
my $next_line = <$ifd>;
|
||||
die "$input_file: file ends within Perl hash\n"
|
||||
if !defined $next_line;
|
||||
$_ .= $next_line;
|
||||
redo;
|
||||
}
|
||||
}
|
||||
|
||||
# If we found a hash reference, keep it, unless it is marked as
|
||||
# autogenerated; in that case it'd duplicate an entry we'll
|
||||
# autogenerate below. (This makes it safe for reformat_dat_file.pl
|
||||
# with --full-tuples to print autogenerated entries, which seems like
|
||||
# useful behavior for debugging.)
|
||||
#
|
||||
# Otherwise, we have a non-data string, which we keep only if
|
||||
# the caller requested it.
|
||||
if (defined $hash_ref)
|
||||
{
|
||||
push @$data, $hash_ref if !$hash_ref->{autogenerated};
|
||||
# Annotate each hash with the source line number.
|
||||
$hash_ref->{line_number} = $.;
|
||||
|
||||
# Expand tuples to their full representation.
|
||||
AddDefaultValues($hash_ref, $schema, $catname);
|
||||
}
|
||||
else
|
||||
{
|
||||
push @$data, $_ if $preserve_comments;
|
||||
my $next_line = <$ifd>;
|
||||
die "$input_file: file ends within Perl hash\n"
|
||||
if !defined $next_line;
|
||||
$_ .= $next_line;
|
||||
redo;
|
||||
}
|
||||
}
|
||||
|
||||
# If we found a hash reference, keep it, unless it is marked as
|
||||
# autogenerated; in that case it'd duplicate an entry we'll
|
||||
# autogenerate below. (This makes it safe for reformat_dat_file.pl
|
||||
# with --full-tuples to print autogenerated entries, which seems like
|
||||
# useful behavior for debugging.)
|
||||
#
|
||||
# Otherwise, we have a non-data string, which we keep only if
|
||||
# the caller requested it.
|
||||
if (defined $hash_ref)
|
||||
{
|
||||
push @$data, $hash_ref if !$hash_ref->{autogenerated};
|
||||
}
|
||||
else
|
||||
{
|
||||
push @$data, $_ if $preserve_comments;
|
||||
}
|
||||
}
|
||||
|
||||
close $ifd;
|
||||
|
||||
# If this is pg_type, auto-generate array types too.
|
||||
|
||||
Reference in New Issue
Block a user