diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 899dbabe08..3958fb1642 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/util/COPYRIGHT.BRIEF b/util/COPYRIGHT.BRIEF deleted file mode 100644 index bb4b74b3bc..0000000000 --- a/util/COPYRIGHT.BRIEF +++ /dev/null @@ -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. diff --git a/util/COPYRIGHT.BSDI b/util/COPYRIGHT.BSDI deleted file mode 100644 index 3f7baea2ac..0000000000 --- a/util/COPYRIGHT.BSDI +++ /dev/null @@ -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. diff --git a/util/COPYRIGHT.NAI b/util/COPYRIGHT.NAI deleted file mode 100644 index 7004588951..0000000000 --- a/util/COPYRIGHT.NAI +++ /dev/null @@ -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. diff --git a/util/COPYRIGHT.NOM b/util/COPYRIGHT.NOM deleted file mode 100644 index 703af5971c..0000000000 --- a/util/COPYRIGHT.NOM +++ /dev/null @@ -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. diff --git a/util/COPYRIGHT.PORTION b/util/COPYRIGHT.PORTION deleted file mode 100644 index e61c2b9903..0000000000 --- a/util/COPYRIGHT.PORTION +++ /dev/null @@ -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. diff --git a/util/COPYRIGHT.TOP b/util/COPYRIGHT.TOP deleted file mode 100644 index d46a559644..0000000000 --- a/util/COPYRIGHT.TOP +++ /dev/null @@ -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/. diff --git a/util/merge_copyrights b/util/merge_copyrights deleted file mode 100644 index 8759fdd310..0000000000 --- a/util/merge_copyrights +++ /dev/null @@ -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, ") { - 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 () { - 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 = ; - $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); diff --git a/util/update_copyrights b/util/update_copyrights deleted file mode 100644 index 0926fb7106..0000000000 --- a/util/update_copyrights +++ /dev/null @@ -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/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 = ; - 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 \n"; - $result = "$result $_\n" foreach (@_); - $result = "$result $holder\n"; - $result = "$result \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 () { - # 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"; - } elsif ($type eq "MKD") { - $mkd_comment = 1; - $start_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: $!"; - $_ = ; - if ($type eq "YACC") { - unless ($_ eq "%{\n") { - print "$file: unexpected yacc file start ", - "(expected \"%{\\n\")\n"; - close(SOURCE); - $ret++; - next; - } - $before_copyright = "$_"; - $_ = ; - } - if ($c_comment && /^\/\*/) { - $_ = ; - if ($_ !~ /[Cc]opyright/) { - print "$file: non-copyright comment\n"; - close(SOURCE); - $ret++; - next; - } - if ($_ !~ /\*\//) { - while () { - last if $_ =~ /\*\//; - } - } - } elsif ($shell_comment) { - if (/^\#\!/) { - $before_copyright = "$_#\n"; - $_ = ; - $_ = if $_ eq "#\n"; - } - if (/^\#/) { - if ($_ !~ /[Cc]opyright/) { - print "$file: non-copyright comment\n"; - close(SOURCE); - $ret++; - next; - } - while () { - if ($_ !~ /^\#/) { - $first = $_; - last; - } - } - } else { - $first = $_; - } - } elsif ($python_comment || $python_bin_comment) { - if ($python_bin_comment && /^\#\!/) { - $before_copyright = "$_"; - $_ = ; - $_ = if $_ eq "#\n"; - $_ = if $_ eq "############################################################################\n"; - } elsif ($python_comment && /^\#/) { - $_ = if $_ eq "#\n"; - $_ = if $_ eq "############################################################################\n"; - } - if (/^\#/) { - if ($_ !~ /[Cc]opyright/) { - print "$file: non-copyright comment\n"; - close(SOURCE); - $ret++; - next; - } - while () { - if ($_ !~ /^\#/) { - $first = $_; - last; - } - } - } else { - $first = $_; - } - } elsif (($m4_comment || $man_comment) && - /^\Q$nonspaceprefix\E/) { - - while (/^\Q$nonspaceprefix\E\s*$/) { - $_ = ; - } - - if ($_ !~ /[Cc]opyright/) { - print "$file: non-copyright comment\n"; - close(SOURCE); - $ret++; - next; - } - while () { - if ($_ !~ /^\Q$nonspaceprefix\E/ || - $_ =~ /$keyword_pat/) { - $first = $_; - last; - } - } - } elsif ($sgml_comment) { - $before_copyright = ""; - while (/^$/ ) { - $_ = ; - close(SOURCE) if (eof(SOURCE)); - next; - } - if (/^; - next if (eof(SOURCE)); - $before_copyright = - "$before_copyright$_"; - if (/]>$/) { - $_ = ; - last; - } - } - close(SOURCE) if (eof(SOURCE)); - next; - } - if (/>$/ ) { - $_ = ; - close(SOURCE) if (eof(SOURCE)); - next; - } - $_ = ; - while (!eof(SOURCE) && ! /^; - } - if (eof(SOURCE)) { - close(SOURCE); - next; - } - } - if (/^//; - $_ = ; - } - print "$file: unterminated comment\n" - unless defined($_); - if ($_ ne "\n") { - $first = $_; - } else { - $first = ; - } - } else { - $first = $_; - } - } elsif ($mkd_comment) { - $before_copyright = ""; - if (/^ if $_ eq "//; - $_ = ; - } - print "$file: unterminated comment\n" - unless defined($_); - if ($_ ne "\n") { - $first = $_; - } else { - $first = ; - } - } else { - $first = $_; - } - } elsif ($rst_comment) { - if ($_ =~ /\.\. \n/) { - $_ = ; - if ($_ !~ /[Cc]opyright/) { - print "$file: non-copyright comment\n"; - close(SOURCE); - $ret++; - next; - } - while () { - if ($_ !~ /^ /) { - last; - } - } - } - $first = $_; - } elsif ($type eq "TXT") { - if ($_ =~ /[Cc]opyright/) { - $/ = ""; # paragraph at a time - while () { - # 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 = ; - } - - 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 () { - # 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 () { - # Remove trailing white space. - s/[ \t]*$//; - $body = "$body$_"; - } - $_ = $body; - } else { - undef $/; - $_ = ; - $/ = "\n"; - } - - if ($type eq 'SGML' && m:.*?:s) { - # print "docinfo: $file\n"; - my $r = copyrights(@years); - s:.*?:\n$r :s; - } - if ($type eq 'SGML' && m:.*?:s) { - # print "docinfo: $file\n"; - my $r = copyrights(@years); - s:.*?:\n$r :s; - } - if ($type eq 'SGML' && m:.*?:s) { - # print "bookinfo: $file\n"; - my $r = copyrights(@years); - $r .= " \n"; - s:.*?:\n$r :s; - } - if ($type eq 'SGML' && m:.*?:s) { - my $r = copyrights(@years); - s:.*?:\n$r :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;