summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-05-24 16:53:05 +0100
committerDavid Mitchell <davem@iabyn.com>2015-06-19 08:44:17 +0100
commita8fc6464d21b7e1fc056ca7bd504ada3f88770d7 (patch)
treea8d9718ffcf95b226256719a41e55b34e5031dfe
parent716436dc7bfe93c174394b2d148df54b22c6f1fb (diff)
downloadperl-a8fc6464d21b7e1fc056ca7bd504ada3f88770d7.tar.gz
S_return_lvalues(): merge two similar blocks
Two blocks of error-reporting code both clean up the context state and then croak with a similar message. Make the second block just goto the first block instead.
-rw-r--r--pp_ctl.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 5bc7f6374a..eafd9ed7f1 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2296,6 +2296,7 @@ S_return_lvalues(pTHX_ SV **base)
PERL_CONTEXT *cx;
SV *sv;
bool ref;
+ const char *what = NULL;
POPBLOCK(cx,newpm);
cxstack_ix++; /* preserve cx entry on stack for use by POPSUB */
@@ -2307,7 +2308,6 @@ S_return_lvalues(pTHX_ SV **base)
if (gimme == G_SCALAR) {
if (CxLVAL(cx) && !ref) { /* Leave it as it is if we can. */
SV *sv;
- const char *what = NULL;
if (MARK < SP) {
assert(MARK+1 == SP);
if ((SvPADTMP(TOPs) || SvREADONLY(TOPs)) &&
@@ -2322,6 +2322,7 @@ S_return_lvalues(pTHX_ SV **base)
/* sub:lvalue{} will take us here. */
what = "undef";
}
+ croak:
LEAVE;
POPSUB(cx,sv);
cxstack_ix--;
@@ -2380,19 +2381,10 @@ S_return_lvalues(pTHX_ SV **base)
if (*MARK != &PL_sv_undef
&& (SvPADTMP(*MARK) || SvREADONLY(*MARK))
) {
- const bool ro = cBOOL( SvREADONLY(*MARK) );
- SV *sv;
/* Might be flattened array after $#array = */
- PUTBACK;
- LEAVE;
- POPSUB(cx,sv);
- cxstack_ix--;
- PL_curpm = newpm;
- LEAVESUB(sv);
- /* diag_listed_as: Can't return %s from lvalue subroutine */
- Perl_croak(aTHX_
- "Can't return a %s from lvalue subroutine",
- ro ? "readonly value" : "temporary");
+ what = SvREADONLY(*MARK)
+ ? "a readonly value" : "a temporary";
+ goto croak;
}
else
*++newsp =