chiark / gitweb /
Commit 2.4.5-5 as unpacked
[inn-innduct.git] / tests / overview / munge-data
1 #!/usr/bin/perl
2
3 ##  $Id: munge-data 5144 2002-02-24 06:24:55Z rra $
4 ##
5 ##  Munge .overview data into something suitable for test data.
6 ##
7 ##  This script isn't used regularly and is here only for the use of INN
8 ##  developers and other people needing to generate more overview test data.
9 ##  It expects overview data but possibly with extra fields at the end, snips
10 ##  off To: data (to avoid putting people's e-mail addresses into INN test
11 ##  data), and if Newsgroups: data is present, rewrites the Xref header to use
12 ##  it instead of keeping the Xref data (this is so that I can use .overview
13 ##  files from Gnus as test data).  It generates overview data but with the
14 ##  newsgroup name and a colon prepended to the article number so that it can
15 ##  be split apart into overview data for multiple groups.
16 ##
17 ##  Please don't include overview information for people's articles into INN's
18 ##  test suite without their permission.
19
20 my %number;
21 while (<>) {
22     s/\s+$//;
23     my @data = split /\t/;
24     @data = grep { !/^To:/ } @data;
25     my $group = pop @data;
26     my $xref = pop @data;
27     if ($group =~ s/^Newsgroups: //) {
28         my @groups = split (/\s*,\s*/, $group);
29         for (@groups) {
30             $number{$_} = 1 unless $number{$_};
31             $data[0] = $_ . ':' . $number{$_}++;
32             $number{$_} += int (rand 5) if rand (10) > 8;
33             print join ("\t", @data, "Xref: inn.example.com $data[0]"), "\n";
34         }
35     } else {
36         $xref =~ s/Xref:\s*\S+\s+//;
37         my @xref = split (' ', $xref);
38         for (@xref) {
39             $data[0] = $_;
40             print join ("\t", @data, "Xref: inn.example.com $xref"), "\n";
41         }
42     }
43 }