From: Sven Eden Date: Fri, 2 Feb 2018 06:15:23 +0000 (+0100) Subject: tools/check-includes.pl : Fixed errors. The constant long list of errors in Eclipse... X-Git-Tag: v235.3~11 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=29aaa6fef99f83e54baed130cb5380294ae2b152;p=elogind.git tools/check-includes.pl : Fixed errors. The constant long list of errors in Eclipse Epic drove me nuts. ;-) --- diff --git a/tools/check-includes.pl b/tools/check-includes.pl index bf23929d4..d93b5668a 100755 --- a/tools/check-includes.pl +++ b/tools/check-includes.pl @@ -3,21 +3,23 @@ # checkincludes: Find files included more than once in (other) files. # Copyright abandoned, 2000, Niels Kristian Bech Jensen . -foreach $file (@ARGV) { - open(FILE, $file) or die "Cannot open $file: $!.\n"; +use strict; +use warnings; +foreach my $file (@ARGV) { my %includedfiles = (); - while () { + open(my $FILE, "<", $file) or die "Cannot open $file: $!.\n"; + while (<$FILE>) { if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { ++$includedfiles{$1}; } } - foreach $filename (keys %includedfiles) { + close($FILE); + + foreach my $filename (keys %includedfiles) { if ($includedfiles{$filename} > 1) { print "$file: $filename is included more than once.\n"; } } - - close(FILE); }