Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Switch most open() calls to three-argument form.
Browse files Browse the repository at this point in the history
Switch from two-argument form.  Filehandle cloning is still done with the two
argument form for backward compatibility.

Committer:  Get all porting tests to pass.  Increment some $VERSIONs.
Run: ./perl -Ilib regen/mk_invlists.pl; ./perl -Ilib regen/regcharclass.pl

For: RT #130122

[cperl did 50% of it already 2 years ago. This is now the rest
with mostly static filenames.]
  • Loading branch information
John Lightsey authored and Reini Urban committed Jan 14, 2017
1 parent a54cb29 commit 3e8b622
Show file tree
Hide file tree
Showing 185 changed files with 399 additions and 398 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -625,6 +625,7 @@ John Holdsworth <coldwave@bigfoot.com>
John Hughes <john@AtlanTech.COM>
John Kristian <jmk2001@engineer.com>
John L. Allen <allen@grumman.com>
John Lightsey <jd@cpanel.net>
John Macdonald <jmm@revenge.elegant.com>
John Malmberg <wb8tyw@gmail.com>
John Nolan <jpnolan@Op.Net>
Expand Down
2 changes: 1 addition & 1 deletion Cross/generate_config_sh
Expand Up @@ -44,7 +44,7 @@ if ($config eq "") {
die("Please run me as generate_config_sh path/to/original/config.sh");
}

open(FILE, "$config") || die("Unable to open $config");
open(FILE, '<', $config) || die("Unable to open $config");

