update_copyrights revision 144a3203a6e1827d78fb046e92b15ece82e6e378
660a209ee4febf8cd6df7c317b363391e65809f4Automatic Updater#!/usr/local/bin/perl -w
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater# Copyright (C) 1998-2001 Internet Software Consortium.
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence#
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence# Permission to use, copy, modify, and/or distribute this software for any
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# purpose with or without fee is hereby granted, provided that the above
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# 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
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence# PERFORMANCE OF THIS SOFTWARE.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence# $Id: update_copyrights,v 1.50 2007/08/28 02:12:55 marka Exp $
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrencerequire 5.002;
101a7960b7989a18d873f3302b3b2415aeafb108Mark Andrews
ea31416b4fcdf23732355a8002f93f29e3b3d2dbAndreas Gustafsson# Map copyright owners to the files containing copyright messages.
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence# The first line of the copyright message is not in the file;
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews# it is constructed by this script.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# Usage:
be801b0fdbcf9b55b3a8cc6bf042ff6c86be6b11Mark Andrews#
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# perl util/update_copyrights <util/copyrights
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleymy %owner2filename = (
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "" => "util/COPYRIGHT",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "NAI" => "util/COPYRIGHT.NAI",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "NOM" => "util/COPYRIGHT.NOM",
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews "BSDI" => "util/COPYRIGHT.BSDI",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "BRIEF" => "util/COPYRIGHT.BRIEF",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff "PORTION" => "util/COPYRIGHT.PORTION",
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff);
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff
3d776d762914d1b675b4fd49728ce353ccf6f77eBrian Wellington# Map each copyright owner name to a reference to an array containing
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff# the lines of the copyright message.
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrewsmy %owner2text = ();
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrewsmy $keyword_pat = '\$(Id:.*|Revision:.*|Id|Revision)\$';
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrewsforeach $owner (keys %owner2filename) {
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews my $f = $owner2filename{$owner};
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence open(COPYRIGHT, "<$f") || die "can't open $f: $!";
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence @copyright_text = <COPYRIGHT>;
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence close(COPYRIGHT);
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence $owner2text{$owner} = [ @copyright_text ];
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence}
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafssonmy %file_types = ();
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafssonmy %file_years = ();
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafssonmy $years_list;
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafssonmy $parent;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrencewhile (<>) {
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence chomp;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence ($file, $type, $years) = split(/\s+/);
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence $file_types{$file} = $type;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence $file_years{$file} = $years;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence}
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrencesub getyears {
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence $parent = $_[0];
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $parent =~ s/PARENT://;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $years_list = $file_years{$parent};
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley if (defined($years_list) && $years_list =~ /^PARENT:/) {
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff print "BAD PARENT:$parent\n";
ce8c568e0d6106bb87069453505e09bc66754b40Andreas Gustafsson undefine($years_list);
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley }
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley}
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halleysub docbook {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $parent = $_[0];
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $parent =~ s/\.[^.]*$/.docbook/;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $years_list = $file_years{$parent};
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley}
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halleysub copyright {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley my $holder = shift;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley my $result = "";
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley return $result unless (@_);
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $result = "$result <copyright>\n";
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $result = "$result <year>$_</year>\n" foreach (@_);
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson $result = "$result <holder>$holder</holder>\n";
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson $result = "$result </copyright>\n";
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson return $result;
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson}
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafssonsub copyrights {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence my $a = copyright("Internet Systems Consortium, Inc. (\"ISC\")",
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence grep({ $_ >= 2004} @_));
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence my $b = copyright("Internet Software Consortium.",
b587e1d83f007ce68a9ae93097c461d8eb7aa373Mark Andrews 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
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if ( ! -f $file ) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence print "$file: missing\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence next;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # print "Doing: $file";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if ($years_list =~ /PARENT:/) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence getyears($years_list);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if (!defined $years_list) {
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence print "$file: has bad parent $parent\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews next;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews # copyright notice is now generated from the source.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews next if ($years_list eq "DOCBOOK");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if ($years_list eq "DOCBOOK") {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews docbook($file);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (!defined $years_list) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews print "$file: has bad parent $parent\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews next;
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence }
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence @years = split(/,/, $years_list);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence my ($type, $owner) = split(/\./, $typeandowner);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $owner = "" if !defined $owner;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $textp = $owner2text{$owner};
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if (!defined $textp) {
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence print "$file: unknown copyright owner $owner\n";
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence next;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews next if $type eq "X" or $type eq "BAT";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $before_copyright = "";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $c_comment = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $shell_comment = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $m4_comment = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $sgml_comment = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $zone_comment = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $man_comment = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $start_comment = "";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $end_comment = "";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $first = "";
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence if ($type =~ /^(C|YACC|CONF-C)$/) {
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence $c_comment = 1;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $start_comment = "/*\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $prefix = " * ";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $end_comment = " */\n";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence } elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH|RNC)$/) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $shell_comment = 1;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $prefix = "# ";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence } elsif ($type eq "ZONE" || $type eq "MC") {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $zone_comment = 1;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $prefix = "; ";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff } elsif ($type eq "MAN") {
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $man_comment = 1;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $prefix = ".\\\" ";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff } elsif ($type eq "M4") {
1ce985ab3c6670662d555c108b35fed84a6a1001David Lawrence $m4_comment = 1;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $prefix = "dnl ";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } elsif ($type eq "HTML" || $type eq "SGML") {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $sgml_comment = 1;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $start_comment = "<!--\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $prefix = " - ";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $end_comment = "-->\n";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence } elsif ($type eq "TXT") {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $prefix = "";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence } else {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence print "$file: type '$type' not supported yet; skipping\n";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence next;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence }
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence ($nonspaceprefix = $prefix) =~ s/\s+$//;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence open(SOURCE, "<$file") || die "can't open $file: $!";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $_ = <SOURCE>;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence if ($type eq "YACC") {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence unless ($_ eq "%{\n") {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence print "$file: unexpected yacc file start ",
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence "(expected \"%{\\n\")\n";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence close(SOURCE);
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff next;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff }
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $before_copyright = "$_";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $_ = <SOURCE>;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff }
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff if ($c_comment && /^\/\*/) {
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $_ = <SOURCE>;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff if ($_ !~ /[Cc]opyright/) {
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff print "$file: non-copyright comment\n";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff close(SOURCE);
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson next;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews if ($_ !~ /\*\//) {
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews while (<SOURCE>) {
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews last if $_ =~ /\*\//;
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews }
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews }
80badf38c74c326a694e24281ee258aa26984171Mark Andrews } elsif ($shell_comment) {
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews if (/^\#\!/) {
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews $before_copyright = "$_#\n";
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews $_ = <SOURCE>;
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews $_ = <SOURCE> if $_ eq "#\n";
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews }
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews if (/^\#/) {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews if ($_ !~ /[Cc]opyright/) {
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews print "$file: non-copyright comment\n";
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews close(SOURCE);
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews next;
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews while (<SOURCE>) {
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews if ($_ !~ /^\#/) {
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews $first = $_;
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews last;
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews } else {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews $first = $_;
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews } elsif (($m4_comment || $zone_comment || $man_comment) &&
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews /^\Q$nonspaceprefix\E/) {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews while (/^\Q$nonspaceprefix\E\s*$/) {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews $_ = <SOURCE>;
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews if ($_ !~ /[Cc]opyright/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson print "$file: non-copyright comment\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson close(SOURCE);
39b973d8873996c3bfb6e5b4cc69731f6c3b77b5Mark Andrews next;
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews }
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews while (<SOURCE>) {
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews if ($_ !~ /^\Q$nonspaceprefix\E/ ||
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews $_ =~ /$keyword_pat/) {
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews $first = $_;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson last;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
8486ce1efa5deded85415d21d5696e5a51c63357Mark Andrews } elsif ($sgml_comment) {
c654449ccf403ccd2b81be2038b1013d6fbb06ccMark Andrews $before_copyright = "";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson while (/^<!DOCTYPE/ || /^<\?xml-stylesheet/ || /^<\?xml /) {
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson # print "SGML: $_";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $before_copyright = "$before_copyright$_";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson if (/>$/ ) {
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson $_ = <SOURCE>;
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson close(SOURCE) if (eof(SOURCE));
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington next;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington }
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $_ = <SOURCE>;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington while (!eof(SOURCE) && ! /^<!/ ) {
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $before_copyright = "$before_copyright$_";
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington $_ = <SOURCE>;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington }
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington if (eof(SOURCE)) {
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington close(SOURCE);
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington next;
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington }
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson }
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson if (/^<!/) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $_ = <SOURCE> if $_ eq "<!--\n";
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson if ($_ !~ /[Cc]opyright/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson print "$file: non-copyright comment\n";
8f3dd8f8e73e4465221a5297819db70e6b383138Mark Andrews close(SOURCE);
6e9efadbea9febb0494e713e54dfea6f7ef70383Mark Andrews next;
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews }
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews while (defined($_)) {
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews last if s/.*-->//;
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews $_ = <SOURCE>;
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews }
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews print "$file: unterminated comment\n"
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews unless defined($_);
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews if ($_ ne "\n") {
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews $first = $_;
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews } else {
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews $first = <SOURCE>;
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews }
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews } else {
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews $first = $_;
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews }
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews } elsif ($type eq "TXT") {
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews if ($_ =~ /[Cc]opyright/) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $/ = ""; # paragraph at a time
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews while (<SOURCE>) {
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews # Not very maintainable, but ok enough for now.
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews last unless
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews /[Cc]opyright/ ||
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews /See COPYRIGHT in the source root/ ||
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews /Permission to use, copy, modify, and / ||
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews /THE SOFTWARE IS PROVIDED "AS IS" AND /;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $/ = "\n";
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews }
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $first = $_;
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews } else {
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $first = $_;
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews }
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $first = "" if ! defined($first);
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews open(TARGET, ">$file.new") || die "can't open $file.new: $!";
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews print TARGET $before_copyright if $before_copyright;
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews print TARGET $start_comment if $start_comment;
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $sysyears = "";
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $sftyears = "";
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $nomyears = "";
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews #
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews # Internet Software Consortium: up to 2003
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews #
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $last_year = 0;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $anchor_year = 0;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $years = "";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 foreach $year (@years) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if ($year >= 2004) { next; }
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if ($last_year != 0 && $year == $last_year + 1) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if ($year > $anchor_year + 1) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 substr($years, $anchor_end) = "-$year";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 } else {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $years .= ", $year";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 }
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 } else {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $years .= $last_year == 0 ? "$year" : ", $year";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 #if ($anchor_year != 0) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 # print "$file: noncontiguous year: ",
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 # "$year != $last_year + 1\n";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 #}
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $anchor_year = $year;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $anchor_end = length($years);
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 }
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $last_year = $year;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 }
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $sftyears = $years;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 #
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 # Nominum: up to 2001.
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 #
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $last_year = 0;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $anchor_year = 0;
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 $years = "";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 foreach $year (@years) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if ($year >= 2002) { next; }
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if ($last_year != 0 && $year == $last_year + 1) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 if ($year > $anchor_year + 1) {
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 substr($years, $anchor_end) = "-$year";
386d3a99c190bad55edf44d076e6bd087e230ab8Tatuya JINMEI 神明達哉 } else {
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews $years .= ", $year";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } else {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $years .= $last_year == 0 ? "$year" : ", $year";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson #if ($anchor_year != 0) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson # print "$file: noncontiguous year: ",
963c48ba4d06a112c70d50328e827749e95f58dbMark Andrews # "$year != $last_year + 1\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson #}
963c48ba4d06a112c70d50328e827749e95f58dbMark Andrews $anchor_year = $year;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $anchor_end = length($years);
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $last_year = $year;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $nomyears = $years;
a1898260ad19d02e88ab76c1855d33c67add9defMark Andrews
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson #
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews # Internet Systems Consortium: 2004 onwards.
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson #
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $last_year = 0;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $anchor_year = 0;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $years = "";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $anchor_end = length($years);
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson my $andor = 0;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson foreach $year (@years) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($year < 2004) { next; }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $andor = 1 if ($year >= 2007);
a1898260ad19d02e88ab76c1855d33c67add9defMark Andrews if ($last_year != 0 && $year == $last_year + 1) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson if ($year > $anchor_year + 1) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews substr($years, $anchor_end) = "-$year";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } else {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $years .= ", $year";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson } else {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $years .= $last_year == 0 ? "$year" : ", $year";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson #if ($anchor_year != 0) {
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson # print "$file: noncontiguous year: ",
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson # "$year != $last_year + 1\n";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson #}
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $anchor_year = $year;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson $anchor_end = length($years);
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff }
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff $last_year = $year;
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff }
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff $sysyears = $years;
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff ($firstline, $secondline, @otherlines) = @$textp;
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff $firstline =~ s/\@SYSYEARS\@/$sysyears/;
3ca0e71a863fe3fbb4f439e5d0bebfd7bd38fb16Mark Andrews $secondline =~ s/\@SFTYEARS\@/$sftyears/;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff print TARGET "$prefix$firstline";
61d5bfc06be978ea962b1c64309894ac80351771Mark Andrews if ($sftyears ne "" ) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews print TARGET $secondline =~ /^$/ ? $nonspaceprefix : $prefix;
3d8dfd44a3be708f00380064411c16b2fa28303aMark Andrews print TARGET "$secondline";
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff }
4cf228853d658a742a826393f341e2486c629f7bMark Andrews
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews foreach $_ (@otherlines) {
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews s:modify, and distribute:modify, and/or distribute: if ($andor);
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews print TARGET (/^$/ ? $nonspaceprefix : $prefix);
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews s/\@NOMYEARS\@/$nomyears/;
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews print TARGET "$_";
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews }
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews print TARGET $end_comment if $end_comment;
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews if ($first eq "") {
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews $first = <SOURCE>;
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews }
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington if (defined($first)) {
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington if ($type eq 'MAN') {
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington print TARGET "$nonspaceprefix\n";
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington } else {
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington print TARGET "\n";
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews }
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews undef $/;
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews $_ = <SOURCE>;
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews $/ = "\n";
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews if ($type eq 'SGML' && m:<articleinfo>.*?</articleinfo>:s) {
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson # print "docinfo: $file\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews my $r = copyrights(@years);
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson s:<articleinfo>.*?</articleinfo>:<articleinfo>\n$r </articleinfo>:s;
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson }
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson if ($type eq 'SGML' && m:<docinfo>.*?</docinfo>:s) {
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson # print "docinfo: $file\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews my $r = copyrights(@years);
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson s:<docinfo>.*?</docinfo>:<docinfo>\n$r </docinfo>:s;
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson }
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson if ($type eq 'SGML' && m:<bookinfo>.*?</bookinfo>:s) {
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson # print "bookinfo: $file\n";
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson my $r = copyrights(@years);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews s:<bookinfo>.*?</bookinfo>:<bookinfo>\n$r </bookinfo>:s;
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson }
80f323528ac699026a609a5e3b765dc6e88fe37cAndreas Gustafsson
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson my ($start, $end);
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson if ($start_comment ne "") {
3fcf6b956f47405750724bd84e1b2290b61c9186Brian Wellington ($start = $start_comment) =~ s/\s*\n/ /;
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews ($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/;
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews } elsif ($prefix ne "") {
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews ($start = $prefix) =~ s/\s*\n//;
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews $end = "\n";
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews } else {
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews $start = "";
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews $end = "\n";
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews }
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews if ($first !~ /$keyword_pat/ && $_ !~ /$keyword_pat/) {
f8f65e2de40b1e9874b88f392f3abeb057ce6172Mark Andrews $end = "\n$nonspaceprefix" if ($type eq "MAN");
f8f65e2de40b1e9874b88f392f3abeb057ce6172Mark Andrews print TARGET "$start\$";
f8f65e2de40b1e9874b88f392f3abeb057ce6172Mark Andrews print TARGET "Id";
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews print TARGET "\$$end\n";
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews }
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews print TARGET $first if $first !~ /^\s*$/;
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews print TARGET $_;
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews }
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews close(TARGET);
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews close(SOURCE);
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews $mode = (stat $file)[2]&511;
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews chmod $mode, "$file.new";
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews if (system("cmp -s $file.new $file") == 0) {
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews unlink("$file.new");
c16aed9c469a986f1b84e457db4a8c4d2da01ca3Mark Andrews } else {
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews rename("$file.new", "$file")
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews or die "rename($file.new, $file): $!";
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews }
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews}
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews