On Thu, May 06, 2010 at 10:43:43AM -0700, Randy Dunlap wrote:
I made one after I spot one place like that.. it's simple
perl script, which spits many false warnings (attached).
I took what I thought was right. I did not want to spend
much time with that. ;)
wbr,
jirka
---
#!/usr/bin/perl
my @ifdefs;
my $lnb = 0;
my $file = $ARGV[0];
open FILE, $file or die $!;
while($line = <FILE>) {
chop $line;
$lnb++;
if ($line =~ /^#[ ]*ifdef|^#[ ]*if/) {
my @ifdef = split(/\s/, $line);
my $def = $ifdef[1];
foreach $d(@ifdefs) {
next if ($d ne $def);
print "$file: [$line]\n";
print "$file: got duplicate $def, line $lnb\n";
}
push(@ifdefs, $def);
}
if ($line =~ /^#[ ]*endif/) {
pop(@ifdefs);
}
}
--