Sometimes, you want to use your favorite code checker tool on an old piece software. Your tool will output many warnings. Only warning you have produced interest you.

Next trivial script take output of your tool as input and filter lines referenced in patch file given as parameter (your changes). Sure, this script could be easliy adapted to output of any tool.

#!/usr/bin/perl
# Syntax:
#   external_tool | ./this_script.pl patch.diff
# Note only unified diff is supported

open(FILE, $ARGV[0]);

my %l;

my $file = "<Syntax error>";

# Fill a table with all chunk of modified lines 
while (<FILE>) {
    $file = $1 if (m/^\+\+\+ ([^\t ]*)/);
    if (m/^@@.*\+([0-9]+),([0-9]+) @@/) {
        push @{$l{$file}}, [ $1, $1 + $2 ];
    }
}

# Dump table
#foreach $k (keys %l) {
#    foreach $i (0 .. $#{$l{$k}}) {
#        print join ":", $k, @{$l{$k}[$i]}; 
#        print "\n"
#    }
#}

while (<STDIN>) {
    if (m/^([^:]+):([0-9]+)/) {
        if (defined $l{$1}) {
            foreach $i (0 .. $#{$l{$1}}) {
                print if ($2 >= $l{$1}[$i][0] and $2 <= $l{$1}[$i][1]);
            }
        }
    } else {
        # Print lines that doesn't looks like errors
        print;
    }
}