# parse a file
sub parsefile {
my($fid,$did,$vfile,$vdir) = @_;
- my(@lines,@phplines,@includes,$depid,$sth,$ifile);
+ my(@lines,@phplines,@includes,$depid,$sth,$ifile,$iexists);
print "parsefile($fid,$did,$vfile,$vdir)\n";
die;
}
if ($include =~ /$mask_inc/) {
+ $iexists=0;
if ($include =~ /^[\.\/]/) {
# the directory is specified
$ifile = &abspath($vdir,$include);
- $depid=&putfile($ifile,(-f &realpath($ifile)));
+ $iexists=1 if (-f &realpath($ifile));
} else {
# directory not specified, go through the include path
foreach my $incp (@incpath) {
$ifile = &abspath(&abspath($vdir,$incp),$include);
print "trying $ifile\n";
if (-f &realpath($ifile)) {
- $depid=&putfile($ifile,1);
+ $iexists=1;
last;
}
}
- # did not find file to be included, add it as if it were
- # in the current directory
- $depid=&putfile(&abspath($vdir,$include),0) if (!$depid);
+ # did not find file to be included, treat it as if it were
+ # in the first segment of include path
+ $ifile = &abspath(&abspath($vdir,$incpath[0]),$include) if (!$iexists);
}
+ $depid=&putfile($ifile,$iexists);
&putdep($fid,$depid,$did,"include");
+ &parsefile($depid,$did,$ifile,$vdir) if ($iexists);
}
}
}