Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 739e3f1

Browse files
committed
Implement src/tools/copyright as a Perl program, so anyone can run it.
David Fetter
1 parent a4b3fee commit 739e3f1

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

src/tools/copyright

-14
This file was deleted.

src/tools/copyright.pl

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/perl
2+
#################################################################
3+
# copyright.pl -- update copyright notices throughout the source tree, idempotently.
4+
#
5+
# Copyright (c) 2011, PostgreSQL Global Development Group
6+
#
7+
# src/tools/copyright.pl
8+
#################################################################
9+
10+
use strict;
11+
use warnings;
12+
13+
use File::Find;
14+
15+
my $pgdg = 'PostgreSQL Global Development Group';
16+
my $cc = 'Copyright (c) ';
17+
# year-1900 is what localtime(time) puts in element 5
18+
my $year = 1900 + ${[localtime(time)]}[5];
19+
20+
print "Using current year: $year\n";
21+
22+
find({wanted => \&wanted, no_chdir => 1}, '.');
23+
24+
sub wanted {
25+
return unless -f $File::Find::name;
26+
27+
my @lines;
28+
tie @lines, Tie::File, $File::Find::name;
29+
30+
foreach my $line (@lines) {
31+
# We only care about lines with a copyright notice.
32+
next unless $line =~ m/$cc.*$pgdg/;
33+
# We stop when we've done one substitution. This is both for
34+
# efficiency and, at least in the case of this program, for
35+
# correctness.
36+
last if $line =~ m/$cc.*$year.*$pgdg/;
37+
last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/;
38+
last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/;
39+
}
40+
untie @lines;
41+
}
42+
43+
print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n";
44+

0 commit comments

Comments
 (0)