From: Steve Peters <steve@fisharerojo.org>
Date: Fri, 9 Mar 2007 18:30:16 +0000 (+0000)
Subject: Prefer dirhandles to filehandles when passing a bareword typeglob
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c08d693782d39895d445f7f2825c1f8240fc9f5a;p=p5sagit%2Fp5-mst-13.2.git

Prefer dirhandles to filehandles when passing a bareword typeglob
to chdir() and the typeglob has both a dirhandle and a
filehandle assigned to it.

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

diff --git a/pp_sys.c b/pp_sys.c
index 29638d9..5693d50 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3442,15 +3442,14 @@ PP(pp_chdir)
 #ifdef HAS_FCHDIR
 	IO* const io = GvIO(gv);
 	if (io) {
-	    if (IoIFP(io)) {
-		PUSHi(fchdir(PerlIO_fileno(IoIFP(io))) >= 0);
-	    }
-	    else if (IoDIRP(io)) {
+	    if (IoDIRP(io)) {
 #ifdef HAS_DIRFD
 		PUSHi(fchdir(dirfd(IoDIRP(io))) >= 0);
 #else
 		DIE(aTHX_ PL_no_func, "dirfd");
 #endif
+	    } else if (IoIFP(io)) {
+                PUSHi(fchdir(PerlIO_fileno(IoIFP(io))) >= 0);
 	    }
 	    else {
 		if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))