diff --git a/util/merge_copyrights b/util/merge_copyrights index 4e02901e01..aa30befd7d 100644 --- a/util/merge_copyrights +++ b/util/merge_copyrights @@ -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 = (); diff --git a/util/update_copyrights b/util/update_copyrights index 7aab80b52a..1b94b45906 100644 --- a/util/update_copyrights +++ b/util/update_copyrights @@ -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 "; } @@ -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: $!"; $_ = ; - if (/^\/\*/) { + if ($c_comment && /^\/\*/) { $_ = ; if ($_ !~ /[Cc]opyright/) { print "$file: non-copyright comment\n"; @@ -44,14 +50,38 @@ while (<>) { } } } - $first = ""; + } elsif ($shell_comment) { + if (/^\#\!/) { + $before_copyright = "$_#\n"; + $_ = ; + if ($_ eq "#\n") { + $_ = ; + } + } + if (/^\#/) { + if ($_ !~ /[Cc]opyright/) { + print "$file: non-copyright comment\n"; + close(SOURCE); + next; + } + while () { + 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 = ; } - while () { - print TARGET $_; + if ($first ne "") { + if ($first !~ /^\s*$/) { + print TARGET "\n"; + } + print TARGET $first; + while () { + print TARGET $_; + } } close(TARGET); close(SOURCE);