--- Devel-FindRef/FindRef.xs 2007/01/11 22:30:34 1.1 +++ Devel-FindRef/FindRef.xs 2007/01/11 23:05:52 1.2 @@ -54,11 +54,27 @@ while (--idx > 0) { SV *sv = &arena [idx]; - + + if (SvTYPE (sv) >= SVt_LAST) + continue; + + /* temporarily disable RMAGICAL, it can easily interfere with us */ if ((rmagical = SvRMAGICAL (sv))) SvRMAGICAL_off (sv); - //TODO: magic + if (SvTYPE (sv) >= SVt_PVMG) + { + MAGIC *mg = SvMAGIC (sv); + while (mg) + { + if (mg->mg_obj == targ) + res_pair (form ("referenced (in mg_obj) by '%c' type magic attached to", mg->mg_type)); + if ((SV *)mg->mg_ptr == targ && mg->mg_flags & MGf_REFCOUNTED) + res_pair (form ("referenced (in mg_ptr) by '%c' type magic attached to", mg->mg_type)); + + mg = mg->mg_moremagic; + } + } switch (SvTYPE (sv)) { @@ -84,20 +100,6 @@ } break; - case SVt_PVGV: - if (GvGP (sv)) - { - if (GvSV (sv) == targ) - res_gv ('$'); - if (GvAV (sv) == (AV *)targ) - res_gv ('@'); - if (GvHV (sv) == (HV *)targ) - res_gv ('%'); - if (GvCV (sv) == (CV *)targ) - res_gv ('&'); - } - break; - case SVt_PVCV: { int depth = CvDEPTH (sv); @@ -117,6 +119,20 @@ } } break; + + case SVt_PVGV: + if (GvGP (sv)) + { + if (GvSV (sv) == targ) + res_gv ('$'); + if (GvAV (sv) == (AV *)targ) + res_gv ('@'); + if (GvHV (sv) == (HV *)targ) + res_gv ('%'); + if (GvCV (sv) == (CV *)targ) + res_gv ('&'); + } + break; } if (rmagical)