my $line_in;
while ($line_in = <FILE>) {
Expand Down
4 changes: 2 additions & 2 deletions NetWare/config_h.PL
Expand Up @@ -19,7 +19,7 @@ $patchlevel =~ s|~VERSION~|$Config{version}|g;
$patchlevel ||= $Config{version};
$patchlevel = qq["$patchlevel"];

open(SH,"<$name") || die "Cannot open $name:$!";
open(SH,'<',$name) || die "Cannot open $name:$!";
while (<SH>)
{
last if /^sed/;
Expand All @@ -42,7 +42,7 @@ eval $str;
die "$str:$@" if $@;
open(H,">$file.new") || die "Cannot open $file.new:$!";
open(H,'>',"$file.new") || die "Cannot open $file.new:$!";
binmode H; # no CRs (which cause a spurious rebuild)
while (<SH>)
{
Expand Down
4 changes: 2 additions & 2 deletions NetWare/config_sh.PL
Expand Up @@ -18,7 +18,7 @@ sub loadopts {
shift @ARGV;
my $optfile = shift @ARGV;
local (*F);
open OPTF, $optfile or die "Can't open $optfile: $!\n";
open OPTF, '<', $optfile or die "Can't open $optfile: $!\n";
my @opts;
chomp(my $line = <OPTF>);
my @vars = split(/\t+~\t+/, $line);
Expand All @@ -43,7 +43,7 @@ while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
my $pl_h = '../patchlevel.h';

if (-e $pl_h) {
open PL, "<$pl_h" or die "Can't open $pl_h: $!";
open PL, '<', $pl_h or die "Can't open $pl_h: $!";
while (<PL>) {
if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
$opt{$1} = $2;
Expand Down
2 changes: 1 addition & 1 deletion NetWare/t/NWModify.pl
Expand Up @@ -85,7 +85,7 @@ sub Process_File
# Do the processing only if the file has '.t' extension.
if($ext eq '.t') {

open(FH, "+< $FileToProcess") or die "Unable to open the file, $FileToProcess for reading and writing.\n";
open(FH, '+<', $FileToProcess) or die "Unable to open the file, $FileToProcess for reading and writing.\n";
@ARRAY = <FH>; # Get the contents of the file into an array.

foreach $Line(@ARRAY) # Get each line of the file.
Expand Down
8 changes: 4 additions & 4 deletions NetWare/t/NWScripts.pl
Expand Up @@ -30,7 +30,7 @@
# Open once in write mode since later files are opened in append mode,
# and if there already exists a file with the same name, all further opens
# will append to that file!!
open(FHW, "> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for writing.\n";
open(FHW, '>', $IntAutoScript) or die "Unable to open the file, $IntAutoScript for writing.\n";
seek(FHW, 0, 0); # seek to the beginning of the file.
close FHW; # close the file.
}
Expand All @@ -39,7 +39,7 @@

print "Generating t/nwauto.pl ...\n\n\n";

open(FHWA, "> t/nwauto.pl") or die "Unable to open the file, t/nwauto.pl for writing.\n";
open(FHWA, '>', 't/nwauto.pl') or die "Unable to open the file, t/nwauto.pl for writing.\n";
seek(FHWA, 0, 0); # seek to the beginning of the file.

$version = sprintf("%vd",$^V);
Expand Down Expand Up @@ -67,7 +67,7 @@
}

# Write into the intermediary auto script.
open(FHW, ">> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for appending.\n";
open(FHW, '>>', $IntAutoScript) or die "Unable to open the file, $IntAutoScript for appending.\n";
seek(FHW, 0, 2); # seek to the end of the file.

$pos = tell(FHW);
Expand Down Expand Up @@ -164,7 +164,7 @@
$IntAutoScript = "t/".$DirItem.".pl";

# Write into the intermediary auto script.
open(FHW, ">> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for appending.\n";
open(FHW, '>>', $IntAutoScript) or die "Unable to open the file, $IntAutoScript for appending.\n";
seek(FHW, 0, 2); # seek to the end of the file.

# Write into the intermediary auto script.
Expand Down
4 changes: 2 additions & 2 deletions Porting/Maintainers.pm
Expand Up @@ -22,7 +22,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION);
show_results process_options files_to_modules
finish_tap_output
reload_manifest);
$VERSION = 0.11;
$VERSION = 0.12;

require Exporter;

Expand All @@ -41,7 +41,7 @@ sub reload_manifest {
$manifest_path = "../MANIFEST";
}

if (open(my $manfh, $manifest_path )) {
if (open(my $manfh, '<', $manifest_path )) {
while (<$manfh>) {
if (/^(\S+)/) {
$MANIFEST{$1}++;
Expand Down
4 changes: 2 additions & 2 deletions Porting/add-package.pl
Expand Up @@ -374,7 +374,7 @@
### update the manifest
{ my $file = $Repo . '/MANIFEST';
my @manifest;
{ open my $fh, "<$file" or die "Could not open $file: $!";
{ open my $fh, '<', $file or die "Could not open $file: $!";
@manifest = <$fh>;
close $fh;
}
Expand Down Expand Up @@ -414,7 +414,7 @@
push @manifest, values %pkg_files;
{ chmod 0644, $file;
open my $fh, ">$file" or die "Could not open $file for writing: $!";
open my $fh, '>', $file or die "Could not open $file for writing: $!";
#print $fh sort { lc $a cmp lc $b } @manifest;
### XXX stolen from pod/buildtoc:sub do_manifest
print $fh
Expand Down
2 changes: 1 addition & 1 deletion Porting/check83.pl
Expand Up @@ -45,7 +45,7 @@ sub eight_dot_three {

my %dir;

if (open(MANIFEST, "MANIFEST")) {
if (open(MANIFEST, '<', 'MANIFEST')) {
while (<MANIFEST>) {
chomp;
s/\s.+//;
Expand Down
3 changes: 2 additions & 1 deletion Porting/checkAUTHORS.pl
Expand Up @@ -232,7 +232,7 @@ sub read_authors_files {
return unless (@authors);
my (%count, %raw);
foreach my $filename (@authors) {
open FH, "<", $filename or die "Can't open $filename: $!";
open FH, '<', $filename or die "Can't open $filename: $!";
binmode FH, ':encoding(UTF-8)';
while (<FH>) {
next if /^\#/;
Expand Down Expand Up @@ -677,6 +677,7 @@ sub _raw_address {
jbuehler\100hekimian.com jhpb\100hekimian.com
jcromie\100100divsol.com jcromie\100cpan.org
+ jim.cromie\100gmail.com
jd\100cpanel.net lightsey\100debian.org
jdhedden\100cpan.org jerry\100hedden.us
+ jdhedden\1001979.usna.com
+ jdhedden\100gmail.com
Expand Down
2 changes: 1 addition & 1 deletion Porting/checkVERSION.pl
Expand Up @@ -24,7 +24,7 @@ sub parse_file {

my $result;

open(FH,$parsefile) or warn "Could not open '$parsefile': $!";
open(FH,'<',$parsefile) or warn "Could not open '$parsefile': $!";

my $inpod = 0;
while (<FH>) {
Expand Down
2 changes: 1 addition & 1 deletion Porting/checkansi.pl
Expand Up @@ -50,7 +50,7 @@
find(sub {
/\.([ch]|xs)$/ or return;

my $fh = IO::File->new($_) or die "$_: $!\n";
my $fh = IO::File->new($_, 'r') or die "$_: $!\n";
my $ll = '';

while (defined(my $line = <$fh>)) {
Expand Down
6 changes: 3 additions & 3 deletions Porting/checkcfguse.pl
Expand Up @@ -47,7 +47,7 @@
print STDERR "$0: Looking for symbols...\n";
for my $pat (@PAT) {
for my $fn (map { glob($_) } @{ $pat->[0] }) {
if (open(my $fh, $fn)) {
if (open(my $fh, '<', $fn)) {
while (<$fh>) {
for my $p (@$pat) {
for my $sym (/$p/g) {
Expand All @@ -70,7 +70,7 @@

my $SYM = join("|", sort { length($b) <=> length($a) || $a cmp $b } keys %SYM);

open(my $mani, "MANIFEST") or die "$0: Failed to open MANIFEST\n";
open(my $mani, '<', "MANIFEST") or die "$0: Failed to open MANIFEST\n";

my %found;
while (<$mani>) {
Expand All @@ -80,7 +80,7 @@
# from metaconfig generated files that refer to
# the config symbols, and from pods.
next if $fn =~ m{^(?:config_h.SH|Configure|configure\.com|Porting/(?:config|Glossary)|(?:NetWare|plan9|win32)/(?:config|(?:GNU)?[Mm]akefile)|uconfig)|\.pod$};
open my $fh, $fn or die qq[$0: Failed to open $fn: $!];
open my $fh, '<', $fn or die qq[$0: Failed to open $fn: $!];
while (<$fh>) {
while (/\b($SYM)\b/go) {
$found{$1}{$fn}++;
Expand Down
4 changes: 2 additions & 2 deletions Porting/config_h.pl
Expand Up @@ -15,7 +15,7 @@
use warnings;

my ($cSH, $ch, @ch, %ch) = ("config_h.SH");
open $ch, "<$cSH" or die "Cannot open $cSH: $!\n";
open $ch, '<', $cSH or die "Cannot open $cSH: $!\n";
{ local $/ = "\n\n";
@ch = <$ch>;
close $ch;
Expand Down Expand Up @@ -68,7 +68,7 @@ ()
push @ch, ";;\nesac\n";


open $ch, "> $cSH" or die "Cannot write $cSH: $!\n";
open $ch, '>', $cSH or die "Cannot write $cSH: $!\n";
print $ch <<EOW;
#!/bin/sh
#
Expand Down
2 changes: 1 addition & 1 deletion Porting/corecpan.pl
Expand Up @@ -58,7 +58,7 @@ ()

# Load the package details. All of them.
my %cpanversions;
open my $fh, $packagefile or die $!;
open my $fh, '<', $packagefile or die $!;
while (<$fh>) {
my ($p, $v) = split ' ';
next if 1../^\s*$/; # skip header
Expand Down
6 changes: 3 additions & 3 deletions Porting/leakfinder.pl
Expand Up @@ -31,9 +31,9 @@
=~ s/\0/'."\\0".'/grid;
$prog = <<end;
open oUt, ">&", STDOUT;
open STDOUT, ">/dev/null";
open STDIN, "</dev/null";
open STDERR, ">/dev/null";
open STDOUT, ">", "/dev/null";
open STDIN, "<", "/dev/null";
open STDERR, ">", "/dev/null";
\$unused_variable = '$q';
eval \$unused_variable while \$also_unused++ < 4;
print oUt sv_count, "\n";
Expand Down
2 changes: 1 addition & 1 deletion Porting/makerel
Expand Up @@ -48,7 +48,7 @@ $relroot = defined $opts{r} ? $opts{r} : "..";
die "Must be in root of the perl source tree.\n"
unless -f "./MANIFEST" and -f "patchlevel.h";

open PATCHLEVEL,"<patchlevel.h" or die;
open PATCHLEVEL, '<', 'patchlevel.h' or die;
my @patchlevel_h = <PATCHLEVEL>;
close PATCHLEVEL;
my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h;
Expand Down
2 changes: 1 addition & 1 deletion Porting/manicheck
Expand Up @@ -8,7 +8,7 @@ use strict;
use warnings;
use File::Find;

open my $fh, 'MANIFEST' or die "Can't read MANIFEST: $!\n";
open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
my @files = map { (split)[0] } <$fh>;
close $fh;
for (@files) {
Expand Down
2 changes: 1 addition & 1 deletion Porting/sync-with-cpan
Expand Up @@ -368,7 +368,7 @@ for my $module (@modules) {
next FILE if $base =~ $qr;
}
# How to deal with unwritable files?
open(my $fh, ">>", $file)
open(my $fh, '>>', $file)
|| warn "Cannot write $file:$!";
close($fh);
utime($t,$t,$file);
Expand Down
2 changes: 1 addition & 1 deletion autodoc.pl
Expand Up @@ -355,7 +355,7 @@ sub output {
while (my $line = <$fh>) {
next unless my ($file) = $line =~ /^(\S+\.[ch])\t/;
open F, "< $file" or die "Cannot open $file for docs: $!\n";
open F, '<', $file or die "Cannot open $file for docs: $!\n";
$curheader = "Functions in file $file\n";
autodoc(\*F,$file);
close F or die "Error closing $file: $!\n";
Expand Down
4 changes: 2 additions & 2 deletions charclass_invlists.h
Expand Up @@ -91533,7 +91533,7 @@ static const U8 WB_table[24][24] = {
#endif /* defined(PERL_IN_REGEXEC_C) */

/* Generated from:
* c7213e6574cb18e168abd7821765b6a2b15472126fa44a3d234c15f30529967f lib/Unicode/UCD.pm
* 69b5ebb58a900be2476eb02ac79a2fed4d377e179a7cc9f9e0463908f3cd17d1 lib/Unicode/UCD.pm
* 47cb62a53beea6d0263e2147331c7e751853c9327225d95bbe2d9e1dc3e1aa44 lib/unicore/ArabicShaping.txt
* 153f0a100c315f9f3945e78f57137611d36c44b3a975919c499fd403413fede8 lib/unicore/BidiBrackets.txt
* fbe806975c1bf9fc9960bbaa39ff6290c42c7da8315f9cd459109b024cc1c485 lib/unicore/BidiMirroring.txt
Expand Down Expand Up @@ -91579,5 +91579,5 @@ static const U8 WB_table[24][24] = {
* 2484cb4361ec91414e5c8a069ef66fdf9f1465e3db71e54ba974b77cee4de9e5 lib/unicore/mktables
* cdecb300baad839a6f62791229f551a4fa33f3cbdca08e378dc976466354e778 lib/unicore/version
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
* 6697977221bf632720408ca9a1a934e43d5d8e51c870532cec3ebdb3e3ba80c6 regen/mk_invlists.pl
* ed40040566a4f1d6b0d912dda2159c1460e0093b318d90626ab9aa513a53b15d regen/mk_invlists.pl
* ex: set ro: */
10 changes: 5 additions & 5 deletions configpm
Expand Up @@ -215,7 +215,7 @@ my $quote;
my %seen_quotes;
{
my ($name, $val);
open(CONFIG_SH, $Config_SH) || die "Can't open $Config_SH: $!";
open(CONFIG_SH, '<', $Config_SH) || die "Can't open $Config_SH: $!";
while (<CONFIG_SH>) {
next if m:^#!/bin/sh:;

Expand Down Expand Up @@ -532,7 +532,7 @@ $heavy_txt .= join('', @non_v) . "\n";

# copy config summary format from the myconfig.SH script
$heavy_txt .= "our \$summary = <<'!END!';\n";
open(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!";
open(MYCONFIG,'<','myconfig.SH') || die "open myconfig.SH failed: $!";
1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
do { $heavy_txt .= $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
close(MYCONFIG);
Expand Down Expand Up @@ -669,7 +669,7 @@ foreach my $prefix (qw(libs libswanted)) {
$heavy_txt .= "${prefix}_nolargefiles='$value'\n";
}

if (open(my $fh, "cflags")) {
if (open(my $fh, '<', 'cflags')) {
my $ccwarnflags;
my $ccstdflags;
while (<$fh>) {
Expand Down Expand Up @@ -884,7 +884,7 @@ tie %%Config, 'Config', {
ENDOFTIE


open(CONFIG_POD, ">$Config_POD") or die "Can't open $Config_POD: $!";
open(CONFIG_POD, '>', $Config_POD) or die "Can't open $Config_POD: $!";
print CONFIG_POD <<'ENDOFTAIL';
=head1 NAME

Expand Down Expand Up @@ -1037,7 +1037,7 @@ in such cases.
ENDOFTAIL

if ($Opts{glossary}) {
open(GLOS, "<", $Glossary) or die "Can't open $Glossary: $!";
open(GLOS, '<', $Glossary) or die "Can't open $Glossary: $!";
}
my %seen = ();
my $text = 0;
Expand Down
4 changes: 2 additions & 2 deletions dist/Devel-SelfStubber/lib/Devel/SelfStubber.pm
Expand Up @@ -4,7 +4,7 @@ require SelfLoader;
@ISA = qw(SelfLoader);
@EXPORT = 'AUTOLOAD';
$JUST_STUBS = 1;
$VERSION = 1.05;
$VERSION = 1.06;
sub Version {$VERSION}

# Use as
Expand Down Expand Up @@ -39,7 +39,7 @@ sub stub {
my (@BEFORE_DATA, @AFTER_DATA, @AFTER_END);
@DATA = @STUBS = ();

open($fh,$mod_file) || die "Unable to open $mod_file";
open($fh,'<',$mod_file) || die "Unable to open $mod_file";
local $/ = "\n";
while(defined ($line = <$fh>) and $line !~ m/^__DATA__/) {
push(@BEFORE_DATA,$line);
Expand Down

0 comments on commit 3e8b622

Please sign in to comment.