summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-01-15 17:18:03 +0000
committerNicholas Clark <nick@ccl4.org>2007-01-15 17:18:03 +0000
commitcde874cac37ec0b08192df9c6fec992f97b30566 (patch)
treed627229cbe233a0722a7476e8a95b24667290d37 /pp_hot.c
parenta20207d7c00bd54d6d2718961a96cd5c7ed1e37b (diff)
downloadperl-cde874cac37ec0b08192df9c6fec992f97b30566.tar.gz
Make changes analagous to pp_rv2hv's 21394 and 24489 in pp_rv2av.
p4raw-id: //depot/perl@29835
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 71673111eb..e08ff7c0f7 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -783,6 +783,8 @@ PP(pp_rv2av)
{
dVAR; dSP; dTOPss;
AV *av;
+ const I32 gimme = GIMME_V;
+ static const char return_array_to_lvalue_scalar[] = "Can't return hash to lvalue scalar context";
if (SvROK(sv)) {
wasref:
@@ -796,8 +798,8 @@ PP(pp_rv2av)
RETURN;
}
else if (LVRET) {
- if (GIMME == G_SCALAR)
- Perl_croak(aTHX_ "Can't return array to lvalue scalar context");
+ if (gimme != G_ARRAY)
+ Perl_croak(aTHX_ return_array_to_lvalue_scalar);
SETs((SV*)av);
RETURN;
}
@@ -813,9 +815,8 @@ PP(pp_rv2av)
RETURN;
}
else if (LVRET) {
- if (GIMME == G_SCALAR)
- Perl_croak(aTHX_ "Can't return array to lvalue"
- " scalar context");
+ if (gimme != G_ARRAY)
+ Perl_croak(aTHX_ return_array_to_lvalue_scalar);
SETs((SV*)av);
RETURN;
}
@@ -835,8 +836,8 @@ PP(pp_rv2av)
DIE(aTHX_ PL_no_usym, "an ARRAY");
if (ckWARN(WARN_UNINITIALIZED))
report_uninit(sv);
- if (GIMME == G_ARRAY) {
- (void)POPs;
+ if (gimme == G_ARRAY) {
+ SP--;
RETURN;
}
RETSETUNDEF;
@@ -869,16 +870,15 @@ PP(pp_rv2av)
RETURN;
}
else if (LVRET) {
- if (GIMME == G_SCALAR)
- Perl_croak(aTHX_ "Can't return array to lvalue"
- " scalar context");
+ if (gimme != G_ARRAY)
+ Perl_croak(aTHX_ return_array_to_lvalue_scalar);
SETs((SV*)av);
RETURN;
}
}
}
- if (GIMME == G_ARRAY) {
+ if (gimme == G_ARRAY) {
const I32 maxarg = AvFILL(av) + 1;
(void)POPs; /* XXXX May be optimized away? */
EXTEND(SP, maxarg);
@@ -897,7 +897,7 @@ PP(pp_rv2av)
}
SP += maxarg;
}
- else if (GIMME_V == G_SCALAR) {
+ else if (gimme == G_SCALAR) {
dTARGET;
const I32 maxarg = AvFILL(av) + 1;
SETi(maxarg);