require 5.005;
+use IO::File;
+
# Parameters set by configure. Not to be changed. NOTE: assign
# VERSION as string so that eg version 0.30 will print correctly.
my $VERSION = "@VERSION@";
}
}
- if (! open (GM_FILE, "> " . $out_file))
+ my $gm_file = new IO::File "> $out_file";
+ if (! $gm_file)
{
warn "automake: ${am_file}.in: cannot write: $!\n";
$exit_status = 1;
# In case we're running under MSWindows, don't write with CRLF
# (as it causes problems for the dependency-file extraction in
# AM_OUTPUT_DEPENDENCY_COMMANDS).
- binmode GM_FILE;
+ binmode $gm_file;
- print GM_FILE $output_vars;
+ print $gm_file $output_vars;
# We make sure that `all:' is the first target.
- print GM_FILE $output_all;
- print GM_FILE $output_header;
- print GM_FILE $output_rules;
- print GM_FILE $output_trailer;
+ print $gm_file $output_all;
+ print $gm_file $output_header;
+ print $gm_file $output_rules;
+ print $gm_file $output_trailer;
- if (! close (GM_FILE))
+ if (! $gm_file->close)
{
warn "automake: $am_file.in: cannot close: $!\n";
$exit_status = 1;
{
my ($filename) = @_;
- if (! open (TEXI, $filename))
+ my $texi = new IO::File ("< $filename");
+ if (! $texi)
{
&am_error ("couldn't open \`$filename': $!");
return '';
print "automake: reading $filename\n" if $verbose;
my ($outfile, $vfile);
- while (<TEXI>)
+ while ($_ = $texi->getline)
{
if (/^\@setfilename +(\S+)/)
{
}
}
- close (TEXI);
+ $texi->close;
return ($outfile, $vfile);
}
&define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
&push_dist_common ('aclocal.m4');
- if (open (ACLOCAL, '< aclocal.m4'))
+ my $aclocal = new IO::File ("< aclocal.m4");
+ if ($aclocal)
{
- my $line = <ACLOCAL>;
- close (ACLOCAL);
+ my $line = $aclocal->getline;
+ $aclocal->close;
if ($line =~ 'generated automatically by aclocal')
{
sub scan_autoconf_traces
{
my ($filename) = @_;
- local *TRACES;
my $traces = "$ENV{amtraces} ";
$traces .= ' -t AC_LIBSOURCE';
$traces .= ' -t AC_SUBST';
- open (TRACES, "$traces |")
- || die "automake: couldn't open \`$traces': $!\n";
+ my $tracefh = new IO::File ("$traces |");
+ if (! $tracefh)
+ {
+ die "automake: couldn't open \`$traces': $!\n";
+ }
print "automake: reading $traces\n" if $verbose;
- while (<TRACES>)
+ while ($_ = $tracefh->getline)
{
chomp;
my ($file, $line, $macro, @args) = split /:/;
}
}
- close (TRACES)
- || die "automake: close: $traces: $!\n";
+ $tracefh->close
+ || die "automake: close: $traces: $!\n";
}
sub scan_one_autoconf_file
{
my ($filename) = @_;
- local *CONFIGURE;
- open (CONFIGURE, $filename)
- || die "automake: couldn't open \`$filename': $!\n";
+ my $configfh = new IO::File ("< $filename");
+ if (! $configfh)
+ {
+ die "automake: couldn't open \`$filename': $!\n";
+ }
print "automake: reading $filename\n" if $verbose;
-
my ($in_ac_output, $in_ac_replace) = (0, 0);
- while (<CONFIGURE>)
+ while ($_ = $configfh->getline)
{
# Remove comments from current line.
s/\bdnl\b.*$//;
}
}
- close (CONFIGURE);
+ $configfh->close;
}
sub read_am_file
{
my ($amfile) = @_;
- local *AM_FILE;
- open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
+ my $am_file = new IO::File ("< $amfile");
+ if (! $am_file)
+ {
+ die "automake: couldn't open \`$amfile': $!\n";
+ }
print "automake: reading $amfile\n" if $verbose;
my $spacing = '';
my $comment = '';
my $blank = 0;
- while (<AM_FILE>)
+ while ($_ = $am_file->getline)
{
if (/$IGNORE_PATTERN/o)
{
$saw_bk = /\\$/;
}
- $_ = <AM_FILE>;
+ $_ = $am_file->getline;
}
$output_trailer .= $comment;
# Swallow the file and applied the COMMAND.
my $file = $am_dir . '/' . $basename . '.am';
- open (FC_FILE, $file)
- || die "automake: installation error: cannot open \`$file'\n";
+ my $fc_file = new IO::File ("< $file");
+ if (! $fc_file)
+ {
+ die "automake: installation error: cannot open \`$file'\n";
+ }
# Looks stupid?
# print "automake: reading $file\n" if $verbose;
# having performed the $COMMAND, and removed Automake comments.
my $contents = '';
- while (<FC_FILE>)
+ while ($_ = $fc_file->getline)
{
$_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
unless $seen_maint_mode;
$contents .= $_;
}
- close (FC_FILE);
+ $fc_file->close;
# We don't need more than two consecutive new-lines.
$contents =~ s/\n{3,}/\n\n/g;
{
my ($file) = @_;
- open (TOUCH, ">> $file");
- close (TOUCH);
+ my $touch = new IO::File (">> $file");
+ $touch->close;
}
# Glob something. Do this to avoid indentation screwups everywhere we