|
| 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 | +subwanted { |
| 25 | +returnunless-f$File::Find::name; |
| 26 | + |
| 27 | +my@lines; |
| 28 | +tie@lines, Tie::File,$File::Find::name; |
| 29 | + |
| 30 | +foreachmy$line (@lines) { |
| 31 | +# We only care about lines with a copyright notice. |
| 32 | +nextunless$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 | +lastif$line =~m/$cc.*$year.*$pgdg/; |
| 37 | +lastif$line =~s/($cc\d{4})(, $pgdg)/$1-$year$2/; |
| 38 | +lastif$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 | + |