New file to look for duplicate includes.

This commit is contained in:
Pavel Roskin 2005-05-10 21:46:36 +00:00
parent 2d72a3f7b9
commit e56462d992
1 changed files with 40 additions and 0 deletions

40
maint/dupincludes.pl Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env perl
# Copyright (c) 2005, Pavel Roskin
# This script is Free Software, and it can be copied, distributed and
# modified under the terms of GNU General Public License, version 2.
# Locate duplicate includes
use strict;
my %sys_includes;
my %loc_includes;
if ($#ARGV != 0) {
print "Usage: dupincludes.pl file\n";
exit 1;
}
my $filename = $ARGV[0];
if (!open (FILE, "$filename")) {
print "Cannot open file \"$filename\"\n";
exit 1;
}
foreach (<FILE>) {
if (/^\s*#\s*include\s*<(.*)>/) {
if (defined $sys_includes{$1}) {
print "$filename: duplicate <$1>\n";
} else {
$sys_includes{$1} = 1;
}
} elsif (/^\s*#\s*include\s*"(.*)"/) {
if (defined $loc_includes{$1}) {
print "$filename: duplicate \"$1\"\n";
} else {
$loc_includes{$1} = 1;
}
}
}