update_copyrights revision e2653c8e8437a0af130346b471c337ca3aa8910c
07dcadc6e24f4572f2b7d7cae7d47d0f5256d129Andreas Gustafsson#!/usr/local/bin/perl -w
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence#
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence# Copyright (C) 2004-2010, 2012-2014 Internet Systems Consortium, Inc. ("ISC")
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence# Copyright (C) 1998-2001 Internet Software Consortium.
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence#
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Permission to use, copy, modify, and/or distribute this software for any
15a44745412679c30a6d022733925af70a38b715David Lawrence# purpose with or without fee is hereby granted, provided that the above
15a44745412679c30a6d022733925af70a38b715David Lawrence# copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence#
15a44745412679c30a6d022733925af70a38b715David Lawrence# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence# PERFORMANCE OF THIS SOFTWARE.
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrencerequire 5.002;
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence# Map copyright owners to the files containing copyright messages.
8f3dd8f8e73e4465221a5297819db70e6b383138Mark Andrews# The first line of the copyright message is not in the file;
ea31416b4fcdf23732355a8002f93f29e3b3d2dbAndreas Gustafsson# it is constructed by this script.
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence#
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley# Usage:
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# perl util/update_copyrights <util/copyrights
be801b0fdbcf9b55b3a8cc6bf042ff6c86be6b11Mark Andrews
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleymy %owner2filename = (
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley "" => "util/COPYRIGHT",
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley "NAI" => "util/COPYRIGHT.NAI",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "NOM" => "util/COPYRIGHT.NOM",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "BSDI" => "util/COPYRIGHT.BSDI",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "BRIEF" => "util/COPYRIGHT.BRIEF",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "PORTION" => "util/COPYRIGHT.PORTION",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff);
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff# Map each copyright owner name to a reference to an array containing
3d776d762914d1b675b4fd49728ce353ccf6f77eBrian Wellington# the lines of the copyright message.
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrencemy %owner2text = ();
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrencemy $keyword_pat = '\$(Id:.*|Revision:.*|Id|Revision)\$';
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrenceforeach $owner (keys %owner2filename) {
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson my $f = $owner2filename{$owner};
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson open(COPYRIGHT, "<$f") || die "can't open $f: $!";
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson @copyright_text = <COPYRIGHT>;
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson close(COPYRIGHT);
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson $owner2text{$owner} = [ @copyright_text ];
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence}
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrencemy %file_types = ();
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrencemy %file_years = ();
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrencemy $years_list;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrencemy $parent;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence($dummy,$dummy,$dummy,$dummy,$this_month,$this_year,$dummy,$dummy,$dummy) = localtime(time());
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence$this_year += 1900;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halleywhile (<>) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley chomp;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley ($file, $type, $years) = split(/\s+/);
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $file_types{$file} = $type;
ce8c568e0d6106bb87069453505e09bc66754b40Andreas Gustafsson $file_years{$file} = $years;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley}
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halleysub getyears {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $parent = $_[0];
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $parent =~ s/PARENT://;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $years_list = $file_years{$parent};
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley if (defined($years_list) && $years_list =~ /^PARENT:/) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley print "BAD PARENT:$parent\n";
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley undefine($years_list);
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley }
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley}
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halleysub docbook {
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $parent = $_[0];
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $parent =~ s/\.[^.]*$/.docbook/;
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson $years_list = $file_years{$parent};
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson}
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafssonsub copyright {
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson my $holder = shift;
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson my $result = "";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence return $result unless (@_);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $result = "$result <copyright>\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $result = "$result <year>$_</year>\n" foreach (@_);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $result = "$result <holder>$holder</holder>\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $result = "$result </copyright>\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence return $result;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence}
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrencesub copyrights {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence my $a = copyright("Internet Systems Consortium, Inc. (\"ISC\")",
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence grep({ $_ >= 2004} @_));
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence my $b = copyright("Internet Software Consortium.",
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence grep({ $_ < 2004} @_));
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence return "$a$b";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence}
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrenceforeach $file (keys %file_types) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $typeandowner = $file_types{$file};
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $years_list = $file_years{$file};
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence if ( ! -f $file ) {
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence print "$file: missing\n";
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence next;
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence }
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence # print "Doing: $file";
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence if ($years_list =~ /PARENT:/) {
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence getyears($years_list);
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence if (!defined $years_list) {
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence print "$file: has bad parent $parent\n";
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence next;
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence }
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence }
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence # copyright notice is now generated from the source.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence next if ($years_list eq "DOCBOOK");
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if ($years_list eq "DOCBOOK") {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence docbook($file);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if (!defined $years_list) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence print "$file: has bad parent $parent\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence next;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence }
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence }
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence @years = split(/,/, $years_list);
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence my ($type, $owner) = split(/\./, $typeandowner);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $owner = "" if !defined $owner;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence $textp = $owner2text{$owner};
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence if (!defined $textp) {
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence print "$file: unknown copyright owner $owner\n";
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence next;
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence }
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence if ($file eq "./CHANGES" || $file eq "./EXCLUDED" ||
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence $file eq "./CHANGES.SE")
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence {
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence open(SOURCE, "<$file") || die "can't open $file: $!";
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence my $body = "";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence while (<SOURCE>) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # Process leading white space.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # Remove 1-7 spaces followed by a tab into a single
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # tab if at start of line or proceeded by tabs.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence s/^(\t*) {1,7}\t/$1\t/ while (/^\t* {1,7}\t/);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence s/^(\s{0,3}\d*\.)\s(\[\w{1,5}\])\s+(\S+)/$1\t$2\t\t$3/;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence s/^(\s{0,3}\d*\.)\s(\[\w{6,}\])\s+(\S+)/$1\t$2\t$3/;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # Convert 8 spaces into tabs if at start of line
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff # or preceeded by tabs.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff s/^(\t*) /$1\t/ while (/^\t* /);
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff # Remove trailing white space.
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff s/[ \t]*$//;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $body = "$body$_";
1ce985ab3c6670662d555c108b35fed84a6a1001David Lawrence }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $_ = $body;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence open(TARGET, ">$file.new") || die "can't open $file.new: $!";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence print TARGET $_;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence close(TARGET);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence close(SOURCE);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if (system("cmp -s $file.new $file") == 0) {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence unlink("$file.new");
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence } else {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence rename("$file.new", "$file")
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence or die "rename($file.new, $file): $!";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence }
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence }
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence next if $type eq "X" or $type eq "BAT";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $before_copyright = "";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $c_comment = 0;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $shell_comment = 0;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $m4_comment = 0;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $sgml_comment = 0;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $mkd_comment = 0;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $zone_comment = 0;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $man_comment = 0;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $python_comment = 0;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $start_comment = "";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $end_comment = "";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $first = "";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff if ($type =~ /^(C|YACC|CONF-C)$/) {
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $c_comment = 1;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $start_comment = "/*\n";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $prefix = " * ";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $end_comment = " */\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH|RNC)$/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $shell_comment = 1;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $prefix = "# ";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } elsif ($type =~ /^PYTHON$/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $python_comment = 1;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $start_comment = "############################################################################\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $prefix = "# ";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $end_comment = "############################################################################\n"
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson } elsif ($type eq "ZONE" || $type eq "MC") {
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $zone_comment = 1;
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $prefix = "; ";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson } elsif ($type eq "MAN") {
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $man_comment = 1;
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $prefix = ".\\\" ";
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington } elsif ($type eq "M4") {
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $m4_comment = 1;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $prefix = "dnl ";
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington } elsif ($type eq "HTML" || $type eq "SGML") {
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $sgml_comment = 1;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $start_comment = "<!--\n";
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $prefix = " - ";
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $end_comment = "-->\n";
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington } elsif ($type eq "MKD") {
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $mkd_comment = 1;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $start_comment = "<!---\n";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $prefix = " - ";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $end_comment = "--->";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson } elsif ($type eq "TXT") {
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $prefix = "";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } else {
8f3dd8f8e73e4465221a5297819db70e6b383138Mark Andrews print "$file: type '$type' not supported yet; skipping\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson next;
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews }
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews ($nonspaceprefix = $prefix) =~ s/\s+$//;
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews open(SOURCE, "<$file") || die "can't open $file: $!";
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews $_ = <SOURCE>;
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews if ($type eq "YACC") {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson unless ($_ eq "%{\n") {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson print "$file: unexpected yacc file start ",
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson "(expected \"%{\\n\")\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson close(SOURCE);
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson next;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $before_copyright = "$_";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $_ = <SOURCE>;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($c_comment && /^\/\*/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $_ = <SOURCE>;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($_ !~ /[Cc]opyright/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson print "$file: non-copyright comment\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson close(SOURCE);
a1898260ad19d02e88ab76c1855d33c67add9defMark Andrews next;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($_ !~ /\*\//) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson while (<SOURCE>) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson last if $_ =~ /\*\//;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } elsif ($shell_comment) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if (/^\#\!/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $before_copyright = "$_#\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $_ = <SOURCE>;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $_ = <SOURCE> if $_ eq "#\n";
a1898260ad19d02e88ab76c1855d33c67add9defMark Andrews }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if (/^\#/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($_ !~ /[Cc]opyright/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson print "$file: non-copyright comment\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson close(SOURCE);
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson next;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson while (<SOURCE>) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($_ !~ /^\#/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $first = $_;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson last;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } else {
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff $first = $_;
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff }
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff } elsif ($python_comment) {
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff if (/^\#\!/) {
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff $before_copyright = "$_";
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff $_ = <SOURCE>;
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff $_ = <SOURCE> if $_ eq "#\n";
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff $_ = <SOURCE> if $_ eq "############################################################################\n";
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson }
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff if (/^\#/) {
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington if ($_ !~ /[Cc]opyright/) {
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington print "$file: non-copyright comment\n";
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington close(SOURCE);
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff next;
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington }
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington while (<SOURCE>) {
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington if ($_ !~ /^\#/) {
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington $first = $_;
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington last;
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington }
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington }
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson } else {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $first = $_;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson }
a0ad323da3597f942881eb2112a82c21450a9d0dBrian Wellington } elsif (($m4_comment || $zone_comment || $man_comment) &&
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson /^\Q$nonspaceprefix\E/) {
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson while (/^\Q$nonspaceprefix\E\s*$/) {
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson $_ = <SOURCE>;
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson }
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson if ($_ !~ /[Cc]opyright/) {
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson print "$file: non-copyright comment\n";
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson close(SOURCE);
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson next;
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson }
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson while (<SOURCE>) {
80f323528ac699026a609a5e3b765dc6e88fe37cAndreas Gustafsson if ($_ !~ /^\Q$nonspaceprefix\E/ ||
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $_ =~ /$keyword_pat/) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $first = $_;
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington last;
e4c7b24ab12572b6781d5c545c7b7949cbd2a6f7Brian Wellington }
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington }
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington } elsif ($sgml_comment) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $before_copyright = "";
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson while (/^<!DOCTYPE/ || /^<\?xml-stylesheet/ || /^<\?xml /) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson # print "SGML: $_";
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $before_copyright = "$before_copyright$_";
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson if (/>$/ ) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $_ = <SOURCE>;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson close(SOURCE) if (eof(SOURCE));
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson next;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson }
cb2a4cad76fbda226e7cd9dd3ca017b52521e3d1Andreas Gustafsson $_ = <SOURCE>;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson while (!eof(SOURCE) && ! /^<!/ ) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $before_copyright = "$before_copyright$_";
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson $_ = <SOURCE>;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson }
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson if (eof(SOURCE)) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson close(SOURCE);
caa736a754e90f44bbc249e22f96bcbf4e04b849Andreas Gustafsson next;
caa736a754e90f44bbc249e22f96bcbf4e04b849Andreas Gustafsson }
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson }
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson if (/^<!/) {
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington $_ = <SOURCE> if $_ eq "<!--\n";
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington if ($_ !~ /[Cc]opyright/) {
08a768e82ad64ede97f640c88e02984b59122753Michael Graff print "$file: non-copyright comment\n";
08a768e82ad64ede97f640c88e02984b59122753Michael Graff close(SOURCE);
08a768e82ad64ede97f640c88e02984b59122753Michael Graff next;
08a768e82ad64ede97f640c88e02984b59122753Michael Graff }
08a768e82ad64ede97f640c88e02984b59122753Michael Graff while (defined($_)) {
08a768e82ad64ede97f640c88e02984b59122753Michael Graff last if s/.*-->//;
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington $_ = <SOURCE>;
08a768e82ad64ede97f640c88e02984b59122753Michael Graff }
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington print "$file: unterminated comment\n"
08a768e82ad64ede97f640c88e02984b59122753Michael Graff unless defined($_);
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington if ($_ ne "\n") {
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington $first = $_;
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington } else {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $first = <SOURCE>;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington }
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington } else {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $first = $_;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington }
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington } elsif ($mkd_comment) {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $before_copyright = "";
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington if (/^<!/) {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $_ = <SOURCE> if $_ eq "<!---\n";
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington if ($_ !~ /[Cc]opyright/) {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington print "$file: non-copyright comment\n";
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington close(SOURCE);
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington next;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington }
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington while (defined($_)) {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington last if s/.*--->//;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $_ = <SOURCE>;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington }
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington print "$file: unterminated comment\n"
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington unless defined($_);
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington if ($_ ne "\n") {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $first = $_;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington } else {
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington $first = <SOURCE>;
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington }
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington } else {
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington $first = $_;
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington }
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington } elsif ($type eq "TXT") {
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington if ($_ =~ /[Cc]opyright/) {
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington $/ = ""; # paragraph at a time
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington while (<SOURCE>) {
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington # Not very maintainable, but ok enough for now.
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington last if /Portions of this code/;
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington last unless
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington /[Cc]opyright/ ||
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington /See COPYRIGHT in the source root/ ||
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington /Permission to use, copy, modify, and / ||
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington /THE SOFTWARE IS PROVIDED "AS IS" AND /;
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington }
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $/ = "\n";
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington }
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $first = $_;
af5ad488cbf17988fbd36a25c908737412ccd382Brian Wellington } else {
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $first = $_;
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington }
af5ad488cbf17988fbd36a25c908737412ccd382Brian Wellington
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $first = "" if ! defined($first);
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington
af5ad488cbf17988fbd36a25c908737412ccd382Brian Wellington open(TARGET, ">$file.new") || die "can't open $file.new: $!";
f317c00e0d5978f29285ea062b34ec73dc419095Brian Wellington print TARGET $before_copyright if $before_copyright;
f317c00e0d5978f29285ea062b34ec73dc419095Brian Wellington print TARGET $start_comment if $start_comment;
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $sysyears = "";
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $sftyears = "";
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $nomyears = "";
dee520f1be8c59e10a55b6995844395e811c310fBrian Wellington
dee520f1be8c59e10a55b6995844395e811c310fBrian Wellington #
dee520f1be8c59e10a55b6995844395e811c310fBrian Wellington # Internet Software Consortium: up to 2003
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington #
529ff4b4959fb157194f985394951108ff5286e4Brian Wellington $last_year = 0;
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $anchor_year = 0;
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington $years = "";
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington foreach $year (@years) {
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington if ($year >= 2004) { next; }
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence if ($last_year != 0 && $year == $last_year + 1) {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence if ($year > $anchor_year + 1) {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence substr($years, $anchor_end) = "-$year";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence } else {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence $years .= ", $year";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson } else {
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $years .= $last_year == 0 ? "$year" : ", $year";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #if ($anchor_year != 0) {
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson # print "$file: noncontiguous year: ",
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson # "$year != $last_year + 1\n";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #}
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_year = $year;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_end = length($years);
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
de2f767791456b45e2c9fc0df5febf33291b5110Brian Wellington
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $last_year = $year;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $sftyears = $years;
1bb05e54a3b0b5b390795e2481b95d07273274e1Brian Wellington
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson # Nominum: up to 2001.
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #
6ef891fbe943d6776ed17439ccb8bbb8e314b7d8Andreas Gustafsson $last_year = 0;
6ef891fbe943d6776ed17439ccb8bbb8e314b7d8Andreas Gustafsson $anchor_year = 0;
6ef891fbe943d6776ed17439ccb8bbb8e314b7d8Andreas Gustafsson $years = "";
9d266ed4d7630d8366fea0a4a627d8c3873821c5Brian Wellington foreach $year (@years) {
9d266ed4d7630d8366fea0a4a627d8c3873821c5Brian Wellington if ($year >= 2002) { next; }
9d266ed4d7630d8366fea0a4a627d8c3873821c5Brian Wellington if ($last_year != 0 && $year == $last_year + 1) {
967fafd9674da590f605d1cbe5f66dd7ddbeb849David Lawrence if ($year > $anchor_year + 1) {
967fafd9674da590f605d1cbe5f66dd7ddbeb849David Lawrence substr($years, $anchor_end) = "-$year";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson } else {
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $years .= ", $year";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson } else {
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $years .= $last_year == 0 ? "$year" : ", $year";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #if ($anchor_year != 0) {
1c0ff8a9cc1e1edd55acff6802f8811966732653Brian Wellington # print "$file: noncontiguous year: ",
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson # "$year != $last_year + 1\n";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #}
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_year = $year;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_end = length($years);
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $last_year = $year;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $nomyears = $years;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson # Internet Systems Consortium: 2004 onwards.
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $last_year = 0;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_year = 0;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $years = "";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence $anchor_end = length($years);
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson my $andor = 0;
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence my $noid = 0;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson foreach $year (@years) {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence if ($year < 2004) { next; }
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence $andor = 1 if ($year >= 2007);
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence $noid = 1 if ($year > 2012 || ($year == 2012 && $this_month >= 5) );
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence if ($last_year != 0 && $year == $last_year + 1) {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence if ($year > $anchor_year + 1) {
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson substr($years, $anchor_end) = "-$year";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson } else {
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $years .= ", $year";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence }
b6cb5907b2159b3e82bfd37d1818f327ca1e7ca0Mark Andrews } else {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence $years .= $last_year == 0 ? "$year" : ", $year";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence #if ($anchor_year != 0) {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence # print "$file: noncontiguous year: ",
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson # "$year != $last_year + 1\n";
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson #}
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_year = $year;
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $anchor_end = length($years);
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson $last_year = $year;
9ce476812c93a1bb8b416adbe707ee5000a015f1Andreas Gustafsson }
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson $sysyears = $years;
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson ($firstline, $secondline, @otherlines) = @$textp;
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $firstline =~ s/\@SYSYEARS\@/$sysyears/;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $secondline =~ s/\@SFTYEARS\@/$sftyears/;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET "$prefix$firstline";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson if ($sftyears ne "" ) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET $secondline =~ /^$/ ? $nonspaceprefix : $prefix;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET "$secondline";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson foreach $_ (@otherlines) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson s:modify, and distribute:modify, and/or distribute: if ($andor);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET (/^$/ ? $nonspaceprefix : $prefix);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson s/\@NOMYEARS\@/$nomyears/;
1706598239da403b86f4befa4c08175d9e101014Andreas Gustafsson print TARGET "$_";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
ea31416b4fcdf23732355a8002f93f29e3b3d2dbAndreas Gustafsson print TARGET $end_comment if $end_comment;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
971d1fe83172bce09d6319c5735d243d68d8cb47Andreas Gustafsson if ($first eq "") {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $first = <SOURCE>;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson if (defined($first)) {
1706598239da403b86f4befa4c08175d9e101014Andreas Gustafsson if ($type eq 'MAN') {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET "$nonspaceprefix\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson } else {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET "\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson if (($type eq "C" || $type eq "CONF-C") &&
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $sysyears =~ /$this_year/) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson my $body = "";
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington while (<SOURCE>) {
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington # Process leading white space.
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington # Remove 1-7 spaces followed by a tab into a single
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington # tab if at start of line or proceeded by tabs.
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington s/^(\t*) {1,7}\t/$1\t/ while (/^\t* {1,7}\t/);
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington # Convert 8 spaces into tabs if at start of line
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington # or preceeded by tabs.
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington s/^(\t*) {8}/$1\t/ while (/^\t* {8}/);
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington # Remove trailing white space.
c356cd618dacb13d47ee9bee78d22a9802d4645eBrian Wellington s/[ \t]*$//;
1706598239da403b86f4befa4c08175d9e101014Andreas Gustafsson $body = "$body$_";
566a01eb745d49bd866971062388cd11d525b60dDavid Lawrence }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $_ = $body;
ce7994d137a013133e874b92604183923267fc94Brian Wellington } else {
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence undef $/;
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence $_ = <SOURCE>;
ce7994d137a013133e874b92604183923267fc94Brian Wellington $/ = "\n";
ce7994d137a013133e874b92604183923267fc94Brian Wellington }
e2b585787f4779f49bd0982562acbbb7d0b65a95Andreas Gustafsson
566a01eb745d49bd866971062388cd11d525b60dDavid Lawrence if ($type eq 'SGML' && m:<articleinfo>.*?</articleinfo>:s) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson # print "docinfo: $file\n";
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington my $r = copyrights(@years);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson s:<articleinfo>.*?</articleinfo>:<articleinfo>\n$r </articleinfo>:s;
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington }
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington if ($type eq 'SGML' && m:<docinfo>.*?</docinfo>:s) {
2271edc0b4ba96e69a283eced420b94ffb678beeBrian Wellington # print "docinfo: $file\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson my $r = copyrights(@years);
2271edc0b4ba96e69a283eced420b94ffb678beeBrian Wellington s:<docinfo>.*?</docinfo>:<docinfo>\n$r </docinfo>:s;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson if ($type eq 'SGML' && m:<bookinfo>.*?</bookinfo>:s) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson # print "bookinfo: $file\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson my $r = copyrights(@years);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $r .= " <xi:include href=\"releaseinfo.xml\"/>\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson s:<bookinfo>.*?</bookinfo>:<bookinfo>\n$r </bookinfo>:s;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
7005cfed8cd3296d356883dcb414979f22e06b13Brian Wellington
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington my ($start, $end);
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington if ($type =~ /^PYTHON$/) {
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington ($start = $prefix) =~ s/\s*\n//;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $end = "\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson } elsif ($start_comment ne "") {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson ($start = $start_comment) =~ s/\s*\n/ /;
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson ($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson } elsif ($prefix ne "") {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson ($start = $prefix) =~ s/\s*\n//;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $end = "\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson } else {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $start = "";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $end = "\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
fa280ff02ad0c29616a0c3a22ef02cbb3f6db7efDavid Lawrence
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson if (!$noid && $first !~ /$keyword_pat/ &&
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson (!defined($_) || $_ !~ /$keyword_pat/)) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $end = "\n$nonspaceprefix" if ($type eq "MAN");
fa280ff02ad0c29616a0c3a22ef02cbb3f6db7efDavid Lawrence print TARGET "$start\$";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET "Id";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET "\$$end\n";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET $first if $first !~ /^\s*$/;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson print TARGET $_ if (defined($_));
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson close(TARGET);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson close(SOURCE);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson $mode = (stat $file)[2]&511;
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson chmod $mode, "$file.new";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson if (system("cmp -s $file.new $file") == 0) {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson unlink("$file.new");
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson } else {
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson rename("$file.new", "$file")
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson or die "rename($file.new, $file): $!";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson }
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson}
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson