From: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>
Date: Fri, 28 Sep 2001 22:18:13 +0000 (+0200)
Subject: Allow an @INC hook to set %INC
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d3a4e64e0737f054931b8b9fa88a25b20bbdd085;p=p5sagit%2Fp5-mst-13.2.git

Allow an @INC hook to set %INC
Message-ID: <20010928221813.A16889@rafael>

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

diff --git a/pp_ctl.c b/pp_ctl.c
index 4b81fe5..8b320bf 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3323,10 +3323,14 @@ trylocal: {
 	SETERRNO(0, SS$_NORMAL);
 
     /* Assume success here to prevent recursive requirement. */
-    (void)hv_store(GvHVn(PL_incgv), name, strlen(name),
-		   (hook_sv ? SvREFCNT_inc(hook_sv)
-			    : newSVpv(CopFILE(&PL_compiling), 0)),
-		   0 );
+    len = strlen(name);
+    /* Check whether a hook in @INC has already filled %INC */
+    if (!hook_sv || !(svp = hv_fetch(GvHVn(PL_incgv), name, len, 0))) {
+	(void)hv_store(GvHVn(PL_incgv), name, len,
+		       (hook_sv ? SvREFCNT_inc(hook_sv)
+				: newSVpv(CopFILE(&PL_compiling), 0)),
+		       0 );
+    }
 
     ENTER;
     SAVETMPS;