merge_copyrights revision 012a352f4b26cfd874db8d06debc495c2303e8b2
2521N/A#!/usr/local/bin/perl -w
2521N/A#
2521N/A# Copyright (C) 1998, 1999 Internet Software Consortium.
2521N/A#
2521N/A# Permission to use, copy, modify, and distribute this software for any
2521N/A# purpose with or without fee is hereby granted, provided that the above
2521N/A# copyright notice and this permission notice appear in all copies.
2521N/A#
2521N/A# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
2521N/A# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
2521N/A# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
2521N/A# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
2521N/A# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
2521N/A# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
2521N/A# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2521N/A# SOFTWARE.
2521N/A
2521N/A%file_types = ();
2521N/A%file_years = ();
2521N/A
2521N/Aopen(COPYRIGHTS, "<util/copyrights") || die "can't open copyrights: $!";
2521N/Awhile (<COPYRIGHTS>) {
2521N/A chomp;
2521N/A ($file, $type, $years) = split;
2521N/A $file_types{$file} = $type;
2521N/A $file_years{$file} = $years;
2521N/A}
2521N/Aclose(COPYRIGHTS);
2521N/A
2521N/A($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
2521N/A$year += 1900;
2521N/A
2521N/Aopen(FILES, "<util/files") || die "can't open files: $!";
2521N/Awhile (<FILES>) {
2521N/A chomp;
2521N/A if (!$file_types{$_}) {
2521N/A if ($_ =~ /\.[chy]$/) {
2521N/A $file_types{$_} = "C";
2521N/A } elsif ($_ =~ /\/Makefile\.in$/) {
2521N/A $file_types{$_} = "MAKE";
2521N/A } elsif ($_ =~ /\/\.cvsignore$/) {
2521N/A $file_types{$_} = "X";
2521N/A } else {
2521N/A $file_types{$_} = "?";
2521N/A }
2521N/A ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
2521N/A $blksize,$blocks)
2521N/A = stat($_);
2521N/A ($sec,$min,$hour,$mday,$mon,$c_year,$wday,$yday,$isdst) =
2521N/A localtime($ctime);
2521N/A ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
2521N/A localtime($mtime);
2521N/A $c_year += 1900;
2521N/A $m_year += 1900;
2521N/A if ($m_year != $year || $c_year != $year) {
2521N/A print "$_: must set copyright year(s) manually\n";
2521N/A $file_years{$_} = "????";
2521N/A } else {
2521N/A $file_years{$_} = "$year";
2521N/A }
2521N/A # keep perl from issuing warnings about "used only once"
2521N/A $dev = $ino = $mode = $nlink = $uid = $gid = $rdev = $size = 0;
2521N/A $atime = $blksize = $blocks = 0;
2521N/A } else {
2521N/A if ($file_types{$_} eq "X" || $file_years{$_} eq "????") {
2521N/A next;
2521N/A }
2521N/A @years = split(/,/, $file_years{$_});
2521N/A $has_current = 0;
2521N/A foreach $fyear (@years) {
2521N/A if ($fyear == $year) {
2521N/A $has_current = 1;
2521N/A }
2521N/A }
2521N/A if (!$has_current) {
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks)
= stat($_);
($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
localtime($mtime);
$m_year += 1900;
if ($m_year == $year) {
$file_years{$_} .= ",$year";
}
}
}
}
close(FILES);
open(NEWCOPYRIGHTS, ">util/newcopyrights") ||
die "can't open newcopyrights: $!";
foreach $file (sort(keys(%file_types))) {
print NEWCOPYRIGHTS "$file";
$len = length($file);
if ($len >= 48) {
$tabs = 1;
} else {
$needed = int (48 - $len);
$tabs = int ($needed / 8);
if ($needed % 8 != 0) {
$tabs++;
}
}
for ($i = 0; $i < $tabs; $i++) {
printf NEWCOPYRIGHTS "\t";
}
printf NEWCOPYRIGHTS "%s\t%s\n", $file_types{$file}, $file_years{$file};
}
close(NEWCOPYRIGHTS);