if (SvTHINKFIRST(sv)) {
if (SvROK(sv)) {
SV* tmpstr;
- SV *referent;
- register const char *typestr;
+
if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,string)) &&
(!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) {
/* Unwrap this: */
else
SvUTF8_off(sv);
return pv;
- }
- referent = (SV*)SvRV(sv);
- if (!referent)
- typestr = "NULLREF";
- else {
+ } else {
MAGIC *mg;
+ const SV *const referent = (SV*)SvRV(sv);
+
+ if (!referent) {
+ if (lp)
+ *lp = 7;
+ return (char *)"NULLREF";
+ }
if (SvTYPE(referent) == SVt_PVMG && ((SvFLAGS(referent) &
(SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG))
if (lp)
*lp = mg->mg_len;
return mg->mg_ptr;
+ } else {
+ const char *const typestr = sv_reftype(referent, 0);
+
+ tsv = sv_newmortal();
+ if (SvOBJECT(referent)) {
+ const char *const name = HvNAME_get(SvSTASH(referent));
+ Perl_sv_setpvf(aTHX_ tsv, "%s=%s(0x%"UVxf")",
+ name ? name : "__ANON__" , typestr,
+ PTR2UV(referent));
+ }
+ else
+ Perl_sv_setpvf(aTHX_ tsv, "%s(0x%"UVxf")", typestr,
+ PTR2UV(referent));
+ if (lp)
+ *lp = SvCUR(tsv);
+ return SvPVX(tsv);
}
-
- typestr = sv_reftype(referent, 0);
-
- tsv = sv_newmortal();
- if (SvOBJECT(referent)) {
- const char * const name = HvNAME_get(SvSTASH(referent));
- Perl_sv_setpvf(aTHX_ tsv, "%s=%s(0x%"UVxf")",
- name ? name : "__ANON__" , typestr, PTR2UV(referent));
- }
- else
- Perl_sv_setpvf(aTHX_ tsv, "%s(0x%"UVxf")", typestr, PTR2UV(referent));
- if (lp)
- *lp = SvCUR(tsv);
- return SvPVX(tsv);
}
- if (lp)
- *lp = strlen(typestr);
- return (char *)typestr;
}
if (SvREADONLY(sv) && !SvOK(sv)) {
if (ckWARN(WARN_UNINITIALIZED))