require should ignore directories found when searching @INC not just
authorGisle Aas <gisle@activestate.com>
Thu, 16 Mar 2006 12:01:10 +0000 (12:01 +0000)
committerGisle Aas <gisle@activestate.com>
Thu, 16 Mar 2006 12:01:10 +0000 (12:01 +0000)
die as soon as it finds one.  It should for instance be possible to
for require "File" to read the file "./File" even if there happens to
be a "File" directory in perl's standard library.

This fixes the RT #24404 fix in change 26373.

p4raw-id: //depot/perl@27515

pp_ctl.c
t/comp/require.t

index fcc6220..4b0703b 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3011,14 +3011,10 @@ S_check_type_and_open(pTHX_ const char *name, const char *mode)
 {
     Stat_t st;
     const int st_rc = PerlLIO_stat(name, &st);
-    if (st_rc < 0) {
+    if (st_rc < 0 || S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode)) {
        return NULL;
     }
 
-    if(S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode)) {
-       Perl_die(aTHX_ "%s %s not allowed in require",
-           S_ISDIR(st.st_mode) ? "Directory" : "Block device", name);
-    }
     return PerlIO_open(name, mode);
 }
 
index 72f11d8..d06834a 100755 (executable)
@@ -183,7 +183,7 @@ $foo = eval  {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
 my $r = "threads";
 eval { require $r };
 $i++;
-if($@ =~ /Directory .*threads not allowed in require/) {
+if($@ =~ /Can't locate threads in \@INC/) {
     print "ok $i\n";
 } else {
     print "not ok $i\n";