use strict;
use warnings;
use File::Find;
use File::Basename;
use Tie::File;
my $pgdg = 'PostgreSQL Global Development Group';
my $cc = 'Copyright \(c\) ';
my $year = 1900 + ${ [ localtime(time) ] }[5];
print "Using current year: $year\n";
find({ wanted => \&wanted, no_chdir => 1 }, '.');
sub wanted
{
if (basename($_) eq '.git')
{
$File::Find::prune = 1;
return;
}
return if ! -f $File::Find::name || -l $File::Find::name;
return if ($_ =~ m/\.(ico|bin)$/);
my @lines;
tie @lines, "Tie::File", $File::Find::name;
foreach my $line (@lines)
{
next unless $line =~ m/$cc.*$pgdg/;
next if $line =~ m/$cc$year, $pgdg/;
$line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
$line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
}
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";