Apply the same policy for the value returned by push() and unshift()
Vincent Pit [Sun, 4 Oct 2009 13:02:56 +0000 (15:02 +0200)]
That is, only push the len when the static context is not void, and honour
len magic.

pp.c

diff --git a/pp.c b/pp.c
index fae2d6d..ef7d7ab 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4720,10 +4720,6 @@ PP(pp_push)
        call_method("PUSH",G_SCALAR|G_DISCARD);
        LEAVE;
        SPAGAIN;
-       SP = ORIGMARK;
-       if (GIMME_V != G_VOID) {
-           PUSHi( AvFILL(ary) + 1 );
-       }
     }
     else {
        PL_delaymagic = DM_DELAY;
@@ -4737,10 +4733,10 @@ PP(pp_push)
            mg_set(MUTABLE_SV(ary));
 
        PL_delaymagic = 0;
-       SP = ORIGMARK;
-       if (OP_GIMME(PL_op, 0) != G_VOID) {
-           PUSHi( AvFILL(ary) + 1 );
-       }
+    }
+    SP = ORIGMARK;
+    if (OP_GIMME(PL_op, 0) != G_VOID) {
+       PUSHi( AvFILL(ary) + 1 );
     }
     RETURN;
 }
@@ -4783,7 +4779,7 @@ PP(pp_unshift)
        }
     }
     SP = ORIGMARK;
-    if (GIMME_V != G_VOID) {
+    if (OP_GIMME(PL_op, 0) != G_VOID) {
        PUSHi( AvFILL(ary) + 1 );
     }
     RETURN;