Related articles |
---|
script to unravel nested C header files? hsu@alumni.EECS.Berkeley.EDU (1995-02-15) |
Re: script to unravel nested C header files? jpowers@ti.com (1995-02-16) |
Re: script to unravel nested C header files? beorn@swindle.Berkeley.EDU (1995-02-17) |
Re: script to unravel nested C header files? wjm@metronet.com (Bill Middleton) (1995-02-17) |
Newsgroups: | comp.compilers |
From: | jpowers@ti.com |
Keywords: | C |
Organization: | Texas Instruments |
References: | 95-02-121 |
Date: | Thu, 16 Feb 1995 20:14:49 GMT |
<hsu@alumni.EECS.Berkeley.EDU> writes:
> I recall someone once posted a very handy script (in perl I
> believe) to print out which header files were included by a C file,
> with the proper level of indentation for nested includes.
# Display include file dependency tree
$shiftwidth = 4;
foreach $file (@ARGV)
{
print "$file...\n";
&scanfile($file, 'fh00', $shiftwidth);
%seen = ();
print "\n\n";
}
sub scanfile {
local($thisfile, $input, $depth) = @_;
local($incfile);
$input++;
unless (open($input, $thisfile))
{
print STDERR "Can't open $thisfile\n";
return;
}
while (<$input>)
{
next unless /^\s*#\s*include\s+"(.+)"/;
$incfile = $1;
print "\t" x ($depth / 8), ' ' x ($depth % 8), $incfile;
print " DUPLICATE" if $seen{$incfile}++;
print "\n";
&scanfile($incfile, $input, $depth+$shiftwidth);
}
close $input;
}
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.