2 #################################################################
3 # copyright.pl -- update copyright notices throughout the source tree, idempotently.
5 # Copyright (c) 2011-2012, PostgreSQL Global Development Group
7 # src/tools/copyright.pl
8 #################################################################
16 my $pgdg = 'PostgreSQL Global Development Group';
17 my $cc = 'Copyright \(c\) ';
18 # year-1900 is what localtime(time) puts in element 5
19 my $year = 1900 + ${[localtime(time)]}[5];
21 print "Using current year: $year\n";
23 find({wanted => \&wanted, no_chdir => 1}, '.');
26 # prevent corruption of git indexes, ./.git
27 if ($File::Find::name =~ m{^\./\.git$})
29 $File::Find::prune = 1;
33 return if ! -f $File::Find::name || -l $File::Find::name;
36 tie @lines, "Tie::File", $File::Find::name;
38 foreach my $line (@lines) {
39 # We only care about lines with a copyright notice.
40 next unless $line =~ m/$cc.*$pgdg/;
41 # We stop when we've done one substitution. This is both for
42 # efficiency and, at least in the case of this program, for
44 last if $line =~ m/$cc.*$year.*$pgdg/;
45 last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
46 last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
51 print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n";