# them into $self led to build problems. In most cases, strings being
# 'eval'-ed contain the variables' names hard-coded.
our (
- $FH, $Package, $func_name, $Full_func_name, $pname, $ALIAS,
+ $Package, $func_name, $Full_func_name, $pname, $ALIAS,
);
our $self = bless {} => __PACKAGE__;
prototypes => 0,
typemap => [],
versioncheck => 1,
+ FH => Symbol::gensym(),
%options,
);
$args{except} = $args{except} ? ' TRY' : '';
}
@{ $self->{XSStack} } = ({type => 'none'});
$self->{InitFileCode} = [ @ExtUtils::ParseXS::Constants::InitFileCode ];
- $FH = $ExtUtils::ParseXS::Constants::FH;
$self->{Overload} = $ExtUtils::ParseXS::Constants::Overload;
$self->{errors} = $ExtUtils::ParseXS::Constants::errors;
$self->{Fallback} = $ExtUtils::ParseXS::Constants::Fallback;
# Open the input file (using $self->{filename} which
# is a basename'd $args{filename} due to chdir above)
- open($FH, $self->{filename}) or die "cannot open $self->{filename}: $!\n";
+ open($self->{FH}, '<', $self->{filename}) or die "cannot open $self->{filename}: $!\n";
firstmodule:
- while (<$FH>) {
+ while (readline($self->{FH})) {
if (/^=/) {
my $podstartline = $.;
do {
next firstmodule
}
- } while (<$FH>);
+ } while (readline($self->{FH}));
# At this point $. is at end of file so die won't state the start
# of the problem, and as we haven't yet read any lines &death won't
# show the correct line in the message either.
chdir($orig_cwd);
select($orig_fh);
untie *PSEUDO_STDOUT if tied *PSEUDO_STDOUT;
- close $FH;
+ close $self->{FH};
return 1;
}
LineNo => $self->{line_no},
Filename => $self->{filename},
Filepathname => $self->{filepathname},
- Handle => $FH,
+ Handle => $self->{FH},
IsPipe => scalar($self->{filename} =~ /\|\s*$/),
%args,
});
$self->PushXSStack();
- $FH = Symbol::gensym();
+ $self->{FH} = Symbol::gensym();
# open the new file
- open ($FH, "$_") or $self->death("Cannot open '$_': $!");
+ open ($self->{FH}, '<', $_) or $self->death("Cannot open '$_': $!");
print Q(<<"EOF");
#
# non-blank line
# skip leading blank lines
- while (<$FH>) {
+ while (readline($self->{FH})) {
last unless /^\s*$/;
}
$self->PushXSStack( IsPipe => 1 );
- $FH = Symbol::gensym();
+ $self->{FH} = Symbol::gensym();
# If $^X is used in INCLUDE_COMMAND, we know it's supposed to be
# the same perl interpreter as we're currently running
s/^\s*\$\^X/$^X/;
# open the new file
- open ($FH, "-|", "$_")
+ open ($self->{FH}, "-|", $_)
or $self->death( $self, "Cannot run command '$_' to include its output: $!");
print Q(<<"EOF");
# non-blank line
# skip leading blank lines
- while (<$FH>) {
+ while (readline($self->{FH})) {
last unless /^\s*$/;
}
--$self->{IncludedFiles}->{$self->{filename}}
unless $isPipe;
- close $FH;
+ close $self->{FH};
- $FH = $data->{Handle};
+ $self->{FH} = $data->{Handle};
# $filename is the leafname, which for some reason isused for diagnostic
# messages, whereas $filepathname is the full pathname, and is used for
# #line directives.
$text;
}
-# Read next xsub into @{ $self->{line} } from ($lastline, <$FH>).
+# Read next xsub into @{ $self->{line} } from ($lastline, readline($self->{FH})).
sub fetch_para {
my $self = shift;
for (;;) {
# Skip embedded PODs
while ($self->{lastline} =~ /^=/) {
- while ($self->{lastline} = <$FH>) {
+ while ($self->{lastline} = readline($self->{FH})) {
last if ($self->{lastline} =~ /^=cut\s*$/);
}
$self->death("Error: Unterminated pod") unless $self->{lastline};
- $self->{lastline} = <$FH>;
+ $self->{lastline} = readline($self->{FH});
chomp $self->{lastline};
$self->{lastline} =~ s/^\s+$//;
}
my $end_marker = quotemeta(defined($1) ? $2 : $3);
my @tmaplines;
while (1) {
- $self->{lastline} = <$FH>;
+ $self->{lastline} = readline($self->{FH});
$self->death("Error: Unterminated typemap") if not defined $self->{lastline};
last if $self->{lastline} =~ /^$end_marker\s*$/;
push @tmaplines, $self->{lastline};
);
$self->{typemap}->merge(typemap => $tmap, replace => 1);
- last unless defined($self->{lastline} = <$FH>);
+ last unless defined($self->{lastline} = readline($self->{FH}));
next;
}
}
# Read next line and continuation lines
- last unless defined($self->{lastline} = <$FH>);
+ last unless defined($self->{lastline} = readline($self->{FH}));
$self->{lastline_no} = $.;
my $tmp_line;
$self->{lastline} .= $tmp_line
- while ($self->{lastline} =~ /\\$/ && defined($tmp_line = <$FH>));
+ while ($self->{lastline} =~ /\\$/ && defined($tmp_line = readline($self->{FH})));
chomp $self->{lastline};
$self->{lastline} =~ s/^\s+$//;