summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-07-14 06:58:29 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-07-14 17:35:31 -0700
commit152e8a12bd1ba6c9b17f3da2f81f37518f992ad2 (patch)
tree0a25bab0009411335281a3367dd2f352109bb498 /op.c
parentc650d6974333f05db3de6fe88357fb0e710220a3 (diff)
downloadperl-152e8a12bd1ba6c9b17f3da2f81f37518f992ad2.tar.gz
Simplify ck_grep
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.
Diffstat (limited to 'op.c')
-rw-r--r--op.c12
1 files changed, 2 insertions, 10 deletions
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;