update_copyrights revision db88737897a943c6005724f21064ab4cc34a245b
63b0524b961b6dce1aa18488d7175ca4ee17778fTinderbox User#!/usr/local/bin/perl -w
7bd455641455950eff7d21be652c8142b134d32fTinderbox User#
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# Copyright (C) 1998-2001 Internet Software Consortium.
7bd455641455950eff7d21be652c8142b134d32fTinderbox User#
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# Permission to use, copy, modify, and distribute this software for any
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# purpose with or without fee is hereby granted, provided that the above
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# copyright notice and this permission notice appear in all copies.
7bd455641455950eff7d21be652c8142b134d32fTinderbox User#
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
7bd455641455950eff7d21be652c8142b134d32fTinderbox User# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
8cbf3b6fc35091abde426930f2eadb8f53476c98Evan Hunt# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# PERFORMANCE OF THIS SOFTWARE.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# $Id: update_copyrights,v 1.43 2006/10/26 01:42:27 marka Exp $
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrewsrequire 5.002;
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# Map copyright owners to the files containing copyright messages.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# The first line of the copyright message is not in the file;
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews# it is constructed by this script.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrewsmy %owner2filename = (
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews "" => "util/COPYRIGHT",
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews "NAI" => "util/COPYRIGHT.NAI",
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence "NOM" => "util/COPYRIGHT.NOM",
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence "BSDI" => "util/COPYRIGHT.BSDI",
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews "BRIEF" => "util/COPYRIGHT.BRIEF",
bff64bf12b58a6f80e740e94f2e42a32df18113aEvan Hunt "PORTION" => "util/COPYRIGHT.PORTION",
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence);
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence
92b796c963e7ba0217debfa27a0709f94934f5d5Mark Andrews# Map each copyright owner name to a reference to an array containing
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews# the lines of the copyright message.
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleymy %owner2text = ();
63dd46733010bb9622810faa17d88c3e3c28b730Mark Andrews
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleymy $keyword_pat = '\$(Id:.*|Revision:.*|Id|Revision)\$';
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyforeach $owner (keys %owner2filename) {
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff my $f = $owner2filename{$owner};
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews open(COPYRIGHT, "<$f") || die "can't open $f: $!";
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews @copyright_text = <COPYRIGHT>;
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews close(COPYRIGHT);
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews $owner2text{$owner} = [ @copyright_text ];
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews}
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrewsmy %file_types = ();
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrewsmy %file_years = ();
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrewsmy $years_list;
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrewsmy $parent;
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrewswhile (<>) {
f4ea363e3acc321b24ffe95a64a583e8041d6fd5Mark Andrews chomp;
914eeb33149a0008e26741d9e7d89dcd6f8b6d0bMark Andrews ($file, $type, $years) = split(/\s+/);
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff $file_types{$file} = $type;
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews $file_years{$file} = $years;
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff}
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graffsub getyears {
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff $parent = $_[0];
3d776d762914d1b675b4fd49728ce353ccf6f77eBrian Wellington $parent =~ s/PARENT://;
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt $years_list = $file_years{$parent};
6b66ee9147e940572a0e873ecbd67456ccb85c39Mark Andrews if (defined($years_list) && $years_list =~ /^PARENT:/) {
ccdac53c027e8964753b36c4d8c7b0e98af501c2Michael Graff print "BAD PARENT:$parent\n";
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews undefine($years_list);
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews }
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews}
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrewssub docbook {
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews $parent = $_[0];
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews $parent =~ s/\.[^.]*$/.docbook/;
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews $years_list = $file_years{$parent};
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews}
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrewssub copyright {
11dbf2fc38eea8c5d3fe7123718bf197a8bb2e6bMark Andrews my $holder = shift;
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt my $result = "";
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt return $result unless (@_);
1c1290afabb3c8f4dd498170ac9592e5be450161Mark Andrews $result = "$result <copyright>\n";
1c1290afabb3c8f4dd498170ac9592e5be450161Mark Andrews $result = "$result <year>$_</year>\n" foreach (@_);
b123b265e3a3d9b72a14230b6517e0f6fdb5c5b5Mark Andrews $result = "$result <holder>$holder</holder>\n";
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews $result = "$result </copyright>\n";
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews return $result;
740e7340c55e9f0cf80c6fbbf7e8d3c1bdeaa255Mark Andrews}
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews
84f95ddb2572641022619950a211aff49e331c98Mukund Sivaramansub copyrights {
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews my $a = copyright("Internet Systems Consortium, Inc. (\"ISC\")",
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews grep({ $_ >= 2004} @_));
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews my $b = copyright("Internet Software Consortium.",
71697fd082b1c76562dc80fa91787af3860146bfEvan Hunt grep({ $_ < 2004} @_));
1c1290afabb3c8f4dd498170ac9592e5be450161Mark Andrews return "$a$b";
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt}
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrews
32ebb157b1d9409a186c86002827f8a1f4931f5aMark Andrewsforeach $file (keys %file_types) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $typeandowner = $file_types{$file};
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $years_list = $file_years{$file};
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
1831311ac6179951c8fcca75aa29dc2f5c0218b9Francis Dupont if ( ! -f $file ) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt print "$file: missing\n";
206e697f24e47b8868bd68a5b6ef42f5f62e39d5Evan Hunt next;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt }
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt if ($years_list =~ /PARENT:/) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt getyears($years_list);
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt if (!defined $years_list) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt print "$file: has bad parent $parent\n";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt next;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt }
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt }
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt # copyright notice is now generated from the source.
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt next if ($years_list eq "DOCBOOK");
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt if ($years_list eq "DOCBOOK") {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt docbook($file);
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt if (!defined $years_list) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt print "$file: has bad parent $parent\n";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt next;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt }
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt }
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt @years = split(/,/, $years_list);
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt my ($type, $owner) = split(/\./, $typeandowner);
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $owner = "" if !defined $owner;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $textp = $owner2text{$owner};
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt if (!defined $textp) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt print "$file: unknown copyright owner $owner\n";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt next;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt }
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt next if $type eq "X" or $type eq "BAT";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $before_copyright = "";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $c_comment = 0;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $shell_comment = 0;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $m4_comment = 0;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $sgml_comment = 0;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $zone_comment = 0;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $man_comment = 0;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $start_comment = "";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $end_comment = "";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $first = "";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt if ($type =~ /^(C|YACC|CONF-C)$/) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $c_comment = 1;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $start_comment = "/*\n";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $prefix = " * ";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $end_comment = " */\n";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt } elsif ($type =~ /^(SH|PERL|TCL|MAKE|CONF-SH)$/) {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $shell_comment = 1;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $prefix = "# ";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt } elsif ($type eq "ZONE" || $type eq "MC") {
206e697f24e47b8868bd68a5b6ef42f5f62e39d5Evan Hunt $zone_comment = 1;
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $prefix = "; ";
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt } elsif ($type eq "MAN") {
6fa84a3e255ef9e6233f0a8d134fc6d273f04599Evan Hunt $man_comment = 1;
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews $prefix = ".\\\" ";
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews } elsif ($type eq "M4") {
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews $m4_comment = 1;
323a9f3430abf186f8f84d795549391a8ed7f274Francis Dupont $prefix = "dnl ";
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews } elsif ($type eq "HTML" || $type eq "SGML") {
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews $sgml_comment = 1;
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews $start_comment = "<!--\n";
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence $prefix = " - ";
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence $end_comment = "-->\n";
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence } elsif ($type eq "TXT") {
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence $prefix = "";
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrence } else {
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson print "$file: type '$type' not supported yet; skipping\n";
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson next;
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson }
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson ($nonspaceprefix = $prefix) =~ s/\s+$//;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence open(SOURCE, "<$file") || die "can't open $file: $!";
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence $_ = <SOURCE>;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence if ($type eq "YACC") {
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence unless ($_ eq "%{\n") {
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence print "$file: unexpected yacc file start ",
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence "(expected \"%{\\n\")\n";
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence close(SOURCE);
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence next;
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence }
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $before_copyright = "$_";
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $_ = <SOURCE>;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley }
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff if ($c_comment && /^\/\*/) {
ce8c568e0d6106bb87069453505e09bc66754b40Andreas Gustafsson $_ = <SOURCE>;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley if ($_ !~ /[Cc]opyright/) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley print "$file: non-copyright comment\n";
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley close(SOURCE);
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley next;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley }
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley if ($_ !~ /\*\//) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley while (<SOURCE>) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley last if $_ =~ /\*\//;
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley }
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley }
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley } elsif ($shell_comment) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley if (/^\#\!/) {
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley $before_copyright = "$_#\n";
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $_ = <SOURCE>;
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff $_ = <SOURCE> if $_ eq "#\n";
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson }
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson if (/^\#/) {
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 if ($_ !~ /[Cc]opyright/) {
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 print "$file: non-copyright comment\n";
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson close(SOURCE);
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson next;
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson }
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson while (<SOURCE>) {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews if ($_ !~ /^\#/) {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews $first = $_;
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews last;
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews }
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews }
b5f6271f4daf1e54501af2cb7dd278d7e8003d65Mark Andrews } else {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews $first = $_;
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt } elsif (($m4_comment || $zone_comment || $man_comment) &&
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt /^\Q$nonspaceprefix\E/) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews while (/^\Q$nonspaceprefix\E\s*$/) {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews $_ = <SOURCE>;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews if ($_ !~ /[Cc]opyright/) {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews print "$file: non-copyright comment\n";
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews close(SOURCE);
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews next;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt while (<SOURCE>) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt if ($_ !~ /^\Q$nonspaceprefix\E/ ||
1f27b7873c640771df00a47ee3be188c4079479cFrancis Dupont $_ =~ /$keyword_pat/) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $first = $_;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt last;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt } elsif ($sgml_comment) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt if (/^<!DOCTYPE/) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $before_copyright = $_;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $_ = <SOURCE>;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt ;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt while (!eof(SOURCE) && ! /^<!/ ) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $before_copyright = "$before_copyright$_";
1f27b7873c640771df00a47ee3be188c4079479cFrancis Dupont $_ = <SOURCE>;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt if (eof(SOURCE)) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt close(SOURCE);
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt next;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt if (/^<!/) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $_ = <SOURCE> if $_ eq "<!--\n";
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt if ($_ !~ /[Cc]opyright/) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt print "$file: non-copyright comment\n";
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt close(SOURCE);
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews next;
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews }
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews while (defined($_)) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt last if s/.*-->//;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $_ = <SOURCE>;
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt print "$file: unterminated comment\n"
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt unless defined($_);
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews if ($_ ne "\n") {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews $first = $_;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt } else {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $first = <SOURCE>;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt } else {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $first = $_;
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt }
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt } elsif ($type eq "TXT") {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt if ($_ =~ /[Cc]opyright/) {
523f3d630243211ddfda852f5224f7eff681d3a5Evan Hunt $/ = ""; # paragraph at a time
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews while (<SOURCE>) {
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews # Not very maintainable, but ok enough for now.
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews last unless
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews /[Cc]opyright/ ||
66dddd906ada6035d65bbbad2ecbcd74037759a8Mark Andrews /See COPYRIGHT in the source root/ ||
831f59eb43b56642b00f82e07722836d2f9593abEvan Hunt /Permission to use, copy, modify, and / ||
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews /THE SOFTWARE IS PROVIDED "AS IS" AND /;
d7729155dff87d3c7a2b9103bf6e5164ea4d7dd7Mark Andrews }
66dddd906ada6035d65bbbad2ecbcd74037759a8Mark Andrews $/ = "\n";
831f59eb43b56642b00f82e07722836d2f9593abEvan Hunt }
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews $first = $_;
66dddd906ada6035d65bbbad2ecbcd74037759a8Mark Andrews } else {
831f59eb43b56642b00f82e07722836d2f9593abEvan Hunt $first = $_;
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews }
1cefb9df3fa34d08734f29005cfafa6be5cf3e93Mark Andrews
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $first = "" if ! defined($first);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence open(TARGET, ">$file.new") || die "can't open $file.new: $!";
b587e1d83f007ce68a9ae93097c461d8eb7aa373Mark Andrews print TARGET $before_copyright if $before_copyright;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence print TARGET $start_comment if $start_comment;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $sysyears = "";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $sftyears = "";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $nomyears = "";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence #
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # Internet Software Consortium: up to 2003
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence #
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $last_year = 0;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $anchor_year = 0;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $years = "";
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence foreach $year (@years) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if ($year >= 2004) { next; }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if ($last_year != 0 && $year == $last_year + 1) {
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence if ($year > $anchor_year + 1) {
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence substr($years, $anchor_end) = "-$year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $years .= ", $year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $years .= $last_year == 0 ? "$year" : ", $year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews #if ($anchor_year != 0) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews # print "$file: noncontiguous year: ",
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews # "$year != $last_year + 1\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews #}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $anchor_year = $year;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $anchor_end = length($years);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence $last_year = $year;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $sftyears = $years;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence #
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # Nominum: up to 2001.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence #
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $last_year = 0;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $anchor_year = 0;
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence $years = "";
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence foreach $year (@years) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if ($year >= 2002) { next; }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if ($last_year != 0 && $year == $last_year + 1) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if ($year > $anchor_year + 1) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews substr($years, $anchor_end) = "-$year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $years .= ", $year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $years .= $last_year == 0 ? "$year" : ", $year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews #if ($anchor_year != 0) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews # print "$file: noncontiguous year: ",
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews # "$year != $last_year + 1\n";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews #}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $anchor_year = $year;
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence $anchor_end = length($years);
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $last_year = $year;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence }
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence $nomyears = $years;
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence #
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence # Internet Systems Consortium: 2004 onwards.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence #
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $last_year = 0;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $anchor_year = 0;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $years = "";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $anchor_end = length($years);
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff foreach $year (@years) {
1ce985ab3c6670662d555c108b35fed84a6a1001David Lawrence if ($year < 2004) { next; }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if ($last_year != 0 && $year == $last_year + 1) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if ($year > $anchor_year + 1) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews substr($years, $anchor_end) = "-$year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews $years .= ", $year";
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence } else {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $years .= $last_year == 0 ? "$year" : ", $year";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence #if ($anchor_year != 0) {
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence # print "$file: noncontiguous year: ",
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence # "$year != $last_year + 1\n";
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence #}
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $anchor_year = $year;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $anchor_end = length($years);
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence }
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $last_year = $year;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence }
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence $sysyears = $years;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence ($firstline, $secondline, $thirdline, @otherlines) = @$textp;
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $firstline =~ s/\@SYSYEARS\@/$sysyears/;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $secondline =~ s/\@SFTYEARS\@/$sftyears/;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff $thirdline =~ s/\@NOMYEARS\@/$nomyears/;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff print TARGET "$prefix$firstline";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff if ($sftyears ne "" ) {
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff print TARGET $secondline =~ /^$/ ? $nonspaceprefix : $prefix;
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff print TARGET "$secondline";
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff }
657ce0b9d84fbd66514df53d61a087e8f1161187Michael Graff print TARGET $thirdline =~ /^$/ ? $nonspaceprefix : $prefix;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson print TARGET "$thirdline";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews foreach $_ (@otherlines) {
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews print TARGET (/^$/ ? $nonspaceprefix : $prefix);
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews print TARGET "$_";
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews }
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews print TARGET $end_comment if $end_comment;
80badf38c74c326a694e24281ee258aa26984171Mark Andrews
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews if ($first eq "") {
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews $first = <SOURCE>;
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews }
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews if (defined($first)) {
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews if ($type eq 'MAN') {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews print TARGET "$nonspaceprefix\n";
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews } else {
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews print TARGET "\n";
323a9f3430abf186f8f84d795549391a8ed7f274Francis Dupont }
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews undef $/;
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews $_ = <SOURCE>;
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews $/ = "\n";
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews if ($type eq 'SGML' && m:<articleinfo>.*?</articleinfo>:s) {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews # print "docinfo: $file\n";
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews my $r = copyrights(@years);
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews s:<articleinfo>.*?</articleinfo>:<articleinfo>\n$r </articleinfo>:s;
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews if ($type eq 'SGML' && m:<docinfo>.*?</docinfo>:s) {
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews # print "docinfo: $file\n";
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews my $r = copyrights(@years);
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews s:<docinfo>.*?</docinfo>:<docinfo>\n$r </docinfo>:s;
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews }
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews if ($type eq 'SGML' && m:<bookinfo>.*?</bookinfo>:s) {
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews # print "bookinfo: $file\n";
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews my $r = copyrights(@years);
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews s:<bookinfo>.*?</bookinfo>:<bookinfo>\n$r </bookinfo>:s;
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews }
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews
89119e3cafff373426858f6cec7c09539f53e209Mark Andrews my ($start, $end);
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews if ($start_comment ne "") {
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews ($start = $start_comment) =~ s/\s*\n/ /;
d7896edb4e93c4785a9281ea86afba86b758e813Mark Andrews ($end = $end_comment) =~ s/^\s*(.*)\n/ $1\n/;
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff } elsif ($prefix ne "") {
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff ($start = $prefix) =~ s/\s*\n//;
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff $end = "\n";
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff } else {
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff $start = "";
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff $end = "\n";
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff }
ab3aeba682460fd39deb7901aa69f976583c9f47Michael Graff
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews if ($first !~ /$keyword_pat/ && $_ !~ /$keyword_pat/) {
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews $end = "\n$nonspaceprefix" if ($type eq "MAN");
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt print TARGET "$start\$";
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt print TARGET "Id";
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt print TARGET "\$$end\n";
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt }
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt print TARGET $first if $first !~ /^\s*$/;
5b7abbef511cea0b568be0bc8d5b3120a0b9034dEvan Hunt print TARGET $_;
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson close(TARGET);
850b5e80930907e4747347201dc41e4d04e036f8Mark Andrews close(SOURCE);
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews $mode = (stat $file)[2]&511;
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews chmod $mode, "$file.new";
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews
62ec9fd1681ffae7d6b0d54618599ecf650e3100Mark Andrews if (system("cmp -s $file.new $file") == 0) {
62ec9fd1681ffae7d6b0d54618599ecf650e3100Mark Andrews unlink("$file.new");
62ec9fd1681ffae7d6b0d54618599ecf650e3100Mark Andrews } else {
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews rename("$file.new", "$file")
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson or die "rename($file.new, $file): $!";
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson }
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson}
8486ce1efa5deded85415d21d5696e5a51c63357Mark Andrews