From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHo51-0005uT-MG for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:09:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHo4v-0007UD-KA for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:09:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58718) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHo4v-0007U9-E1 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 04:09:05 -0400 From: Markus Armbruster References: <1466777957-5126-1-git-send-email-armbru@redhat.com> <1466777957-5126-2-git-send-email-armbru@redhat.com> <576D49AA.30906@redhat.com> <87oa6nhv7b.fsf@dusky.pond.sub.org> <577136E6.4030404@redhat.com> Date: Tue, 28 Jun 2016 10:09:03 +0200 In-Reply-To: <577136E6.4030404@redhat.com> (Eric Blake's message of "Mon, 27 Jun 2016 08:23:34 -0600") Message-ID: <87lh1penvk.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: Re: [Qemu-devel] [PATCH RFC v2 1/5] Use #include "..." exactly for our own headers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, pbonzini@redhat.com --=-=-= Content-Type: text/plain Eric Blake writes: > On 06/27/2016 02:50 AM, Markus Armbruster wrote: > >> With an ugly Perl script, of course %-/ >> > >> I'm afraid my script and its usage is too brittle to be of much use >> later on. I attach it anyway. > > A zero byte file map-include-to-header.pl~. Infinite compression :) Looks like my fingers were even more reluctant to show off their ugly work than my brain was... --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=map-include-to-header.pl #!/usr/bin/perl -w use strict; my %ihdr = (); my %idir = (); my @sall = (); my @sinc = (); open(my $fh, "-|", "git grep '^[ \t]*#[ \t]*include[ \t]'") or die "can't run git grep: $!"; while (<$fh>) { m,^([^:/]*)/?[^:/]*:[ \t]*#[ \t]*include[ \t]*(["<])([^">]*),; my $dir = $1 // "."; my $delim = $2; my $h = $3; $ihdr{$h} |= 1 << ($delim eq "<"); if (exists $idir{$h}) { my $aref = $idir{$h}; push @$aref, $dir unless grep($_ eq $dir, @$aref); } else { $idir{$h} = [$dir]; } } close ($fh); open($fh, "-|", "git ls-tree -r --name-only HEAD") or die "can't run git ls-tree: $!"; while (<$fh>) { chomp; push @sall, $_; } close ($fh); @sinc = grep(/^include\//, @sall); sub pr { my ($h, $fn, $src) = @_; print "$h -> $fn"; if ($ihdr{$h} == 3) { print " (included inconsistently)"; } elsif ($src) { print " (included with <>)" if ($ihdr{$h} != 1); } else { print " (included with \"\")" if ($ihdr{$h} != 2); } print "\n"; } for my $h (keys %ihdr) { $h =~ m,^(\.\./)*(include/)?(.*), or die; my $hh = $3; my @fn = grep(/^include\/\Q$hh\E$/, @sinc); if (@fn) { pr($h, $fn[0], 1); next; } @fn = grep(/^\Q$hh\E$/, @sall); if (@fn) { pr($h, $fn[0], 1); next; } for my $dir (@{$idir{$h}}) { next if $dir eq "."; @fn = grep(/^\Q$dir\/$hh\E$/, @sall); if (@fn) { pr($h, $fn[0], 1); } else { pr($h, "? (in $dir)", 0); } } } --=-=-=--