]> xenbits.xensource.com Git - libvirt.git/commitdiff
prohibit-duplicate-header: print file name and line
authorJán Tomko <jtomko@redhat.com>
Wed, 22 Jun 2016 20:27:43 +0000 (22:27 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 23 Jun 2016 10:48:40 +0000 (12:48 +0200)
This way :make syntax-check in ViM will point you at the offending line.

build-aux/prohibit-duplicate-header.pl

index f9ab3f58a6bb59d51c96444d6557385bdd4f1ba0..f0539aeca5afc20bb96e9fc6fe43c5c7a7b2978b 100644 (file)
@@ -5,17 +5,21 @@ use strict;
 my $file = " ";
 my $ret = 0;
 my %includes = ( );
+my $lineno = 0;
 
 while (<>) {
     if (not $file eq $ARGV) {
         %includes = ( );
         $file = $ARGV;
+        $lineno = 0;
     }
+    $lineno++;
     if (/^# *include *[<"]([^>"]*\.h)[">]/) {
         $includes{$1}++;
         if ($includes{$1} == 2) {
             $ret = 1;
-            print STDERR "$1 included multiple times in $ARGV\n";
+            print STDERR "$ARGV:$lineno: $_";
+            print STDERR "Do not include a header more than once per file\n";
         }
     }
 }