All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC v2 1/5] Use #include "..." exactly for our own headers
Date: Tue, 28 Jun 2016 10:09:03 +0200	[thread overview]
Message-ID: <87lh1penvk.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <577136E6.4030404@redhat.com> (Eric Blake's message of "Mon, 27 Jun 2016 08:23:34 -0600")

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]

Eric Blake <eblake@redhat.com> 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...


[-- Attachment #2: map-include-to-header.pl --]
[-- Type: text/plain, Size: 1459 bytes --]

#!/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);
	}
    }
}

  reply	other threads:[~2016-06-28  8:09 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 14:19 [Qemu-devel] [PATCH RFC v2 0/5] Baby steps towards saner headers Markus Armbruster
2016-06-24 14:19 ` [Qemu-devel] [PATCH RFC v2 1/5] Use #include "..." exactly for our own headers Markus Armbruster
2016-06-24 14:54   ` Eric Blake
2016-06-27  6:34     ` Markus Armbruster
2016-06-27  8:50     ` Markus Armbruster
2016-06-27 10:07       ` Peter Maydell
2016-06-28  8:17         ` Markus Armbruster
2016-06-27 14:23       ` Eric Blake
2016-06-28  8:09         ` Markus Armbruster [this message]
2016-06-24 14:19 ` [Qemu-devel] [PATCH RFC v2 2/5] tests: New make target check-source Markus Armbruster
2016-06-24 14:23   ` Peter Maydell
2016-06-27  6:34     ` Markus Armbruster
2016-06-27 10:02       ` Peter Maydell
2016-06-28  8:19         ` Markus Armbruster
2016-06-28  8:33           ` Peter Maydell
2016-06-30  6:30   ` [Qemu-devel] [PATCH RFC] fixup! " Markus Armbruster
2016-06-30 10:58     ` Sascha Silbe
2016-06-30 12:14       ` Markus Armbruster
2016-07-01 13:52         ` Markus Armbruster
2016-07-04 11:16           ` Sascha Silbe
2016-07-06 13:46             ` Markus Armbruster
2016-06-24 14:19 ` [Qemu-devel] [PATCH RFC v2 3/5] tests: Make check-block a phony target Markus Armbruster
2016-06-24 15:17   ` Eric Blake
2016-06-27  6:35     ` Markus Armbruster
2016-06-24 14:19 ` [Qemu-devel] [PATCH RFC v2 4/5] include: Move typedef qemu_irq to qemu/typedefs.h Markus Armbruster
2016-06-24 14:19 ` [Qemu-devel] [PATCH RFC v2 5/5] include: Include exec/hwaddr.h where hwaddr is used Markus Armbruster
2016-06-27 17:27 ` [Qemu-devel] [PATCH RFC v2 0/5] Baby steps towards saner headers Sascha Silbe
2016-06-27 18:13   ` Paolo Bonzini
2016-06-27 20:39     ` Sascha Silbe
2016-06-28  8:40       ` Markus Armbruster
2016-06-29 23:54         ` John Snow
2016-06-30  6:30           ` Markus Armbruster
2016-06-30 16:19             ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lh1penvk.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.