Applied MC indentation policy.
[kaloumi3.git] / maint / dupincludes.pl
blobbc8fa220bb74868f5aa0112729bac56fec042269
1 #!/usr/bin/env perl
3 # Copyright (c) 2005, Pavel Roskin
4 # This script is Free Software, and it can be copied, distributed and
5 # modified under the terms of GNU General Public License, version 2.
7 # Locate duplicate includes
9 use strict;
11 my %sys_includes;
12 my %loc_includes;
14 if ($#ARGV != 0) {
15 print "Usage: dupincludes.pl file\n";
16 exit 1;
19 my $filename = $ARGV[0];
21 if (!open (FILE, "$filename")) {
22 print "Cannot open file \"$filename\"\n";
23 exit 1;
26 foreach (<FILE>) {
27 if (/^\s*#\s*include\s*<(.*)>/) {
28 if (defined $sys_includes{$1}) {
29 print "$filename: duplicate <$1>\n";
30 } else {
31 $sys_includes{$1} = 1;
33 } elsif (/^\s*#\s*include\s*"(.*)"/) {
34 if (defined $loc_includes{$1}) {
35 print "$filename: duplicate \"$1\"\n";
36 } else {
37 $loc_includes{$1} = 1;