]> Pileus Git - ~andy/fetchmail/blob - timeseries
First round ofmlong-delayed bug fixes.
[~andy/fetchmail] / timeseries
1 #!/usr/bin/perl
2 #
3 # Extract information on the fetchmail project size from the NEWS file
4 #
5 # Note: this only works if you have a news file from 5.1.1 or later --
6 # I didn't patch the code sizes into NEWS until then.
7 #
8 my($release, $date, $jdate);
9
10 %month_offsets = (
11         "Jan",   0,
12         "Feb",   31,
13         "Mar",   59,
14         "Apr",   90,
15         "May",   120,
16         "Jun",   151,
17         "Jul",   181,
18         "Aug",   212,
19         "Sep",   243,
20         "Oct",   273,
21         "Nov",   304,
22         "Dec",   334,
23 );
24
25
26 sub day_offset
27 {
28     my($datestring) = @_;
29     my($wday, $month, $day, $time, $zone, $year) = split(' ', $datestring);
30     my($jdate);
31
32     # We don't deal with leap years here because the baseline day is after
33     # the last leap year (1996) and there's a long time before the next
34     # one (2004).
35     $jdate = ($year - 1996) * 365;
36
37     $jdate += $month_offsets{$month};
38
39     $jdate += ($day - 1);
40
41     # Baseline day for the size data was Fri Oct 25 23:02:26 EDT 1996 
42     $jdate -= 297;
43
44     return($jdate);
45 }
46
47 open(NEWS, "NEWS");
48 $timestamp = `date`;
49 chop $timestamp;
50 $release = "unknown";
51 $lines = "unknown";
52 $date = "unknown";
53 $jdate = "unknown";
54 print <<EOF;
55 # Population data from fetchmail NEWS file, as of $timestamp.
56 #
57 # Output other than pass-through % lines is tab-separated fields.
58 # Field 1: release ID
59 # Field 2: count of source lines under version control 
60 # Field 3: count of fetchmail-friends subscribers
61 # Field 4: count of fetchmail-announce subscribers
62 # Field 5: total subscribers to both lists
63 # Field 6: date of release (days since first datum)
64 # Field 7: date of release (RFC822 date format)
65 #
66 EOF
67 while ($_ = <NEWS>)
68 {
69     my($sum);
70
71     if (/^%/) {
72         print $_;
73     }
74     elsif (/^fetchmail-([^ ]*) \(([^)]+)\)(, [0-9]* lines)?:/) {
75         $release = $1;
76         $date = $2;
77         $jdate = &day_offset($date);
78         if ($3) {
79             $lines = substr($3, 2, length($3) - 8);
80         } else {
81             $lines = 'na'
82         }
83     }
84     elsif (/There are ([0-9]*) people on fetchmail-friends and ([0-9]*) on fetchmail-announce/) {
85         $sum = $1 + $2;
86         print "${release}\t${lines}\t$1\t$2\t${sum}\t${jdate}\t${date}\n";
87         $release = "unknown";
88         $date = "unknown";
89     }
90     elsif (/There are ([0-9]*) people on the fetchmail-friends list./) {
91         print "$release\t${lines}\t$1\t0\t$1\t$jdate\t$date\n";
92         $release = "unknown";
93         $date = "unknown";
94     }
95 }
96
97 # end
98
99
100
101