summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-12-14 15:25:39 +0000
committerNicholas Clark <nick@ccl4.org>2005-12-14 15:25:39 +0000
commitdeb46114c3cc895c9e08a296579a1315c920625c (patch)
tree343a95f70b5710066ce00a0dfc0f6d33b5fd4df4 /sv.c
parent1c7ff15ea62f0cb57f76bc4b2a270c075f724f44 (diff)
downloadperl-deb46114c3cc895c9e08a296579a1315c920625c.tar.gz
Duplicate the AMAGIC temporary variable consting from sv_2iv_flags into
sv_2uv_flags, sv_2nv and sv_2pv_flags. p4raw-id: //depot/perl@26355
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c72
1 files changed, 39 insertions, 33 deletions
diff --git a/sv.c b/sv.c
index 199b8df465..b2d9d2e40e 100644
--- a/sv.c
+++ b/sv.c
@@ -1992,12 +1992,14 @@ Perl_sv_2uv_flags(pTHX_ register SV *sv, I32 flags)
}
if (SvTHINKFIRST(sv)) {
if (SvROK(sv)) {
- SV* tmpstr;
return_rok:
- if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,numer)) &&
- (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv))))
- return SvUV(tmpstr);
- return PTR2UV(SvRV(sv));
+ if (SvAMAGIC(sv)) {
+ SV *const tmpstr = AMG_CALLun(sv,numer);
+ if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) {
+ return SvUV(tmpstr);
+ }
+ }
+ return PTR2UV(SvRV(sv));
}
if (SvIsCOW(sv)) {
sv_force_normal_flags(sv, 0);
@@ -2057,12 +2059,14 @@ Perl_sv_2nv(pTHX_ register SV *sv)
function. */
} else if (SvTHINKFIRST(sv)) {
if (SvROK(sv)) {
- SV* tmpstr;
return_rok:
- if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,numer)) &&
- (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv))))
- return SvNV(tmpstr);
- return PTR2NV(SvRV(sv));
+ if (SvAMAGIC(sv)) {
+ SV *const tmpstr = AMG_CALLun(sv,numer);
+ if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) {
+ return SvNV(tmpstr);
+ }
+ }
+ return PTR2NV(SvRV(sv));
}
if (SvIsCOW(sv)) {
sv_force_normal_flags(sv, 0);
@@ -2414,33 +2418,35 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags)
function. */
} else if (SvTHINKFIRST(sv)) {
if (SvROK(sv)) {
- SV* tmpstr;
-
return_rok:
- if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,string)) &&
- (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) {
- /* 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);
+ if (SvAMAGIC(sv)) {
+ SV *const tmpstr = AMG_CALLun(sv,string);
+ if (tmpstr && (!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) {
+ /* 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 = (flags & SV_MUTABLE_RETURN)
- ? SvPVX_mutable(tmpstr) : SvPVX(tmpstr);
+ pv = sv_2pv_flags(tmpstr, lp, flags);
}
- if (lp)
- *lp = SvCUR(tmpstr);
- } else {
- pv = sv_2pv_flags(tmpstr, lp, flags);
+ if (SvUTF8(tmpstr))
+ SvUTF8_on(sv);
+ else
+ SvUTF8_off(sv);
+ return pv;
}
- if (SvUTF8(tmpstr))
- SvUTF8_on(sv);
- else
- SvUTF8_off(sv);
- return pv;
- } else {
+ }
+ {
SV *tsv;
MAGIC *mg;
const SV *const referent = (SV*)SvRV(sv);