Skip to content

Commit a83466f

Browse files
committed
ParseXS: refactor: move a chomp()
(This commit is part of a series which will extend the AST parse tree from just representing individual XSUBs to representing the whole XS file.) Change where $pxs->{lastline} gets chomped at the start of the XS half of the file, where the fetch_para() loop is first entered - do it just the once when transitioning rather than polluting the main fetch_para() loop with it. No functional changes.
1 parent 8ace24a commit a83466f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ sub fetch_para {
604604
my ExtUtils::ParseXS $self = shift;
605605

606606
return 0 if not defined $self->{lastline}; # EOF
607-
chomp $self->{lastline}; # may not already have been for first MODULE line
608607

609608
@{ $self->{line} } = ();
610609
@{ $self->{line_no} } = ();

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,14 @@ sub parse {
662662
$pxs->{lastline_no} = $.;
663663

664664
while (defined $pxs->{lastline}) {
665-
return 1 if ExtUtils::ParseXS::Utilities::looks_like_MODULE_line(
666-
$pxs->{lastline});
665+
if (ExtUtils::ParseXS::Utilities::looks_like_MODULE_line(
666+
$pxs->{lastline}))
667+
{
668+
# the fetch_para() regime in place in the XS part of the file
669+
# expects this to have been chomped
670+
chomp $pxs->{lastline};
671+
return 1;
672+
}
667673

668674
my $node =
669675
$pxs->{lastline} =~ /^=/

0 commit comments

Comments
 (0)