killed system filter
[exim-website.git] / filter / process_re2filtermatch.pl
index c82670270209101a9318ec314fff7a034da4bcfd..851a40ff6512d08c31ecefb457d29f4e969bd55b 100644 (file)
@@ -1,22 +1,50 @@
 #!/usr/bin/perl
 #
 use strict;
+use FileHandle;
 
-my $re;
-while(<>) {
-    chomp();
-    # dispose of comments with their leading spaces
-    s/\s+\#.*$//;
-    # recode \" -> "
-    s/\\\"/\"/g;
-    # double all \ (twice)
-    s/\\/\\\\/g;
-    s/\\/\\\\/g;
-    # escape " again
-    s/\"/\\\"/g;
-    # remove all space
-    s/\s+//g;
-    # add to re
-    $re .= $_;
+\f
+
+sub process_file {
+    my $fn = shift;
+
+    my $re;
+    print STDERR "Opening $fn\n";
+    my $fh = FileHandle->new($fn, 'r') || die $!;
+    while (<$fh>) {
+       chomp();
+       # process includes
+       if (/^\#include\s/) {
+           my($junk, $nfn) = split;
+           $re .= process_file($nfn);
+           next;
+       }
+       # ignore comments starting at the begining of the line
+       next if (/^\#/);
+       # dispose of comments with their leading spaces
+       s/\s+\#.*$//;
+       # recode \" -> "
+       s/\\\"/\"/g;
+       # double all \ (twice)
+       s/\\/\\\\/g;
+       s/\\/\\\\/g;
+       # escape " again
+       s/\"/\\\"/g;
+       # remove all space
+       s/\s+//g;
+       # add to re
+       $re .= $_;
+    }
+    return $re;
+}
+
+\f
+
+# main
+{
+    my $re;
+    while($_ = shift) {
+       $re .= process_file($_);
+    }
+    print "\"$re\"\n";
 }
-print "\"$re\"\n";