Skip to content

Commit 7c7e63d

Browse files
committed
ParseXS: fix POD on last line
If POD continued to the last line of the XS file, a bunch of "Use of uninitialized value" warnings would be generated. The fix is trivial, but it also required a slight tweak to the test framework in t/001-basic.t, which was unconditionally adding a \n to the end of each test string, thus making the '=cut' appear not to be at EOF.
1 parent fc392db commit 7c7e63d

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ sub fetch_para {
626626
$self->death("Error: Unterminated pod")
627627
unless defined $self->{lastline};
628628
$self->{lastline} = readline($self->{in_fh});
629+
return 0 unless defined $self->{lastline};
629630
chomp $self->{lastline};
630631
$self->{lastline} =~ s/^\s+$//;
631632
}

dist/ExtUtils-ParseXS/t/001-basic.t

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ sub test_many {
8787
my ($desc_prefix, $xsub_lines, @tests) = @$test_fn;
8888

8989
my $text = $preamble;
90-
$text .= "$_\n" for @$xsub_lines;
90+
for (@$xsub_lines) {
91+
$text .= $_;
92+
$text .= "\n" unless /\n\z/;
93+
}
9194

9295
tie *FH, 'Capture';
9396
my $pxs = ExtUtils::ParseXS->new;
@@ -5795,4 +5798,32 @@ EOF
57955798
test_many($preamble, undef, \@test_fns);
57965799
}
57975800

5801+
5802+
{
5803+
# Test POD
5804+
5805+
my $preamble = Q(<<'EOF');
5806+
|MODULE = Foo PACKAGE = Foo
5807+
|
5808+
|PROTOTYPES: DISABLE
5809+
|
5810+
EOF
5811+
5812+
my @test_fns = (
5813+
[
5814+
"POD at EOF doesn't warn",
5815+
[ Q(<<'EOF') ],
5816+
|void foo()
5817+
|
5818+
|=pod
5819+
|=cut
5820+
EOF
5821+
5822+
[ 0, 0, qr{XS}, "no undef warning" ],
5823+
],
5824+
);
5825+
5826+
test_many($preamble, undef, \@test_fns);
5827+
}
5828+
57985829
done_testing;

0 commit comments

Comments
 (0)