Staging
v0.5.1
https://github.com/torvalds/linux
Raw File
Tip revision: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 authored by Linus Torvalds on 16 April 2005, 22:20:36 UTC
Linux-2.6.12-rc2
Tip revision: 1da177e
checkincludes.pl
#!/usr/bin/perl
#
# checkincludes: Find files included more than once in (other) files.
# Copyright abandoned, 2000, Niels Kristian Bech Jensen <nkbj@image.dk>.

foreach $file (@ARGV) {
	open(FILE, $file) or die "Cannot open $file: $!.\n";

	my %includedfiles = ();

	while (<FILE>) {
		if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
			++$includedfiles{$1};
		}
	}
	
	foreach $filename (keys %includedfiles) {
		if ($includedfiles{$filename} > 1) {
			print "$file: $filename is included more than once.\n";
		}
	}

	close(FILE);
}
back to top