1 #!/usr/bin/perl -0777 -pi
2 # Update an FSF copyright year list to include the current year.
4 my $VERSION = '2009-07-30.13:24'; # UTC
6 # Copyright (C) 2009 Free Software Foundation
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Written by Jim Meyering
23 # In the copyright statement in each file, "Copyright (C)" must appear
24 # at the beginning of the line except that it may be preceded by any
25 # sequence (e.g., a comment) of no more than 5 characters. Iff that
26 # prefix is present, the same prefix should appear at the beginning
27 # of each remaining line within the copyright statement so that it
28 # can be parsed correctly.
30 # For example, these are fine:
32 # # Copyright (C) 1990-2005, 2007-2009 Free Software
36 # * Copyright (C) 1990-2005, 2007-2009 Free Software
40 # The following format is not recognized:
42 # /* Copyright (C) 1990-2005, 2007-2009 Free Software
43 # * Foundation, Inc. */
45 # A warning is printed for every file for which the copyright format is
46 # not recognized. The culprit may be that the above preconditions are
47 # not obeyed as in the previous example, or it may simply be that the
48 # stated copyright holder is not the Free Software Foundation.
50 # You may wish to place a target like the following in your top-level
51 # makefile in your project:
53 # .PHONY: update-copyright
55 # if test -d .git; then \
56 # git grep -l -w Copyright \
57 # | grep -v -E '(^|/)(COPYING|ChangeLog)' \
58 # | xargs $(srcdir)/build-aux/$@; \
61 # You can build a list of files to skip in the second grep.
66 my ($sec, $min, $hour, $mday, $month, $year) = localtime (time());
67 my $this_year = $year + 1900;
68 my $holder = 'Free Software Foundation';
71 if (/(?:^|\n)(.{0,5})Copyright \([cC]\)/) {
72 $prefix = quotemeta $1;
75 $holder =~ s/\s/\\s*(?:\\s|\\n$prefix)\\s*/g;
77 if (/([- ])((?:\d\d)?\d\d)($holder)/s)
79 my ($sep, $last_c_year, $rest) = ($1, $2, $3);
81 # Handle two-digit year numbers like "98" and "99".
83 and $last_c_year += 1900;
85 if ($last_c_year != $this_year)
87 if ($sep eq '-' && $last_c_year + 1 == $this_year)
91 elsif ($sep eq ' ' && $last_c_year + 1 == $this_year)
93 s// $last_c_year-$this_year$rest/;
97 s//$sep$last_c_year, $this_year$rest/;
104 "$ARGV: warning: external copyright holder or parse failure\n";
108 # indent-tabs-mode: nil
109 # eval: (add-hook 'write-file-hooks 'time-stamp)
110 # time-stamp-start: "my $VERSION = '"
111 # time-stamp-format: "%:y-%02m-%02d.%02H:%02M"
112 # time-stamp-time-zone: "UTC"
113 # time-stamp-end: "'; # UTC"