use Carp qw(:DEFAULT cluck);
use Pod::Checker;
+use Cwd qw(realpath);
use File::Find;
use File::Basename;
use File::Spec::Functions;
"$config{sourcedir}/test",
);
my @except_env_files = (
- "$config{sourcedir}/providers/implementations/keymgmt/template_kmgmt.c",
"$config{sourcedir}/providers/implementations/kem/template_kem.c",
- "$config{sourcedir}/Makefile.in",
+ # The following files are generated, and are therefore found in the
+ # build directory rather than the source directory
+ "$config{builddir}/providers/implementations/keymgmt/template_kmgmt.c",
+ "$config{builddir}/Makefile.in",
);
my @env_headers;
my @env_macro;
}
}
+ # Because we compare against them, make sure that all elements in
+ # @except_dirs and @except_env_files are real paths. Otherwise,
+ # we may get false positives because relative paths to the same
+ # file could look different.
+ # For example, './foo.c' == '../dir/foo.c', but turning them into
+ # real paths will have them actually look the same.
+ @except_dirs = map { realpath($_) } @except_dirs;
+ @except_env_files = map { realpath($_) } @except_env_files;
+
# look for source files
find(sub { push @env_files, $File::Find::name if /\.c$|\.in$/; },
$config{sourcedir});
foreach my $filename (@env_files) {
- next if (grep { $filename =~ /^$_\// } @except_dirs)
- || grep { $_ eq $filename } @except_env_files;
+ my $realfilename = realpath($filename);
+ next if (grep { $realfilename =~ /^$_\// } @except_dirs)
+ || grep { $_ eq $realfilename } @except_env_files;
open my $fh, '<', $filename or die "Can't open $filename: $!";
while (my $line = <$fh>) {