From 152e8a12bd1ba6c9b17f3da2f81f37518f992ad2 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 14 Jul 2012 06:58:29 -0700 Subject: Simplify ck_grep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Back in perl 5.000, ck_grep would call ck_sort (which was still the case until 354dd559d99 just recently) and the latter would traverse its way through the op_next pointers to find an op that tried to escape the block, setting its op_next pointer to null. Then ck_grep would traverse op_next pointers itself to find the place where ck_sort stopped. That caused problems for grep which were fixed in 748a93069b (perl 5.001). It was fixed by setting op_next to 0 on the first op, so that the loop in ck_grep would not do anything. But that loop was left there. This commit removes it. There are also a couple of things I missed when disentangling ck_grep and ck_sort in commit /354dd559d9. I accidentally put if (o->op_flags & OPf_STACKED) inside if (o->op_flags & OPf_STACKED). And the OPf_SPECIAL flag was only being set for sort’s use, so ck_grep doesn’t need to copy that. --- op.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'op.c') diff --git a/op.c b/op.c index 211ffb208c..acea933661 100644 --- a/op.c +++ b/op.c @@ -8580,20 +8580,12 @@ Perl_ck_grep(pTHX_ OP *o) /* don't allocate gwop here, as we may leak it if PL_parser->error_count > 0 */ if (o->op_flags & OPf_STACKED) { - OP* k; OP *firstkid = cLISTOPo->op_first->op_sibling; kid = cUNOPx(firstkid)->op_first; if (kid->op_type != OP_SCOPE && kid->op_type != OP_LEAVE) return no_fh_allowed(o); - if (o->op_flags & OPf_STACKED) { - LINKLIST(kid); - firstkid->op_next = kLISTOP->op_first; - kid->op_next = 0; /* just disconnect the leave/scope */ - o->op_flags |= OPf_SPECIAL; - } - for (k = kid; k; k = k->op_next) { - kid = k; - } + LINKLIST(kid); + firstkid->op_next = kLISTOP->op_first; NewOp(1101, gwop, 1, LOGOP); kid->op_next = (OP*)gwop; o->op_flags &= ~OPf_STACKED; -- cgit v1.2.1