From: mike@exegenix.com Date: Mon, 24 Mar 2003 16:29:08 +0000 (+0000) Subject: [perl #21672] IO::New and undefined filename behaviour X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f21dc558ba1787c481c41d0e2a712ea60b9b1444;p=p5sagit%2Fp5-mst-13.2.git [perl #21672] IO::New and undefined filename behaviour From: "mike@exegenix.com (via RT)" Message-Id: plus a regression test p4raw-id: //depot/perl@19072 --- diff --git a/ext/IO/lib/IO/File.pm b/ext/IO/lib/IO/File.pm index d5520cb..9c4177a 100644 --- a/ext/IO/lib/IO/File.pm +++ b/ext/IO/lib/IO/File.pm @@ -158,9 +158,11 @@ sub open { defined $perms or $perms = 0666; return sysopen($fh, $file, $mode, $perms); } - if (! File::Spec->file_name_is_absolute($file)) { - $file = File::Spec->catfile(File::Spec->curdir(),$file); - } + if (defined($file) && length($file) + && ! File::Spec->file_name_is_absolute($file)) + { + $file = File::Spec->catfile(File::Spec->curdir(),$file); + } $file = IO::Handle::_open_mode_string($mode) . " $file\0"; } open($fh, $file); diff --git a/lib/FileHandle.t b/lib/FileHandle.t index c994c8b..ddbd944 100755 --- a/lib/FileHandle.t +++ b/lib/FileHandle.t @@ -22,7 +22,7 @@ autoflush STDOUT 1; $mystdout = new_from_fd FileHandle 1,"w"; $| = 1; autoflush $mystdout; -print "1..11\n"; +print "1..12\n"; print $mystdout "ok ".fileno($mystdout)."\n"; @@ -93,3 +93,5 @@ else { exit(0); } } + +print FileHandle->new('','r') ? "not ok 12\n" : "ok 12\n";