summaryrefslogtreecommitdiff
path: root/lib/File
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/File
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/File')
-rw-r--r--lib/File/Compare.t2
-rw-r--r--lib/File/Copy.t36
-rw-r--r--lib/File/stat.t2
3 files changed, 20 insertions, 20 deletions
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');