From: Tassilo von Parseval <tassilo.parseval@post.rwth-aachen.de>
Date: Thu, 4 Sep 2003 11:13:41 +0000 (+0200)
Subject: honoring void context for map()
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c90a460cdb7d8d7e800ddcf78d3a123f45708a6;p=p5sagit%2Fp5-mst-13.2.git

honoring void context for map()
Message-id: <20030904091341.GA30655@ethan>

p4raw-id: //depot/perl@21062
---

diff --git a/pp_ctl.c b/pp_ctl.c
index 1fd6e01..3339548 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -893,6 +893,7 @@ PP(pp_mapstart)
 PP(pp_mapwhile)
 {
     dSP;
+    I32 gimme = GIMME_V;
     I32 items = (SP - PL_stack_base) - *PL_markstack_ptr; /* how many new items */
     I32 count;
     I32 shift;
@@ -903,7 +904,7 @@ PP(pp_mapwhile)
     ++PL_markstack_ptr[-1];
 
     /* if there are new items, push them into the destination list */
-    if (items) {
+    if (items && gimme != G_VOID) {
 	/* might need to make room back there first */
 	if (items > PL_markstack_ptr[-1] - PL_markstack_ptr[-2]) {
 	    /* XXX this implementation is very pessimal because the stack
@@ -947,7 +948,6 @@ PP(pp_mapwhile)
 
     /* All done yet? */
     if (PL_markstack_ptr[-1] > *PL_markstack_ptr) {
-	I32 gimme = GIMME_V;
 
 	(void)POPMARK;				/* pop top */
 	LEAVE;					/* exit outer scope */