support more file types

This commit is contained in:
Bob Halley
1999-03-06 03:24:48 +00:00
parent 036f4a76ec
commit 178f6ad061
2 changed files with 60 additions and 9 deletions

View File

@@ -1,4 +1,19 @@
#!/usr/local/bin/perl -w
#
# Copyright (C) 1998, 1999 Internet Software Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
%file_types = ();
%file_years = ();

View File

@@ -1,7 +1,5 @@
#!/usr/local/bin/perl -w
die "This program is being updated; talk to Bob.";
if (@ARGV == 0) {
die "usage: update_copyrights <copyright_text>";
}
@@ -22,15 +20,23 @@ while (<>) {
next;
}
$before_copyright = "";
$c_comment = 0;
$shell_comment = 0;
$first = "";
if ($type eq "C") {
$c_comment = 1;
$prefix = " * ";
} elsif ($type eq "SH" || $type eq "PERL" || $type eq "MAKE") {
$shell_comment = 1;
$prefix = "# ";
} else {
print "$file: type '$type' not supported yet; skipping\n";
next;
}
open(SOURCE, "<$file") || die "can't open $file: $!";
$_ = <SOURCE>;
if (/^\/\*/) {
if ($c_comment && /^\/\*/) {
$_ = <SOURCE>;
if ($_ !~ /[Cc]opyright/) {
print "$file: non-copyright comment\n";
@@ -44,14 +50,38 @@ while (<>) {
}
}
}
$first = "";
} elsif ($shell_comment) {
if (/^\#\!/) {
$before_copyright = "$_#\n";
$_ = <SOURCE>;
if ($_ eq "#\n") {
$_ = <SOURCE>;
}
}
if (/^\#/) {
if ($_ !~ /[Cc]opyright/) {
print "$file: non-copyright comment\n";
close(SOURCE);
next;
}
while (<SOURCE>) {
if ($_ !~ /^\#/) {
$first = $_;
last;
}
}
} else {
$first = $_;
}
} else {
$first = $_;
}
open(TARGET, ">$file.new") || die "can't open $file.new: $!";
if ($before_copyright ne "") {
print TARGET $before_copyright;
}
if ($c_comment) {
print TARGET "/*\n";
$prefix = " * ";
}
print TARGET "${prefix}Copyright (C) ";
$first_year = 1;
@@ -70,11 +100,17 @@ while (<>) {
if ($c_comment) {
print TARGET " */\n";
}
if ($first ne "") {
print TARGET $first;
if ($first eq "") {
$first = <SOURCE>;
}
while (<SOURCE>) {
print TARGET $_;
if ($first ne "") {
if ($first !~ /^\s*$/) {
print TARGET "\n";
}
print TARGET $first;
while (<SOURCE>) {
print TARGET $_;
}
}
close(TARGET);
close(SOURCE);