suit les inclusions
authorJeremy Laine <jeremy.laine@m4x.org>
Sat, 23 Nov 2002 16:04:20 +0000 (16:04 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Sat, 23 Nov 2002 16:04:20 +0000 (16:04 +0000)
deptrack/deptrack.pl

index 22a51a7..c4a7aa8 100755 (executable)
@@ -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);
     }
   }
 }