update_copyrights revision 0295f63b67bb09cd4d00dd1d9c2238c37beefed8
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#!/usr/local/bin/perl -w
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Copyright (C) 1998-2001 Internet Software Consortium.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Permission to use, copy, modify, and distribute this software for any
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# purpose with or without fee is hereby granted, provided that the above
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# copyright notice and this permission notice appear in all copies.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# $Id: update_copyrights,v 1.27 2004/03/04 03:21:19 marka Exp $
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntrequire 5.002;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Map copyright owners to the files containing copyright messages.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# The first line of the copyright message is not in the file;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# it is constructed by this script.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntmy %owner2filename = (
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "" => "util/COPYRIGHT",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "NAI" => "util/COPYRIGHT.NAI",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "NOM" => "util/COPYRIGHT.NOM",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "BSDI" => "util/COPYRIGHT.BSDI",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "BRIEF" => "util/COPYRIGHT.BRIEF",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "PORTION" => "util/COPYRIGHT.PORTION",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Map each copyright owner name to a reference to an array containing
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# the lines of the copyright message.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntmy %owner2text = ();
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntmy $keyword_pat = '\$(Id|Revision):.*\$';
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntforeach $owner (keys %owner2filename) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt my $f = $owner2filename{$owner};
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt open(COPYRIGHT, "<$f") || die "can't open $f: $!";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt @copyright_text = <COPYRIGHT>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(COPYRIGHT);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $owner2text{$owner} = [ @copyright_text ];
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt}
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntwhile (<>) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($file, $typeandowner, $years_list) = split(/\s+/);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt @years = split(/,/, $years_list);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ( ! -f $file ) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: missing\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt my ($type, $owner) = split(/\./, $typeandowner);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $owner = "" if !defined $owner;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $textp = $owner2text{$owner};
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (!defined $textp) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: unknown copyright owner $owner\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next if $type eq "X" or $type eq "BAT";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $before_copyright = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $c_comment = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $shell_comment = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $m4_comment = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $sgml_comment = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $zone_comment = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $man_comment = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $start_comment = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $end_comment = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($type =~ /^(C|YACC|CONF-C)$/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $c_comment = 1;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $start_comment = "/*\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = " * ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $end_comment = " */\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH)$/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $shell_comment = 1;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = "# ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type eq "ZONE") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $zone_comment = 1;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = "; ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type eq "MAN") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $man_comment = 1;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = ".\\\" ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type eq "M4") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $m4_comment = 1;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = "dnl ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type eq "HTML" || $type eq "SGML") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $sgml_comment = 1;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $start_comment = "<!--\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = " - ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $end_comment = "-->\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type eq "TXT") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $prefix = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: type '$type' not supported yet; skipping\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($nonspaceprefix = $prefix) =~ s/\s+$//;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt open(SOURCE, "<$file") || die "can't open $file: $!";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($type eq "YACC") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unless ($_ eq "%{\n") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: unexpected yacc file start ",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "(expected \"%{\\n\")\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(SOURCE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $before_copyright = "$_";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($c_comment && /^\/\*/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /[Cc]opyright/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: non-copyright comment\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(SOURCE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /\*\//) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (<SOURCE>) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt last if $_ =~ /\*\//;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($shell_comment) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (/^\#\!/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $before_copyright = "$_#\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE> if $_ eq "#\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (/^\#/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /[Cc]opyright/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: non-copyright comment\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(SOURCE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (<SOURCE>) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /^\#/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt last;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif (($m4_comment || $zone_comment || $man_comment) &&
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /^\Q$nonspaceprefix\E/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (/^\Q$nonspaceprefix\E\s*$/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /[Cc]opyright/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: non-copyright comment\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(SOURCE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (<SOURCE>) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /^\Q$nonspaceprefix\E/ ||
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ =~ /$keyword_pat/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt last;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($sgml_comment) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (/^<!DOCTYPE/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $before_copyright = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (/^<!/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE> if $_ eq "<!--\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ !~ /[Cc]opyright/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: non-copyright comment\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(SOURCE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt next;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (defined($_)) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt last if s/.*-->//;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: unterminated comment\n"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unless defined($_);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ ne "\n") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($type eq "TXT") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($_ =~ /[Cc]opyright/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $/ = ""; # paragraph at a time
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt while (<SOURCE>) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Not very maintainable, but ok enough for now.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt last unless
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /See COPYRIGHT in the source root/ ||
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /Permission to use, copy, modify, and / ||
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /THE SOFTWARE IS PROVIDED "AS IS" AND /;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $/ = "\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = "" if ! defined($first);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt open(TARGET, ">$file.new") || die "can't open $file.new: $!";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $before_copyright if $before_copyright;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $start_comment if $start_comment;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $sysyears = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $sftyears = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $nomyears = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Internet Software Consortium: up to 2003
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $last_year = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_year = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt foreach $year (@years) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($year >= 2004) { next; }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($last_year != 0 && $year == $last_year + 1) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($year > $anchor_year + 1) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt substr($years, $anchor_end) = "-$year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years .= ", $year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years .= $last_year == 0 ? "$year" : ", $year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($anchor_year != 0) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: noncontiguous year: ",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$year != $last_year + 1\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_year = $year;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_end = length($years);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $last_year = $year;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $sftyears = $years;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Nominum: up to 2001.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $last_year = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_year = 0;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt foreach $year (@years) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($year >= 2002) { next; }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($last_year != 0 && $year == $last_year + 1) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($year > $anchor_year + 1) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt substr($years, $anchor_end) = "-$year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years .= ", $year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years .= $last_year == 0 ? "$year" : ", $year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($anchor_year != 0) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: noncontiguous year: ",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$year != $last_year + 1\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_year = $year;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_end = length($years);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $last_year = $year;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $nomyears = $years;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Internet Systems Consortium: 2004 onwards.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $last_year = 2004;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_year = 2004;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years = "2004";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_end = length($years);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt foreach $year (@years) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($year < 2005) { next; }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($last_year != 0 && $year == $last_year + 1) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($year > $anchor_year + 1) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt substr($years, $anchor_end) = "-$year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years .= ", $year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $years .= $last_year == 0 ? "$year" : ", $year";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($anchor_year != 0) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print "$file: noncontiguous year: ",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$year != $last_year + 1\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_year = $year;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $anchor_end = length($years);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $last_year = $year;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $sysyears = $years;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($firstline, $secondline, $thirdline, @otherlines) = @$textp;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $firstline =~ s/\@SYSYEARS\@/$sysyears/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $secondline =~ s/\@SFTYEARS\@/$sftyears/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $thirdline =~ s/\@NOMYEARS\@/$nomyears/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "$prefix$firstline";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($sftyears ne "" ) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $secondline =~ /^$/ ? $nonspaceprefix : $prefix;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "$secondline";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $thirdline =~ /^$/ ? $nonspaceprefix : $prefix;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "$thirdline";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt foreach $_ (@otherlines) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET (/^$/ ? $nonspaceprefix : $prefix);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "$_";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $end_comment if $end_comment;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($first eq "") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $first = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (defined($first)) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($type eq 'MAN') {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "$nonspaceprefix\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt undef $/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $_ = <SOURCE>;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $/ = "\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt my ($start, $end);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($start_comment ne "") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($start = $start_comment) =~ s/\s*\n/ /;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } elsif ($prefix ne "") {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ($start = $prefix) =~ s/\s*\n//;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $end = "\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $start = "";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $end = "\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if ($first !~ /$keyword_pat/ && $_ !~ /$keyword_pat/) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "$start\$";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "Id: ";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET "\$$end\n";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $first if $first !~ /^\s*$/;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt print TARGET $_;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(TARGET);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt close(SOURCE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt $mode = (stat $file)[2]&511;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt chmod $mode, "$file.new";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (system("cmp -s $file.new $file") == 0) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unlink("$file.new");
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt } else {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt rename("$file.new", "$file")
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt or die "rename($file.new, $file): $!";
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt }
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt}
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt