X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.c;h=85751576dd551feadac5ed271d0fd9464ef801b0;hb=50adf7d25d4fa2ebde52a8067c5d9b35f5c7c054;hp=81f407c25c4858ab2ce02b18029a1641483ad91e;hpb=cfd0369c40b647df9444518ec26b924a57e14ac8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.c b/sv.c index 81f407c..8575157 100644 --- a/sv.c +++ b/sv.c @@ -3441,8 +3441,22 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags) register const char *typestr; if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,string)) && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) { - /* FIXME - figure out best way to pass context inwards. */ - char *pv = lp ? SvPV(tmpstr, *lp) : SvPV_nolen(tmpstr); + /* Unwrap this: */ + /* char *pv = lp ? SvPV(tmpstr, *lp) : SvPV_nolen(tmpstr); */ + + char *pv; + if ((SvFLAGS(tmpstr) & (SVf_POK)) == SVf_POK) { + if (flags & SV_CONST_RETURN) { + pv = (char *) SvPVX_const(tmpstr); + } else { + pv = (flags & SV_MUTABLE_RETURN) + ? SvPVX_mutable(tmpstr) : SvPVX(tmpstr); + } + if (lp) + *lp = SvCUR(tmpstr); + } else { + pv = sv_2pv_flags(tmpstr, lp, flags); + } if (SvUTF8(tmpstr)) SvUTF8_on(sv); else