From: Nicholas Clark Date: Mon, 15 Jan 2007 17:18:03 +0000 (+0000) Subject: Make changes analagous to pp_rv2hv's 21394 and 24489 in pp_rv2av. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cde874cac37ec0b08192df9c6fec992f97b30566;p=p5sagit%2Fp5-mst-13.2.git Make changes analagous to pp_rv2hv's 21394 and 24489 in pp_rv2av. p4raw-id: //depot/perl@29835 --- diff --git a/pp_hot.c b/pp_hot.c index 7167311..e08ff7c 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);