]> granicus.if.org Git - postgresql/blob - src/tools/copyright.pl
Repair failure with SubPlans in multi-row VALUES lists.
[postgresql] / src / tools / copyright.pl
1 #!/usr/bin/perl
2 #################################################################
3 # copyright.pl -- update copyright notices throughout the source tree, idempotently.
4 #
5 # Copyright (c) 2011-2017, PostgreSQL Global Development Group
6 #
7 # src/tools/copyright.pl
8 #
9 # FYI, Tie adds a trailing newline on the last line if missing.
10 #################################################################
11
12 use strict;
13 use warnings;
14
15 use File::Find;
16 use File::Basename;
17 use Tie::File;
18
19 my $pgdg      = 'PostgreSQL Global Development Group';
20 my $cc        = 'Copyright \(c\)';
21 my $ccliteral = 'Copyright (c)';
22
23 # year-1900 is what localtime(time) puts in element 5
24 my $year = 1900 + ${ [ localtime(time) ] }[5];
25
26 print "Using current year:  $year\n";
27
28 find({ wanted => \&wanted, no_chdir => 1 }, '.');
29
30 sub wanted
31 {
32
33         # prevent corruption of git indexes by ignoring any .git/
34         if (basename($_) eq '.git')
35         {
36                 $File::Find::prune = 1;
37                 return;
38         }
39
40         return if !-f $File::Find::name || -l $File::Find::name;
41
42         # skip file names with binary extensions
43         # How are these updated?  bjm 2012-01-02
44         return if ($_ =~ m/\.(ico|bin|po)$/);
45
46         my @lines;
47         tie @lines, "Tie::File", $File::Find::name;
48
49         foreach my $line (@lines)
50         {
51
52                 # We only care about lines with a copyright notice.
53                 next unless $line =~ m/$cc.*$pgdg/i;
54
55                 # Skip line if already matches the current year; if not
56                 # we get $year-$year, e.g. 2012-2012
57                 next if $line =~ m/$cc $year, $pgdg/i;
58
59                 # We process all lines because some files have copyright
60                 # strings embedded in them, e.g. src/bin/psql/help.c
61                 $line =~ s/$cc (\d{4})-\d{4}, $pgdg/$ccliteral $1-$year, $pgdg/i;
62                 $line =~ s/$cc (\d{4}), $pgdg/$ccliteral $1-$year, $pgdg/i;
63         }
64         untie @lines;
65 }
66
67 print "Manually update:\n";
68 print "  ./src/interfaces/libpq/libpq.rc.in in head\n";
69 print "  ./doc/src/sgml/legal.sgml in head and back branches\n";
70 print "  ./COPYRIGHT in back branches\n";