summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-07-09 06:18:24 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-07-09 06:21:19 -0700
commit001de1221d5719ff84596edb61dbfaf861df18bf (patch)
treefe70063fbba60014b8498809324ab8cd0f84a6a7 /pp_ctl.c
parenta5ad7a5a06c866e7ce197fe08fcc657fa8089311 (diff)
downloadperl-001de1221d5719ff84596edb61dbfaf861df18bf.tar.gz
S_return_lvalues: collapse duplicated code
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 5fd7bf51da..caa0da5038 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2296,6 +2296,7 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
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) ||
@@ -2303,30 +2304,24 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
== SVf_READONLY
) &&
!SvSMAGICAL(TOPs)) {
- LEAVE;
- cxstack_ix--;
- POPSUB(cx,sv);
- PL_curpm = newpm;
- LEAVESUB(sv);
- Perl_croak(aTHX_
- "Can't return %s from lvalue subroutine",
+ what =
SvREADONLY(TOPs) ? (TOPs == &PL_sv_undef) ? "undef"
- : "a readonly value" : "a temporary");
+ : "a readonly value" : "a temporary";
}
- goto copy_sv;
+ else goto copy_sv;
}
else {
/* sub:lvalue{} will take us here. */
- LEAVE;
- cxstack_ix--;
- POPSUB(cx,sv);
- PL_curpm = newpm;
- LEAVESUB(sv);
- Perl_croak(aTHX_
- /* diag_listed_as: Can't return %s from lvalue subroutine*/
- "Can't return undef from lvalue subroutine"
- );
+ what = "undef";
}
+ LEAVE;
+ cxstack_ix--;
+ POPSUB(cx,sv);
+ PL_curpm = newpm;
+ LEAVESUB(sv);
+ Perl_croak(aTHX_
+ "Can't return %s from lvalue subroutine", what
+ );
}
if (MARK < SP) {
copy_sv: