mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-01 21:10:55 -05:00
Remove the copyright handling via util/copyrights
The copyright handling has been long obsolete, the works is covered as whole by the COPYING/LICENSE file even if a specific file doesn't have a copyright header. The important thing to remember here is that any work is covered by a copyright law and by explicitly giving it license we provide extra rights to the users of the works.
This commit is contained in:
parent
47a9915888
commit
09c32a8d75
9 changed files with 0 additions and 931 deletions
|
|
@ -421,11 +421,6 @@ misc:
|
|||
- test ! -f CHANGES.SE || perl util/check-changes master=0 CHANGES.SE
|
||||
- test ! -f CHANGES.SE || sh util/check-line-length.sh CHANGES.SE
|
||||
- rm CHANGES.tmp
|
||||
- perl -w util/merge_copyrights
|
||||
- diff -urNap util/copyrights util/newcopyrights
|
||||
- rm util/newcopyrights
|
||||
- perl -w util/update_copyrights < util/copyrights
|
||||
- if test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi
|
||||
- sh util/check-categories.sh
|
||||
- if git grep SYSTEMTESTTOP -- ':!.gitlab-ci.yml'; then echo 'Please use relative paths instead of $SYSTEMTESTTOP.'; exit 1; fi
|
||||
- bash util/unused-headers.sh
|
||||
|
|
@ -433,7 +428,6 @@ misc:
|
|||
needs: []
|
||||
artifacts:
|
||||
paths:
|
||||
- util/newcopyrights
|
||||
- checklibs.out
|
||||
expire_in: "1 day"
|
||||
when: on_failure
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See the COPYRIGHT file distributed with this work for additional
|
||||
information regarding copyright ownership.
|
||||
|
||||
This code is derived from software contributed to ISC by
|
||||
Berkeley Software Design, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND BERKELEY SOFTWARE DESIGN, INC.
|
||||
DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
|
||||
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See the COPYRIGHT file distributed with this work for additional
|
||||
information regarding copyright ownership.
|
||||
|
||||
Portions Copyright (C) Network Associates, Inc.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
|
||||
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
|
||||
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See the COPYRIGHT file distributed with this work for additional
|
||||
information regarding copyright ownership.
|
||||
|
||||
Portions Copyright (C) @NOMYEARS@ Nominum, Inc.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
|
||||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
See the COPYRIGHT file distributed with this work for additional
|
||||
information regarding copyright ownership.
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
Copyright (C) @SYSYEARS@ Internet Systems Consortium, Inc. ("ISC")
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
#!/usr/local/bin/perl -w
|
||||
#
|
||||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
use strict;
|
||||
|
||||
my %file_types = ();
|
||||
my %file_years = ();
|
||||
|
||||
open(COPYRIGHTS, "<util/copyrights") || die "can't open ./util/copyrights: $!";
|
||||
while (<COPYRIGHTS>) {
|
||||
chomp;
|
||||
my ($file, $type, $years) = split;
|
||||
$file_types{$file} = $type;
|
||||
$file_years{$file} = $years;
|
||||
}
|
||||
close(COPYRIGHTS);
|
||||
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time());
|
||||
$sec = $min = $hour = $mday = $mon = $wday = $yday = $isdst = 0;
|
||||
$year += 1900;
|
||||
|
||||
open(CHANGES, "git ls-files | sed 's;^;./;' | sort |") || die "git ls-files: $!";
|
||||
while (<CHANGES>) {
|
||||
chomp;
|
||||
|
||||
next if (m%/\. | # just ignore all hidden files
|
||||
/ChangeLog | #
|
||||
Makefile.(am|in) | # build system doesn't need to have copyright
|
||||
/m4/ | # build system doesn't need to have copyright
|
||||
/configure | # build system doesn't need to have copyright
|
||||
/fuzz/.*\.in/ | # ignore fuzz corpus
|
||||
util/newcopyrights | # our output
|
||||
\.bak$ | # created by update_copyrights
|
||||
\.md$ | # READMEs and such
|
||||
\.data$ | # zone files
|
||||
\.data[0-9]$ | # zone files
|
||||
\.data\.in$ | # zone files
|
||||
\.db$ | # zone files
|
||||
\.db\.in$ | # zone files
|
||||
/db\.[^/]*$ | # zone files
|
||||
/[^/]*\.db\.[^/]* | # zone files
|
||||
\.hints?$ | # zone files
|
||||
\.hints?\.in$ | # zone files
|
||||
/hints$ | # zone files
|
||||
\.zone$ | # zone files
|
||||
/cocci/.* | # coccinelle spatch files
|
||||
\.conf$ | # configuration files
|
||||
\.conf\.in$ | # configuration files
|
||||
/(dnssafe|openssl)/.*\.[ch]$ | # imported
|
||||
doc/dnssec-guide/img/ | # images
|
||||
doc/dev/ | # developer notes
|
||||
doc/(draft|expired|rfc)/ | # imported
|
||||
doc/notes/ | # release notes doesn't really need copyright
|
||||
\.*in$ | # the generated documentation doesn't really need copyright
|
||||
grammar\.rst$ | # -"-
|
||||
zoneopt\.rst$ | # -"-
|
||||
zoneopt$ | # -"-
|
||||
\.txt$ # text files don't really need copyright
|
||||
%x);
|
||||
|
||||
if (!$file_types{$_}) {
|
||||
# Strip any .in extension to find out the file's real type.
|
||||
# .in files are processed by configure to produce the target file.
|
||||
my $base;
|
||||
($base = $_) =~ s/\.in$//;
|
||||
|
||||
# Contributed code should maintain its own copyright.
|
||||
if ($base =~ /\.\/contrib\//) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/openssl-[a-z0-9.]*-patch$/) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.(c|h|css)$/) {
|
||||
$file_types{$_} = "C";
|
||||
} elsif ($base =~ /\.y$/) {
|
||||
$file_types{$_} = "YACC";
|
||||
} elsif ($base =~ /\.pl$/i) {
|
||||
$file_types{$_} = "PERL";
|
||||
} elsif ($base =~ /\.py$/i) {
|
||||
$file_types{$_} = "PYTHON";
|
||||
if (open(PYTHON, $_)) {
|
||||
my $line = <PYTHON>;
|
||||
$file_types{$_} = "PYTHON-BIN" if ($line && $line =~ /^#!/);
|
||||
close(PYTHON);
|
||||
}
|
||||
} elsif ($base =~ /\.sh$/) {
|
||||
$file_types{$_} = "SH";
|
||||
} elsif ($base =~ /\.docbook$/ ||
|
||||
$base =~ /\.xsl$/ ||
|
||||
$base =~ /\.xml$/) {
|
||||
$file_types{$_} = "SGML";
|
||||
} elsif ($base =~ /\.rst$/ ||
|
||||
$base =~ /\.inc$/) {
|
||||
$file_types{$_} = "RST";
|
||||
} elsif ($base =~ /doc\/arm\/.*\.html$/) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.(sty|pdf|eps)$/) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.html$/) {
|
||||
$file_types{$_} = "HTML";
|
||||
$base =~ s/\.html$//;
|
||||
$base = $base . ".docbook";
|
||||
} elsif ($base =~ /\.(man|[0-9])$/) {
|
||||
$file_types{$_} = "MAN";
|
||||
$base =~ s/\.[0-9]$//;
|
||||
$base = $base . ".docbook";
|
||||
} elsif ($base =~ /\/Makefile$/) {
|
||||
$file_types{$_} = "MAKE";
|
||||
} elsif ($base =~ /\/resolv.?\.conf$/) {
|
||||
$file_types{$_} = "CONF-SH";
|
||||
} elsif ($base =~ /\.md$/) {
|
||||
$file_types{$_} = "MKD";
|
||||
} elsif ($base =~ /(\/\.(gitignore|gitattributes)|\.(gif|jpg))$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.(def|dep|dsp|dsw|mak|sln)$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.(vcxproj(|\.(user|filters)))$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.rnc$/i) {
|
||||
$file_types{$_} = "RNC";
|
||||
} elsif ($base =~ /^\.\/EXCLUDED$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\.bat$/i) {
|
||||
$file_types{$_} = "BAT";
|
||||
} elsif ($base =~ /\.(key|private)$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/named\d{0,2}\.args$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/named\.port$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/named\.dropedns$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/named\.notcp$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/doc\/misc\/[-a-z]*\.zoneopt$/i) {
|
||||
$file_types{$_} = "X";
|
||||
} elsif ($base =~ /\/README$/i) {
|
||||
$file_types{$_} = "TXT.BRIEF";
|
||||
} else {
|
||||
$file_types{$_} = "?";
|
||||
}
|
||||
if (($file_types{$_} eq "MAN" || $file_types{$_} eq "HTML") &&
|
||||
$base =~ /\.docbook$/ && -e $base) {
|
||||
$file_years{$_} = "DOCBOOK";
|
||||
} else {
|
||||
$file_years{$_} = "$year";
|
||||
}
|
||||
} else {
|
||||
if (! defined($file_years{$_}) || $file_years{$_} eq "????") {
|
||||
print "$_: must set copyright year(s) manually\n";
|
||||
$file_years{$_} = "????";
|
||||
next;
|
||||
}
|
||||
|
||||
# track the modification years even if we are not going to be
|
||||
# updating the copyrights.
|
||||
# next if $file_types{$_} eq "X";
|
||||
next if ($file_years{$_} =~ /^PARENT:/);
|
||||
next if ($file_years{$_} eq "DOCBOOK");
|
||||
|
||||
my @years = split(/,/, $file_years{$_});
|
||||
my $has_current = 0;
|
||||
foreach my $fyear (@years) {
|
||||
if ($fyear == $year) {
|
||||
$has_current = 1;
|
||||
}
|
||||
}
|
||||
if (!$has_current) {
|
||||
$file_years{$_} .= ",$year";
|
||||
}
|
||||
}
|
||||
}
|
||||
close(CHANGES);
|
||||
|
||||
open(NEWCOPYRIGHTS, ">util/newcopyrights") ||
|
||||
die "can't open newcopyrights: $!";
|
||||
foreach my $file (sort(keys(%file_types))) {
|
||||
print NEWCOPYRIGHTS "$file";
|
||||
my $len = length($file);
|
||||
my $tabs = 0;
|
||||
if ($len >= 48) {
|
||||
$tabs = 1;
|
||||
} else {
|
||||
my $needed = int (48 - $len);
|
||||
$tabs = int ($needed / 8);
|
||||
if ($needed % 8 != 0) {
|
||||
$tabs++;
|
||||
}
|
||||
}
|
||||
for (my $i = 0; $i < $tabs; $i++) {
|
||||
printf NEWCOPYRIGHTS "\t";
|
||||
}
|
||||
printf NEWCOPYRIGHTS "%s\t%s\n", $file_types{$file}, $file_years{$file};
|
||||
|
||||
if (($file_years{$file} eq "????") || ($file_types{$file} eq "?")) {
|
||||
print "Unknown file type or year: $file\n";
|
||||
}
|
||||
}
|
||||
close(NEWCOPYRIGHTS);
|
||||
|
|
@ -1,636 +0,0 @@
|
|||
#!/usr/local/bin/perl -w
|
||||
#
|
||||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
require 5.002;
|
||||
|
||||
# Map copyright owners to the files containing copyright messages.
|
||||
# The first line of the copyright message is not in the file;
|
||||
# it is constructed by this script.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# perl util/update_copyrights <util/copyrights
|
||||
|
||||
my %owner2filename = (
|
||||
"" => "util/COPYRIGHT",
|
||||
TOP => "util/COPYRIGHT.TOP",
|
||||
"NAI" => "util/COPYRIGHT.NAI",
|
||||
"NOM" => "util/COPYRIGHT.NOM",
|
||||
"BSDI" => "util/COPYRIGHT.BSDI",
|
||||
"BRIEF" => "util/COPYRIGHT.BRIEF",
|
||||
"PORTION" => "util/COPYRIGHT.PORTION",
|
||||
);
|
||||
|
||||
# Map each copyright owner name to a reference to an array containing
|
||||
# the lines of the copyright message.
|
||||
|
||||
my %owner2text = ();
|
||||
|
||||
my $keyword_pat = '\$(Id:.*|Revision:.*|Id|Revision)\$';
|
||||
|
||||
foreach $owner (keys %owner2filename) {
|
||||
my $f = $owner2filename{$owner};
|
||||
open(COPYRIGHT, "<$f") || die "can't open $f: $!";
|
||||
@copyright_text = <COPYRIGHT>;
|
||||
close(COPYRIGHT);
|
||||
$owner2text{$owner} = [ @copyright_text ];
|
||||
}
|
||||
|
||||
my %file_types = ();
|
||||
my %file_years = ();
|
||||
my $years_list;
|
||||
my $parent;
|
||||
|
||||
($dummy,$dummy,$dummy,$dummy,$this_month,$this_year,$dummy,$dummy,$dummy) = localtime(time());
|
||||
$this_year += 1900;
|
||||
|
||||
while (<>) {
|
||||
chomp;
|
||||
($file, $type, $years) = split(/\s+/);
|
||||
$file_types{$file} = $type;
|
||||
$file_years{$file} = $years;
|
||||
}
|
||||
|
||||
sub getyears {
|
||||
$parent = $_[0];
|
||||
$parent =~ s/PARENT://;
|
||||
$years_list = $file_years{$parent};
|
||||
if (defined($years_list) && $years_list =~ /^PARENT:/) {
|
||||
print "BAD PARENT:$parent\n";
|
||||
undefine($years_list);
|
||||
}
|
||||
}
|
||||
|
||||
sub docbook {
|
||||
$parent = $_[0];
|
||||
$parent =~ s/\.[^.]*$/.docbook/;
|
||||
$years_list = $file_years{$parent};
|
||||
}
|
||||
|
||||
sub copyright {
|
||||
my $holder = shift;
|
||||
my $result = "";
|
||||
return $result unless (@_);
|
||||
$result = "$result <copyright>\n";
|
||||
$result = "$result <year>$_</year>\n" foreach (@_);
|
||||
$result = "$result <holder>$holder</holder>\n";
|
||||
$result = "$result </copyright>\n";
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub copyrights {
|
||||
my $a = copyright("Internet Systems Consortium, Inc. (\"ISC\")", @_);
|
||||
return "$a";
|
||||
}
|
||||
|
||||
my $ret = 0;
|
||||
|
||||
foreach $file (keys %file_types) {
|
||||
$typeandowner = $file_types{$file};
|
||||
$years_list = $file_years{$file};
|
||||
|
||||
if ( ! -f $file ) {
|
||||
print "$file: missing\n";
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
# print "Doing: $file";
|
||||
|
||||
if ($years_list =~ /PARENT:/) {
|
||||
getyears($years_list);
|
||||
if (!defined $years_list) {
|
||||
print "$file: has bad parent $parent\n";
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
# copyright notice is now generated from the source.
|
||||
next if ($years_list eq "DOCBOOK");
|
||||
|
||||
if ($years_list eq "DOCBOOK") {
|
||||
docbook($file);
|
||||
if (!defined $years_list) {
|
||||
print "$file: has bad parent $parent\n";
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
@years = split(/,/, $years_list);
|
||||
|
||||
my ($type, $owner) = split(/\./, $typeandowner);
|
||||
$owner = "" if !defined $owner;
|
||||
|
||||
$textp = $owner2text{$owner};
|
||||
if (!defined $textp) {
|
||||
print "$file: unknown copyright owner $owner\n";
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($file eq "./CHANGES" || $file eq "./EXCLUDED" ||
|
||||
$file eq "./CHANGES.SE")
|
||||
{
|
||||
open(SOURCE, "<$file") || die "can't open $file: $!";
|
||||
my $body = "";
|
||||
while (<SOURCE>) {
|
||||
# Process leading white space.
|
||||
# Remove 1-7 spaces followed by a tab into a single
|
||||
# tab if at start of line or proceeded by tabs.
|
||||
s/^(\t*) {1,7}\t/$1\t/ while (/^\t* {1,7}\t/);
|
||||
s/^(\s{0,3}\d*\.)\s(\[\w{1,5}\])\s+(\S+)/$1\t$2\t\t$3/;
|
||||
s/^(\s{0,3}\d*\.)\s(\[\w{6,}\])\s+(\S+)/$1\t$2\t$3/;
|
||||
# Convert 8 spaces into tabs if at start of line
|
||||
# or preceded by tabs.
|
||||
s/^(\t*) /$1\t/ while (/^\t* /);
|
||||
# Remove trailing white space.
|
||||
s/[ \t]*$//;
|
||||
$body = "$body$_";
|
||||
}
|
||||
$_ = $body;
|
||||
open(TARGET, ">$file.new") || die "can't open $file.new: $!";
|
||||
print TARGET $_;
|
||||
close(TARGET);
|
||||
close(SOURCE);
|
||||
if (system("cmp -s $file.new $file") == 0) {
|
||||
unlink("$file.new");
|
||||
} else {
|
||||
rename("$file.new", "$file")
|
||||
or die "rename($file.new, $file): $!";
|
||||
}
|
||||
}
|
||||
|
||||
next if $type eq "X" or $type eq "BAT";
|
||||
|
||||
$before_copyright = "";
|
||||
$c_comment = 0;
|
||||
$shell_comment = 0;
|
||||
$m4_comment = 0;
|
||||
$sgml_comment = 0;
|
||||
$mkd_comment = 0;
|
||||
$man_comment = 0;
|
||||
$rst_comment = 0;
|
||||
$python_comment = 0;
|
||||
$python_bin_comment = 0;
|
||||
$start_comment = "";
|
||||
$end_comment = "";
|
||||
$first = "";
|
||||
if ($type =~ /^(C|YACC)$/) {
|
||||
$c_comment = 1;
|
||||
$start_comment = "/*\n";
|
||||
$prefix = " * ";
|
||||
$end_comment = " */\n";
|
||||
} elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH|RNC)$/) {
|
||||
$shell_comment = 1;
|
||||
$prefix = "# ";
|
||||
} elsif ($type =~ /^PYTHON-BIN$/) {
|
||||
$python_bin_comment = 1;
|
||||
$start_comment = "############################################################################\n";
|
||||
$prefix = "# ";
|
||||
$end_comment = "############################################################################\n"
|
||||
} elsif ($type =~ /^PYTHON$/) {
|
||||
$python_comment = 1;
|
||||
$start_comment = "############################################################################\n";
|
||||
$prefix = "# ";
|
||||
$end_comment = "############################################################################\n"
|
||||
} elsif ($type eq "MAN") {
|
||||
$man_comment = 1;
|
||||
$prefix = ".\\\" ";
|
||||
} elsif ($type eq "M4") {
|
||||
$m4_comment = 1;
|
||||
$prefix = "dnl ";
|
||||
} elsif ($type eq "HTML" || $type eq "SGML") {
|
||||
$sgml_comment = 1;
|
||||
$start_comment = "<!--\n";
|
||||
$prefix = " - ";
|
||||
$end_comment = "-->\n";
|
||||
} elsif ($type eq "MKD") {
|
||||
$mkd_comment = 1;
|
||||
$start_comment = "<!--\n";
|
||||
$prefix = " - ";
|
||||
$end_comment = "-->";
|
||||
} elsif ($type eq "TXT") {
|
||||
$prefix = "";
|
||||
} elsif ($type eq "RST") {
|
||||
$rst_comment = 1;
|
||||
$start_comment = ".. \n";
|
||||
$prefix = " ";
|
||||
$end_comment = "";
|
||||
} else {
|
||||
print "$file: type '$type' not supported yet; skipping\n";
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
|
||||
($nonspaceprefix = $prefix) =~ s/\s+$//;
|
||||
|
||||
open(SOURCE, "<:crlf", $file) || die "can't open $file: $!";
|
||||
$_ = <SOURCE>;
|
||||
if ($type eq "YACC") {
|
||||
unless ($_ eq "%{\n") {
|
||||
print "$file: unexpected yacc file start ",
|
||||
"(expected \"%{\\n\")\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
$before_copyright = "$_";
|
||||
$_ = <SOURCE>;
|
||||
}
|
||||
if ($c_comment && /^\/\*/) {
|
||||
$_ = <SOURCE>;
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
if ($_ !~ /\*\//) {
|
||||
while (<SOURCE>) {
|
||||
last if $_ =~ /\*\//;
|
||||
}
|
||||
}
|
||||
} elsif ($shell_comment) {
|
||||
if (/^\#\!/) {
|
||||
$before_copyright = "$_#\n";
|
||||
$_ = <SOURCE>;
|
||||
$_ = <SOURCE> if $_ eq "#\n";
|
||||
}
|
||||
if (/^\#/) {
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
while (<SOURCE>) {
|
||||
if ($_ !~ /^\#/) {
|
||||
$first = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$first = $_;
|
||||
}
|
||||
} elsif ($python_comment || $python_bin_comment) {
|
||||
if ($python_bin_comment && /^\#\!/) {
|
||||
$before_copyright = "$_";
|
||||
$_ = <SOURCE>;
|
||||
$_ = <SOURCE> if $_ eq "#\n";
|
||||
$_ = <SOURCE> if $_ eq "############################################################################\n";
|
||||
} elsif ($python_comment && /^\#/) {
|
||||
$_ = <SOURCE> if $_ eq "#\n";
|
||||
$_ = <SOURCE> if $_ eq "############################################################################\n";
|
||||
}
|
||||
if (/^\#/) {
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
while (<SOURCE>) {
|
||||
if ($_ !~ /^\#/) {
|
||||
$first = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$first = $_;
|
||||
}
|
||||
} elsif (($m4_comment || $man_comment) &&
|
||||
/^\Q$nonspaceprefix\E/) {
|
||||
|
||||
while (/^\Q$nonspaceprefix\E\s*$/) {
|
||||
$_ = <SOURCE>;
|
||||
}
|
||||
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
while (<SOURCE>) {
|
||||
if ($_ !~ /^\Q$nonspaceprefix\E/ ||
|
||||
$_ =~ /$keyword_pat/) {
|
||||
$first = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
} elsif ($sgml_comment) {
|
||||
$before_copyright = "";
|
||||
while (/^<!DOCTYPE/ || /^<!ENTITY/ || /^<\?xml-stylesheet/ || /^<\?xml /) {
|
||||
# print "SGML: $_";
|
||||
$before_copyright = "$before_copyright$_";
|
||||
if (/\]>$/ ) {
|
||||
$_ = <SOURCE>;
|
||||
close(SOURCE) if (eof(SOURCE));
|
||||
next;
|
||||
}
|
||||
if (/^<!DOCTYPE.*\[$/) {
|
||||
while (!eof(SOURCE)) {
|
||||
$_ = <SOURCE>;
|
||||
next if (eof(SOURCE));
|
||||
$before_copyright =
|
||||
"$before_copyright$_";
|
||||
if (/]>$/) {
|
||||
$_ = <SOURCE>;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(SOURCE) if (eof(SOURCE));
|
||||
next;
|
||||
}
|
||||
if (/>$/ ) {
|
||||
$_ = <SOURCE>;
|
||||
close(SOURCE) if (eof(SOURCE));
|
||||
next;
|
||||
}
|
||||
$_ = <SOURCE>;
|
||||
while (!eof(SOURCE) && ! /^<!/ ) {
|
||||
$before_copyright = "$before_copyright$_";
|
||||
$_ = <SOURCE>;
|
||||
}
|
||||
if (eof(SOURCE)) {
|
||||
close(SOURCE);
|
||||
next;
|
||||
}
|
||||
}
|
||||
if (/^<!--/) {
|
||||
$_ = <SOURCE> if $_ eq "<!--\n";
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
while (defined($_)) {
|
||||
last if s/.*-->//;
|
||||
$_ = <SOURCE>;
|
||||
}
|
||||
print "$file: unterminated comment\n"
|
||||
unless defined($_);
|
||||
if ($_ ne "\n") {
|
||||
$first = $_;
|
||||
} else {
|
||||
$first = <SOURCE>;
|
||||
}
|
||||
} else {
|
||||
$first = $_;
|
||||
}
|
||||
} elsif ($mkd_comment) {
|
||||
$before_copyright = "";
|
||||
if (/^<!/) {
|
||||
$_ = <SOURCE> if $_ eq "<!--\n";
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
while (defined($_)) {
|
||||
last if s/.*-->//;
|
||||
$_ = <SOURCE>;
|
||||
}
|
||||
print "$file: unterminated comment\n"
|
||||
unless defined($_);
|
||||
if ($_ ne "\n") {
|
||||
$first = $_;
|
||||
} else {
|
||||
$first = <SOURCE>;
|
||||
}
|
||||
} else {
|
||||
$first = $_;
|
||||
}
|
||||
} elsif ($rst_comment) {
|
||||
if ($_ =~ /\.\. \n/) {
|
||||
$_ = <SOURCE>;
|
||||
if ($_ !~ /[Cc]opyright/) {
|
||||
print "$file: non-copyright comment\n";
|
||||
close(SOURCE);
|
||||
$ret++;
|
||||
next;
|
||||
}
|
||||
while (<SOURCE>) {
|
||||
if ($_ !~ /^ /) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
$first = $_;
|
||||
} elsif ($type eq "TXT") {
|
||||
if ($_ =~ /[Cc]opyright/) {
|
||||
$/ = ""; # paragraph at a time
|
||||
while (<SOURCE>) {
|
||||
# Not very maintainable, but ok enough for now.
|
||||
last if /Portions of this code/;
|
||||
last unless
|
||||
/[Cc]opyright/ ||
|
||||
/This Source Code Form is subject to the terms of the Mozilla Public/ ||
|
||||
/If a copy of the MPL was not distributed with this/ ||
|
||||
/You can obtain one at http:\/\/mozilla.org\/MPL\/2.0\// ||
|
||||
/See COPYRIGHT in the source root/ ||
|
||||
/Permission to use, copy, modify, and / ||
|
||||
/THE SOFTWARE IS PROVIDED "AS IS" AND /;
|
||||
}
|
||||
$/ = "\n";
|
||||
}
|
||||
$first = $_;
|
||||
} else {
|
||||
$first = $_;
|
||||
}
|
||||
|
||||
$first = "" if ! defined($first);
|
||||
|
||||
open(TARGET, ">$file.new") || die "can't open $file.new: $!";
|
||||
print TARGET $before_copyright if $before_copyright;
|
||||
print TARGET $start_comment if $start_comment;
|
||||
|
||||
$sysyears = "";
|
||||
$nomyears = "";
|
||||
|
||||
#
|
||||
# Nominum: up to 2001.
|
||||
#
|
||||
$last_year = 0;
|
||||
$anchor_year = 0;
|
||||
$years = "";
|
||||
foreach $year (@years) {
|
||||
if ($year >= 2002) { next; }
|
||||
if ($last_year != 0 && $year == $last_year + 1) {
|
||||
if ($year > $anchor_year + 1) {
|
||||
substr($years, $anchor_end) = "-$year";
|
||||
} else {
|
||||
$years .= ", $year";
|
||||
}
|
||||
} else {
|
||||
$years .= $last_year == 0 ? "$year" : ", $year";
|
||||
$anchor_year = $year;
|
||||
$anchor_end = length($years);
|
||||
}
|
||||
|
||||
$last_year = $year;
|
||||
}
|
||||
$nomyears = $years;
|
||||
|
||||
$last_year = 0;
|
||||
$anchor_year = 0;
|
||||
$years = "";
|
||||
$anchor_end = length($years);
|
||||
my $andor = 0;
|
||||
my $noid = 0;
|
||||
foreach $year (@years) {
|
||||
$andor = 1 if ($year >= 2007);
|
||||
$noid = 1 if ($year > 2012 || ($year == 2012 && $this_month >= 5) );
|
||||
if ($last_year != 0 && $year == $last_year + 1) {
|
||||
if ($year > $anchor_year + 1) {
|
||||
substr($years, $anchor_end) = "-$year";
|
||||
} else {
|
||||
$years .= ", $year";
|
||||
}
|
||||
} else {
|
||||
$years .= $last_year == 0 ? "$year" : ", $year";
|
||||
#if ($anchor_year != 0) {
|
||||
# print "$file: noncontiguous year: ",
|
||||
# "$year != $last_year + 1\n";
|
||||
#}
|
||||
$anchor_year = $year;
|
||||
$anchor_end = length($years);
|
||||
}
|
||||
|
||||
$last_year = $year;
|
||||
}
|
||||
$sysyears = $years;
|
||||
|
||||
# make a copy
|
||||
@lines = @$textp;
|
||||
|
||||
foreach $_ (@lines) {
|
||||
next if (/\@SYSYEARS\@/ && $sysyears eq "");
|
||||
s:modify, and distribute:modify, and/or distribute: if ($andor);
|
||||
if ($type eq "RST") {
|
||||
print TARGET $prefix;
|
||||
} else {
|
||||
print TARGET (/^$/ ? $nonspaceprefix : $prefix);
|
||||
}
|
||||
s/\@SYSYEARS\@/$sysyears/;
|
||||
s/\@NOMYEARS\@/$nomyears/;
|
||||
print TARGET "$_";
|
||||
}
|
||||
print TARGET $end_comment if $end_comment;
|
||||
|
||||
if ($first eq "") {
|
||||
$first = <SOURCE>;
|
||||
}
|
||||
|
||||
if (defined($first)) {
|
||||
if ($type eq 'MAN') {
|
||||
print TARGET "$nonspaceprefix\n";
|
||||
} else {
|
||||
print TARGET "\n";
|
||||
}
|
||||
|
||||
if (($type eq "C") &&
|
||||
$sysyears =~ /$this_year/) {
|
||||
my $body = "";
|
||||
while (<SOURCE>) {
|
||||
# Process leading white space.
|
||||
# Remove 1-7 spaces followed by a tab into a single
|
||||
# tab if at start of line or proceeded by tabs.
|
||||
# s/^(\t*) {1,7}\t/$1\t/ while (/^\t* {1,7}\t/);
|
||||
# Convert 8 spaces into tabs if at start of line
|
||||
# or preceded by tabs.
|
||||
# s/^(\t*) {8}/$1\t/ while (/^\t* {8}/);
|
||||
# Remove trailing white space.
|
||||
s/[ \t]*$//;
|
||||
$body = "$body$_";
|
||||
}
|
||||
$_ = $body;
|
||||
} elsif (($type eq "SGML" || $type eq "HTML" ||
|
||||
$type eq "MAKE") &&
|
||||
$sysyears =~ /$this_year/) {
|
||||
my $body = "";
|
||||
while (<SOURCE>) {
|
||||
# Remove trailing white space.
|
||||
s/[ \t]*$//;
|
||||
$body = "$body$_";
|
||||
}
|
||||
$_ = $body;
|
||||
} else {
|
||||
undef $/;
|
||||
$_ = <SOURCE>;
|
||||
$/ = "\n";
|
||||
}
|
||||
|
||||
if ($type eq 'SGML' && m:<articleinfo>.*?</articleinfo>:s) {
|
||||
# print "docinfo: $file\n";
|
||||
my $r = copyrights(@years);
|
||||
s:<articleinfo>.*?</articleinfo>:<articleinfo>\n$r </articleinfo>:s;
|
||||
}
|
||||
if ($type eq 'SGML' && m:<docinfo>.*?</docinfo>:s) {
|
||||
# print "docinfo: $file\n";
|
||||
my $r = copyrights(@years);
|
||||
s:<docinfo>.*?</docinfo>:<docinfo>\n$r </docinfo>:s;
|
||||
}
|
||||
if ($type eq 'SGML' && m:<bookinfo>.*?</bookinfo>:s) {
|
||||
# print "bookinfo: $file\n";
|
||||
my $r = copyrights(@years);
|
||||
$r .= " <xi:include href=\"releaseinfo.xml\"/>\n";
|
||||
s:<bookinfo>.*?</bookinfo>:<bookinfo>\n$r </bookinfo>:s;
|
||||
}
|
||||
if ($type eq 'SGML' && m:<!-- insert copyright start -->.*?<!-- insert copyright end -->:s) {
|
||||
my $r = copyrights(@years);
|
||||
s:<!-- insert copyright start -->.*?<!-- insert copyright end -->:<!-- insert copyright start -->\n$r <!-- insert copyright end -->:s;
|
||||
}
|
||||
|
||||
my ($start, $end);
|
||||
if ($type =~ /^PYTHON(|-BIN)$/) {
|
||||
($start = $prefix) =~ s/\s*\n//;
|
||||
$end = "\n";
|
||||
} elsif ($start_comment ne "") {
|
||||
($start = $start_comment) =~ s/\s*\n/ /;
|
||||
($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/;
|
||||
} elsif ($prefix ne "") {
|
||||
($start = $prefix) =~ s/\s*\n//;
|
||||
$end = "\n";
|
||||
} else {
|
||||
$start = "";
|
||||
$end = "\n";
|
||||
}
|
||||
|
||||
if (!$noid && $first !~ /$keyword_pat/ &&
|
||||
(!defined($_) || $_ !~ /$keyword_pat/)) {
|
||||
$end = "\n$nonspaceprefix" if ($type eq "MAN");
|
||||
print TARGET "$start\$";
|
||||
print TARGET "Id";
|
||||
print TARGET "\$$end\n";
|
||||
}
|
||||
|
||||
print TARGET $first if $first !~ /^\s*$/;
|
||||
print TARGET $_ if (defined($_));
|
||||
}
|
||||
close(TARGET);
|
||||
close(SOURCE);
|
||||
|
||||
$mode = (stat $file)[2]&511;
|
||||
chmod $mode, "$file.new";
|
||||
|
||||
if (system("cmp -s $file.new $file") == 0) {
|
||||
unlink("$file.new");
|
||||
} else {
|
||||
rename("$file.new", "$file")
|
||||
or die "rename($file.new, $file): $!";
|
||||
}
|
||||
}
|
||||
|
||||
exit $ret;
|
||||
Loading…
Reference in a new issue