# Build a subroutine to scan for any specified patterns.
if (@pats) {
$sub = "sub pats {\n";
foreach $pat (@pats) {
$sub .= " print '>>>>>>> ',\$_ if m$pat;\n";
}
$sub .= "}\n";
eval $sub;
++$pats;
}
# Now process each file on the command line.
foreach $file (@ARGV) {
open(CPP,"$CPP $defines $includes $file|")
|| die "Can't run cpp: $!\n";
$line = 2;
while (<CPP>) {
++$line;
&pats if $pats; # Avoid expensive call if we can.
next unless /^#/;
next unless /^# \d/;
($junk,$newline,$filename) = split;
$filename =~ s/"//g;
# Now figure out if it's a push, a pop, or neither.
if ($stack[$#stack] eq $filename) { # Same file.
$line = $newline-1;
next;
}