From a5d444f35aea4cf0eaf1d41f59785e6ed6f72413 Mon Sep 17 00:00:00 2001 From: Jeremy Laine Date: Sat, 23 Nov 2002 16:04:20 +0000 Subject: [PATCH] suit les inclusions --- deptrack/deptrack.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/deptrack/deptrack.pl b/deptrack/deptrack.pl index 22a51a7..c4a7aa8 100755 --- a/deptrack/deptrack.pl +++ b/deptrack/deptrack.pl @@ -272,7 +272,7 @@ sub parsedir { # 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"; @@ -301,25 +301,28 @@ sub parsefile { 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); } } } -- 2.1.4