3 # leading and trailing context lines.
10 if ( !scalar @ARGV ) {
11 print "Usage: parse_warn.pl <files>\n";
12 print "Example: parse_warn.pl log/*\n";
19 foreach $file (@ARGV) {
21 print "warning: $file does not exist.\n";
24 my $str = ' at .* line ';
26 print "Opening $file... ";
27 if ( $file =~ /bz2$/ ) { # bz2
28 open( FILE, "bzcat $file | egrep '$str' |" );
30 elsif ( $file =~ /gz$/ ) { # gz
31 open( FILE, "zegrep '$str' $file |" );
34 open( FILE, "egrep '$str' $file |" );
39 if (/ at (\S+) line (\d+)/) {
40 my ( $file, $lineno ) = ( $1, $2 + 1 );
41 $done{$file}{$lineno}++;
49 foreach $file ( keys %done ) {
50 my $count = scalar( keys %{ $done{$file} } );
51 print "warn $file: $count unique warnings.\n";
54 print "=> error: does not exist.\n\n";
58 if ( open( IN, $file ) ) {
62 my $total = scalar @lines;
65 for ( my $i = 0 ; $i <= $total ; $i++ ) {
67 unless ( exists $done{$file}{ $i + $contextspread } or $spread );
69 if ( exists $done{$file}{ $i + $contextspread } ) {
70 print "@@ $i @@\n" unless ($spread);
72 # max lines between offending lines should be 2*context-1.
73 # coincidence that it is!
74 $spread = 2 * $contextspread;
80 if ( exists $done{$file}{$i} ) {
97 print "=> error: could not open file.\n";
101 # vim:ts=4:sw=4:expandtab:tw=80