1 ;# $Id: copyright.pl,v 3.0 1993/08/18 12:10:51 ram Exp $
3 ;# Copyright (c) 1991-1993, Raphael Manfredi
5 ;# You may redistribute only under the terms of the Artistic Licence,
6 ;# as specified in the README file that comes with the distribution.
7 ;# You may reuse parts of this distribution only within the terms of
8 ;# that same Artistic Licence; a copy of which may be found at the root
9 ;# of the source tree for dist 3.0.
11 ;# $Log: copyright.pl,v $
12 ;# Revision 3.0 1993/08/18 12:10:51 ram
13 ;# Baseline for dist 3.0 netwide release.
16 ;# Copyright expansion. The @COPYRIGHT@ symbol is expanded the first time
17 ;# it is seen in a file, and before the $Log RCS marker is reached. The
18 ;# automaton needs to be reset for each file.
22 # Read in copyright file
24 local($file) = @_; # Copyright file
26 open(COPYRIGHT, $file) || die "Can't open $file: $!\n";
27 chop(@copyright = <COPYRIGHT>);
31 # Reset the automaton for a new file.
33 $copyright_seen = @copyright ? 0 : 1;
37 # Filter file, line by line, and expand the copyright string. The @COPYRIGHT@
38 # symbol may be preceded by some random comment. A leader can be defined and
39 # will be pre-pended to all the input lines.
41 local($line, $leader) = @_; # Leader is optional
42 return $leader . $line if $copyright_seen || $marker_seen;
43 $marker_seen = 1 if $line =~ /\$Log[:\$]/;
44 $copyright_seen = 1 if $line =~ /\@COPYRIGHT\@/;
45 return $leader . $line unless $copyright_seen;
46 local($comment, $trailer) = $line =~ /^(.*)\@COPYRIGHT\@\s*(.*)/;
47 $comment = $leader . $comment;
48 $comment . join("\n$comment", @copyright) . "\n";
51 # Filter output of $cmd redirected into $file by expanding copyright, if any.
53 local($cmd, $file) = @_;
55 open(CMD,"$cmd|") || die "Can't start '$cmd': $!\n";
56 open(OUT, ">$file") || die "Can't create $file: $!\n";
60 print OUT &filter($_);
65 system "$cmd > $file";
66 die "Command '$cmd' failed!" if $?;