From 3023b5f30c62e26185b48118c7c84030adb5b623 Mon Sep 17 00:00:00 2001 From: Gerard Goossen Date: Sat, 6 Aug 2011 17:50:40 +0200 Subject: Change aassign_common_vars to check using the optree without using the linked list. Besides no longer depending on the op chain this also solves a bug where the common vars where not detected because of logical operators. --- op.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'op.c') diff --git a/op.c b/op.c index 4187b50c6b..f862cd88ff 100644 --- a/op.c +++ b/op.c @@ -4806,9 +4806,8 @@ S_is_list_assignment(pTHX_ register const OP *o) PERL_STATIC_INLINE bool S_aassign_common_vars(pTHX_ OP* o) { - OP *lastop = o; OP *curop; - for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) { + for (curop = cUNOPo->op_first; curop; curop=curop->op_sibling) { if (PL_opargs[curop->op_type] & OA_DANGEROUS) { if (curop->op_type == OP_GV) { GV *gv = cGVOPx_gv(curop); @@ -4834,7 +4833,7 @@ S_aassign_common_vars(pTHX_ OP* o) curop->op_type == OP_RV2AV || curop->op_type == OP_RV2HV || curop->op_type == OP_RV2GV) { - if (lastop->op_type != OP_GV) /* funny deref? */ + if (cUNOPx(curop)->op_first->op_type != OP_GV) /* funny deref? */ return TRUE; } else if (curop->op_type == OP_PUSHRE) { @@ -4860,7 +4859,11 @@ S_aassign_common_vars(pTHX_ OP* o) else return TRUE; } - lastop = curop; + + if (curop->op_flags & OPf_KIDS) { + if (aassign_common_vars(curop)) + return TRUE; + } } return FALSE; } @@ -5006,6 +5009,7 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) PL_generation++; if (aassign_common_vars(o)) o->op_private |= OPpASSIGN_COMMON; + LINKLIST(o); } if (right && right->op_type == OP_SPLIT && !PL_madskills) { -- cgit v1.2.1