merge_copyrights revision 9c3531d72aeaad6c5f01efe6a1c82023e1379e4d
341N/A#!/usr/local/bin/perl -w
341N/A#
1064N/A# Copyright (C) 1998-2000 Internet Software Consortium.
341N/A#
341N/A# Permission to use, copy, modify, and distribute this software for any
919N/A# purpose with or without fee is hereby granted, provided that the above
919N/A# copyright notice and this permission notice appear in all copies.
919N/A#
919N/A# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
919N/A# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
919N/A# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
919N/A# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
919N/A# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
919N/A# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
919N/A# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
919N/A# SOFTWARE.
919N/A
919N/A# $Id: merge_copyrights,v 1.10 2000/06/22 22:00:38 tale Exp $
919N/A
919N/A%file_types = ();
919N/A%file_years = ();
919N/A
341N/Aopen(COPYRIGHTS, "<util/copyrights") || die "can't open ./util/copyrights: $!";
341N/Awhile (<COPYRIGHTS>) {
341N/A chomp;
341N/A ($file, $type, $years) = split;
493N/A $file_types{$file} = $type;
341N/A $file_years{$file} = $years;
341N/A}
1179N/Aclose(COPYRIGHTS);
341N/A
911N/A($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
1179N/A$year += 1900;
1179N/A
1179N/A$find = "find . -type f -print";
911N/A
341N/Aopen(FILES, "$find | sort |") || die "can't start \"$find\": $!";
341N/Awhile (<FILES>) {
341N/A chomp;
341N/A
341N/A next if (m%/\.\# | # CVS old conflict file
341N/A /CVS/ | # CVS directory
1179N/A \.bak$ | # created by update_copyrights
1233N/A /(dnssafe|openssl)/.*\.[ch]$ | # imported
341N/A doc/(draft|expired|rfc)/ # imported
604N/A %x);
1179N/A
688N/A if (!$file_types{$_}) {
688N/A if ($_ =~ /\.(c|h|css)$/) {
688N/A $file_types{$_} = "C";
688N/A } elsif ($_ =~ /\.y$/) {
1179N/A $file_types{$_} = "YACC";
1179N/A } elsif ($_ =~ /\.pl$/i) {
1179N/A $file_types{$_} = "PERL";
688N/A } elsif ($_ =~ /\.sh$/) {
688N/A $file_types{$_} = "SH";
688N/A } elsif ($_ =~ /\.html$/) {
688N/A $file_types{$_} = "HTML";
688N/A } elsif ($_ =~ /\.man$/) {
688N/A $file_types{$_} = "MAN";
688N/A } elsif ($_ =~ /\/Makefile\.in$/) {
688N/A $file_types{$_} = "MAKE";
688N/A } elsif ($_ =~ /\/named.?\.conf$/) {
688N/A $file_types{$_} = "CONF-C";
688N/A } elsif ($_ =~ /\.(db|hint)(\.in)?$/) {
688N/A $file_types{$_} = "ZONE";
688N/A } elsif ($_ =~ /(\/\.cvsignore|\.gif|\.jpg)$/i) {
688N/A $file_types{$_} = "X";
688N/A } else {
688N/A $file_types{$_} = "?";
688N/A }
688N/A ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
688N/A $blksize,$blocks)
688N/A = stat($_);
996N/A ($sec,$min,$hour,$mday,$mon,$c_year,$wday,$yday,$isdst) =
1179N/A localtime($ctime);
688N/A ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
688N/A localtime($mtime);
688N/A $c_year += 1900;
688N/A $m_year += 1900;
688N/A if ($m_year != $year || $c_year != $year) {
688N/A print "$_: must set copyright year(s) manually\n";
688N/A $file_years{$_} = "????";
688N/A } else {
688N/A $file_years{$_} = "$year";
688N/A }
1146N/A # keep perl from issuing warnings about "used only once"
688N/A $dev = $ino = $mode = $nlink = $uid = $gid = $rdev = $size = 0;
688N/A $atime = $blksize = $blocks = 0;
688N/A } else {
688N/A if ($file_types{$_} eq "X" || $file_years{$_} eq "????") {
688N/A next;
816N/A }
1064N/A @years = split(/,/, $file_years{$_});
341N/A $has_current = 0;
341N/A foreach $fyear (@years) {
341N/A if ($fyear == $year) {
341N/A $has_current = 1;
970N/A }
970N/A }
970N/A if (!$has_current) {
970N/A ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
970N/A $blksize,$blocks)
970N/A = stat($_);
970N/A ($sec,$min,$hour,$mday,$mon,$m_year,$wday,$yday,$isdst) =
970N/A localtime($mtime);
970N/A $m_year += 1900;
970N/A if ($m_year == $year) {
970N/A $file_years{$_} .= ",$year";
970N/A }
970N/A }
1029N/A }
1029N/A}
970N/Aclose(FILES);
341N/A
341N/Aopen(NEWCOPYRIGHTS, ">util/newcopyrights") ||
493N/A die "can't open newcopyrights: $!";
969N/Aforeach $file (sort(keys(%file_types))) {
341N/A print NEWCOPYRIGHTS "$file";
341N/A $len = length($file);
493N/A if ($len >= 48) {
1064N/A $tabs = 1;
1029N/A } else {
341N/A $needed = int (48 - $len);
341N/A $tabs = int ($needed / 8);
341N/A if ($needed % 8 != 0) {
341N/A $tabs++;
493N/A }
341N/A }
1064N/A for ($i = 0; $i < $tabs; $i++) {
341N/A printf NEWCOPYRIGHTS "\t";
341N/A }
1029N/A printf NEWCOPYRIGHTS "%s\t%s\n", $file_types{$file}, $file_years{$file};
1029N/A}
1029N/Aclose(NEWCOPYRIGHTS);
341N/A