From: Steve Grazzini <grazz@pobox.com>
Date: Fri, 11 Oct 2002 22:28:58 +0000 (+0000)
Subject: Re: [perl #17830] open FH, "<&", $fd
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24a7a40d02cc0ea4a7e6fc143f53dd60b2d0d047;p=p5sagit%2Fp5-mst-13.2.git

Re: [perl #17830] open FH, "<&", $fd
Message-ID: <20021011222858.452.qmail@onion.perl.org>

p4raw-id: //depot/perl@18023
---

diff --git a/doio.c b/doio.c
index fdd83f6..2da66c6 100644
--- a/doio.c
+++ b/doio.c
@@ -325,6 +325,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
 		    }
 		    if (num_svs && (SvIOK(*svp) || (SvPOK(*svp) && looks_like_number(*svp)))) {
 			fd = SvUV(*svp);
+			num_svs = 0;
 		    }
 		    else if (isDIGIT(*type)) {
 			/*SUPPRESS 530*/
diff --git a/t/io/open.t b/t/io/open.t
index cf1d39d..9e067b7 100755
--- a/t/io/open.t
+++ b/t/io/open.t
@@ -12,7 +12,7 @@ use Config;
 $Is_VMS = $^O eq 'VMS';
 $Is_MacOS = $^O eq 'MacOS';
 
-plan tests => 94;
+plan tests => 95;
 
 my $Perl = which_perl();
 
@@ -210,14 +210,14 @@ like( $@, qr/Bad filehandle:\s+afile/,          '       right error' );
 {
     local *F;
     for (1..2) {
-        ok( open(F, qq{$Perl -le "print 'ok'"|}), 'open to pipe' );
+	ok( open(F, qq{$Perl -le "print 'ok'"|}), 'open to pipe' );
 	is(scalar <F>, "ok\n",  '       readline');
-        ok( close F,            '       close' );
+	ok( close F,            '       close' );
     }
 
     for (1..2) {
-        ok( open(F, "-|", qq{$Perl -le "print 'ok'"}), 'open -|');
-        is( scalar <F>, "ok\n", '       readline');
+	ok( open(F, "-|", qq{$Perl -le "print 'ok'"}), 'open -|');
+	is( scalar <F>, "ok\n", '       readline');
 	ok( close F,            '       close' );
     }
 }
@@ -225,8 +225,11 @@ like( $@, qr/Bad filehandle:\s+afile/,          '       right error' );
 
 # other dupping techniques
 {
-    ok( open(my $stdout, ">&", \*STDOUT), 'dup \*STDOUT into lexical fh');
-    ok( open(STDOUT,     ">&", $stdout),  'restore dupped STDOUT from lexical fh');
+    ok( open(my $stdout, ">&", \*STDOUT),       'dup \*STDOUT into lexical fh');
+    ok( open(STDOUT,     ">&", $stdout),        'restore dupped STDOUT from lexical fh');
+
+    # used to try to open a file [perl #17830]
+    ok( open(my $stdin,  "<&", fileno STDIN),   'dup fileno(STDIN) into lexical fh');
 }
 
 SKIP: {