X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=XS.xs;h=27de74240cc7ad3ebec1671c702c88cf70e81dfc;hb=HEAD;hp=02f80bada244f5d66997cdaef49707d2b282b661;hpb=3277bbc437306ad76a15c90b4271b4534ea633a5;p=gitmo%2FClass-C3-XS.git diff --git a/XS.xs b/XS.xs index 02f80ba..27de742 100644 --- a/XS.xs +++ b/XS.xs @@ -189,9 +189,15 @@ __mro_linear_isa_c3(pTHX_ HV* stash, HV* cache, I32 level) HE* const he = hv_fetch_ent(tails, seqitem, 1, 0); if(he) { SV* const val = HeVAL(he); - /* This will increment undef to 1, which is what we - want for a newly created entry. */ - sv_inc(val); + /* For 5.8.0 and later, sv_inc() with increment undef to + an IV of 1, which is what we want for a newly created + entry. However, for 5.6.x it will become an NV of + 1.0, which confuses the SvIVX() checks above */ + if(SvIOK(val)) { + SvIVX(val)++; + } else { + sv_setiv(val, 1); + } } else { croak("failed to store value in hash"); } @@ -407,12 +413,18 @@ XS(XS_Class_C3_XS_nextcan) } /* we found a real sub here */ - sv = sv_2mortal(newSV(0)); + sv = sv_newmortal(); gv_efullname3(sv, cvgv, NULL); - fq_subname = SvPVX(sv); - fq_subname_len = SvCUR(sv); + if (SvPOK(sv)) { + fq_subname = SvPVX(sv); + fq_subname_len = SvCUR(sv); + + subname = strrchr(fq_subname, ':'); + } else { + subname = NULL; + } subname = strrchr(fq_subname, ':'); if(!subname) @@ -514,7 +526,7 @@ XS(XS_Class_C3_XS_nextcan) if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { SvREFCNT_dec(linear_av); SvREFCNT_inc((SV*)cand_cv); - if (!hv_store_ent(nmcache, newSVsv(cachekey), (SV*)cand_cv, 0)) { + if (!hv_store_ent(nmcache, cachekey, (SV*)cand_cv, 0)) { croak("failed to store value in hash"); } XPUSHs(sv_2mortal(newRV_inc((SV*)cand_cv))); @@ -524,7 +536,7 @@ XS(XS_Class_C3_XS_nextcan) } SvREFCNT_dec(linear_av); - if (!hv_store_ent(nmcache, newSVsv(cachekey), &PL_sv_undef, 0)) { + if (!hv_store_ent(nmcache, cachekey, &PL_sv_undef, 0)) { croak("failed to store value in hash"); } if(throw_nomethod)