doc update
[exim-website.git] / filter / process_re2filtermatch.pl
1 #!/usr/bin/perl
2 #
3 use strict;
4 use FileHandle;
5
6 \f
7
8 sub process_file {
9     my $fn = shift;
10
11     my $re;
12     print STDERR "Opening $fn\n";
13     my $fh = FileHandle->new($fn, 'r') || die $!;
14     while (<$fh>) {
15         chomp();
16         # process includes
17         if (/^\#include\s/) {
18             my($junk, $nfn) = split;
19             $re .= process_file($nfn);
20             next;
21         }
22         # ignore comments starting at the begining of the line
23         next if (/^\#/);
24         # dispose of comments with their leading spaces
25         s/\s+\#.*$//;
26         # recode \" -> "
27         s/\\\"/\"/g;
28         # double all \ (twice)
29         s/\\/\\\\/g;
30         s/\\/\\\\/g;
31         # escape " again
32         s/\"/\\\"/g;
33         # remove all space
34         s/\s+//g;
35         # add to re
36         $re .= $_;
37     }
38     return $re;
39 }
40
41 \f
42
43 # main
44 {
45     my $re;
46     while($_ = shift) {
47         $re .= process_file($_);
48     }
49     print "\"$re\"\n";
50 }