3 # Usage: inctree [options] [files]
5 # Configuration parameters.
15 while ($ARGV[0] =~ /^-/) {
18 $defines .= " -D" . ($1 ?
$1 : shift);
21 $CPP = 'cl /nologo /E';
23 while (! chdir "build/win32")
25 die "could not find build/win32 in search backwards" if (++$count > 50);
31 $include = ($1 ?
$1 : shift);
33 if ($include =~ /\.rsp$/)
39 $includes .= " -I" . $_;
44 $includes .= " -I" . $include;
48 push(@pats, $1 ?
$1 : shift);
54 die "Unrecognized switch: $_\n";
58 # Build a subroutine to scan for any specified patterns.
61 $sub = "sub pats {\n";
62 foreach $pat (@pats) {
63 $sub .= " print '>>>>>>> ',\$_ if m$pat;\n";
70 # Now process each file on the command line.
72 foreach $file (@ARGV) {
73 open(CPP
,"$CPP $defines $includes $file|")
74 || die "Can't run cpp: $!\n";
79 &pats
if $pats; # Avoid expensive call if we can.
80 s/^#line /# /; # handle dev-studio style line info as well
86 while (s
#/\w+/../#/#) {}
87 ($junk,$newline,$filename) = split(/\s+/, $_, 3);
89 $filename =~ s/^\s+//;
90 $filename =~ s/\s+$//;
92 # Now figure out if it's a push, a pop, or neither.
94 if ($stack[$#stack] eq $filename) { # Same file.
99 if ($stack[$#stack-1] eq $filename) { # Leaving file.
100 $indent -= $shiftwidth;
101 $line = pop(@lines)-1;
105 printf "%6d ", $line-2 if $lines;
108 print " " x
($indent), $filename;
109 print " DUPLICATE" if $seen{$filename}++;
111 $indent += $shiftwidth;
112 push(@stack,$filename);