develooper Front page | perl.perl5.porters | Postings from November 2005

Re: [PATCH] sort/multicall patch

Thread Previous | Thread Next
From:
Robin Houston
Date:
November 4, 2005 05:53
Subject:
Re: [PATCH] sort/multicall patch
Message ID:
20051104135134.GA16220@rpc142.cs.man.ac.uk
On Fri, Nov 04, 2005 at 10:57:34AM -0000, Paul Marquess wrote:
> I see that quite a few of the smoke builds have been failing in DB_File over
> the last few days. I assume this is related to the sort/multicall patch,
> given that this is what I got when I build bleed on redhat3.

Interesting, thanks.

I can't reproduce that problem here, but the patch below fixes a
bug that could cause the problem you report. Does it fix the
problem?

Robin

--- pp_ctl.c.orig	2005-11-04 13:31:15.000000000 +0000
+++ pp_ctl.c	2005-11-04 13:48:45.000000000 +0000
@@ -1949,6 +1949,7 @@
 				     * sort block, which is a CXt_NULL
 				     * not a CXt_SUB */
 	    dounwind(0);
+	    PL_stack_sp = PL_stack_base + 1;
 	    return 0;
 	}
 	else
@@ -1957,8 +1958,12 @@
     if (cxix < cxstack_ix)
 	dounwind(cxix);
 
-    if (CxMULTICALL(&cxstack[cxix]))
+    if (CxMULTICALL(&cxstack[cxix])) {
+	gimme = cxstack[cxix].blk_gimme;
+	if (gimme != G_ARRAY)
+	    PL_stack_sp = PL_stack_base + (gimme == G_SCALAR ? 1 : 0);
 	return 0;
+    }
 
     POPBLOCK(cx,newpm);
     switch (CxTYPE(cx)) {
--- t/op/sort.t.orig	2005-11-04 13:36:39.000000000 +0000
+++ t/op/sort.t	2005-11-04 13:47:08.000000000 +0000
@@ -5,7 +5,7 @@
     @INC = '../lib';
 }
 use warnings;
-print "1..141\n";
+print "1..143\n";
 
 # these shouldn't hang
 {
@@ -790,3 +790,13 @@
 # Using return() should be okay even in a deeper context
 @b = sort {while (1) {return ($a <=> $b)} } 1..10;
 ok("@b", "1 2 3 4 5 6 7 8 9 10", "return within loop");
+
+# Using return() should be okay even if there are other items
+# on the stack at the time.
+@b = sort {$_ = 7 + do{return $b<=> $a}} 1..10;
+ok("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");
+
+# As above, but with a sort sub rather than a sort block.
+sub ret_with_stacked { $_ = 7 + do {return $b <=> $a} }
+@b = sort ret_with_stacked 1..10;
+ok("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About