register const char *nend;
const char *nsplit = 0;
GV* gv;
+ HV* ostash = stash;
+
+ if (stash && SvTYPE(stash) < SVt_PVHV)
+ stash = Nullhv;
for (nend = name; *nend; nend++) {
if (*nend == '\'')
gv_stashpvn(origname, nsplit - origname - 7, FALSE))
stash = gv_stashpvn(origname, nsplit - origname, TRUE);
}
+ ostash = stash;
}
gv = gv_fetchmeth(stash, name, nend - name, 0);
if (strEQ(name,"import") || strEQ(name,"unimport"))
gv = (GV*)&PL_sv_yes;
else if (autoload)
- gv = gv_autoload4(stash, name, nend - name, TRUE);
+ gv = gv_autoload4(ostash, name, nend - name, TRUE);
}
else if (autoload) {
CV* cv = GvCV(gv);
HV* varstash;
GV* vargv;
SV* varsv;
+ char *packname = "";
- if (!stash)
- return Nullgv; /* UNIVERSAL::AUTOLOAD could cause trouble */
if (len == autolen && strnEQ(name, autoload, autolen))
return Nullgv;
+ if (stash) {
+ if (SvTYPE(stash) < SVt_PVHV) {
+ packname = SvPV_nolen((SV*)stash);
+ stash = Nullhv;
+ }
+ else {
+ packname = HvNAME(stash);
+ }
+ }
if (!(gv = gv_fetchmeth(stash, autoload, autolen, FALSE)))
return Nullgv;
cv = GvCV(gv);
(GvCVGEN(gv) || GvSTASH(gv) != stash))
Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
"Use of inherited AUTOLOAD for non-method %s::%.*s() is deprecated",
- HvNAME(stash), (int)len, name);
+ packname, (int)len, name);
if (CvXSUB(cv)) {
/* rather than lookup/init $AUTOLOAD here
gv_init(vargv, varstash, autoload, autolen, FALSE);
LEAVE;
varsv = GvSV(vargv);
- sv_setpv(varsv, HvNAME(stash));
+ sv_setpv(varsv, packname);
sv_catpvn(varsv, "::", 2);
sv_catpvn(varsv, name, len);
SvTAINTED_off(varsv);
char* name;
STRLEN namelen;
char* packname = 0;
+ SV *packsv = Nullsv;
STRLEN packlen;
name = SvPV(meth, namelen);
}
/* assume it's a package name */
stash = gv_stashpvn(packname, packlen, FALSE);
+ if (!stash)
+ packsv = sv;
goto fetch;
}
/* it _is_ a filehandle name -- replace with a reference */
}
}
- gv = gv_fetchmethod(stash, name);
+ gv = gv_fetchmethod(stash ? stash : (HV*)packsv, name);
if (!gv) {
/* This code tries to figure out just what went wrong with
require "test.pl";
}
-print "1..75\n";
+print "1..78\n";
@A::ISA = 'B';
@B::ISA = 'C';
Bminor->test('y', 'z');
is("@X", "Amajor Bminor x y Bminor Bminor y z");
+package main;
+for my $meth (['Bar', 'Foo::Bar'],
+ ['SUPER::Bar', 'main::SUPER::Bar'],
+ ['Xyz::SUPER::Bar', 'Xyz::SUPER::Bar'])
+{
+ fresh_perl_is(<<EOT,
+package UNIVERSAL; sub AUTOLOAD { my \$c = shift; print "\$c \$AUTOLOAD\\n" }
+package Xyz;
+package main; Foo->$meth->[0]();
+EOT
+ "Foo $meth->[1]",
+ { switches => [ '-w' ] },
+ "check if UNIVERSAL::AUTOLOAD works",
+ );
+}