From: Nicholas Clark Date: Sat, 11 Jun 2005 14:08:00 +0000 (+0000) Subject: Propagate const/mutable/not into the SvPV call for retrieving an X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=50adf7d25d4fa2ebde52a8067c5d9b35f5c7c054;p=p5sagit%2Fp5-mst-13.2.git Propagate const/mutable/not into the SvPV call for retrieving an overloaded value. p4raw-id: //depot/perl@24801 --- 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