2017-09-18 20:35:50 +08:00
|
|
|
#!/usr/bin/env perl
|
2016-06-16 00:01:24 +08:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $file = " ";
|
|
|
|
my $ret = 0;
|
|
|
|
my %includes = ( );
|
2016-06-23 04:27:43 +08:00
|
|
|
my $lineno = 0;
|
2016-06-16 00:01:24 +08:00
|
|
|
|
|
|
|
while (<>) {
|
|
|
|
if (not $file eq $ARGV) {
|
|
|
|
%includes = ( );
|
|
|
|
$file = $ARGV;
|
2016-06-23 04:27:43 +08:00
|
|
|
$lineno = 0;
|
2016-06-16 00:01:24 +08:00
|
|
|
}
|
2016-06-23 04:27:43 +08:00
|
|
|
$lineno++;
|
2016-06-16 00:01:24 +08:00
|
|
|
if (/^# *include *[<"]([^>"]*\.h)[">]/) {
|
|
|
|
$includes{$1}++;
|
|
|
|
if ($includes{$1} == 2) {
|
|
|
|
$ret = 1;
|
2016-06-23 04:27:43 +08:00
|
|
|
print STDERR "$ARGV:$lineno: $_";
|
|
|
|
print STDERR "Do not include a header more than once per file\n";
|
2016-06-16 00:01:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit $ret;
|