#!usr/bin/perl

%czech = ();
%flawfinder = ();

open (CZECH_LOG, "<czech-log.txt") || die 'cannot open the czech-log';

my $Filename = "/";

while (<CZECH_LOG>) {
	$ThisLine = $_;
	chomp ($ThisLine);
	#
	#scanning ./nsprpub/pr/src/io/prprf.c ...
	#	line 362: unformatted string in sprintf
	#
	if ($ThisLine =~ /^scanning\s(.*?)\s...$/)
	{
		$FileName = $1;
		#print "$ThisLine ($1)\n";
	}
	if ($ThisLine =~ /\tline\s(\d+)(.*?)/)
	{
		#print "c-$FileName:$1\n";
		$czech{"$FileName:$1"} = undef;
	}
		
}
close (CZECH_LOG);

open (FLAWFINDER_LOG, "<flawfinder-log.txt") || die 'cannot open the flawfinder log';
while (<FLAWFINDER_LOG>) {
	$ThisLine = $_;
	chomp ($ThisLine);
	#./nsprpub/config/nsinstall.c:199 [3] (buffer) getopt: this does not protect
	if ($ThisLine =~ /^\.\/(.*?):(\d+)/)
	{
		#print "f-./$1:$2\n";
		$flawfinder{"./$1:$2"} = undef;
	}

}
close (FLAWFINDER_LOG);
=pod
open (CZECH_OUTPUT, ">czech-output.txt") || die 'cannot open the czech output';
foreach (keys %czech)
{
	print CZECH_OUTPUT "$_\n" unless exists $flawfinder{$_};
}

close (CZECH_OUTPUT);
=cut
###########################################################

open (FLAWFINDER_OUTPUT, ">flawfinder-output.txt") || die 'cannot open the flawfinder output';
foreach (keys %flawfinder)
{
	print FLAWFINDER_OUTPUT "$_\n" unless exists $czech{$_};
}

close (FLAWFINDER_OUTPUT);


