summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohn Lightsey <lightsey@debian.org>2016-12-23 12:35:45 -0500
committerJames E Keenan <jkeenan@cpan.org>2016-12-23 13:52:28 -0500
commit1ae6ead94905dfee43773cf3b18949c91b33f9d1 (patch)
tree6a54545d46d1ae3f61696e23111a21c736b3b2b5 /lib
parent7527883f8c7b71d808abdbd3cff07f61280a42b5 (diff)
downloadperl-1ae6ead94905dfee43773cf3b18949c91b33f9d1.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/DBM_Filter/t/01error.t2
-rw-r--r--lib/DBM_Filter/t/02core.t2
-rw-r--r--lib/English.t6
-rw-r--r--lib/ExtUtils/Embed.pm4
-rw-r--r--lib/File/Compare.t2
-rw-r--r--lib/File/Copy.t36
-rw-r--r--lib/File/stat.t2
-rw-r--r--lib/SelectSaver.t4
-rw-r--r--lib/Symbol.pm4
-rw-r--r--lib/Tie/Handle/stdhandle.t2
-rw-r--r--lib/Unicode/UCD.pm4
-rw-r--r--lib/diagnostics.pm6
-rw-r--r--lib/h2ph.t2
-rw-r--r--lib/h2xs.t4
-rw-r--r--lib/perl5db.pl18
-rw-r--r--lib/utf8.t2
-rw-r--r--lib/vmsish.t6
17 files changed, 53 insertions, 53 deletions
diff --git a/lib/DBM_Filter/t/01error.t b/lib/DBM_Filter/t/01error.t
index 1aff972b4e..33173f3e7e 100644
--- a/lib/DBM_Filter/t/01error.t
+++ b/lib/DBM_Filter/t/01error.t
@@ -24,7 +24,7 @@ sub writeFile
{
my $filename = shift ;
my $content = shift;
- open F, ">$filename" or croak "Cannot open $filename: $!" ;
+ open F, '>', $filename or croak "Cannot open $filename: $!" ;
print F $content ;
close F;
}
diff --git a/lib/DBM_Filter/t/02core.t b/lib/DBM_Filter/t/02core.t
index a9538e52d1..1f5fef94f1 100644
--- a/lib/DBM_Filter/t/02core.t
+++ b/lib/DBM_Filter/t/02core.t
@@ -22,7 +22,7 @@ sub writeFile
{
my $filename = shift ;
my $content = shift;
- open F, ">DBM_Filter/$filename.pm" or croak "Cannot open $filename: $!" ;
+ open F, '>', "DBM_Filter/$filename.pm" or croak "Cannot open $filename: $!" ;
print F $content ;
close F;
$files{"DBM_Filter/$filename.pm"} ++;
diff --git a/lib/English.t b/lib/English.t
index bed1162677..35a06caacf 100644
--- a/lib/English.t
+++ b/lib/English.t
@@ -36,7 +36,7 @@ $ORS = "\n";
if ($^O ne 'dos') {
pipe(IN, OUT);
} else {
- open(OUT, ">en.tmp");
+ open(OUT, ">", "en.tmp");
}
select(OUT);
$| = 1;
@@ -48,7 +48,7 @@ $ORS = "\n";
my $close = close OUT;
ok( !($close) == $CHILD_ERROR, '$CHILD_ERROR should be false' );
- open(IN, "<en.tmp") if ($^O eq 'dos');
+ open(IN, "<", "en.tmp") if ($^O eq 'dos');
my $foo = <IN>;
like( $foo, qr/ok 7/, '$OFS' );
@@ -129,7 +129,7 @@ is( $keys[1], 'd|e|f', '$SUBSCRIPT_SEPARATOR' );
eval { is( $EXCEPTIONS_BEING_CAUGHT, 1, '$EXCEPTIONS_BEING_CAUGHT' ) };
ok( !$EXCEPTIONS_BEING_CAUGHT, '$EXCEPTIONS_BEING_CAUGHT should be false' );
-eval { local *F; my $f = 'asdasdasd'; ++$f while -e $f; open(F, $f); };
+eval { local *F; my $f = 'asdasdasd'; ++$f while -e $f; open(F, '<', $f); };
is( $OS_ERROR, $ERRNO, '$OS_ERROR' );
ok( $OS_ERROR{ENOENT}, '%OS_ERROR (ENOENT should be set)' );
diff --git a/lib/ExtUtils/Embed.pm b/lib/ExtUtils/Embed.pm
index 9305b5dc13..b26bf7382e 100644
--- a/lib/ExtUtils/Embed.pm
+++ b/lib/ExtUtils/Embed.pm
@@ -10,7 +10,7 @@ use vars qw(@ISA @EXPORT $VERSION
use strict;
# This is not a dual-life module, so no need for development version numbers
-$VERSION = '1.33';
+$VERSION = '1.34';
@ISA = qw(Exporter);
@EXPORT = qw(&xsinit &ldopts
@@ -199,7 +199,7 @@ sub ldopts {
push @archives, $archive;
if(-e ($extra = File::Spec->catdir($_,"auto",$root,"extralibs.ld"))) {
local(*FH);
- if(open(FH, $extra)) {
+ if(open(FH, '<', $extra)) {
my($libs) = <FH>; chomp $libs;
push @potential_libs, split /\s+/, $libs;
}
diff --git a/lib/File/Compare.t b/lib/File/Compare.t
index c8c730d6fe..b7c9d9f7be 100644
--- a/lib/File/Compare.t
+++ b/lib/File/Compare.t
@@ -73,7 +73,7 @@ eval {
{
local $/; #slurp
my $fh;
- open($fh,$README);
+ open($fh,'<',$README);
binmode($fh);
my $data = <$fh>;
print $tfh $data;
diff --git a/lib/File/Copy.t b/lib/File/Copy.t
index 9e49c7d3f0..05590b262f 100644
--- a/lib/File/Copy.t
+++ b/lib/File/Copy.t
@@ -43,14 +43,14 @@ for my $cross_partition_test (0..1) {
}
# First we create a file
- open(F, ">file-$$") or die $!;
+ open(F, ">", "file-$$") or die $!;
binmode F; # for DOSISH platforms, because test 3 copies to stdout
printf F "ok\n";
close F;
copy "file-$$", "copy-$$";
- open(F, "copy-$$") or die $!;
+ open(F, "<", "copy-$$") or die $!;
my $foo = <F>;
close(F);
@@ -65,16 +65,16 @@ for my $cross_partition_test (0..1) {
$TB->current_test($TB->current_test + 1);
unlink "copy-$$" or die "unlink: $!";
- open(F,"file-$$");
+ open(F, "<", "file-$$");
copy(*F, "copy-$$");
- open(R, "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
+ open(R, "<", "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
is $foo, "ok\n", 'copy(*F, fn): same contents';
unlink "copy-$$" or die "unlink: $!";
- open(F,"file-$$");
+ open(F, "<", "file-$$");
copy(\*F, "copy-$$");
close(F) or die "close: $!";
- open(R, "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
+ open(R, "<", "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
is $foo, "ok\n", 'copy(\*F, fn): same contents';
unlink "copy-$$" or die "unlink: $!";
@@ -83,7 +83,7 @@ for my $cross_partition_test (0..1) {
binmode $fh or die $!;
copy("file-$$",$fh);
$fh->close or die "close: $!";
- open(R, "copy-$$") or die; $foo = <R>; close(R);
+ open(R, "<", "copy-$$") or die; $foo = <R>; close(R);
is $foo, "ok\n", 'copy(fn, io): same contents';
unlink "copy-$$" or die "unlink: $!";
@@ -92,7 +92,7 @@ for my $cross_partition_test (0..1) {
binmode $fh or die $!;
copy("file-$$",$fh);
$fh->close;
- open(R, "copy-$$") or die $!; $foo = <R>; close(R);
+ open(R, "<", "copy-$$") or die $!; $foo = <R>; close(R);
is $foo, "ok\n", 'copy(fn, fh): same contents';
unlink "file-$$" or die "unlink: $!";
@@ -111,7 +111,7 @@ for my $cross_partition_test (0..1) {
ok move("copy-$$", "file-$$"), 'move';
ok -e "file-$$", ' destination exists';
ok !-e "copy-$$", ' source does not';
- open(R, "file-$$") or die $!; $foo = <R>; close(R);
+ open(R, "<", "file-$$") or die $!; $foo = <R>; close(R);
is $foo, "ok\n", 'contents preserved';
TODO: {
@@ -126,13 +126,13 @@ for my $cross_partition_test (0..1) {
# trick: create lib/ if not exists - not needed in Perl core
unless (-d 'lib') { mkdir 'lib' or die $!; }
copy "file-$$", "lib";
- open(R, "lib/file-$$") or die $!; $foo = <R>; close(R);
+ open(R, "<", "lib/file-$$") or die $!; $foo = <R>; close(R);
is $foo, "ok\n", 'copy(fn, dir): same contents';
unlink "lib/file-$$" or die "unlink: $!";
# Do it twice to ensure copying over the same file works.
copy "file-$$", "lib";
- open(R, "lib/file-$$") or die $!; $foo = <R>; close(R);
+ open(R, "<", "lib/file-$$") or die $!; $foo = <R>; close(R);
is $foo, "ok\n", 'copy over the same file works';
unlink "lib/file-$$" or die "unlink: $!";
@@ -146,7 +146,7 @@ for my $cross_partition_test (0..1) {
}
move "file-$$", "lib";
- open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
+ open(R, "<", "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
is $foo, "ok\n", 'move(fn, dir): same contents';
ok !-e "file-$$", 'file moved indeed';
unlink "lib/file-$$" or die "unlink: $!";
@@ -154,7 +154,7 @@ for my $cross_partition_test (0..1) {
SKIP: {
skip "Testing symlinks", 3 unless $Config{d_symlink};
- open(F, ">file-$$") or die $!;
+ open(F, ">", "file-$$") or die $!;
print F "dummy content\n";
close F;
symlink("file-$$", "symlink-$$") or die $!;
@@ -175,7 +175,7 @@ for my $cross_partition_test (0..1) {
skip "Testing hard links", 3
if !$Config{d_link} or $^O eq 'MSWin32' or $^O eq 'cygwin';
- open(F, ">file-$$") or die $!;
+ open(F, ">", "file-$$") or die $!;
print F "dummy content\n";
close F;
link("file-$$", "hardlink-$$") or die $!;
@@ -192,13 +192,13 @@ for my $cross_partition_test (0..1) {
unlink "file-$$" or die $!;
}
- open(F, ">file-$$") or die $!;
+ open(F, ">", "file-$$") or die $!;
binmode F;
print F "this is file\n";
close F;
my $copy_msg = "this is copy\n";
- open(F, ">copy-$$") or die $!;
+ open(F, ">", "copy-$$") or die $!;
binmode F;
print F $copy_msg;
close F;
@@ -216,7 +216,7 @@ for my $cross_partition_test (0..1) {
}
is -s "copy-$$", length $copy_msg, "but does not truncate the destination";
- open(F, "copy-$$") or die $!;
+ open(F, "<", "copy-$$") or die $!;
$foo = <F>;
close(F);
is $foo, $copy_msg, "nor change the destination's contents";
@@ -228,7 +228,7 @@ for my $cross_partition_test (0..1) {
TODO: {
local $TODO = 'spaces in filenames require DECC$EFS_CHARSET enabled' if $^O eq 'VMS';
- open(F, ">file-$$") or die $!;
+ open(F, ">", "file-$$") or die $!;
close F;
copy "file-$$", " copy-$$";
ok -e " copy-$$", "copy with leading whitespace";
diff --git a/lib/File/stat.t b/lib/File/stat.t
index 7c9b9cc340..c403fc4498 100644
--- a/lib/File/stat.t
+++ b/lib/File/stat.t
@@ -144,7 +144,7 @@ for (split //, "tTB") {
SKIP: {
local *STAT;
- skip("Could not open file: $!", 2) unless open(STAT, $file);
+ skip("Could not open file: $!", 2) unless open(STAT, '<', $file);
isa_ok(File::stat::stat('STAT'), 'File::stat',
'... should be able to find filehandle');
diff --git a/lib/SelectSaver.t b/lib/SelectSaver.t
index 3b58d709ab..757f0cd6ec 100644
--- a/lib/SelectSaver.t
+++ b/lib/SelectSaver.t
@@ -9,7 +9,7 @@ print "1..3\n";
use SelectSaver;
-open(FOO, ">foo-$$") || die;
+open(FOO, ">", "foo-$$") || die;
print "ok 1\n";
{
@@ -18,7 +18,7 @@ print "ok 1\n";
}
# Get data written to file
-open(FOO, "foo-$$") || die;
+open(FOO, "<", "foo-$$") || die;
chomp($foo = <FOO>);
close FOO;
unlink "foo-$$";
diff --git a/lib/Symbol.pm b/lib/Symbol.pm
index 1e408b59f7..0e8d67fffd 100644
--- a/lib/Symbol.pm
+++ b/lib/Symbol.pm
@@ -9,7 +9,7 @@ Symbol - manipulate Perl symbols and their names
use Symbol;
$sym = gensym;
- open($sym, "filename");
+ open($sym, '<', "filename");
$_ = <$sym>;
# etc.
@@ -85,7 +85,7 @@ require Exporter;
@EXPORT = qw(gensym ungensym qualify qualify_to_ref);
@EXPORT_OK = qw(delete_package geniosym);
-$VERSION = '1.07';
+$VERSION = '1.08';
my $genpkg = "Symbol::";
my $genseq = 0;
diff --git a/lib/Tie/Handle/stdhandle.t b/lib/Tie/Handle/stdhandle.t
index 228004fce2..d2f04bcc5c 100644
--- a/lib/Tie/Handle/stdhandle.t
+++ b/lib/Tie/Handle/stdhandle.t
@@ -15,7 +15,7 @@ $f = 'tst';
unlink("afile") if -f "afile";
-ok(open($f,"+>afile"), "open +>afile");
+ok(open($f, "+>", "afile"), "open +>, afile");
ok(open($f, "+<", "afile"), "open +<, afile");
ok(binmode($f), "binmode")
or diag("binmode: $!\n");
diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm
index 75b2b80666..4939677fcc 100644
--- a/lib/Unicode/UCD.pm
+++ b/lib/Unicode/UCD.pm
@@ -5,7 +5,7 @@ use warnings;
no warnings 'surrogate'; # surrogates can be inputs to this
use charnames ();
-our $VERSION = '0.67';
+our $VERSION = '0.68';
require Exporter;
@@ -154,7 +154,7 @@ sub openunicode {
for my $d (@INC) {
use File::Spec;
$f = File::Spec->catfile($d, "unicore", @path);
- last if open($$rfh, $f);
+ last if open($$rfh, '<', $f);
undef $f;
}
croak __PACKAGE__, ": failed to find ",
diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm
index 731b1a00a7..860a0aa846 100644
--- a/lib/diagnostics.pm
+++ b/lib/diagnostics.pm
@@ -186,7 +186,7 @@ use 5.009001;
use Carp;
$Carp::Internal{__PACKAGE__.""}++;
-our $VERSION = '1.35';
+our $VERSION = '1.36';
our $DEBUG;
our $VERBOSE;
our $PRETTY;
@@ -231,7 +231,7 @@ CONFIG: {
$PRETTY = $opt_p;
}
- if (open(POD_DIAG, $PODFILE)) {
+ if (open(POD_DIAG, '<', $PODFILE)) {
warn "Happy happy podfile from real $PODFILE\n" if $DEBUG;
last CONFIG;
}
@@ -240,7 +240,7 @@ CONFIG: {
INCPATH: {
for my $file ( (map { "$_/".__PACKAGE__.".pm" } @INC), $0) {
warn "Checking $file\n" if $DEBUG;
- if (open(POD_DIAG, $file)) {
+ if (open(POD_DIAG, '<', $file)) {
while (<POD_DIAG>) {
next unless
/^__END__\s*# wish diag dbase were more accessible/;
diff --git a/lib/h2ph.t b/lib/h2ph.t
index bdcc389073..377cc63131 100644
--- a/lib/h2ph.t
+++ b/lib/h2ph.t
@@ -23,7 +23,7 @@ plan(6);
sub txt_compare {
local $/;
my ($A, $B);
- for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ }
+ for (($A,$B) = @_) { open(_,"<",$_) ? $_ = <_> : die "$_ : $!"; close _ }
$A cmp $B;
}
diff --git a/lib/h2xs.t b/lib/h2xs.t
index 25502dadd1..69746a52b3 100644
--- a/lib/h2xs.t
+++ b/lib/h2xs.t
@@ -167,7 +167,7 @@ for (my $i = $#tests; $i > 0; $i-=3) {
plan tests => $total_tests;
-ok (open (HEADER, ">$header"), "open '$header'");
+ok (open (HEADER, '>', $header), "open '$header'");
print HEADER <<HEADER or die $!;
#define Camel 2
#define Dromedary 1
@@ -238,7 +238,7 @@ while (my ($args, $version, $expectation) = splice @tests, 0, 3) {
foreach my $leaf (File::Spec->catfile('lib', "$name.pm"), 'Makefile.PL') {
my $file = File::Spec->catfile($name, $leaf);
- if (ok (open (FILE, $file), "open $file")) {
+ if (ok (open (FILE, '<', $file), "open $file")) {
my $match = qr/use $version;/;
my $found;
while (<FILE>) {
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 07ee636c58..4668a1fc05 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -529,7 +529,7 @@ BEGIN {
use vars qw($VERSION $header);
# bump to X.XX in blead, only use X.XX_XX in maint
-$VERSION = '1.50';
+$VERSION = '1.51';
$header = "perl5db.pl version $VERSION";
@@ -1656,14 +1656,14 @@ and if we can.
$o = $i unless defined $o;
# read/write on in, or just read, or read on STDIN.
- open( IN, "+<$i" )
- || open( IN, "<$i" )
+ open( IN, '+<', $i )
+ || open( IN, '<', $i )
|| open( IN, "<&STDIN" );
# read/write/create/clobber out, or write/create/clobber out,
# or merge with STDERR, or merge with STDOUT.
- open( OUT, "+>$o" )
- || open( OUT, ">$o" )
+ open( OUT, '+>', $o )
+ || open( OUT, '>', $o )
|| open( OUT, ">&STDERR" )
|| open( OUT, ">&STDOUT" ); # so we don't dongle stdout
@@ -6828,8 +6828,8 @@ sub setterm {
if ($tty) {
my ( $i, $o ) = split $tty, /,/;
$o = $i unless defined $o;
- open( IN, "<$i" ) or die "Cannot open TTY '$i' for read: $!";
- open( OUT, ">$o" ) or die "Cannot open TTY '$o' for write: $!";
+ open( IN, '<', $i ) or die "Cannot open TTY '$i' for read: $!";
+ open( OUT, '>', $o ) or die "Cannot open TTY '$o' for write: $!";
$IN = \*IN;
$OUT = \*OUT;
_autoflush($OUT);
@@ -7752,8 +7752,8 @@ sub TTY {
}
# Open file onto the debugger's filehandles, if you can.
- open IN, $in or die "cannot open '$in' for read: $!";
- open OUT, ">$out" or die "cannot open '$out' for write: $!";
+ open IN, '<', $in or die "cannot open '$in' for read: $!";
+ open OUT, '>', $out or die "cannot open '$out' for write: $!";
# Swap to the new filehandles.
reset_IN_OUT( \*IN, \*OUT );
diff --git a/lib/utf8.t b/lib/utf8.t
index 06d9a84af9..6b28eae948 100644
--- a/lib/utf8.t
+++ b/lib/utf8.t
@@ -170,7 +170,7 @@ BANG
);
foreach (@tests) {
my ($why, $prog, $expect) = @$_;
- open P, ">$progfile" or die "Can't open '$progfile': $!";
+ open P, ">", $progfile or die "Can't open '$progfile': $!";
binmode(P, ":bytes") if $has_perlio;
print P $show, $prog, '; print $b'
or die "Print to 'progfile' failed: $!";
diff --git a/lib/vmsish.t b/lib/vmsish.t
index f2b451d918..7681f07f60 100644
--- a/lib/vmsish.t
+++ b/lib/vmsish.t
@@ -106,7 +106,7 @@ is($?,0,"outer lex scope of vmsish [POSIX status]");
ok(($msg !~ /ABORT/),"vmsish ERR exit, vmsish hushed at runtime, DCL error message check");
local *TEST;
- open(TEST,'>vmsish_test.pl') || die('not ok ?? : unable to open "vmsish_test.pl" for writing');
+ open(TEST,'>','vmsish_test.pl') || die('not ok ?? : unable to open "vmsish_test.pl" for writing');
print TEST "#! perl\n";
print TEST "use vmsish qw(hushed);\n";
print TEST "\$obvious = (\$compile(\$error;\n";
@@ -137,7 +137,7 @@ is($?,0,"outer lex scope of vmsish [POSIX status]");
# we create a file rather than using an existing one for the stat() test.
my $file = 'sys$scratch:vmsish_t_flirble.tmp';
- open TMP, ">$file" or die "Couldn't open file $file";
+ open TMP, '>', $file or die "Couldn't open file $file";
close TMP;
END { 1 while unlink $file; }
@@ -187,7 +187,7 @@ is($?,0,"outer lex scope of vmsish [POSIX status]");
# they were turned off in invoking procedure
sub do_a_perl {
local *P;
- open(P,'>vmsish_test.com') || die('not ok ?? : unable to open "vmsish_test.com" for writing');
+ open(P,'>','vmsish_test.com') || die('not ok ?? : unable to open "vmsish_test.com" for writing');
print P "\$ set message/facil/sever/ident/text\n";
print P "\$ define/nolog/user sys\$error _nla0:\n";
print P "\$ $Invoke_Perl @_\n";