This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
honoring void context for map()
authorTassilo von Parseval <tassilo.parseval@post.rwth-aachen.de>
Thu, 4 Sep 2003 11:13:41 +0000 (13:13 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sun, 7 Sep 2003 12:44:33 +0000 (12:44 +0000)
Message-id: <20030904091341.GA30655@ethan>

p4raw-id: //depot/perl@21062

pp_ctl.c

index 1fd6e01..3339548 100644 (file)
--- 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 */