5 # Note: This is for C/C++ files only.
27 open AUTHORS
, "<AUTHORS" or die "Can't open AUTHORS file: $!";
28 my @AUTHORS = <AUTHORS
>;
34 if (m{^([^-].*) <([^>]+)> \((.*)\)$}) {
39 for my $file (@ARGV) {
41 print "Processing $file...\n";
42 my @log = `svn log -q "$file"`;
43 @log = grep { /^r/ } @log;
45 print STDERR
"No svn log information found for $file! Skipping...\n";
51 my ($orig_author, $orig_date);
53 for my $entry (@log) {
55 unless ($entry =~ /^r\d+ \| (.+) \| (\d{4}).* \((.*)\)/) {
56 printf STDERR
"Malformed svn output: $entry\n";
59 my ($author, $year) = ($1, $2);
62 my $aname = $authors{$author};
63 if (!defined $aname) {
65 #print STDERR "Author $author not found! Add to AUTHORS.\n";
69 $orig_author = $aname;
75 if (!exists $fauthors{$author}) {
76 $fauthors{$author} = [$year, $year];
78 my ($syear, $eyear) = @
{$fauthors{$author}};
79 $fauthors{$author} = [min
($year, $syear), max
($year, $eyear)];
83 if (!defined $orig_author) {
84 print STDERR
"No recognized authorship data found for $file.\n";
88 open FIN
, "<$file" or die "Can't open file $file";
93 for my $author (sort keys %fauthors) {
94 my ($syear, $eyear) = @
{$fauthors{$author}};
95 my $df = "$syear-$eyear";
96 if ($syear == $eyear) {
100 my $cline = " * Copyright (c) $df $author. All rights reserved.\n";
101 push @clines, $cline;
109 * Created by $orig_author on $orig_date.
114 * This library is free software; you can redistribute it and/or
115 * modify it under the terms of the GNU Lesser General Public
116 * License as published by the Free Software Foundation; either
117 * version 2 of the License, or (at your option) any later version.
119 * This library is distributed in the hope that it will be useful,
120 * but WITHOUT ANY WARRANTY; without even the implied warranty of
121 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
122 * Lesser General Public License for more details.
128 splice @lines, 0, 0, @clines;
129 rename $file, "$file.bak" or die "Can't rename $file to $file.bak: $!";
130 open FILE
, ">$file" or die "Can't open $file for writing: $!";
131 print FILE
@lines or die "Can't write to $file: $!";