You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2004/01/08 07:59:31 UTC
svn commit: rev 6116 - in incubator/spamassassin/trunk: . build
Author: jm
Date: Wed Jan 7 22:59:30 2004
New Revision: 6116
Added:
incubator/spamassassin/trunk/build/replace_license_blocks (contents, props changed)
Modified:
incubator/spamassassin/trunk/MANIFEST.SKIP
Log:
added license-replacing helper script
Modified: incubator/spamassassin/trunk/MANIFEST.SKIP
==============================================================================
--- incubator/spamassassin/trunk/MANIFEST.SKIP (original)
+++ incubator/spamassassin/trunk/MANIFEST.SKIP Wed Jan 7 22:59:30 2004
@@ -120,3 +120,4 @@
tasks/.*
build/2.60_change_summary
t/spamd_parallel.t
+build/replace_license_blocks
Added: incubator/spamassassin/trunk/build/replace_license_blocks
==============================================================================
--- (empty file)
+++ incubator/spamassassin/trunk/build/replace_license_blocks Wed Jan 7 22:59:30 2004
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -i.bak
+#
+# build/replace_license_blocks file ...
+#
+# Replace a <@LICENSE> ... </...@LICENSE> delimited block of comment text inside
+# an arbitrary number of files with the contents of the file named
+# 'newlicense'. The comment character to use at start-of-line is read
+# from the file being worked on, e.g.
+#
+# * <@LICENSE>
+#
+# will result in all lines of the license text being prefixed with " * ".
+
+# read the new license text; die if not available
+open (IN, "<newlicense") or die "cannot read 'newlicense'";
+my $license = join ('', <IN>);
+close IN;
+
+# remove final comment if present
+$license =~ s/\n \*\/$//gs;
+# remove C comment start-of-line markers
+$license =~ s/^(?:\/\* | \* | \*\/| \*)//gm;
+
+# and fixup in-place
+$in_license_block = 0;
+
+while (<>) {
+ if ($in_license_block) {
+ # we're waiting until the end-of-license "closing tag"
+ if (s/^.+<\/...@LICENSE>//) {
+ $in_license_block = 0;
+ }
+ } else {
+ if (s{^(.+)<\...@LICENSE>\s*$}{ license_with_prefix($1); }eg) {
+ $in_license_block = 1;
+ } else {
+ # a non-block form -- will be replaced with a block
+ s{^(.+)\@LICENSE\s*$}{ license_with_prefix($1); }eg;
+ }
+ }
+ print;
+}
+
+sub license_with_prefix {
+ my $prefix = shift;
+ my $text = $license; $text =~ s/^/$prefix/gm;
+
+ return $prefix."<\...@LICENSE>\n".
+ $text.
+ $prefix."</\...@LICENSE>\n";
+}