Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#21 Wrong file counts for require/include

open
nobody
None
5
2012-08-29
2007-11-18
No

The number of files required/included, as well as the number requiring/including the current file, are not always accurate. All I know is sometimes the count shown is 0 when I know there are files in the corresponding category.

Discussion

  • Tomasz Klim
    Tomasz Klim
    2008-03-05

    Logged In: YES
    user_id=910879
    Originator: NO

    Hello

    This error happens, when you scan the multi-level directory tree with code, and is simply a result of bad parser assumption to have %allfiles variable always filled with files from all subdirectories. In the below patch, I changed this behaviour to just check, if a required file physically exists in any possible location, which fixes the problem.

    --- orig/phpxref.pl 2007-01-03 04:21:49.000000000 +0100
    +++ tkl/phpxref.pl 2008-03-05 15:28:26.000000000 +0100
    @@ -480,7 +481,8 @@
    }
    $pn =~ s|/+|/|;
    $pn=collapse_path($pn);
    - if ($allfiles{$pn}) {
    + if (-f $pn) {
    + $pn =~ s/$source_dir//g;
    return($pn);
    }
    }
    @@ -583,17 +585,35 @@
    }
    }
    $reqname=join('',@parts);
    - #print "Resolving $reqname\n";
    - return unless $pn=resolve_path($reqname);
    - push(@{$require_references{$pn}},
    - {
    - 'subdir' => "$subdir/",
    - 'filename' => $filename,
    - 'line' => $line
    - }
    - );
    - $filerequires{"$subdir/$filename"}{$pn}=1;
    - $parsed_requires{$orgreqname}=$pn;
    + #return unless $pn=resolve_path($reqname);
    +
    + $pn=resolve_path(basename($reqname));
    + if ($pn) {
    +
    + push(@{$require_references{$pn}},
    + {
    + 'subdir' => "$subdir/",
    + 'filename' => $filename,
    + 'line' => $line
    + }
    + );
    + $filerequires{"$subdir/$filename"}{$pn}=1;
    + $parsed_requires{basename($orgreqname)}=$pn;
    +
    + } else {
    +
    + return unless $pn=resolve_path($reqname);
    + push(@{$require_references{$pn}},
    + {
    + 'subdir' => "$subdir/",
    + 'filename' => $filename,
    + 'line' => $line
    + }
    + );
    + $filerequires{"$subdir/$filename"}{$pn}=1;
    + $parsed_requires{$orgreqname}=$pn;
    + }
    +
    return 1;
    }