summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-10-24 23:26:56 +0200
committerDaniel Stenberg <daniel@haxx.se>2022-10-26 11:27:29 +0200
commit3678336b201730fc081cf11d52eaf9b0f641ee45 (patch)
tree613f69630a94076707510eb3b11c1f6cbee8cc2a /scripts
parent6092eaa3e6e1ea7676c9f631a2431c29bfbc2e61 (diff)
downloadcurl-3678336b201730fc081cf11d52eaf9b0f641ee45.tar.gz
scripts/checksrc.pl: detect duplicated include files
After an idea by Dan Fandrich in #9794 Closes #9796
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checksrc.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl
index 651b4b700..54cd30cd9 100755
--- a/scripts/checksrc.pl
+++ b/scripts/checksrc.pl
@@ -380,6 +380,7 @@ sub scanfile {
my $incomment=0;
my @copyright=();
+ my %includes;
checksrc_clear(); # for file based ignores
accept_violations();
@@ -472,6 +473,15 @@ sub scanfile {
$line, length($1), $file, $l, "\/\/ comment");
}
+ if($l =~ /^(\#\s*include\s+)([\">].*[>}"])/) {
+ my ($pre, $path) = ($1, $2);
+ if($includes{$path}) {
+ checkwarn("INCLUDEDUP",
+ $line, length($1), $file, $l, "duplicated include");
+ }
+ $includes{$path} = $l;
+ }
+
# detect and strip preprocessor directives
if($l =~ /^[ \t]*\#/) {
# preprocessor line