update_copyrights revision d9156bba3e3836d281e4f73d4eb8e8fbac9db657
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley#!/usr/local/bin/perl -w
72d6be2c1101df11c05360f78d47197027d419c3Automatic Updater#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# Copyright (C) 2004-2010, 2012-2015 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 1998-2001 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater#
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley# Permission to use, copy, modify, and/or distribute this software for any
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley# purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley# PERFORMANCE OF THIS SOFTWARE.
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley
be40453080750077f1161c70f03c5f6921a27961Automatic Updaterrequire 5.002;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein# Map copyright owners to the files containing copyright messages.
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# The first line of the copyright message is not in the file;
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley# it is constructed by this script.
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer#
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley# Usage:
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews#
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley# perl util/update_copyrights <util/copyrights
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halleymy %owner2filename = (
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley "" => "util/COPYRIGHT",
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley "NAI" => "util/COPYRIGHT.NAI",
de8661e517ed679cfaa12e47eb9a8e23829ed320David Lawrence "NOM" => "util/COPYRIGHT.NOM",
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley "BSDI" => "util/COPYRIGHT.BSDI",
de8661e517ed679cfaa12e47eb9a8e23829ed320David Lawrence "BRIEF" => "util/COPYRIGHT.BRIEF",
de8661e517ed679cfaa12e47eb9a8e23829ed320David Lawrence "PORTION" => "util/COPYRIGHT.PORTION",
90c4900d5cf1a1b556ae4c1de6338b2e7475ee55Mark Andrews);
de8661e517ed679cfaa12e47eb9a8e23829ed320David Lawrence
764808211e952f1617aaa609281da66d80120c0dMark Andrews# Map each copyright owner name to a reference to an array containing
764808211e952f1617aaa609281da66d80120c0dMark Andrews# the lines of the copyright message.
764808211e952f1617aaa609281da66d80120c0dMark Andrews
de8661e517ed679cfaa12e47eb9a8e23829ed320David Lawrencemy %owner2text = ();
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley
cf300e03de3df3ff422db922520bf07c686c86daMark Andrewsmy $keyword_pat = '\$(Id:.*|Revision:.*|Id|Revision)\$';
76477bd0e0a8f150f06f45c347d286b782cfa679Brian Wellington
108490a7f8529aff50a0ac7897580b59a73d9845David Lawrenceforeach $owner (keys %owner2filename) {
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews my $f = $owner2filename{$owner};
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer open(COPYRIGHT, "<$f") || die "can't open $f: $!";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews @copyright_text = <COPYRIGHT>;
108490a7f8529aff50a0ac7897580b59a73d9845David Lawrence close(COPYRIGHT);
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley $owner2text{$owner} = [ @copyright_text ];
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley}
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrewsmy %file_types = ();
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrewsmy %file_years = ();
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrewsmy $years_list;
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halleymy $parent;
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews($dummy,$dummy,$dummy,$dummy,$this_month,$this_year,$dummy,$dummy,$dummy) = localtime(time());
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington$this_year += 1900;
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrewswhile (<>) {
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews chomp;
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews ($file, $type, $years) = split(/\s+/);
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $file_types{$file} = $type;
1d8cbe855fc355b80802dcf29f4ac24bebdd1193Brian Wellington $file_years{$file} = $years;
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington}
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington
f8727bd90366af835f551da1b5e1fdfcd2d3d01fBrian Wellingtonsub getyears {
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $parent = $_[0];
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $parent =~ s/PARENT://;
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $years_list = $file_years{$parent};
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington if (defined($years_list) && $years_list =~ /^PARENT:/) {
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews print "BAD PARENT:$parent\n";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt undefine($years_list);
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews }
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington}
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrewssub docbook {
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $parent = $_[0];
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $parent =~ s/\.[^.]*$/.docbook/;
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $years_list = $file_years{$parent};
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews}
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellingtonsub copyright {
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington my $holder = shift;
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington my $result = "";
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews return $result unless (@_);
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $result = "$result <copyright>\n";
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $result = "$result <year>$_</year>\n" foreach (@_);
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $result = "$result <holder>$holder</holder>\n";
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews $result = "$result </copyright>\n";
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington return $result;
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington}
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellingtonsub copyrights {
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews my $a = copyright("Internet Systems Consortium, Inc. (\"ISC\")",
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington grep({ $_ >= 2004} @_));
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington my $b = copyright("Internet Software Consortium.",
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews grep({ $_ < 2004} @_));
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington return "$a$b";
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews}
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellingtonforeach $file (keys %file_types) {
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $typeandowner = $file_types{$file};
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $years_list = $file_years{$file};
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington if ( ! -f $file ) {
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley print "$file: missing\n";
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley next;
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley }
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley # print "Doing: $file";
4e5388b45908ce8b8b35825ca6f16c1d236643baBrian Wellington
c336121fb5a5c1b9cb9b2cd4cea50f0788270505Brian Wellington if ($years_list =~ /PARENT:/) {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews getyears($years_list);
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence if (!defined $years_list) {
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley print "$file: has bad parent $parent\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley next;
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington }
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington }
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews # copyright notice is now generated from the source.
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews next if ($years_list eq "DOCBOOK");
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein if ($years_list eq "DOCBOOK") {
077daa21229ffaedda79588fa70fbaeae19ae998Bob Halley docbook($file);
077daa21229ffaedda79588fa70fbaeae19ae998Bob Halley if (!defined $years_list) {
077daa21229ffaedda79588fa70fbaeae19ae998Bob Halley print "$file: has bad parent $parent\n";
077daa21229ffaedda79588fa70fbaeae19ae998Bob Halley next;
077daa21229ffaedda79588fa70fbaeae19ae998Bob Halley }
077daa21229ffaedda79588fa70fbaeae19ae998Bob Halley }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt @years = split(/,/, $years_list);
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt my ($type, $owner) = split(/\./, $typeandowner);
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $owner = "" if !defined $owner;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $textp = $owner2text{$owner};
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if (!defined $textp) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt print "$file: unknown copyright owner $owner\n";
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley next;
f8727bd90366af835f551da1b5e1fdfcd2d3d01fBrian Wellington }
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington if ($file eq "./CHANGES" || $file eq "./EXCLUDED" ||
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington $file eq "./CHANGES.SE")
1d8cbe855fc355b80802dcf29f4ac24bebdd1193Brian Wellington {
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington open(SOURCE, "<$file") || die "can't open $file: $!";
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington my $body = "";
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington while (<SOURCE>) {
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington # Process leading white space.
da76a8046e01e1c1c2e6f75772afb2c4f202cc25Brian Wellington # Remove 1-7 spaces followed by a tab into a single
da76a8046e01e1c1c2e6f75772afb2c4f202cc25Brian Wellington # tab if at start of line or proceeded by tabs.
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley s/^(\t*) {1,7}\t/$1\t/ while (/^\t* {1,7}\t/);
d1e4b08844175357a925ddd6dcfa750cccd2b116Brian Wellington s/^(\s{0,3}\d*\.)\s(\[\w{1,5}\])\s+(\S+)/$1\t$2\t\t$3/;
f8727bd90366af835f551da1b5e1fdfcd2d3d01fBrian Wellington s/^(\s{0,3}\d*\.)\s(\[\w{6,}\])\s+(\S+)/$1\t$2\t$3/;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley # Convert 8 spaces into tabs if at start of line
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt # or preceeded by tabs.
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt s/^(\t*) /$1\t/ while (/^\t* /);
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt # Remove trailing white space.
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt s/[ \t]*$//;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $body = "$body$_";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley $_ = $body;
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley open(TARGET, ">$file.new") || die "can't open $file.new: $!";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt print TARGET $_;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt close(TARGET);
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley close(SOURCE);
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley if (system("cmp -s $file.new $file") == 0) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt unlink("$file.new");
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews } else {
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley rename("$file.new", "$file")
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellington or die "rename($file.new, $file): $!";
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
2f734e0a7e518c89c2b2b179714b8885b7626b3aAndreas Gustafsson
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley next if $type eq "X" or $type eq "BAT";
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley
2f734e0a7e518c89c2b2b179714b8885b7626b3aAndreas Gustafsson $before_copyright = "";
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley $c_comment = 0;
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley $shell_comment = 0;
bb99a72b219ad4f1daa80c636883ab485174c9a6Mark Andrews $m4_comment = 0;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $sgml_comment = 0;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $mkd_comment = 0;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $zone_comment = 0;
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews $man_comment = 0;
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews $python_comment = 0;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $start_comment = "";
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews $end_comment = "";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $first = "";
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews if ($type =~ /^(C|YACC|CONF-C)$/) {
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews $c_comment = 1;
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews $start_comment = "/*\n";
dc2a0aa7aaa8b85398ae183c7274c0eeec5009afMark Andrews $prefix = " * ";
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley $end_comment = " */\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley } elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH|RNC)$/) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $shell_comment = 1;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $prefix = "# ";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt } elsif ($type =~ /^PYTHON$/) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $python_comment = 1;
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $start_comment = "############################################################################\n";
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $prefix = "# ";
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $end_comment = "############################################################################\n"
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews } elsif ($type eq "ZONE" || $type eq "MC") {
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $zone_comment = 1;
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $prefix = "; ";
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews } elsif ($type eq "MAN") {
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $man_comment = 1;
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $prefix = ".\\\" ";
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews } elsif ($type eq "M4") {
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $m4_comment = 1;
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $prefix = "dnl ";
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews } elsif ($type eq "HTML" || $type eq "SGML") {
88674be66567d3c7db91e717cd5972655e2e2488Mark Andrews $sgml_comment = 1;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $start_comment = "<!--\n";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $prefix = " - ";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $end_comment = "-->\n";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt } elsif ($type eq "MKD") {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $mkd_comment = 1;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $start_comment = "<!---\n";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $prefix = " - ";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $end_comment = "--->";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt } elsif ($type eq "TXT") {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $prefix = "";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt } else {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt print "$file: type '$type' not supported yet; skipping\n";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt next;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley ($nonspaceprefix = $prefix) =~ s/\s+$//;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt open(SOURCE, "<$file") || die "can't open $file: $!";
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $_ = <SOURCE>;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if ($type eq "YACC") {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt unless ($_ eq "%{\n") {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt print "$file: unexpected yacc file start ",
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt "(expected \"%{\\n\")\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley close(SOURCE);
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein next;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $before_copyright = "$_";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $_ = <SOURCE>;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if ($c_comment && /^\/\*/) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $_ = <SOURCE>;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if ($_ !~ /[Cc]opyright/) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley print "$file: non-copyright comment\n";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley close(SOURCE);
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt next;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if ($_ !~ /\*\//) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley while (<SOURCE>) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley last if $_ =~ /\*\//;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
f8727bd90366af835f551da1b5e1fdfcd2d3d01fBrian Wellington } elsif ($shell_comment) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if (/^\#\!/) {
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $before_copyright = "$_#\n";
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $_ = <SOURCE>;
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $_ = <SOURCE> if $_ eq "#\n";
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington }
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if (/^\#/) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if ($_ !~ /[Cc]opyright/) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley print "$file: non-copyright comment\n";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley close(SOURCE);
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington next;
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington }
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington while (<SOURCE>) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if ($_ !~ /^\#/) {
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington $first = $_;
d119051ef75d5a88d28c13fb0a7c6d6757a4e9b5Brian Wellington last;
d119051ef75d5a88d28c13fb0a7c6d6757a4e9b5Brian Wellington }
d119051ef75d5a88d28c13fb0a7c6d6757a4e9b5Brian Wellington }
d119051ef75d5a88d28c13fb0a7c6d6757a4e9b5Brian Wellington } else {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $first = $_;
d119051ef75d5a88d28c13fb0a7c6d6757a4e9b5Brian Wellington }
5e4b7294d88ab58371d8c98e05ea80086dcb67cdBob Halley } elsif ($python_comment) {
5e4b7294d88ab58371d8c98e05ea80086dcb67cdBob Halley if (/^\#\!/) {
5e4b7294d88ab58371d8c98e05ea80086dcb67cdBob Halley $before_copyright = "$_";
108490a7f8529aff50a0ac7897580b59a73d9845David Lawrence $_ = <SOURCE>;
108490a7f8529aff50a0ac7897580b59a73d9845David Lawrence $_ = <SOURCE> if $_ eq "#\n";
108490a7f8529aff50a0ac7897580b59a73d9845David Lawrence $_ = <SOURCE> if $_ eq "############################################################################\n";
5e4b7294d88ab58371d8c98e05ea80086dcb67cdBob Halley }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if (/^\#/) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if ($_ !~ /[Cc]opyright/) {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley print "$file: non-copyright comment\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley close(SOURCE);
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley next;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley while (<SOURCE>) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt if ($_ !~ /^\#/) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt $first = $_;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt last;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt } else {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $first = $_;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein } elsif (($m4_comment || $zone_comment || $man_comment) &&
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley /^\Q$nonspaceprefix\E/) {
5e4b7294d88ab58371d8c98e05ea80086dcb67cdBob Halley
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley while (/^\Q$nonspaceprefix\E\s*$/) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $_ = <SOURCE>;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley if ($_ !~ /[Cc]opyright/) {
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt print "$file: non-copyright comment\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley close(SOURCE);
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews next;
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews }
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews while (<SOURCE>) {
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews if ($_ !~ /^\Q$nonspaceprefix\E/ ||
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews $_ =~ /$keyword_pat/) {
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews $first = $_;
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews last;
0415ca35ada2cac6a86127eaca64f3a997aea121Evan Hunt }
8fd925169f3d690f6c50c17d711adc9695407528Mark Andrews }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley } elsif ($sgml_comment) {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $before_copyright = "";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley while (/^<!DOCTYPE/ || /^<!ENTITY/ || /^<\?xml-stylesheet/ || /^<\?xml /) {
f8727bd90366af835f551da1b5e1fdfcd2d3d01fBrian Wellington # print "SGML: $_";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $before_copyright = "$before_copyright$_";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if (/\]>$/ ) {
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $_ = <SOURCE>;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein close(SOURCE) if (eof(SOURCE));
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley next;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if (/^<!DOCTYPE.*\[$/) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley while (!eof(SOURCE)) {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $_ = <SOURCE>;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews next if (eof(SOURCE));
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $before_copyright =
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews "$before_copyright$_";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews if (/]>$/) {
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellington $_ = <SOURCE>;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley last;
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellington }
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellington }
77771185071bf74d53378f1a3099a04d2af5153eBrian Wellington close(SOURCE) if (eof(SOURCE));
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley next;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley if (/>$/ ) {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $_ = <SOURCE>;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley close(SOURCE) if (eof(SOURCE));
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley next;
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley }
663841abe0bb1cc8040e552597ef721c35b799e5Brian Wellington $_ = <SOURCE>;
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley while (!eof(SOURCE) && ! /^<!/ ) {
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley $before_copyright = "$before_copyright$_";
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley $_ = <SOURCE>;
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley }
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley if (eof(SOURCE)) {
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley close(SOURCE);
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews next;
1fc4929aa610263a2362afed516d7dc8e689397dBob Halley }
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley if (/^<!--/) {
663841abe0bb1cc8040e552597ef721c35b799e5Brian Wellington $_ = <SOURCE> if $_ eq "<!--\n";
663841abe0bb1cc8040e552597ef721c35b799e5Brian Wellington if ($_ !~ /[Cc]opyright/) {
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley print "$file: non-copyright comment\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley close(SOURCE);
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley next;
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley }
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley while (defined($_)) {
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley last if s/.*-->//;
90c4900d5cf1a1b556ae4c1de6338b2e7475ee55Mark Andrews $_ = <SOURCE>;
90c4900d5cf1a1b556ae4c1de6338b2e7475ee55Mark Andrews }
90c4900d5cf1a1b556ae4c1de6338b2e7475ee55Mark Andrews print "$file: unterminated comment\n"
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley unless defined($_);
9b2267b5ba9d0640512a41e139a4a36caa43730dBob Halley if ($_ ne "\n") {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $first = $_;
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley } else {
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley $first = <SOURCE>;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews }
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley } else {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $first = $_;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews } elsif ($mkd_comment) {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $before_copyright = "";
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews if (/^<!/) {
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley $_ = <SOURCE> if $_ eq "<!---\n";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews if ($_ !~ /[Cc]opyright/) {
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews print "$file: non-copyright comment\n";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews close(SOURCE);
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews next;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews while (defined($_)) {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews last if s/.*--->//;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $_ = <SOURCE>;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater print "$file: unterminated comment\n"
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews unless defined($_);
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews if ($_ ne "\n") {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $first = $_;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews } else {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $first = <SOURCE>;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews } else {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $first = $_;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews } elsif ($type eq "TXT") {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews if ($_ =~ /[Cc]opyright/) {
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley $/ = ""; # paragraph at a time
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley while (<SOURCE>) {
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley # Not very maintainable, but ok enough for now.
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley last if /Portions of this code/;
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley last unless
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley /[Cc]opyright/ ||
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley /See COPYRIGHT in the source root/ ||
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley /Permission to use, copy, modify, and / ||
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley /THE SOFTWARE IS PROVIDED "AS IS" AND /;
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews }
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $/ = "\n";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews }
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $first = $_;
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley } else {
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley $first = $_;
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley }
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley
15197aefa1659e98ea1c48e2cbae631136a072b7Michael Graff $first = "" if ! defined($first);
15197aefa1659e98ea1c48e2cbae631136a072b7Michael Graff
15197aefa1659e98ea1c48e2cbae631136a072b7Michael Graff open(TARGET, ">$file.new") || die "can't open $file.new: $!";
15197aefa1659e98ea1c48e2cbae631136a072b7Michael Graff print TARGET $before_copyright if $before_copyright;
15197aefa1659e98ea1c48e2cbae631136a072b7Michael Graff print TARGET $start_comment if $start_comment;
15197aefa1659e98ea1c48e2cbae631136a072b7Michael Graff
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley $sysyears = "";
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $sftyears = "";
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $nomyears = "";
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews #
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews # Internet Software Consortium: up to 2003
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews #
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $last_year = 0;
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $anchor_year = 0;
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $years = "";
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews foreach $year (@years) {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews if ($year >= 2004) { next; }
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews if ($last_year != 0 && $year == $last_year + 1) {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews if ($year > $anchor_year + 1) {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews substr($years, $anchor_end) = "-$year";
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews } else {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $years .= ", $year";
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews } else {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $years .= $last_year == 0 ? "$year" : ", $year";
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews #if ($anchor_year != 0) {
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews # print "$file: noncontiguous year: ",
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews # "$year != $last_year + 1\n";
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews #}
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $anchor_year = $year;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $anchor_end = length($years);
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $last_year = $year;
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews }
2c329da87c5c886e7f4468c69a9e6323121068cbMark Andrews $sftyears = $years;
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews #
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews # Nominum: up to 2001.
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews #
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $last_year = 0;
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $anchor_year = 0;
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews $years = "";
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews foreach $year (@years) {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews if ($year >= 2002) { next; }
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews if ($last_year != 0 && $year == $last_year + 1) {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews if ($year > $anchor_year + 1) {
c52ae25dd70636c673d4a299859137a1c8ba611aMark Andrews substr($years, $anchor_end) = "-$year";
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley } else {
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley $years .= ", $year";
2aa67e804d85f4d88153368ce65ce4df7b5390e6Bob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley } else {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $years .= $last_year == 0 ? "$year" : ", $year";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley #if ($anchor_year != 0) {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley # print "$file: noncontiguous year: ",
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley # "$year != $last_year + 1\n";
e63f7c6f556aef66ff81fb128605f9eadf1ddcd9Mark Andrews #}
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $anchor_year = $year;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $anchor_end = length($years);
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $last_year = $year;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $nomyears = $years;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews #
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews # Internet Systems Consortium: 2004 onwards.
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews #
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews $last_year = 0;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $anchor_year = 0;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $years = "";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $anchor_end = length($years);
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews my $andor = 0;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews my $noid = 0;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews foreach $year (@years) {
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews if ($year < 2004) { next; }
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $andor = 1 if ($year >= 2007);
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $noid = 1 if ($year > 2012 || ($year == 2012 && $this_month >= 5) );
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews if ($last_year != 0 && $year == $last_year + 1) {
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews if ($year > $anchor_year + 1) {
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews substr($years, $anchor_end) = "-$year";
f754fa97bc698cc251d227173a95e4d39a88ac01Mark Andrews } else {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $years .= ", $year";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley } else {
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $years .= $last_year == 0 ? "$year" : ", $year";
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence #if ($anchor_year != 0) {
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews # print "$file: noncontiguous year: ",
c336121fb5a5c1b9cb9b2cd4cea50f0788270505Brian Wellington # "$year != $last_year + 1\n";
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley #}
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $anchor_year = $year;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley $anchor_end = length($years);
4e5388b45908ce8b8b35825ca6f16c1d236643baBrian Wellington }
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley
4e5388b45908ce8b8b35825ca6f16c1d236643baBrian Wellington $last_year = $year;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence $sysyears = $years;
4e5388b45908ce8b8b35825ca6f16c1d236643baBrian Wellington
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley ($firstline, $secondline, @otherlines) = @$textp;
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington $firstline =~ s/\@SYSYEARS\@/$sysyears/;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews $secondline =~ s/\@SFTYEARS\@/$sftyears/;
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews print TARGET "$prefix$firstline";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews if ($sftyears ne "" ) {
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington print TARGET $secondline =~ /^$/ ? $nonspaceprefix : $prefix;
71954c957132c35ddf5f9e4dcc98c057b265b6d8Brian Wellington print TARGET "$secondline";
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence }
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence foreach $_ (@otherlines) {
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence s:modify, and distribute:modify, and/or distribute: if ($andor);
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews print TARGET (/^$/ ? $nonspaceprefix : $prefix);
c336121fb5a5c1b9cb9b2cd4cea50f0788270505Brian Wellington s/\@NOMYEARS\@/$nomyears/;
c6ab6ca3fd5f0bca400aac931f616722bbb19109Andreas Gustafsson print TARGET "$_";
c6ab6ca3fd5f0bca400aac931f616722bbb19109Andreas Gustafsson }
c336121fb5a5c1b9cb9b2cd4cea50f0788270505Brian Wellington print TARGET $end_comment if $end_comment;
c336121fb5a5c1b9cb9b2cd4cea50f0788270505Brian Wellington
c6ab6ca3fd5f0bca400aac931f616722bbb19109Andreas Gustafsson if ($first eq "") {
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $first = <SOURCE>;
c6ab6ca3fd5f0bca400aac931f616722bbb19109Andreas Gustafsson }
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews if (defined($first)) {
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews if ($type eq 'MAN') {
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews print TARGET "$nonspaceprefix\n";
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews } else {
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews print TARGET "\n";
31a71adf14d106260127079f6ea26bea600163e9Mark Andrews }
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if (($type eq "C" || $type eq "CONF-C") &&
c6ab6ca3fd5f0bca400aac931f616722bbb19109Andreas Gustafsson $sysyears =~ /$this_year/) {
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews my $body = "";
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews while (<SOURCE>) {
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews # Process leading white space.
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews # Remove 1-7 spaces followed by a tab into a single
4e5388b45908ce8b8b35825ca6f16c1d236643baBrian Wellington # tab if at start of line or proceeded by tabs.
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews s/^(\t*) {1,7}\t/$1\t/ while (/^\t* {1,7}\t/);
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews # Convert 8 spaces into tabs if at start of line
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews # or preceeded by tabs.
4b87939256ede703385e9cab92d3c58d03c31098Mark Andrews s/^(\t*) {8}/$1\t/ while (/^\t* {8}/);
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington # Remove trailing white space.
d53520b78d4a8726396efdbaa71f86f687a6f308Mark Andrews s/[ \t]*$//;
d53520b78d4a8726396efdbaa71f86f687a6f308Mark Andrews $body = "$body$_";
d53520b78d4a8726396efdbaa71f86f687a6f308Mark Andrews }
d53520b78d4a8726396efdbaa71f86f687a6f308Mark Andrews $_ = $body;
d53520b78d4a8726396efdbaa71f86f687a6f308Mark Andrews } else {
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews undef $/;
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews $_ = <SOURCE>;
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews $/ = "\n";
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews }
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews if ($type eq 'SGML' && m:<articleinfo>.*?</articleinfo>:s) {
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews # print "docinfo: $file\n";
f61a7c87bf36b189d8f04ea4c8ab3ec55778355cMark Andrews my $r = copyrights(@years);
d53520b78d4a8726396efdbaa71f86f687a6f308Mark Andrews s:<articleinfo>.*?</articleinfo>:<articleinfo>\n$r </articleinfo>:s;
2dfd6bca9aa6d9279b4278d6fa18ea5f63ba0ec9Bob Halley }
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley if ($type eq 'SGML' && m:<docinfo>.*?</docinfo>:s) {
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews # print "docinfo: $file\n";
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews my $r = copyrights(@years);
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews s:<docinfo>.*?</docinfo>:<docinfo>\n$r </docinfo>:s;
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews }
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews if ($type eq 'SGML' && m:<bookinfo>.*?</bookinfo>:s) {
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews # print "bookinfo: $file\n";
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews my $r = copyrights(@years);
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews $r .= " <xi:include href=\"releaseinfo.xml\"/>\n";
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews s:<bookinfo>.*?</bookinfo>:<bookinfo>\n$r </bookinfo>:s;
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews }
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews my ($start, $end);
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews if ($type =~ /^PYTHON$/) {
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews ($start = $prefix) =~ s/\s*\n//;
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews $end = "\n";
be40453080750077f1161c70f03c5f6921a27961Automatic Updater } elsif ($start_comment ne "") {
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews ($start = $start_comment) =~ s/\s*\n/ /;
6d54a6fc180acaf8772c9447cb925b31f39c7158Mark Andrews ($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/;
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley } elsif ($prefix ne "") {
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence ($start = $prefix) =~ s/\s*\n//;
f8727bd90366af835f551da1b5e1fdfcd2d3d01fBrian Wellington $end = "\n";
c6ab6ca3fd5f0bca400aac931f616722bbb19109Andreas Gustafsson } else {
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley $start = "";
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence $end = "\n";
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington }
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington if (!$noid && $first !~ /$keyword_pat/ &&
202991557a4b7e8d3df7725d84f0fcae90dbaee6David Lawrence (!defined($_) || $_ !~ /$keyword_pat/)) {
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington $end = "\n$nonspaceprefix" if ($type eq "MAN");
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington print TARGET "$start\$";
51e0ad287f1b345f0c3316f0633aab14d0e8bb65Brian Wellington print TARGET "Id";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley print TARGET "\$$end\n";
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley }
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer print TARGET $first if $first !~ /^\s*$/;
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer print TARGET $_ if (defined($_));
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews }
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley close(TARGET);
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews close(SOURCE);
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley $mode = (stat $file)[2]&511;
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews chmod $mode, "$file.new";
c9e698df1b2f3731577eaf9598ed3845eac67e1bBrian Wellington
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley if (system("cmp -s $file.new $file") == 0) {
c9e698df1b2f3731577eaf9598ed3845eac67e1bBrian Wellington unlink("$file.new");
9ee5efde7df57cbe70fb9b32c9d898e8ef7eca1eBob Halley } else {
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer rename("$file.new", "$file")
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer or die "rename($file.new, $file): $!";
5d98cf67b32d785aca1a72ea1dc4d559fab39208Mark Andrews }
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer}
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer