0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 use strict;
0016
0017 sub usage {
0018 print "Usage: checkdeclares.pl file1.h ...\n";
0019 print "Warns of struct declaration duplicates\n";
0020 exit 1;
0021 }
0022
0023 if ($#ARGV < 0) {
0024 usage();
0025 }
0026
0027 my $dup_counter = 0;
0028
0029 foreach my $file (@ARGV) {
0030 open(my $f, '<', $file)
0031 or die "Cannot open $file: $!.\n";
0032
0033 my %declaredstructs = ();
0034
0035 while (<$f>) {
0036 if () {
0037 ++$declaredstructs{$1};
0038 }
0039 }
0040
0041 close($f);
0042
0043 foreach my $structname (keys %declaredstructs) {
0044 if ($declaredstructs{$structname} > 1) {
0045 print "$file: struct $structname is declared more than once.\n";
0046 ++$dup_counter;
0047 }
0048 }
0049 }
0050
0051 if ($dup_counter == 0) {
0052 print "No duplicate struct declares found.\n";
0053 }