3 # Locate duplicate includes
5 # Copyright (c) 2005, Pavel Roskin
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 print "Usage: dupincludes.pl file\n";
30 my $filename = $ARGV[0];
32 if (!open (FILE
, "$filename")) {
33 print "Cannot open file \"$filename\"\n";
38 if (/^\s*#\s*include\s*<(.*)>/) {
39 if (defined $sys_includes{$1}) {
40 print "$filename: duplicate <$1>\n";
42 $sys_includes{$1} = 1;
44 } elsif (/^\s*#\s*include\s*"(.*)"/) {
45 if (defined $loc_includes{$1}) {
46 print "$filename: duplicate \"$1\"\n";
48 $loc_includes{$1} = 1;