proposal : put the @INC-hooks directly in %INC
Rafael Garcia-Suarez [Wed, 19 Sep 2001 22:47:14 +0000 (00:47 +0200)]
Message-ID: <20010919224714.A6382@rafael>

p4raw-id: //depot/perl@12162

pod/perlvar.pod
pp_ctl.c

index 99d2960..e61e8ed 100644 (file)
@@ -1156,10 +1156,9 @@ value is the location of the file found.  The C<require>
 operator uses this hash to determine whether a particular file has
 already been included.
 
-If the file was loaded via a hook (see L<perlfunc/require> for a
-description of these hooks), a fake filename is inserted into %INC. It
-looks like F</loader/0x81095c8/Foo.pm>, where the hexadecimal number
-corresponds to the reference that was put in @INC.
+If the file was loaded via a hook (e.g. a subroutine reference, see
+L<perlfunc/require> for a description of these hooks), this hook is
+inserted into %INC in place of a filename.
 
 =item %ENV
 
index 5d2d10f..d488b7c 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3032,6 +3032,7 @@ PP(pp_require)
     GV *filter_child_proc = 0;
     SV *filter_state = 0;
     SV *filter_sub = 0;
+    SV *hook_sv = 0;
 
     sv = POPs;
     if (SvNIOKp(sv)) {
@@ -3230,6 +3231,7 @@ trylocal: {
                    LEAVE;
 
                    if (tryrsfp) {
+                       hook_sv = dirsv;
                        break;
                    }
 
@@ -3319,7 +3321,9 @@ trylocal: {
 
     /* Assume success here to prevent recursive requirement. */
     (void)hv_store(GvHVn(PL_incgv), name, strlen(name),
-                  newSVpv(CopFILE(&PL_compiling), 0), 0 );
+                  (hook_sv ? SvREFCNT_inc(hook_sv)
+                           : newSVpv(CopFILE(&PL_compiling), 0)),
+                  0 );
 
     ENTER;
     SAVETMPS;