Skip to content

Commit 1ae6ead

Browse files
John Lightseyjkeenan
John Lightsey
authored andcommitted
Switch most open() calls to three-argument form.
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
1 parent 7527883 commit 1ae6ead

File tree

187 files changed

+406
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+406
-406
lines changed

Cross/generate_config_sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if ($config eq "") {
4444
die("Please run me as generate_config_sh path/to/original/config.sh");
4545
}
4646

47-
open(FILE, "$config") || die("Unable to open $config");
47+
open(FILE, '<', $config) || die("Unable to open $config");
4848

4949
my $line_in;
5050
while ($line_in = <FILE>) {

NetWare/config_h.PL

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $patchlevel =~ s|~VERSION~|$Config{version}|g;
1919
$patchlevel ||= $Config{version};
2020
$patchlevel = qq["$patchlevel"];
2121

22-
open(SH,"<$name") || die "Cannot open $name:$!";
22+
open(SH,'<',$name) || die "Cannot open $name:$!";
2323
while (<SH>)
2424
{
2525
last if /^sed/;
@@ -42,7 +42,7 @@ eval $str;
4242
4343
die "$str:$@" if $@;
4444
45-
open(H,">$file.new") || die "Cannot open $file.new:$!";
45+
open(H,'>',"$file.new") || die "Cannot open $file.new:$!";
4646
binmode H; # no CRs (which cause a spurious rebuild)
4747
while (<SH>)
4848
{

NetWare/config_sh.PL

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ sub loadopts {
1818
shift @ARGV;
1919
my $optfile = shift @ARGV;
2020
local (*F);
21-
open OPTF, $optfile or die "Can't open $optfile: $!\n";
21+
open OPTF, '<', $optfile or die "Can't open $optfile: $!\n";
2222
my @opts;
2323
chomp(my $line = <OPTF>);
2424
my @vars = split(/\t+~\t+/, $line);
@@ -43,7 +43,7 @@ while (@{$optref} && $optref->[0] =~ /^([\w_]+)=(.*)$/) {
4343
my $pl_h = '../patchlevel.h';
4444

4545
if (-e $pl_h) {
46-
open PL, "<$pl_h" or die "Can't open $pl_h: $!";
46+
open PL, '<', $pl_h or die "Can't open $pl_h: $!";
4747
while (<PL>) {
4848
if (/^#\s*define\s+(PERL_\w+)\s+([\d.]+)/) {
4949
$opt{$1} = $2;

NetWare/t/NWModify.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ sub Process_File
8585
# Do the processing only if the file has '.t' extension.
8686
if($ext eq '.t') {
8787

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

9191
foreach $Line(@ARRAY) # Get each line of the file.

NetWare/t/NWScripts.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# Open once in write mode since later files are opened in append mode,
3131
# and if there already exists a file with the same name, all further opens
3232
# will append to that file!!
33-
open(FHW, "> $IntAutoScript") or die "Unable to open the file, $IntAutoScript for writing.\n";
33+
open(FHW, '>', $IntAutoScript) or die "Unable to open the file, $IntAutoScript for writing.\n";
3434
seek(FHW, 0, 0); # seek to the beginning of the file.
3535
close FHW; # close the file.
3636
}
@@ -39,7 +39,7 @@
3939

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

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

4545
$version = sprintf("%vd",$^V);
@@ -67,7 +67,7 @@
6767
}
6868

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

7373
$pos = tell(FHW);
@@ -164,7 +164,7 @@
164164
$IntAutoScript = "t/".$DirItem.".pl";
165165

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

170170
# Write into the intermediary auto script.

Porting/Maintainers.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION);
2222
show_results process_options files_to_modules
2323
finish_tap_output
2424
reload_manifest);
25-
$VERSION = 0.11;
25+
$VERSION = 0.12;
2626

2727
require Exporter;
2828

@@ -41,7 +41,7 @@ sub reload_manifest {
4141
$manifest_path = "../MANIFEST";
4242
}
4343

44-
if (open(my $manfh, $manifest_path )) {
44+
if (open(my $manfh, '<', $manifest_path )) {
4545
while (<$manfh>) {
4646
if (/^(\S+)/) {
4747
$MANIFEST{$1}++;

Porting/add-package.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
### update the manifest
375375
{ my $file = $Repo . '/MANIFEST';
376376
my @manifest;
377-
{ open my $fh, "<$file" or die "Could not open $file: $!";
377+
{ open my $fh, '<', $file or die "Could not open $file: $!";
378378
@manifest = <$fh>;
379379
close $fh;
380380
}
@@ -414,7 +414,7 @@
414414
push @manifest, values %pkg_files;
415415
416416
{ chmod 0644, $file;
417-
open my $fh, ">$file" or die "Could not open $file for writing: $!";
417+
open my $fh, '>', $file or die "Could not open $file for writing: $!";
418418
#print $fh sort { lc $a cmp lc $b } @manifest;
419419
### XXX stolen from pod/buildtoc:sub do_manifest
420420
print $fh

Porting/check83.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sub eight_dot_three {
4545

4646
my %dir;
4747

48-
if (open(MANIFEST, "MANIFEST")) {
48+
if (open(MANIFEST, '<', 'MANIFEST')) {
4949
while (<MANIFEST>) {
5050
chomp;
5151
s/\s.+//;

Porting/checkAUTHORS.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ sub read_authors_files {
215215
return unless (@authors);
216216
my (%count, %raw);
217217
foreach my $filename (@authors) {
218-
open FH, "<$filename" or die "Can't open $filename: $!";
218+
open FH, '<', $filename or die "Can't open $filename: $!";
219219
binmode FH, ':encoding(UTF-8)';
220220
while (<FH>) {
221221
next if /^\#/;
@@ -661,6 +661,7 @@ sub _raw_address {
661661
jbuehler\100hekimian.com jhpb\100hekimian.com
662662
jcromie\100100divsol.com jcromie\100cpan.org
663663
+ jim.cromie\100gmail.com
664+
jd\100cpanel.net lightsey\100debian.org
664665
jdhedden\100cpan.org jerry\100hedden.us
665666
+ jdhedden\1001979.usna.com
666667
+ jdhedden\100gmail.com

Porting/checkVERSION.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sub parse_file {
2424

2525
my $result;
2626

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

2929
my $inpod = 0;
3030
while (<FH>) {

Porting/checkansi.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
find(sub {
5151
/\.([ch]|xs)$/ or return;
5252

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

5656
while (defined(my $line = <$fh>)) {

Porting/checkcfguse.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
print STDERR "$0: Looking for symbols...\n";
4848
for my $pat (@PAT) {
4949
for my $fn (map { glob($_) } @{ $pat->[0] }) {
50-
if (open(my $fh, $fn)) {
50+
if (open(my $fh, '<', $fn)) {
5151
while (<$fh>) {
5252
for my $p (@$pat) {
5353
for my $sym (/$p/g) {
@@ -70,7 +70,7 @@
7070

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

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

7575
my %found;
7676
while (<$mani>) {
@@ -80,7 +80,7 @@
8080
# from metaconfig generated files that refer to
8181
# the config symbols, and from pods.
8282
next if $fn =~ m{^(?:config_h.SH|Configure|configure\.com|Porting/(?:config|Glossary)|(?:NetWare|plan9|win32)/(?:config|(?:GNU)?[Mm]akefile)|uconfig)|\.pod$};
83-
open my $fh, $fn or die qq[$0: Failed to open $fn: $!];
83+
open my $fh, '<', $fn or die qq[$0: Failed to open $fn: $!];
8484
while (<$fh>) {
8585
while (/\b($SYM)\b/go) {
8686
$found{$1}{$fn}++;

Porting/config_h.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use warnings;
1616

1717
my ($cSH, $ch, @ch, %ch) = ("config_h.SH");
18-
open $ch, "<$cSH" or die "Cannot open $cSH: $!\n";
18+
open $ch, '<', $cSH or die "Cannot open $cSH: $!\n";
1919
{ local $/ = "\n\n";
2020
@ch = <$ch>;
2121
close $ch;
@@ -68,7 +68,7 @@ ()
6868
push @ch, ";;\nesac\n";
6969

7070

71-
open $ch, "> $cSH" or die "Cannot write $cSH: $!\n";
71+
open $ch, '>', $cSH or die "Cannot write $cSH: $!\n";
7272
print $ch <<EOW;
7373
#!/bin/sh
7474
#

Porting/corecpan.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ()
5858

5959
# Load the package details. All of them.
6060
my %cpanversions;
61-
open my $fh, $packagefile or die $!;
61+
open my $fh, '<', $packagefile or die $!;
6262
while (<$fh>) {
6363
my ($p, $v) = split ' ';
6464
next if 1../^\s*$/; # skip header

Porting/leakfinder.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
=~ s/\0/'."\\0".'/grid;
3232
$prog = <<end;
3333
open oUt, ">&", STDOUT;
34-
open STDOUT, ">/dev/null";
35-
open STDIN, "</dev/null";
36-
open STDERR, ">/dev/null";
34+
open STDOUT, ">", "/dev/null";
35+
open STDIN, "<", "/dev/null";
36+
open STDERR, ">", "/dev/null";
3737
\$unused_variable = '$q';
3838
eval \$unused_variable while \$also_unused++ < 4;
3939
print oUt sv_count, "\n";

Porting/makerel

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $relroot = defined $opts{r} ? $opts{r} : "..";
4848
die "Must be in root of the perl source tree.\n"
4949
unless -f "./MANIFEST" and -f "patchlevel.h";
5050

51-
open PATCHLEVEL,"<patchlevel.h" or die;
51+
open PATCHLEVEL, '<', 'patchlevel.h' or die;
5252
my @patchlevel_h = <PATCHLEVEL>;
5353
close PATCHLEVEL;
5454
my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h;

Porting/manicheck

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use strict;
88
use warnings;
99
use File::Find;
1010

11-
open my $fh, 'MANIFEST' or die "Can't read MANIFEST: $!\n";
11+
open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
1212
my @files = map { (split)[0] } <$fh>;
1313
close $fh;
1414
for (@files) {

Porting/sync-with-cpan

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Archive::Tar->extract_archive( $new_file );
290290
# ensure 'make' will update all files
291291
my $t= time;
292292
for my $file (find_type_f($new_dir)) {
293-
open(my $fh,">>$file") || die "Cannot write $file:$!";
293+
open(my $fh,'>>',$file) || die "Cannot write $file:$!";
294294
close($fh);
295295
utime($t,$t,$file);
296296
};

autodoc.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ sub output {
355355
while (my $line = <$fh>) {
356356
next unless my ($file) = $line =~ /^(\S+\.[ch])\t/;
357357
358-
open F, "< $file" or die "Cannot open $file for docs: $!\n";
358+
open F, '<', $file or die "Cannot open $file for docs: $!\n";
359359
$curheader = "Functions in file $file\n";
360360
autodoc(\*F,$file);
361361
close F or die "Error closing $file: $!\n";

charclass_invlists.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -91515,7 +91515,7 @@ static const U8 WB_table[24][24] = {
9151591515
#endif /* defined(PERL_IN_REGEXEC_C) */
9151691516

9151791517
/* Generated from:
91518-
* f1951e655fd5fa35478f641663ef164146d743362998b01378327afac5f20270 lib/Unicode/UCD.pm
91518+
* 59e717586b720a821ee0d7397679d5322e38b49f6fb7840545aedf669c733b70 lib/Unicode/UCD.pm
9151991519
* 47cb62a53beea6d0263e2147331c7e751853c9327225d95bbe2d9e1dc3e1aa44 lib/unicore/ArabicShaping.txt
9152091520
* 153f0a100c315f9f3945e78f57137611d36c44b3a975919c499fd403413fede8 lib/unicore/BidiBrackets.txt
9152191521
* fbe806975c1bf9fc9960bbaa39ff6290c42c7da8315f9cd459109b024cc1c485 lib/unicore/BidiMirroring.txt
@@ -91561,5 +91561,5 @@ static const U8 WB_table[24][24] = {
9156191561
* 066d6e75f95cf6794161c8ac0b1a40990277de90eefb913be2e675a7cba38d59 lib/unicore/mktables
9156291562
* cdecb300baad839a6f62791229f551a4fa33f3cbdca08e378dc976466354e778 lib/unicore/version
9156391563
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
91564-
* 6697977221bf632720408ca9a1a934e43d5d8e51c870532cec3ebdb3e3ba80c6 regen/mk_invlists.pl
91564+
* ed40040566a4f1d6b0d912dda2159c1460e0093b318d90626ab9aa513a53b15d regen/mk_invlists.pl
9156591565
* ex: set ro: */

configpm

+5-5
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ my $quote;
216216
my %seen_quotes;
217217
{
218218
my ($name, $val);
219-
open(CONFIG_SH, $Config_SH) || die "Can't open $Config_SH: $!";
219+
open(CONFIG_SH, '<', $Config_SH) || die "Can't open $Config_SH: $!";
220220
while (<CONFIG_SH>) {
221221
next if m:^#!/bin/sh:;
222222

@@ -527,7 +527,7 @@ $heavy_txt .= join('', @non_v) . "\n";
527527

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

635-
if (open(my $fh, "cflags")) {
635+
if (open(my $fh, '<', 'cflags')) {
636636
my $ccwarnflags;
637637
my $ccstdflags;
638638
while (<$fh>) {
@@ -838,7 +838,7 @@ tie %%Config, 'Config', {
838838
ENDOFTIE
839839

840840

841-
open(CONFIG_POD, ">$Config_POD") or die "Can't open $Config_POD: $!";
841+
open(CONFIG_POD, '>', $Config_POD) or die "Can't open $Config_POD: $!";
842842
print CONFIG_POD <<'ENDOFTAIL';
843843
=head1 NAME
844844

@@ -991,7 +991,7 @@ in such cases.
991991
ENDOFTAIL
992992

993993
if ($Opts{glossary}) {
994-
open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!";
994+
open(GLOS, '<', $Glossary) or die "Can't open $Glossary: $!";
995995
}
996996
my %seen = ();
997997
my $text = 0;

dist/Devel-SelfStubber/lib/Devel/SelfStubber.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require SelfLoader;
44
@ISA = qw(SelfLoader);
55
@EXPORT = 'AUTOLOAD';
66
$JUST_STUBS = 1;
7-
$VERSION = 1.05;
7+
$VERSION = 1.06;
88
sub Version {$VERSION}
99

1010
# Use as
@@ -39,7 +39,7 @@ sub stub {
3939
my (@BEFORE_DATA, @AFTER_DATA, @AFTER_END);
4040
@DATA = @STUBS = ();
4141

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

0 commit comments

Comments
 (0)