diff options
author | Michael G. Schwern <schwern@pobox.com> | 2002-01-21 10:16:42 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-01-23 14:17:52 +0000 |
commit | 301daebccb7cf8ef4420fe0ae3cdddd299f11568 (patch) | |
tree | 6925d913db3736972e5e2609e0ce031fa8012baa /universal.c | |
parent | d9984052ba632ec50d14b1afa97960143b6781f2 (diff) | |
download | perl-301daebccb7cf8ef4420fe0ae3cdddd299f11568.tar.gz |
Re: bless() bug ? Why fails reblessing of 'main::Object' to 'Object' ?
Message-ID: <20020121201642.GA6659@blackrider>
p4raw-id: //depot/perl@14385
Diffstat (limited to 'universal.c')
-rw-r--r-- | universal.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/universal.c b/universal.c index 8fc7d699a8..53b9e9fb70 100644 --- a/universal.c +++ b/universal.c @@ -8,7 +8,8 @@ */ STATIC SV * -S_isa_lookup(pTHX_ HV *stash, const char *name, int len, int level) +S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash, + int len, int level) { AV* av; GV* gv; @@ -16,8 +17,10 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, int len, int level) HV* hv = Nullhv; SV* subgen = Nullsv; - if (!stash) - return &PL_sv_undef; + /* A stash/class can go by many names (ie. User == main::User), so + we compare the stash itself just in case */ + if (name_stash && (stash == name_stash)) + return &PL_sv_yes; if (strEQ(HvNAME(stash), name)) return &PL_sv_yes; @@ -80,7 +83,8 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, int len, int level) SvPVX(sv), HvNAME(stash)); continue; } - if (&PL_sv_yes == isa_lookup(basestash, name, len, level + 1)) { + if (&PL_sv_yes == isa_lookup(basestash, name, name_stash, + len, level + 1)) { (void)hv_store(hv,name,len,&PL_sv_yes,0); return &PL_sv_yes; } @@ -109,6 +113,7 @@ Perl_sv_derived_from(pTHX_ SV *sv, const char *name) { char *type; HV *stash; + HV *name_stash; stash = Nullhv; type = Nullch; @@ -126,8 +131,11 @@ Perl_sv_derived_from(pTHX_ SV *sv, const char *name) stash = gv_stashsv(sv, FALSE); } + name_stash = gv_stashpv(name, FALSE); + return (type && strEQ(type,name)) || - (stash && isa_lookup(stash, name, strlen(name), 0) == &PL_sv_yes) + (stash && isa_lookup(stash, name, name_stash, strlen(name), 0) + == &PL_sv_yes) ? TRUE : FALSE ; } |