Skip to content

Commit 09034cd

Browse files
committed
ParseXS: standard_typemap_locations(): skip -e
standard_typemap_locations() returns a set of filenames for where a typemap file map be expected, relative to both the current directory and to @inc. The @inc files are filtered using -e, but the others (../../typemap etc) aren't. This commit removes the -e filtering for @inc, for consistency. This means that standard_typemap_locations() now returns a list of filenames of *all* the standard locations where a typemap file *might* be found, regardless of whether the file exists. Previously it was a weird hybrid. This commit should make no difference in practice, since the one caller of this function, process_typemaps() does it's own -f filtering too. So really the net effect of this commit is to remove a few duplicate stat() OS calls. It also allows one existing test to be simplified, since now there will always be one returned entry per @inc entry, whereas before it might have been less.
1 parent 9815ff9 commit 09034cd

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ SCOPE: {
147147
my @tm = @tm_template;
148148
foreach my $dir (@{ $include_ref}) {
149149
my $file = File::Spec->catfile($dir, ExtUtils => 'typemap');
150-
unshift @tm, $file if -e $file;
150+
unshift @tm, $file;
151151
}
152152
return @tm;
153153
}

dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,8 @@ use ExtUtils::ParseXS::Utilities qw(
1717
1
1818
unless @stl > 9;
1919

20-
# We check only as many location entries from the start of the array
21-
# (where the @INC-related entries are) as there are entries from @INC.
22-
# We manage to do that by stopping when we find the "updir" related
23-
# entries, which we assume is never contained in a default @INC entry.
24-
my $updir = File::Spec->updir;
20+
# Check that at least one typemap file can be found under @INC
2521
my $max = $#INC;
26-
$max = $#stl if $#stl < $max;
27-
foreach my $i (0.. $max) {
28-
$max = $i, last if $stl[$i] =~ /\Q$updir\E/;
29-
}
30-
3122
ok(
3223
( 0 < (grep -f $_, @stl[0..$max]) ),
3324
"At least one typemap file exists underneath \@INC directories"
@@ -39,6 +30,7 @@ use ExtUtils::ParseXS::Utilities qw(
3930
my @fake_INC = qw(a/b/c d/e/f /g/h/i);
4031
my @expected =
4132
(
33+
map("$_/ExtUtils/typemap", reverse @fake_INC),
4234
qw(
4335
../../../../lib/ExtUtils/typemap
4436
../../../../typemap

0 commit comments

Comments
 (0)