[win32] protect sortcop from C<sort { sort { ... } ... } ...>
authorGurusamy Sarathy <gsar@cpan.org>
Fri, 8 May 1998 19:33:44 +0000 (15:33 -0400)
committerGurusamy Sarathy <gsar@cpan.org>
Sat, 9 May 1998 17:09:09 +0000 (17:09 +0000)
Message-Id: <199805082333.TAA06287@aatma.engin.umich.edu>
Subject: [PATCH] Re: double recursion in sort

p4raw-id: //depot/win32/perl@918

pp_ctl.c
t/op/runlevel.t

index c203126..f54bb75 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -652,8 +652,9 @@ PP(pp_sort)
        RETPUSHUNDEF;
     }
 
+    ENTER;
+    SAVEPPTR(sortcop);
     if (op->op_flags & OPf_STACKED) {
-       ENTER;
        if (op->op_flags & OPf_SPECIAL) {
            OP *kid = cLISTOP->op_first->op_sibling;    /* pass pushmark */
            kid = kUNOP->op_first;                      /* pass rv2gv */
@@ -740,7 +741,6 @@ PP(pp_sort)
            POPSTACK();
            CATCH_SET(oldcatch);
        }
-       LEAVE;
     }
     else {
        if (max > 1) {
@@ -749,6 +749,7 @@ PP(pp_sort)
                  (op->op_private & OPpLOCALE) ? sv_cmp_locale : sv_cmp);
        }
     }
+    LEAVE;
     stack_sp = ORIGMARK + max;
     return nextop;
 }
index b5e5dbb..bff26e4 100755 (executable)
@@ -188,6 +188,8 @@ sub sortfn {
 print "---- ".join(', ', @x)."\n";
 EXPECT
 sortfn 4, 5, 6
+sortfn 4, 5, 6
+sortfn 4, 5, 6
 ---- 1, 2, 3
 ########
 @a = (3, 2, 1);